Source-Changes-HG archive

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

[src/trunk]: src/lib/libcurses _wnoutrefresh - extend current position checks.



details:   https://anonhg.NetBSD.org/src/rev/8903ffd90831
branches:  trunk
changeset: 447278:8903ffd90831
user:      uwe <uwe%NetBSD.org@localhost>
date:      Sun Jan 06 04:27:53 2019 +0000

description:
_wnoutrefresh - extend current position checks.

Also verify that dwin->cury >= begy (ditto for x), i.e. for pads make
sure that the current position is after the beginning of the displayed
portion.  While here refactor the checks for better readability.

We should probably combine the y and x checks b/c if one of them is
not in the range, the current position as a whole is not in the range
and it doesn't make sense to pick and set just the y or just the x
part of it.

diffstat:

 lib/libcurses/refresh.c |  19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diffs (47 lines):

diff -r de8eb823f66c -r 8903ffd90831 lib/libcurses/refresh.c
--- a/lib/libcurses/refresh.c   Sun Jan 06 03:59:17 2019 +0000
+++ b/lib/libcurses/refresh.c   Sun Jan 06 04:27:53 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: refresh.c,v 1.104 2019/01/06 03:59:17 uwe Exp $        */
+/*     $NetBSD: refresh.c,v 1.105 2019/01/06 04:27:53 uwe Exp $        */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)refresh.c  8.7 (Berkeley) 8/13/94";
 #else
-__RCSID("$NetBSD: refresh.c,v 1.104 2019/01/06 03:59:17 uwe Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.105 2019/01/06 04:27:53 uwe Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -165,6 +165,7 @@
 {
        SCREEN *screen = win->screen;
        short   sy, wy, wx, y_off, x_off, mx, dy_off, dx_off, endy;
+       int newy, newx;
        __LINE  *wlp, *vlp, *dwlp;
        WINDOW  *sub_win, *orig, *swin, *dwin;
 
@@ -217,12 +218,14 @@
        }
 
        /* Check that cursor position on "win" is valid for "__virtscr" */
-       if (dwin->cury + wbegy - begy < screen->__virtscr->maxy &&
-           dwin->cury + wbegy - begy >= 0 && dwin->cury < maxy)
-               screen->__virtscr->cury = dwin->cury + wbegy - begy;
-       if (dwin->curx + wbegx - begx < screen->__virtscr->maxx &&
-           dwin->curx + wbegx - begx >= 0 && dwin->curx < maxx)
-               screen->__virtscr->curx = dwin->curx + wbegx - begx;
+       newy = wbegy + dwin->cury - begy;
+       newx = wbegx + dwin->curx - begx;
+       if (begy <= dwin->cury && dwin->cury < maxy
+           && 0 <= newy && newy < screen->__virtscr->maxy)
+               screen->__virtscr->cury = newy;
+       if (begx <= dwin->curx && dwin->curx < maxx
+           && 0 <= newx && newx < screen->__virtscr->maxx)
+               screen->__virtscr->curx = newx;
 
        /* Copy the window flags from "win" to "__virtscr" */
        if (dwin->flags & __CLEAROK) {



Home | Main Index | Thread Index | Old Index