Subject: lib/16532: incorrect handling of long lines by clrtoeol()
To: None <gnats-bugs@gnats.netbsd.org>
From: Onno van der Linden <onno@quicknet.nl>
List: netbsd-bugs
Date: 04/29/2002 00:54:48
>Number: 16532
>Category: lib
>Synopsis: incorrect handling of long lines by clrtoeol()
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Apr 28 15:55:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Onno van der Linden
>Release: NetBSD 1.5ZC
>Organization:
>Environment:
System: NetBSD sheep 1.5ZC NetBSD 1.5ZC (SHEEP) #0: Sat Apr 20 11:01:25 MEST 2002 onno@sheep:/usr/src/sys/arch/i386/compile/SHEEP i386
Architecture: i386
Machine: i386
>Description:
clrtoeol() fails to update the curx and cury of the WINDOW structure
when wrapping the cursor to the next line in case of __ISPASTEOL.
It also needs to clear the __ISPASTEOL bit of the line concerned.
>How-To-Repeat:
With mutt 1.3.28, TERM set to vt220 or wsvt25 and using wsons, create
a file in mbox format which has more than one page of lines and where
the last line has exactly 80 characters. Run mutt -f mbox and
hit PgDn to go to next page and notice that the last line isn't
properly cleaned.
>Fix:
When updating y and x in clrtoeol() they should be saved in the
curx and cury fields of the window structure. The line where the
__ISPASTEOL condition occured should have that bit cleared in its
flags. The appended diff also fixes a couple of errors when libcurses
is compiled with -DDEBUG_CURSES and -DFULL_DEBUG.
*** /usr/src/lib/libcurses/clrtoeol.c.orig Sat Apr 27 16:20:05 2002
--- /usr/src/lib/libcurses/clrtoeol.c Sun Apr 28 22:53:17 2002
***************
*** 74,79 ****
--- 74,82 ----
if (win->lines[y]->flags & __ISPASTEOL) {
if (y < win->maxy - 1) {
+ win->lines[y]->flags &= ~__ISPASTEOL;
y++;
x = 0;
+ win->cury = y;
+ win->curx = x;
} else
return (OK);
*** /usr/src/lib/libcurses/color.c.orig Sat Apr 27 09:51:11 2002
--- /usr/src/lib/libcurses/color.c Sat Apr 27 09:51:31 2002
***************
*** 319,324 ****
#ifdef DEBUG
__CTRACE("__set_color: %d, %d, %d\n", pair,
! _cursesi_screen->pairs[pair].fore,
! _cursesi_screen->pairs[pair].back);
#endif
switch (_cursesi_screen->color_type) {
--- 319,324 ----
#ifdef DEBUG
__CTRACE("__set_color: %d, %d, %d\n", pair,
! _cursesi_screen->colour_pairs[pair].fore,
! _cursesi_screen->colour_pairs[pair].back);
#endif
switch (_cursesi_screen->color_type) {
*** /usr/src/lib/libcurses/setterm.c.orig Sat Apr 27 09:53:15 2002
--- /usr/src/lib/libcurses/setterm.c Sat Apr 27 10:02:57 2002
***************
*** 352,356 ****
*vp++ = t_getnum(screen->cursesi_genbuf, tmp);
#ifdef DEBUG
! __CTRACE("%2.2s = %d\n", namp, *vp[-1]);
#endif
namp += 2;
--- 352,356 ----
*vp++ = t_getnum(screen->cursesi_genbuf, tmp);
#ifdef DEBUG
! __CTRACE("%2.2s = %d\n", namp, vp[-1]);
#endif
namp += 2;
***************
*** 368,372 ****
*sp++ = t_agetstr(screen->cursesi_genbuf, tmp);
#ifdef DEBUG
! __CTRACE("%2.2s = %s", namp, *sp[-1] == NULL ? "NULL\n" : "\"");
if (sp[-1] != NULL) {
for (cp = sp[-1]; *cp; cp++)
--- 368,372 ----
*sp++ = t_agetstr(screen->cursesi_genbuf, tmp);
#ifdef DEBUG
! __CTRACE("%2.2s = %s", namp, sp[-1] == NULL ? "NULL\n" : "\"");
if (sp[-1] != NULL) {
for (cp = sp[-1]; *cp; cp++)
>Release-Note:
>Audit-Trail:
>Unformatted: