Source-Changes-HG archive

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

[src/trunk]: src/tests/lib/libcurses/slave tests/libcurses: replace ARG_CHTYP...



details:   https://anonhg.NetBSD.org/src/rev/923ea6777716
branches:  trunk
changeset: 980610:923ea6777716
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Feb 12 16:59:32 2021 +0000

description:
tests/libcurses: replace ARG_CHTYPE_STRING with ARG_CHTYPE

All uses of the previous macro did not treat the argument as a string or
array of chtype, but as a single chtype.  It's strange that the previous
code arbitrarily split the access to the argument by first storing it as
a pointer and then dereferencing it.

No functional change.

diffstat:

 tests/lib/libcurses/slave/curses_commands.c |  198 ++++++++++++++--------------
 1 files changed, 99 insertions(+), 99 deletions(-)

diffs (truncated from 403 to 300 lines):

diff -r 41c839a524ac -r 923ea6777716 tests/lib/libcurses/slave/curses_commands.c
--- a/tests/lib/libcurses/slave/curses_commands.c       Fri Feb 12 16:49:18 2021 +0000
+++ b/tests/lib/libcurses/slave/curses_commands.c       Fri Feb 12 16:59:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: curses_commands.c,v 1.17 2021/02/12 16:49:18 rillig Exp $      */
+/*     $NetBSD: curses_commands.c,v 1.18 2021/02/12 16:59:32 rillig Exp $      */
 
 /*-
  * Copyright 2009 Brett Lymn <blymn%NetBSD.org@localhost>
@@ -118,8 +118,8 @@
        if (set_uint(args[i], &arg) != 0)                               \
                return
 
-#define ARG_CHTYPE_STRING(i, arg) \
-       chtype *arg = (chtype *)args[i]
+#define ARG_CHTYPE(i, arg) \
+       chtype arg = ((chtype *)args[i])[0]
 
 #define ARG_CCHAR_STRING(i, arg) \
        cchar_t *arg = (cchar_t *)args[i]
@@ -164,10 +164,10 @@
 cmd_addch(int nargs, char **args)
 {
        ARGC(1);
-       ARG_CHTYPE_STRING(0, ch);
-
-       report_count(1);
-       report_return(addch(ch[0]));
+       ARG_CHTYPE(0, ch);
+
+       report_count(1);
+       report_return(addch(ch));
 }
 
 
@@ -306,10 +306,10 @@
 cmd_bkgd(int nargs, char **args)
 {
        ARGC(1);
-       ARG_CHTYPE_STRING(0, ch);
-
-       report_count(1);
-       report_return(bkgd(ch[0]));
+       ARG_CHTYPE(0, ch);
+
+       report_count(1);
+       report_return(bkgd(ch));
 }
 
 
@@ -317,9 +317,9 @@
 cmd_bkgdset(int nargs, char **args)
 {
        ARGC(1);
-       ARG_CHTYPE_STRING(0, ch);
-
-       bkgdset(ch[0]);         /* returns void */
+       ARG_CHTYPE(0, ch);
+
+       bkgdset(ch);            /* returns void */
        report_count(1);
        report_return(OK);
 }
@@ -409,11 +409,11 @@
 cmd_echochar(int nargs, char **args)
 {
        ARGC(1);
-       ARG_CHTYPE_STRING(0, ch);
+       ARG_CHTYPE(0, ch);
 
        /* XXX causes refresh */
        report_count(1);
-       report_return(echochar(ch[0]));
+       report_return(echochar(ch));
 }
 
 
@@ -541,10 +541,10 @@
 cmd_insch(int nargs, char **args)
 {
        ARGC(1);
-       ARG_CHTYPE_STRING(0, ch);
-
-       report_count(1);
-       report_return(insch(ch[0]));
+       ARG_CHTYPE(0, ch);
+
+       report_count(1);
+       report_return(insch(ch));
 }
 
 
@@ -724,10 +724,10 @@
        ARGC(3);
        ARG_INT(0, y);
        ARG_INT(1, x);
-       ARG_CHTYPE_STRING(2, ch);
-
-       report_count(1);
-       report_return(mvaddch(y, x, ch[0]));
+       ARG_CHTYPE(2, ch);
+
+       report_count(1);
+       report_return(mvaddch(y, x, ch));
 }
 
 
@@ -926,10 +926,10 @@
        ARGC(3);
        ARG_INT(0, y);
        ARG_INT(1, x);
-       ARG_CHTYPE_STRING(2, ch);
-
-       report_count(1);
-       report_return(mvinsch(y, x, ch[0]));
+       ARG_CHTYPE(2, ch);
+
+       report_count(1);
+       report_return(mvinsch(y, x, ch));
 }
 
 
@@ -971,10 +971,10 @@
        ARG_WINDOW(0, win);
        ARG_INT(1, y);
        ARG_INT(2, x);
