Details

[Home]

Issue of the Implementation # S0342

Brief

slk_label() doesn't remove trailing blanks

Detailed Description

LSB 3.1 refers to SUSv2 (The Single UNIX Specification, Version 2) for the description of the libncurses functions.
According to this standard, upon successful completion, slk_label() returns the requested label with leading and trailing blanks stripped.
But sometimes slk_label() returns strings that have unstripped trailing blanks.

Problem location(s) in the standard

Linux Standard Base Core Specification 3.1, Chapter 14. Utility Libraries, 14.5. Interfaces for libncurses.

Example

#include <ncurses.h>

int main(int argc, char* argv[])
{
    WINDOW * win;
    char test1[] = "test1";
    char test2[] = "    test2";
    char test3[] = "test3    "; 
    char test4[] = "    test4    "; 
    char test5[] = "        "; 
    
    slk_init(0); // before initscr 
    
    win = initscr(); 
    
    slk_set(1, test1, 0); 
    slk_set(2, test2, 0); 
    slk_set(3, test3, 0); 
    slk_set(4, test4, 0); 
    slk_set(5, test5, 0); 
    
    mvprintw(3, 1, "slk_set: "); 
        mvprintw(3, 12, ""%s",", test1); 
        mvprintw(3, 22, ""%s",", test2); 
        mvprintw(3, 36, ""%s",", test3); 
        mvprintw(3, 50, ""%s",", test4); 
        mvprintw(3, 68, ""%s"", test5); 
    
    mvprintw(5, 1, "slk_label: "); 
        mvprintw(5, 12, ""%s",", slk_label(1) ); 
        mvprintw(5, 22, ""%s",", slk_label(2) ); 
        mvprintw(5, 36, ""%s",", slk_label(3) ); 
        mvprintw(5, 50, ""%s",", slk_label(4) ); 
        mvprintw(5, 68, ""%s"", slk_label(5) ); 
    
    slk_refresh(); 
    
    getch(); 
    
    endwin(); 
    
    printf("
"); 
    
    return 0; 
} 

Component

ncurses 5.4-13

Accepted

Reported to bug-ncurses@gnu.org, archive for Apr 19, 2007

[Home]