Source-Changes-HG archive

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

[src/trunk]: src/lib/libcurses werase, wclrtobot, wclrtoeol - make code even ...



details:   https://anonhg.NetBSD.org/src/rev/3af6c3119058
branches:  trunk
changeset: 970181:3af6c3119058
user:      uwe <uwe%NetBSD.org@localhost>
date:      Sun Mar 15 01:18:43 2020 +0000

description:
werase, wclrtobot, wclrtoeol - make code even more similar.
Rename attr to battr to match bch and WINDOW::battr.
No functional change intended.

diffstat:

 lib/libcurses/clrtobot.c |  30 ++++++++++++++++--------------
 lib/libcurses/clrtoeol.c |  31 +++++++++++++++++--------------
 lib/libcurses/erase.c    |  15 ++++++++-------
 3 files changed, 41 insertions(+), 35 deletions(-)

diffs (186 lines):

diff -r 9bf30c859025 -r 3af6c3119058 lib/libcurses/clrtobot.c
--- a/lib/libcurses/clrtobot.c  Sun Mar 15 01:12:47 2020 +0000
+++ b/lib/libcurses/clrtobot.c  Sun Mar 15 01:18:43 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clrtobot.c,v 1.26 2020/03/13 02:57:26 roy Exp $        */
+/*     $NetBSD: clrtobot.c,v 1.27 2020/03/15 01:18:43 uwe Exp $        */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)clrtobot.c 8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: clrtobot.c,v 1.26 2020/03/13 02:57:26 roy Exp $");
+__RCSID("$NetBSD: clrtobot.c,v 1.27 2020/03/15 01:18:43 uwe Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -66,7 +66,17 @@
        int      minx, startx, starty, y;
        __LDATA *sp, *end, *maxx;
        wchar_t bch;
-       attr_t  attr;
+       attr_t  battr;
+
+#ifdef HAVE_WCHAR
+       bch = (wchar_t)btowc((int)win->bch);
+#else
+       bch = win->bch;
+#endif
+       if (win != curscr)
+               battr = win->battr & __ATTRIBUTES;
+       else
+               battr = 0;
 
 #ifdef __GNUC__
        maxx = NULL;            /* XXX gcc -Wuninitialized */
@@ -78,28 +88,20 @@
                starty = win->cury;
                startx = win->curx;
        }
-#ifdef HAVE_WCHAR
-       bch = (wchar_t)btowc((int)win->bch);
-#else
-       bch = win->bch;
-#endif
-       if (win != curscr)
-               attr = win->battr & __ATTRIBUTES;
-       else
-               attr = 0;
 
        for (y = starty; y < win->maxy; y++) {
                minx = -1;
                end = &win->alines[y]->line[win->maxx];
                for (sp = &win->alines[y]->line[startx]; sp < end; sp++) {
-                       if (!(__NEED_ERASE(sp, bch, attr)))
+                       if (!(__NEED_ERASE(sp, bch, battr)))
                                continue;
 
                        maxx = sp;
                        if (minx == -1)
                                minx = (int)(sp - win->alines[y]->line);
-                       sp->attr = attr | (sp->attr & __ALTCHARSET);
+
                        sp->ch = bch;
+                       sp->attr = battr | (sp->attr & __ALTCHARSET);
 #ifdef HAVE_WCHAR
                        if (_cursesi_copy_nsp(win->bnsp, sp) == ERR)
                                return ERR;
diff -r 9bf30c859025 -r 3af6c3119058 lib/libcurses/clrtoeol.c
--- a/lib/libcurses/clrtoeol.c  Sun Mar 15 01:12:47 2020 +0000
+++ b/lib/libcurses/clrtoeol.c  Sun Mar 15 01:18:43 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clrtoeol.c,v 1.30 2020/03/13 02:57:26 roy Exp $        */
+/*     $NetBSD: clrtoeol.c,v 1.31 2020/03/15 01:18:43 uwe Exp $        */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)clrtoeol.c 8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: clrtoeol.c,v 1.30 2020/03/13 02:57:26 roy Exp $");
+__RCSID("$NetBSD: clrtoeol.c,v 1.31 2020/03/15 01:18:43 uwe Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -66,7 +66,17 @@
        int     minx, x, y;
        __LDATA *end, *maxx, *sp;
        wchar_t bch;
-       attr_t  attr;
+       attr_t  battr;
+
+#ifdef HAVE_WCHAR
+       bch = (wchar_t)btowc((int)win->bch);
+#else
+       bch = win->bch;
+#endif
+       if (win != curscr)
+               battr = win->battr & __ATTRIBUTES;
+       else
+               battr = 0;
 
        y = win->cury;
        x = win->curx;
@@ -83,24 +93,17 @@
        end = &win->alines[y]->line[win->maxx];
        minx = -1;
        maxx = &win->alines[y]->line[x];
-#ifdef HAVE_WCHAR
-       bch = (wchar_t)btowc((int)win->bch);
-#else
-       bch = win->bch;
-#endif
-       if (win != curscr)
-               attr = win->battr & __ATTRIBUTES;
-       else
-               attr = 0;
 
        for (sp = maxx; sp < end; sp++) {
-               if (!(__NEED_ERASE(sp, bch, attr)))
+               if (!(__NEED_ERASE(sp, bch, battr)))
                        continue;
+
                maxx = sp;
                if (minx == -1)
                        minx = (int)(sp - win->alines[y]->line);
-               sp->attr = attr | (sp->attr & __ALTCHARSET);
+
                sp->ch = bch;
+               sp->attr = battr | (sp->attr & __ALTCHARSET);
 #ifdef HAVE_WCHAR
                if (_cursesi_copy_nsp(win->bnsp, sp) == ERR)
                        return ERR;
diff -r 9bf30c859025 -r 3af6c3119058 lib/libcurses/erase.c
--- a/lib/libcurses/erase.c     Sun Mar 15 01:12:47 2020 +0000
+++ b/lib/libcurses/erase.c     Sun Mar 15 01:18:43 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: erase.c,v 1.31 2020/03/13 02:57:26 roy Exp $   */
+/*     $NetBSD: erase.c,v 1.32 2020/03/15 01:18:43 uwe Exp $   */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)erase.c    8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: erase.c,v 1.31 2020/03/13 02:57:26 roy Exp $");
+__RCSID("$NetBSD: erase.c,v 1.32 2020/03/15 01:18:43 uwe Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -67,7 +67,7 @@
        int     y;
        __LDATA *sp, *end, *start;
        wchar_t bch;
-       attr_t  attr;
+       attr_t  battr;
 
 #ifdef DEBUG
        __CTRACE(__CTRACE_ERASE, "werase: (%p)\n", win);
@@ -78,18 +78,19 @@
        bch = win->bch;
 #endif
        if (win != curscr)
-               attr = win->battr & __ATTRIBUTES;
+               battr = win->battr & __ATTRIBUTES;
        else
-               attr = 0;
+               battr = 0;
 
        for (y = 0; y < win->maxy; y++) {
                start = win->alines[y]->line;
                end = &start[win->maxx];
                for (sp = start; sp < end; sp++) {
-                       if (!(__NEED_ERASE(sp, bch, attr)))
+                       if (!(__NEED_ERASE(sp, bch, battr)))
                                continue;
-                       sp->attr = attr | (sp->attr & __ALTCHARSET);
+
                        sp->ch = bch;
+                       sp->attr = battr | (sp->attr & __ALTCHARSET);
 #ifdef HAVE_WCHAR
                        if (_cursesi_copy_nsp(win->bnsp, sp) == ERR)
                                return ERR;



Home | Main Index | Thread Index | Old Index