Module Name: src Committed By: blymn Date: Tue Jun 22 07:49:09 UTC 2021
Modified Files: src/lib/libcurses: addbytes.c Log Message: Rework the fix for lib/56224. Move the scroll check to _cursesi_addwchar Perform the scroll check before updating the cursor location when processing \n. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/lib/libcurses/addbytes.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libcurses/addbytes.c diff -u src/lib/libcurses/addbytes.c:1.56 src/lib/libcurses/addbytes.c:1.57 --- src/lib/libcurses/addbytes.c:1.56 Tue Jun 15 22:18:55 2021 +++ src/lib/libcurses/addbytes.c Tue Jun 22 07:49:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: addbytes.c,v 1.56 2021/06/15 22:18:55 blymn Exp $ */ +/* $NetBSD: addbytes.c,v 1.57 2021/06/22 07:49:09 blymn Exp $ */ /* * Copyright (c) 1987, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: addbytes.c,v 1.56 2021/06/15 22:18:55 blymn Exp $"); +__RCSID("$NetBSD: addbytes.c,v 1.57 2021/06/22 07:49:09 blymn Exp $"); #endif #endif /* not lint */ @@ -171,14 +171,6 @@ _cursesi_waddbytes(WINDOW *win, const ch break; } - /* if scrollok is false and we are at the bottom of - * screen and this character would take us past the - * end of the line then we are done. - */ - if ((win->curx + wcwidth(wc) >= win->maxx) && - (!(win->flags & __SCROLLOK)) && - (win->cury == win->scr_b)) - break; #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "ADDBYTES WIDE(0x%x [%s], %x) at (%d, %d), ate %d bytes\n", @@ -371,16 +363,17 @@ _cursesi_addwchar(WINDOW *win, __LINE ** *x = 0; return OK; case L'\n': - wclrtoeol(win); - *x = 0; - (*lnp)->flags &= ~__ISPASTEOL; if (*y == win->scr_b) { if (!(win->flags & __SCROLLOK)) return ERR; + wclrtoeol(win); scroll(win); } else { + wclrtoeol(win); (*y)++; } + *x = 0; + (*lnp)->flags &= ~__ISPASTEOL; return OK; case L'\t': cc.vals[0] = L' '; @@ -395,7 +388,7 @@ _cursesi_addwchar(WINDOW *win, __LINE ** if ((*y == win->scr_b) && !(win->flags & __SCROLLOK)) { if ((*lnp)->flags & __ISPASTEOL) { - return OK; + return ERR; } if (*x + newx > win->maxx - 1) @@ -489,6 +482,12 @@ _cursesi_addwchar(WINDOW *win, __LINE ** "_cursesi_addwchar: clear EOL (%d,%d)\n", *y, *x); #endif /* DEBUG */ + if (*y == win->scr_b) { + if (!(win->flags & __SCROLLOK)) + return ERR; + scroll(win); + } + (*lnp)->flags |= __ISDIRTY; newx = *x + win->ch_off; if (newx < *(*lnp)->firstchp) @@ -505,11 +504,7 @@ _cursesi_addwchar(WINDOW *win, __LINE ** *(*lnp)->lastchp = newx; __touchline(win, *y, sx, (int) win->maxx - 1); sx = *x = 0; - if (*y == win->scr_b) { - if (!(win->flags & __SCROLLOK)) - return ERR; - scroll(win); - } else { + if (*y != win->scr_b) { (*y)++; } lp = &win->alines[*y]->line[0]; @@ -588,16 +583,23 @@ _cursesi_addwchar(WINDOW *win, __LINE ** #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: do line wrap\n"); #endif /* DEBUG */ + if (*y == win->scr_b) { +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: at bottom of screen\n"); +#endif /* DEBUG */ + if (!(win->flags & __SCROLLOK)) + return ERR; +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: do a scroll\n"); +#endif /* DEBUG */ + scroll(win); + } newx = win->maxx - 1 + win->ch_off; if (newx > *(*lnp)->lastchp) *(*lnp)->lastchp = newx; __touchline(win, *y, sx, (int) win->maxx - 1); *x = sx = 0; - if (*y == win->scr_b) { - if (!(win->flags & __SCROLLOK)) - return ERR; - scroll(win); - } else { + if (*y != win->scr_b) { (*y)++; } lp = &win->alines[*y]->line[0];