-       ARG_CHTYPE_STRING(3, ch);
-
-       report_count(1);
-       report_return(mvwaddch(win, y, x, ch[0]));
+       ARG_CHTYPE(3, ch);
+
+       report_count(1);
+       report_return(mvwaddch(win, y, x, ch));
 }
 
 
@@ -1120,10 +1120,10 @@
        ARG_WINDOW(0, win);
        ARG_INT(1, y);
        ARG_INT(2, x);
-       ARG_CHTYPE_STRING(3, ch);
-
-       report_count(1);
-       report_return(mvwinsch(win, y, x, ch[0]));
+       ARG_CHTYPE(3, ch);
+
+       report_count(1);
+       report_return(mvwinsch(win, y, x, ch));
 }
 
 
@@ -1697,11 +1697,11 @@
 cmd_hline(int nargs, char **args)
 {
        ARGC(2);
-       ARG_CHTYPE_STRING(0, ch);
+       ARG_CHTYPE(0, ch);
        ARG_INT(1, count);
 
        report_count(1);
-       report_return(hline(ch[0], count));
+       report_return(hline(ch, count));
 }
 
 
@@ -1932,10 +1932,10 @@
        ARG_INT(0, y);
        ARG_INT(1, x);
        ARG_INT(3, n);
-       ARG_CHTYPE_STRING(2, ch);
-
-       report_count(1);
-       report_return(mvhline(y, x, ch[0], n));
+       ARG_CHTYPE(2, ch);
+
+       report_count(1);
+       report_return(mvhline(y, x, ch, n));
 }
 
 
@@ -1973,10 +1973,10 @@
        ARG_INT(0, y);
        ARG_INT(1, x);
        ARG_INT(3, n);
-       ARG_CHTYPE_STRING(2, ch);
-
-       report_count(1);
-       report_return(mvvline(y, x, ch[0], n));
+       ARG_CHTYPE(2, ch);
+
+       report_count(1);
+       report_return(mvvline(y, x, ch, n));
 }
 
 
@@ -1988,10 +1988,10 @@
        ARG_INT(1, y);
        ARG_INT(2, x);
        ARG_INT(4, n);
-       ARG_CHTYPE_STRING(3, ch);
-
-       report_count(1);
-       report_return(mvwhline(win, y, x, ch[0], n));
+       ARG_CHTYPE(3, ch);
+
+       report_count(1);
+       report_return(mvwhline(win, y, x, ch, n));
 }
 
 
@@ -2003,10 +2003,10 @@
        ARG_INT(1, y);
        ARG_INT(2, x);
        ARG_INT(4, n);
-       ARG_CHTYPE_STRING(3, ch);
-
-       report_count(1);
-       report_return(mvwvline(win, y, x, ch[0], n));
+       ARG_CHTYPE(3, ch);
+
+       report_count(1);
+       report_return(mvwvline(win, y, x, ch, n));
 }
 
 
@@ -2331,10 +2331,10 @@
 {
        ARGC(2);
        ARG_WINDOW(0, pad);
-       ARG_CHTYPE_STRING(1, ch);
-
-       report_count(1);
-       report_return(pechochar(pad, ch[0]));
+       ARG_CHTYPE(1, ch);
+
+       report_count(1);
+       report_return(pechochar(pad, ch));
 }
 
 
@@ -2677,11 +2677,11 @@
 cmd_vline(int nargs, char **args)
 {
        ARGC(2);
-       ARG_CHTYPE_STRING(0, ch);
+       ARG_CHTYPE(0, ch);
        ARG_INT(1, count);
 
        report_count(1);
-       report_return(vline(ch[0], count));
+       report_return(vline(ch, count));
 }
 
 
@@ -2755,10 +2755,10 @@
 {
        ARGC(2);
        ARG_WINDOW(0, win);
-       ARG_CHTYPE_STRING(1, ch);
-
-       report_count(1);
-       report_return(waddch(win, ch[0]));
+       ARG_CHTYPE(1, ch);
+
+       report_count(1);
+       report_return(waddch(win, ch));
 }
 
 
@@ -2892,10 +2892,10 @@
 {
        ARGC(2);
        ARG_WINDOW(0, win);
-       ARG_CHTYPE_STRING(1, ch);
-
-       report_count(1);
-       report_return(wbkgd(win, ch[0]));
+       ARG_CHTYPE(1, ch);
+
+       report_count(1);
+       report_return(wbkgd(win, ch));
 }
 
 
@@ -2904,9 +2904,9 @@
 {
        ARGC(2);
        ARG_WINDOW(0, win);
-       ARG_CHTYPE_STRING(1, ch);
-
-       wbkgdset(win, *ch);     /* void return */
+       ARG_CHTYPE(1, ch);
+
+       wbkgdset(win, ch);      /* void return */
        report_count(1);
        report_return(OK);
 }
@@ -3006,10 +3006,10 @@
 {



Home | Main Index | Thread Index | Old Index