Source-Changes-HG archive

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

[src/trunk]: src/lib/libcurses Rework the fix for lib/56224.



details:   https://anonhg.NetBSD.org/src/rev/a6af1176b4d9
branches:  trunk
changeset: 379853:a6af1176b4d9
user:      blymn <blymn%NetBSD.org@localhost>
date:      Tue Jun 22 07:49:09 2021 +0000

description:
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.

diffstat:

 lib/libcurses/addbytes.c |  50 ++++++++++++++++++++++++-----------------------
 1 files changed, 26 insertions(+), 24 deletions(-)

diffs (118 lines):

diff -r 04e93bc18db4 -r a6af1176b4d9 lib/libcurses/addbytes.c
--- a/lib/libcurses/addbytes.c  Tue Jun 22 07:29:16 2021 +0000
+++ b/lib/libcurses/addbytes.c  Tue Jun 22 07:49:09 2021 +0000
@@ -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 @@ int
                        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 @@ int
                        *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 @@ int
                        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 @@ int
                         "_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 @@ int
                        *(*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 @@ int
 #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];



Home | Main Index | Thread Index | Old Index