NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/46049: clrtobot() and clrtoeol() do not set background attributes



>Number:         46049
>Category:       lib
>Synopsis:       clrtobot() and clrtoeol() do not set background attributes
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Feb 19 02:15:00 +0000 2012
>Originator:     Tim van der Molen
>Release:        NetBSD 5.1
>Organization:
>Environment:
NetBSD lambda.kariliq.nl 5.1 NetBSD 5.1 (GENERIC) #0: Sun Nov  7 14:39:56 UTC 
2010  
builds%b6.netbsd.org@localhost:/home/builds/ab/netbsd-5-1-RELEASE/i386/201011061943Z-obj/home/builds/ab/netbsd-5-1-RELEASE/src/sys/arch/i386/compile/GENERIC
 i386
>Description:
The clrtobot() and clrtoeol() functions do not apply the background attributes 
(as set by bkgdset()) to the characters they clear.

The below program, for example, only prints the word "hello" in reverse video 
instead of the whole line.

#include <curses.h>

int
main(void)
{
        initscr();
        bkgdset(A_REVERSE);
        addstr("hello");
        clrtoeol();
        refresh();
        getch();
        endwin();
        return 0;
}
>How-To-Repeat:
See the example program in the full description.
>Fix:
The following diff (against -current) fixes this problem. It is based on a 
similar fix to src/lib/libcurses/erase.c r1.25.

diff -pru src/lib/libcurses.orig/clrtobot.c src/lib/libcurses/clrtobot.c
--- src/lib/libcurses.orig/clrtobot.c   Thu Jul 23 05:01:50 2009
+++ src/lib/libcurses/clrtobot.c        Sat Feb 18 20:12:16 2012
@@ -77,8 +77,8 @@ wclrtobot(WINDOW *win)
                starty = win->cury;
                startx = win->curx;
        }
-       if (__using_color && win != curscr)
-               attr = win->battr & __COLOR;
+       if (win != curscr)
+               attr = win->battr & __ATTRIBUTES;
        else
                attr = 0;
        for (y = starty; y < win->maxy; y++) {
@@ -89,12 +89,15 @@ wclrtobot(WINDOW *win)
                        if (sp->ch != win->bch || sp->attr != attr) {
 #else
                        if (sp->ch != (wchar_t)btowc((int) win->bch) ||
-                           (sp->attr & WA_ATTRIBUTES) != 0 || sp->nsp) {
+                           (sp->attr & WA_ATTRIBUTES) != attr || sp->nsp) {
 #endif /* HAVE_WCHAR */
                                maxx = sp;
                                if (minx == -1)
                                        minx = (int)(sp - win->alines[y]->line);
-                               sp->attr = attr;
+                               if (sp->attr & __ALTCHARSET)
+                                       sp->attr = attr | __ALTCHARSET;
+                               else
+                                       sp->attr = attr;
 #ifdef HAVE_WCHAR
                                sp->ch = ( wchar_t )btowc(( int ) win->bch);
                                if (_cursesi_copy_nsp(win->bnsp, sp) == ERR)
diff -pru src/lib/libcurses.orig/clrtoeol.c src/lib/libcurses/clrtoeol.c
--- src/lib/libcurses.orig/clrtoeol.c   Thu Jul 23 05:01:50 2009
+++ src/lib/libcurses/clrtoeol.c        Sat Feb 18 20:11:55 2012
@@ -82,8 +82,8 @@ wclrtoeol(WINDOW *win)
        end = &win->alines[y]->line[win->maxx];
        minx = -1;
        maxx = &win->alines[y]->line[x];
-       if (__using_color && win != curscr)
-               attr = win->battr & __COLOR;
+       if (win != curscr)
+               attr = win->battr & __ATTRIBUTES;
        else
                attr = 0;
        for (sp = maxx; sp < end; sp++)
@@ -97,7 +97,10 @@ wclrtoeol(WINDOW *win)
                        maxx = sp;
                        if (minx == -1)
                                minx = (int) (sp - win->alines[y]->line);
-                       sp->attr = attr;
+                       if (sp->attr & __ALTCHARSET)
+                               sp->attr = attr | __ALTCHARSET;
+                       else
+                               sp->attr = attr;
 #ifdef HAVE_WCHAR
                        sp->ch = ( wchar_t )btowc(( int ) win->bch);
                        if (_cursesi_copy_nsp(win->bnsp, sp) == ERR)



Home | Main Index | Thread Index | Old Index