CVS commit: src/tests/lib/libcurses/slave

2023-12-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 10 15:42:29 UTC 2023

Modified Files:
src/tests/lib/libcurses/slave: commands.c

Log Message:
tests/libcurses: fix typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/tests/lib/libcurses/slave/commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2023-12-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 10 15:42:29 UTC 2023

Modified Files:
src/tests/lib/libcurses/slave: commands.c

Log Message:
tests/libcurses: fix typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/tests/lib/libcurses/slave/commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/commands.c
diff -u src/tests/lib/libcurses/slave/commands.c:1.17 src/tests/lib/libcurses/slave/commands.c:1.18
--- src/tests/lib/libcurses/slave/commands.c:1.17	Mon Dec  6 22:45:42 2021
+++ src/tests/lib/libcurses/slave/commands.c	Sun Dec 10 15:42:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.17 2021/12/06 22:45:42 rillig Exp $	*/
+/*	$NetBSD: commands.c,v 1.18 2023/12/10 15:42:29 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -194,7 +194,7 @@ report_message(data_enum_t type, const c
 }
 
 /*
- * Report a string of chtype back to the director via the command pipe.
+ * Report a single chtype back to the director via the command pipe.
  */
 void
 report_byte(chtype c)



CVS commit: src/tests/lib/libcurses/slave

2021-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec  7 06:55:44 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: fix grammar in comment (since yesterday)


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.30 src/tests/lib/libcurses/slave/curses_commands.c:1.31
--- src/tests/lib/libcurses/slave/curses_commands.c:1.30	Mon Dec  6 22:45:42 2021
+++ src/tests/lib/libcurses/slave/curses_commands.c	Tue Dec  7 06:55:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.30 2021/12/06 22:45:42 rillig Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.31 2021/12/07 06:55:44 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -150,8 +150,8 @@ set_scrn(const char *arg, SCREEN **x)
 		return
 
 /*
- * These NULL argument is required by the API, intended for future extensions,
- * but this implementation does not support the extension.
+ * These NULL arguments are required by the API, intended for future
+ * extensions, but this implementation does not support any extensions.
  */
 #define ARG_NULL() \
 	args++



CVS commit: src/tests/lib/libcurses/slave

2021-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec  7 06:55:44 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: fix grammar in comment (since yesterday)


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec  6 22:45:42 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: commands.c curses_commands.c
curses_commands.h

Log Message:
tests/libcurses: clean up comments


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libcurses/slave/commands.c
cvs rdiff -u -r1.29 -r1.30 src/tests/lib/libcurses/slave/curses_commands.c
cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libcurses/slave/curses_commands.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/commands.c
diff -u src/tests/lib/libcurses/slave/commands.c:1.16 src/tests/lib/libcurses/slave/commands.c:1.17
--- src/tests/lib/libcurses/slave/commands.c:1.16	Sat Sep  4 01:34:32 2021
+++ src/tests/lib/libcurses/slave/commands.c	Mon Dec  6 22:45:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.16 2021/09/04 01:34:32 rin Exp $	*/
+/*	$NetBSD: commands.c,v 1.17 2021/12/06 22:45:42 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -108,7 +108,7 @@ write_to_director_type(data_enum_t retur
 }
 
 /*
- * Report an pointer value back to the director
+ * Report a pointer value back to the director
  */
 void
 report_ptr(void *ptr)

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.29 src/tests/lib/libcurses/slave/curses_commands.c:1.30
--- src/tests/lib/libcurses/slave/curses_commands.c:1.29	Sun Jun 13 21:54:51 2021
+++ src/tests/lib/libcurses/slave/curses_commands.c	Mon Dec  6 22:45:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.29 2021/06/13 21:54:51 rillig Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.30 2021/12/06 22:45:42 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -150,8 +150,8 @@ set_scrn(const char *arg, SCREEN **x)
 		return
 
 /*
- * Required by the API, intended for future extensions, but this
- * implementation does not support the extension.
+ * These NULL argument is required by the API, intended for future extensions,
+ * but this implementation does not support the extension.
  */
 #define ARG_NULL() \
 	args++

Index: src/tests/lib/libcurses/slave/curses_commands.h
diff -u src/tests/lib/libcurses/slave/curses_commands.h:1.8 src/tests/lib/libcurses/slave/curses_commands.h:1.9
--- src/tests/lib/libcurses/slave/curses_commands.h:1.8	Sun Jun 13 19:17:53 2021
+++ src/tests/lib/libcurses/slave/curses_commands.h	Mon Dec  6 22:45:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.h,v 1.8 2021/06/13 19:17:53 rillig Exp $	*/
+/*	$NetBSD: curses_commands.h,v 1.9 2021/12/06 22:45:42 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -42,7 +42,7 @@ struct command_def {
 
 void cmd_DRAIN(int, char **); /* not a curses function */
 
-/* These functions can be called before initscr*/
+/* These functions can be called before initscr */
 void cmd_filter(int, char **);
 void cmd_ripoffline(int, char **);
 void cmd_use_env(int, char **);
@@ -398,7 +398,7 @@ void cmd_mvwinwstr(int, char **);
 void cmd_winnwstr(int, char **);
 void cmd_winwstr(int, char **);
 
-/* cchar handlgin */
+/* cchar handling */
 void cmd_setcchar(int, char **);
 void cmd_getcchar(int, char **);
 



CVS commit: src/tests/lib/libcurses/slave

2021-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec  6 22:45:42 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: commands.c curses_commands.c
curses_commands.h

Log Message:
tests/libcurses: clean up comments


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libcurses/slave/commands.c
cvs rdiff -u -r1.29 -r1.30 src/tests/lib/libcurses/slave/curses_commands.c
cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libcurses/slave/curses_commands.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-09-03 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Sep  4 01:34:32 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: commands.c

Log Message:
Cosmetic fixes. No functional changes intended.
- Reorganize logic to reduce indent levels significantly.
- Use ``for'' rather than ``while''.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libcurses/slave/commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/commands.c
diff -u src/tests/lib/libcurses/slave/commands.c:1.15 src/tests/lib/libcurses/slave/commands.c:1.16
--- src/tests/lib/libcurses/slave/commands.c:1.15	Sun Jun 13 12:46:01 2021
+++ src/tests/lib/libcurses/slave/commands.c	Sat Sep  4 01:34:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.15 2021/06/13 12:46:01 rillig Exp $	*/
+/*	$NetBSD: commands.c,v 1.16 2021/09/04 01:34:32 rin Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -53,32 +53,32 @@ command_execute(char *func, int nargs, c
 {
 	size_t i, j;
 
-	i = 0;
-	while (i < ncmds) {
-		if (strcmp(func, commands[i].name) == 0) {
-			/* Check only restricted set of functions is called before
-			 * initscr/newterm */
-			if (!initdone) {
-j = 0;
-while (j < nrcmds) {
-	if (strcmp(func, restricted_commands[j]) == 0) {
-		if (strcmp(func, "initscr") == 0  ||
-			strcmp(func, "newterm") == 0)
-			initdone = 1;
-		/* matched function */
-		commands[i].func(nargs, args);
-		return;
-	}
-	j++;
-}
-report_status("YOU NEED TO CALL INITSCR/NEWTERM FIRST");
-return;
-			}
+	for (i = 0; i < ncmds; i++) {
+		if (strcmp(func, commands[i].name) != 0)
+			continue;
+
+		/* Check only restricted set of functions is called before
+		 * initscr/newterm */
+		if (initdone) {
 			/* matched function */
 			commands[i].func(nargs, args);
 			return;
 		}
-		i++;
+
+		for (j = 0; j < nrcmds; j++) {
+			if (strcmp(func, restricted_commands[j]) != 0)
+continue;
+
+			if (strcmp(func, "initscr") == 0  ||
+			strcmp(func, "newterm") == 0)
+initdone = 1;
+
+			/* matched function */
+			commands[i].func(nargs, args);
+			return;
+		}
+		report_status("YOU NEED TO CALL INITSCR/NEWTERM FIRST");
+		return;
 	}
 
 	report_status("UNKNOWN_FUNCTION");



CVS commit: src/tests/lib/libcurses/slave

2021-09-03 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Sep  4 01:34:32 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: commands.c

Log Message:
Cosmetic fixes. No functional changes intended.
- Reorganize logic to reduce indent levels significantly.
- Use ``for'' rather than ``while''.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libcurses/slave/commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-06-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 13 21:54:52 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: fix argument handling for mvwget_wch

There's currently no test for that function, therefore no functional
change.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-06-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 13 21:54:52 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: fix argument handling for mvwget_wch

There's currently no test for that function, therefore no functional
change.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.28 src/tests/lib/libcurses/slave/curses_commands.c:1.29
--- src/tests/lib/libcurses/slave/curses_commands.c:1.28	Sun Jun 13 19:17:53 2021
+++ src/tests/lib/libcurses/slave/curses_commands.c	Sun Jun 13 21:54:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.28 2021/06/13 19:17:53 rillig Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.29 2021/06/13 21:54:51 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -4084,7 +4084,7 @@ cmd_mvwget_wch(int nargs, char **args)
 {
 	wchar_t ch;
 
-	ARGC(1);	/* FIXME: 3 */
+	ARGC(3);
 	ARG_WINDOW(win);
 	ARG_INT(y);
 	ARG_INT(x);



CVS commit: src/tests/lib/libcurses/slave

2021-06-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 13 19:50:18 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: lint.lua

Log Message:
tests/libcurses: make error handling in the linter simpler


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libcurses/slave/lint.lua

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-06-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 13 19:50:18 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: lint.lua

Log Message:
tests/libcurses: make error handling in the linter simpler


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libcurses/slave/lint.lua

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/lint.lua
diff -u src/tests/lib/libcurses/slave/lint.lua:1.5 src/tests/lib/libcurses/slave/lint.lua:1.6
--- src/tests/lib/libcurses/slave/lint.lua:1.5	Sun Jun 13 19:41:12 2021
+++ src/tests/lib/libcurses/slave/lint.lua	Sun Jun 13 19:50:18 2021
@@ -1,5 +1,5 @@
 #! /usr/bin/lua
--- $NetBSD: lint.lua,v 1.5 2021/06/13 19:41:12 rillig Exp $
+-- $NetBSD: lint.lua,v 1.6 2021/06/13 19:50:18 rillig Exp $
 
 --[[
 
@@ -24,18 +24,10 @@ local function load_lines(fname)
   return lines
 end
 
-
-local function new_errors()
-  local errors = {}
-  errors.add = function(self, fmt, ...)
-table.insert(self, string.format(fmt, ...))
-  end
-  errors.print = function(self)
-for _, msg in ipairs(self) do
-  print(msg)
-end
-  end
-  return errors
+local had_errors = false
+local function print_error(fmt, ...)
+  print(fmt:format(...))
+  had_errors = true
 end
 
 
@@ -46,7 +38,7 @@ end
 
 
 -- After each macro ARGC, there must be the corresponding macros for ARG.
-local function check_args(errors)
+local function check_args()
   local fname = "curses_commands.c"
   local lines = load_lines(fname)
   local curr_argc, curr_arg ---@type number|nil, number|nil
@@ -66,9 +58,9 @@ local function check_args(errors)
 curr_argc, curr_arg = nil, nil
   end
 elseif line_arg then
-  errors:add("%s:%d: ARG without preceding ARGC", fname, lineno)
+  print_error("%s:%d: ARG without preceding ARGC", fname, lineno)
 elseif curr_arg then
-  errors:add("%s:%d: expecting ARG %d, got %s",
+  print_error("%s:%d: expecting ARG %d, got %s",
 fname, lineno, curr_arg, line)
   curr_argc, curr_arg = nil, nil
 end
@@ -77,13 +69,5 @@ local function check_args(errors)
   end
 end
 
-
-local function main(arg)
-  local errors = new_errors()
-  check_args(errors)
-  errors:print()
-  return #errors == 0
-end
-
-
-os.exit(main(arg))
+check_args()
+os.exit(not had_errors)



CVS commit: src/tests/lib/libcurses/slave

2021-06-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 13 19:41:12 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: lint.lua

Log Message:
tests/libcurses: improve code locality in linter

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libcurses/slave/lint.lua

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-06-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 13 19:41:12 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: lint.lua

Log Message:
tests/libcurses: improve code locality in linter

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libcurses/slave/lint.lua

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/lint.lua
diff -u src/tests/lib/libcurses/slave/lint.lua:1.4 src/tests/lib/libcurses/slave/lint.lua:1.5
--- src/tests/lib/libcurses/slave/lint.lua:1.4	Sun Jun 13 19:25:08 2021
+++ src/tests/lib/libcurses/slave/lint.lua	Sun Jun 13 19:41:12 2021
@@ -1,5 +1,5 @@
 #! /usr/bin/lua
--- $NetBSD: lint.lua,v 1.4 2021/06/13 19:25:08 rillig Exp $
+-- $NetBSD: lint.lua,v 1.5 2021/06/13 19:41:12 rillig Exp $
 
 --[[
 
@@ -53,29 +53,27 @@ local function check_args(errors)
 
   for lineno, line in ipairs(lines) do
 
-local line_argc = num(line:match("^\tARGC%((%d)"))
-local line_arg = line:match("^\tARG_[%w_]+%(")
-
+local line_argc = num(line:match("^\tARGC%((%d+)"))
 if line_argc and line_argc > 0 then
   curr_argc, curr_arg = line_argc, 0
+  goto next
 end
 
-if line_arg and not curr_arg then
-  errors:add("%s:%d: ARG without preceding ARGC", fname, lineno)
-end
-
-if not line_arg and curr_arg and not line_argc then
-  errors:add("%s:%d: expecting ARG %d, got %s",
-fname, lineno, curr_arg, line)
-  curr_argc, curr_arg = nil, nil
-end
-
+local line_arg = line:match("^\tARG_[%w_]+%(")
 if line_arg and curr_arg then
   curr_arg = curr_arg + 1
   if curr_arg == curr_argc then
 curr_argc, curr_arg = nil, nil
   end
+elseif line_arg then
+  errors:add("%s:%d: ARG without preceding ARGC", fname, lineno)
+elseif curr_arg then
+  errors:add("%s:%d: expecting ARG %d, got %s",
+fname, lineno, curr_arg, line)
+  curr_argc, curr_arg = nil, nil
 end
+
+::next::
   end
 end
 



CVS commit: src/tests/lib/libcurses/slave

2021-06-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 13 19:25:08 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: lint.lua

Log Message:
tests/libcurses: improve local variable names in linter


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/slave/lint.lua

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/lint.lua
diff -u src/tests/lib/libcurses/slave/lint.lua:1.3 src/tests/lib/libcurses/slave/lint.lua:1.4
--- src/tests/lib/libcurses/slave/lint.lua:1.3	Sun Jun 13 18:11:44 2021
+++ src/tests/lib/libcurses/slave/lint.lua	Sun Jun 13 19:25:08 2021
@@ -1,11 +1,11 @@
 #! /usr/bin/lua
--- $NetBSD: lint.lua,v 1.3 2021/06/13 18:11:44 rillig Exp $
+-- $NetBSD: lint.lua,v 1.4 2021/06/13 19:25:08 rillig Exp $
 
 --[[
 
 usage: lua ./lint.lua
 
-Check that the boilerplate code does not contain unintended
+Check that the argument handling code does not contain unintended
 inconsistencies.
 
 ]]
@@ -49,29 +49,31 @@ end
 local function check_args(errors)
   local fname = "curses_commands.c"
   local lines = load_lines(fname)
-  local argi, argc
+  local curr_argc, curr_arg ---@type number|nil, number|nil
 
   for lineno, line in ipairs(lines) do
 
-local c = num(line:match("^\tARGC%((%d)"))
-if c and c > 0 then
-  argc, argi = c, 0
+local line_argc = num(line:match("^\tARGC%((%d)"))
+local line_arg = line:match("^\tARG_[%w_]+%(")
+
+if line_argc and line_argc > 0 then
+  curr_argc, curr_arg = line_argc, 0
 end
 
-local arg = line:match("^\tARG_[%w_]+%(")
-if arg and not argi then
+if line_arg and not curr_arg then
   errors:add("%s:%d: ARG without preceding ARGC", fname, lineno)
 end
 
-if not arg and argi and not c then
-  errors:add("%s:%d: expecting ARG %d, got %s", fname, lineno, argi, line)
-  argc, argi = nil, nil
+if not line_arg and curr_arg and not line_argc then
+  errors:add("%s:%d: expecting ARG %d, got %s",
+fname, lineno, curr_arg, line)
+  curr_argc, curr_arg = nil, nil
 end
 
-if arg and argi then
-  argi = argi + 1
-  if argi == argc then
-argc, argi = nil, nil
+if line_arg and curr_arg then
+  curr_arg = curr_arg + 1
+  if curr_arg == curr_argc then
+curr_argc, curr_arg = nil, nil
   end
 end
   end



CVS commit: src/tests/lib/libcurses/slave

2021-06-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 13 19:25:08 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: lint.lua

Log Message:
tests/libcurses: improve local variable names in linter


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/slave/lint.lua

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-06-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 13 19:17:53 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c curses_commands.h

Log Message:
tests/libcurses: unexport argument handling functions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/tests/lib/libcurses/slave/curses_commands.c
cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libcurses/slave/curses_commands.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-06-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 13 19:17:53 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c curses_commands.h

Log Message:
tests/libcurses: unexport argument handling functions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/tests/lib/libcurses/slave/curses_commands.c
cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libcurses/slave/curses_commands.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.27 src/tests/lib/libcurses/slave/curses_commands.c:1.28
--- src/tests/lib/libcurses/slave/curses_commands.c:1.27	Sun Jun 13 19:13:20 2021
+++ src/tests/lib/libcurses/slave/curses_commands.c	Sun Jun 13 19:17:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.27 2021/06/13 19:13:20 rillig Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.28 2021/06/13 19:17:53 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -38,8 +38,8 @@
 #include "slave.h"
 #include "curses_commands.h"
 
-int
-set_int(char *arg, int *x)
+static int
+set_int(const char *arg, int *x)
 {
 	if (sscanf(arg, "%d", x) == 0) {
 		report_count(1);
@@ -50,8 +50,8 @@ set_int(char *arg, int *x)
 	return 0;
 }
 
-int
-set_uint(char *arg, unsigned int *x)
+static int
+set_uint(const char *arg, unsigned int *x)
 {
 	if (sscanf(arg, "%u", x) == 0) {
 		report_count(1);
@@ -62,8 +62,8 @@ set_uint(char *arg, unsigned int *x)
 	return 0;
 }
 
-int
-set_short(char *arg, short *x)
+static int
+set_short(const char *arg, short *x)
 {
 	if (sscanf(arg, "%hd", x) == 0) {
 		report_count(1);
@@ -74,8 +74,8 @@ set_short(char *arg, short *x)
 	return 0;
 }
 
-int
-set_win(char *arg, WINDOW **x)
+static int
+set_win(const char *arg, WINDOW **x)
 {
 	if (sscanf(arg, "%p", x) == 0) {
 		report_count(1);
@@ -86,8 +86,8 @@ set_win(char *arg, WINDOW **x)
 	return 0;
 }
 
-int
-set_scrn(char *arg, SCREEN **x)
+static int
+set_scrn(const char *arg, SCREEN **x)
 {
 	if (sscanf(arg, "%p", x) == 0) {
 		report_count(1);

Index: src/tests/lib/libcurses/slave/curses_commands.h
diff -u src/tests/lib/libcurses/slave/curses_commands.h:1.7 src/tests/lib/libcurses/slave/curses_commands.h:1.8
--- src/tests/lib/libcurses/slave/curses_commands.h:1.7	Sat Feb 13 08:14:46 2021
+++ src/tests/lib/libcurses/slave/curses_commands.h	Sun Jun 13 19:17:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.h,v 1.7 2021/02/13 08:14:46 rillig Exp $	*/
+/*	$NetBSD: curses_commands.h,v 1.8 2021/06/13 19:17:53 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -36,12 +36,6 @@ struct command_def {
 	void (*func)(int, char **);
 };
 
-int set_int(char *, int *);
-int set_uint(char *, unsigned int *);
-int set_short(char *, short *);
-int set_win(char *, WINDOW **);
-int set_scrn(char *, SCREEN **);
-
 /*
  * prototypes for test commands
  */



CVS commit: src/tests/lib/libcurses/slave

2021-06-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 13 19:13:20 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: KNF for while loop


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.26 src/tests/lib/libcurses/slave/curses_commands.c:1.27
--- src/tests/lib/libcurses/slave/curses_commands.c:1.26	Sun Jun 13 18:11:44 2021
+++ src/tests/lib/libcurses/slave/curses_commands.c	Sun Jun 13 19:13:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.26 2021/06/13 18:11:44 rillig Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.27 2021/06/13 19:13:20 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -165,7 +165,9 @@ cmd_DRAIN(int nargs, char **args)
 	ARGC(1);
 	ARG_WINDOW(win);
 
-	while (wgetch(win) != ERR);
+	while (wgetch(win) != ERR)
+		continue;
+
 	report_count(1);
 	report_return(OK);
 }



CVS commit: src/tests/lib/libcurses/slave

2021-06-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 13 19:13:20 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: KNF for while loop


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-06-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 13 18:11:44 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c lint.lua

Log Message:
tests/libcurses: remove redundant argument numbers

Since all arguments are processed in increasing order, there is no need
to add the redundant argument numbers.  Most of the curses functions
have less than 5 arguments, which makes it easy enough to count the ARG
macros.

Changes to curses_commands.c:

* replace ^(\tARG_\w+\()\d(?:, |) with $1
* replace (define ARG_\w+\()i,\s with $1
* replace args\[i\] with *args++
* replace \(i\) with ()
* replace \(void\)0 with args++

The wrong argument count in cmd_mvwget_wch is still detected by
lint.lua, as it was before.  There is no test yet that covers this
function.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/tests/lib/libcurses/slave/curses_commands.c
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/slave/lint.lua

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.25 src/tests/lib/libcurses/slave/curses_commands.c:1.26
--- src/tests/lib/libcurses/slave/curses_commands.c:1.25	Sun Apr  4 09:49:13 2021
+++ src/tests/lib/libcurses/slave/curses_commands.c	Sun Jun 13 18:11:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.25 2021/04/04 09:49:13 rin Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.26 2021/06/13 18:11:44 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -102,68 +102,68 @@ set_scrn(char *arg, SCREEN **x)
 	if (check_arg_count(nargs, n) == 1)\
 		return
 
-#define ARG_SHORT(i, arg) \
+#define ARG_SHORT(arg) \
 	short arg;			\
-	if (set_short(args[i], ) != 0)\
+	if (set_short(*args++, ) != 0)\
 		return
 
-#define ARG_INT(i, arg) \
+#define ARG_INT(arg) \
 	int arg;			\
-	if (set_int(args[i], ) != 0)\
+	if (set_int(*args++, ) != 0)\
 		return
 
-#define ARG_UINT(i, arg) \
+#define ARG_UINT(arg) \
 	unsigned int arg;		\
-	if (set_uint(args[i], ) != 0)\
+	if (set_uint(*args++, ) != 0)\
 		return
 
-#define ARG_CHTYPE(i, arg) \
-	chtype arg = ((const chtype *)args[i])[0]
+#define ARG_CHTYPE(arg) \
+	chtype arg = ((const chtype *)*args++)[0]
 
-#define ARG_WCHAR(i, arg) \
-	wchar_t arg = ((const wchar_t *)args[i])[0]
+#define ARG_WCHAR(arg) \
+	wchar_t arg = ((const wchar_t *)*args++)[0]
 
-#define ARG_STRING(i, arg) \
-	const char *arg = args[i]
+#define ARG_STRING(arg) \
+	const char *arg = *args++
 
 /* Only used for legacy interfaces that are missing the 'const'. */
-#define ARG_MODIFIABLE_STRING(i, arg) \
-	char *arg = args[i]
+#define ARG_MODIFIABLE_STRING(arg) \
+	char *arg = *args++
 
-#define ARG_CHTYPE_STRING(i, arg) \
-	const chtype *arg = (const chtype *)args[i]
+#define ARG_CHTYPE_STRING(arg) \
+	const chtype *arg = (const chtype *)*args++
 
-#define ARG_CCHAR_STRING(i, arg) \
-	const cchar_t *arg = (const cchar_t *)args[i]
+#define ARG_CCHAR_STRING(arg) \
+	const cchar_t *arg = (const cchar_t *)*args++
 
-#define ARG_WCHAR_STRING(i, arg) \
-	wchar_t *arg = (wchar_t *)args[i]
+#define ARG_WCHAR_STRING(arg) \
+	wchar_t *arg = (wchar_t *)*args++
 
-#define ARG_WINDOW(i, arg) \
+#define ARG_WINDOW(arg) \
 	WINDOW *arg;			\
-	if (set_win(args[i], ) != 0)\
+	if (set_win(*args++, ) != 0)\
 		return
 
-#define ARG_SCREEN(i, arg) \
+#define ARG_SCREEN(arg) \
 	SCREEN *arg;			\
-	if (set_scrn(args[i], ) != 0)\
+	if (set_scrn(*args++, ) != 0)\
 		return
 
 /*
  * Required by the API, intended for future extensions, but this
  * implementation does not support the extension.
  */
-#define ARG_NULL(i) \
-	(void)0
+#define ARG_NULL() \
+	args++
 
-#define ARG_IGNORE(i) \
-	(void)0
+#define ARG_IGNORE() \
+	args++
 
 void
 cmd_DRAIN(int nargs, char **args)
 {
 	ARGC(1);
-	ARG_WINDOW(0, win);
+	ARG_WINDOW(win);
 
 	while (wgetch(win) != ERR);
 	report_count(1);
@@ -174,8 +174,8 @@ void
 cmd_addbytes(int nargs, char **args)
 {
 	ARGC(2);
-	ARG_STRING(0, str);
-	ARG_INT(1, count);
+	ARG_STRING(str);
+	ARG_INT(count);
 
 	report_count(1);
 	report_return(addbytes(str, count));
@@ -186,7 +186,7 @@ void
 cmd_addch(int nargs, char **args)
 {
 	ARGC(1);
-	ARG_CHTYPE(0, ch);
+	ARG_CHTYPE(ch);
 
 	report_count(1);
 	report_return(addch(ch));
@@ -197,8 +197,8 @@ void
 cmd_addchnstr(int nargs, char **args)
 {
 	ARGC(2);
-	ARG_CHTYPE_STRING(0, chstr);
-	ARG_INT(1, count);
+	ARG_CHTYPE_STRING(chstr);
+	ARG_INT(count);
 
 	report_count(1);
 	report_return(addchnstr(chstr, count));
@@ -209,7 +209,7 @@ void
 cmd_addchstr(int nargs, char **args)
 {
 	ARGC(1);
-	ARG_CHTYPE_STRING(0, chstr);
+	ARG_CHTYPE_STRING(chstr);
 
 	report_count(1);
 	report_return(addchstr(chstr));
@@ -220,8 +220,8 @@ void
 cmd_addnstr(int nargs, char **args)
 {
 	ARGC(2);
-	ARG_STRING(0, str);
-	ARG_INT(1, count);
+	ARG_STRING(str);
+	

CVS commit: src/tests/lib/libcurses/slave

2021-06-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 13 18:11:44 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c lint.lua

Log Message:
tests/libcurses: remove redundant argument numbers

Since all arguments are processed in increasing order, there is no need
to add the redundant argument numbers.  Most of the curses functions
have less than 5 arguments, which makes it easy enough to count the ARG
macros.

Changes to curses_commands.c:

* replace ^(\tARG_\w+\()\d(?:, |) with $1
* replace (define ARG_\w+\()i,\s with $1
* replace args\[i\] with *args++
* replace \(i\) with ()
* replace \(void\)0 with args++

The wrong argument count in cmd_mvwget_wch is still detected by
lint.lua, as it was before.  There is no test yet that covers this
function.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/tests/lib/libcurses/slave/curses_commands.c
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/slave/lint.lua

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-06-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 13 12:46:02 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: commands.c slave.c

Log Message:
tests/libcurses: add parentheses around argument to sizeof


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libcurses/slave/commands.c
cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libcurses/slave/slave.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/commands.c
diff -u src/tests/lib/libcurses/slave/commands.c:1.14 src/tests/lib/libcurses/slave/commands.c:1.15
--- src/tests/lib/libcurses/slave/commands.c:1.14	Mon Feb 15 07:06:27 2021
+++ src/tests/lib/libcurses/slave/commands.c	Sun Jun 13 12:46:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.14 2021/02/15 07:06:27 rillig Exp $	*/
+/*	$NetBSD: commands.c,v 1.15 2021/06/13 12:46:01 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -98,7 +98,7 @@ write_to_director(const void *mem, size_
 static void
 write_to_director_int(int i)
 {
-	write_to_director(, sizeof i);
+	write_to_director(, sizeof(i));
 }
 
 static void
@@ -218,7 +218,7 @@ report_nstr(chtype *string)
 	for (p = string; (*p & __CHARTEXT) != 0; p++)
 		continue;
 
-	size = (size_t)(p + 1 - string) * sizeof *p;
+	size = (size_t)(p + 1 - string) * sizeof(*p);
 
 	write_to_director_type(data_byte);
 	write_to_director_int(size);
@@ -233,8 +233,8 @@ report_cchar(cchar_t c)
 {
 
 	write_to_director_type(data_cchar);
-	write_to_director_int(sizeof c);
-	write_to_director(, sizeof c);
+	write_to_director_int(sizeof(c));
+	write_to_director(, sizeof(c));
 }
 
 /*
@@ -262,7 +262,7 @@ report_wstr(wchar_t *wstr)
 
 	for (p = wstr; *p != L'\0'; p++)
 		continue;
-	size = (size_t)(p + 1 - wstr) * sizeof *p;
+	size = (size_t)(p + 1 - wstr) * sizeof(*p);
 
 
 	write_to_director_type(data_wchar);

Index: src/tests/lib/libcurses/slave/slave.c
diff -u src/tests/lib/libcurses/slave/slave.c:1.16 src/tests/lib/libcurses/slave/slave.c:1.17
--- src/tests/lib/libcurses/slave/slave.c:1.16	Sat Feb 13 10:03:49 2021
+++ src/tests/lib/libcurses/slave/slave.c	Sun Jun 13 12:46:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: slave.c,v 1.16 2021/02/13 10:03:49 rillig Exp $	*/
+/*	$NetBSD: slave.c,v 1.17 2021/06/13 12:46:01 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -82,12 +82,12 @@ read_command_argument(char ***pargs, int
 	int type, len;
 	char **args = *pargs;
 
-	read_from_director(, sizeof type);
-	read_from_director(, sizeof len);
+	read_from_director(, sizeof(type));
+	read_from_director(, sizeof(len));
 	if (len < 0)
 		return false;
 
-	args = realloc(args, (argslen + 1) * sizeof args[0]);
+	args = realloc(args, (argslen + 1) * sizeof(args[0]));
 	if (args == NULL)
 		err(1, "slave realloc of args array failed");
 	*pargs = args;
@@ -134,11 +134,11 @@ process_commands(void)
 	if ((cmdbuf = malloc(maxlen)) == NULL)
 		err(1, "slave cmdbuf malloc failed");
 
-	while (try_read_from_director(, sizeof type)) {
+	while (try_read_from_director(, sizeof(type))) {
 		if (type != data_string)
 			errx(1, "Unexpected type for command, got %d", type);
 
-		read_from_director(, sizeof len);
+		read_from_director(, sizeof(len));
 
 		if ((len + 1) > maxlen) {
 			maxlen = len + 1;



CVS commit: src/tests/lib/libcurses/slave

2021-06-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 13 12:46:02 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: commands.c slave.c

Log Message:
tests/libcurses: add parentheses around argument to sizeof


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libcurses/slave/commands.c
cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libcurses/slave/slave.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-04-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Apr  4 09:34:24 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
s//string/ for mvscanw(3); string is already pointer to buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-04-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Apr  4 09:34:24 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
s//string/ for mvscanw(3); string is already pointer to buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.22 src/tests/lib/libcurses/slave/curses_commands.c:1.23
--- src/tests/lib/libcurses/slave/curses_commands.c:1.22	Sat Feb 13 08:14:46 2021
+++ src/tests/lib/libcurses/slave/curses_commands.c	Sun Apr  4 09:34:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.22 2021/02/13 08:14:46 rillig Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.23 2021/04/04 09:34:24 rin Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -1988,7 +1988,7 @@ cmd_mvscanw(int nargs, char **args)
 	ARG_STRING(2, fmt);	/* Must have a single "%s" in this test. */
 
 	report_count(2);
-	report_return(mvscanw(y, x, fmt, ));
+	report_return(mvscanw(y, x, fmt, string));
 	report_status(string);
 }
 



CVS commit: src/tests/lib/libcurses/slave

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 19:23:11 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: commands.c

Log Message:
tests/libcurses: protect against short writes

The previous code only errored out if a write failed completely.  If it
was partially written, the program continued without writing the rest of
it.

Extract the common code into a few functions that write raw data to the
parent process.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libcurses/slave/commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 19:23:11 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: commands.c

Log Message:
tests/libcurses: protect against short writes

The previous code only errored out if a write failed completely.  If it
was partially written, the program continued without writing the rest of
it.

Extract the common code into a few functions that write raw data to the
parent process.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libcurses/slave/commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/commands.c
diff -u src/tests/lib/libcurses/slave/commands.c:1.12 src/tests/lib/libcurses/slave/commands.c:1.13
--- src/tests/lib/libcurses/slave/commands.c:1.12	Sat Feb 13 08:14:46 2021
+++ src/tests/lib/libcurses/slave/commands.c	Sat Feb 13 19:23:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.12 2021/02/13 08:14:46 rillig Exp $	*/
+/*	$NetBSD: commands.c,v 1.13 2021/02/13 19:23:11 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -42,8 +42,7 @@
 
 extern int initdone;
 
-static void report_type(data_enum_t);
-static void report_message(int, const char *);
+static void report_message(data_enum_t, const char *);
 
 /*
  * Match the passed command string and execute the associated test
@@ -85,6 +84,29 @@ command_execute(char *func, int nargs, c
 	report_status("UNKNOWN_FUNCTION");
 }
 
+static void
+write_to_director(const void *mem, size_t size)
+{
+	ssize_t nwritten = write(to_director, mem, size);
+	if (nwritten == -1)
+		err(1, "writing to director failed");
+	if ((size_t)nwritten != size)
+		err(1, "short write to director, expected %zu, got %zd",
+		size, nwritten);
+}
+
+static void
+write_to_director_int(int i)
+{
+	write_to_director(, sizeof i);
+}
+
+static void
+write_to_director_type(data_enum_t return_type)
+{
+	write_to_director_int(return_type);
+}
+
 /*
  * Report an pointer value back to the director
  */
@@ -121,9 +143,9 @@ void
 report_return(int status)
 {
 	if (status == ERR)
-		report_type(data_err);
+		write_to_director_type(data_err);
 	else if (status == OK)
-		report_type(data_ok);
+		write_to_director_type(data_ok);
 	else if (status == KEY_CODE_YES)
 		report_int(status);
 	else
@@ -131,33 +153,13 @@ report_return(int status)
 }
 
 /*
- * Report the type back to the director via the command pipe
- */
-static void
-report_type(data_enum_t return_type)
-{
-	int type;
-
-	type = return_type;
-	if (write(to_director, , sizeof(int)) < 0)
-		err(1, "command pipe write for status type failed");
-
-}
-
-/*
  * Report the number of returns back to the director via the command pipe
  */
 void
 report_count(int count)
 {
-	int type;
-
-	type = data_count;
-	if (write(to_director, , sizeof(int)) < 0)
-		err(1, "command pipe write for count type failed");
-
-	if (write(to_director, , sizeof(int)) < 0)
-		err(1, "command pipe write for count");
+	write_to_director_type(data_count);
+	write_to_director_int(count);
 }
 
 /*
@@ -183,20 +185,12 @@ report_error(const char *status)
  * command pipe.
  */
 static void
-report_message(int type, const char *status)
+report_message(data_enum_t type, const char *status)
 {
-	int len;
-
-	len = strlen(status);
-
-	if (write(to_director, , sizeof(int)) < 0)
-		err(1, "command pipe write for message type failed");
-
-	if (write(to_director, , sizeof(int)) < 0)
-		err(1, "command pipe write for message length failed");
-
-	if (write(to_director, status, len) < 0)
-		err(1, "command pipe write of message data failed");
+	size_t len = strlen(status);
+	write_to_director_type(type);
+	write_to_director_int(len);
+	write_to_director(status, len);
 }
 
 /*
@@ -218,31 +212,17 @@ report_byte(chtype c)
 void
 report_nstr(chtype *string)
 {
-	int len, type;
+	size_t size;
 	chtype *p;
 
-	len = 0;
-	p = string;
+	for (p = string; (*p & __CHARTEXT) != 0; p++)
+		continue;
 
-	while ((*p++ & __CHARTEXT) != 0) {
-		len++;
-	}
+	size = (size_t)(p + 1 - string) * sizeof *p;
 
-	len++; /* add in the termination chtype */
-	len *= sizeof(chtype);
-
-	type = data_byte;
-	if (write(to_director, , sizeof(int)) < 0)
-		err(1, "%s: command pipe write for status type failed",
-		__func__);
-
-	if (write(to_director, , sizeof(int)) < 0)
-		err(1, "%s: command pipe write for status length failed",
-		__func__);
-
-	if (write(to_director, string, len) < 0)
-		err(1, "%s: command pipe write of status data failed",
-		__func__);
+	write_to_director_type(data_byte);
+	write_to_director_int(size);
+	write_to_director(string, size);
 }
 
 /*
@@ -251,21 +231,10 @@ report_nstr(chtype *string)
 void
 report_cchar(cchar_t c)
 {
-	int len, type;
-	len = sizeof(cchar_t);
-	type = data_cchar;
-
-	if (write(to_director, , sizeof(int)) < 0)
-		err(1, "%s: command pipe write for status type failed",
-		__func__);
-
-	if (write(to_director, , sizeof(int)) 

CVS commit: src/tests/lib/libcurses/slave

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 18:24:11 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: lint.lua

Log Message:
tests/libcurses: remove unused code in linter


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/slave/lint.lua

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/lint.lua
diff -u src/tests/lib/libcurses/slave/lint.lua:1.1 src/tests/lib/libcurses/slave/lint.lua:1.2
--- src/tests/lib/libcurses/slave/lint.lua:1.1	Fri Feb 12 20:41:37 2021
+++ src/tests/lib/libcurses/slave/lint.lua	Sat Feb 13 18:24:11 2021
@@ -1,5 +1,5 @@
 #! /usr/bin/lua
--- $NetBSD: lint.lua,v 1.1 2021/02/12 20:41:37 rillig Exp $
+-- $NetBSD: lint.lua,v 1.2 2021/02/13 18:24:11 rillig Exp $
 
 --[[
 
@@ -83,15 +83,6 @@ local function check_args(errors)
 end
 
 
-local function check_file(fname, msgs)
-  local errors = collect_errors(fname, msgs)
-  for _, err in ipairs(errors) do
-print(err)
-  end
-  return #errors == 0
-end
-
-
 local function main(arg)
   local errors = new_errors()
   check_args(errors)



CVS commit: src/tests/lib/libcurses/slave

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 18:24:11 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: lint.lua

Log Message:
tests/libcurses: remove unused code in linter


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/slave/lint.lua

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 10:03:49 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: slave.c

Log Message:
tests/libcurses: extract read_command_argument from process_commands

Having code indented so far to the right that each word gets its own
line is ridiculous.  Fix that.

While here, remove the cargo-cult realloc pattern, which is not needed
if the process exits immediately on error.

While here, reduce the indentation of the code by returning early.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libcurses/slave/slave.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/slave.c
diff -u src/tests/lib/libcurses/slave/slave.c:1.15 src/tests/lib/libcurses/slave/slave.c:1.16
--- src/tests/lib/libcurses/slave/slave.c:1.15	Sat Feb 13 09:28:27 2021
+++ src/tests/lib/libcurses/slave/slave.c	Sat Feb 13 10:03:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: slave.c,v 1.15 2021/02/13 09:28:27 rillig Exp $	*/
+/*	$NetBSD: slave.c,v 1.16 2021/02/13 10:03:49 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -76,6 +76,50 @@ read_from_director(void *data, size_t n)
 		n, (size_t)nread);
 }
 
+static bool
+read_command_argument(char ***pargs, int argslen)
+{
+	int type, len;
+	char **args = *pargs;
+
+	read_from_director(, sizeof type);
+	read_from_director(, sizeof len);
+	if (len < 0)
+		return false;
+
+	args = realloc(args, (argslen + 1) * sizeof args[0]);
+	if (args == NULL)
+		err(1, "slave realloc of args array failed");
+	*pargs = args;
+
+	if (type != data_null) {
+		args[argslen] = malloc(len + 1);
+
+		if (args[argslen] == NULL)
+			err(1, "slave alloc of %d bytes for args failed", len);
+	}
+
+	if (len == 0) {
+		if (type == data_null)
+			args[argslen] = NULL;
+		else
+			args[argslen][0] = '\0';
+	} else {
+		read_from_director(args[argslen], len);
+		if (type != data_byte)
+			args[argslen][len] = '\0';
+
+		if (len == 6 && strcmp(args[argslen], "STDSCR") == 0) {
+			char *stdscr_buf;
+			if (asprintf(_buf, "%p", stdscr) < 0)
+err(2, "asprintf of stdscr failed");
+			free(args[argslen]);
+			args[argslen] = stdscr_buf;
+		}
+	}
+	return true;
+}
+
 /*
  * Read the command pipe for the function to execute, gather the args
  * and then process the command.
@@ -83,8 +127,8 @@ read_from_director(void *data, size_t n)
 static void
 process_commands(void)
 {
-	int len, maxlen, argslen, i, ret, type;
-	char *cmdbuf, *tmpbuf, **args, **tmpargs;
+	int len, maxlen, argslen, i, type;
+	char *cmdbuf, *tmpbuf, **args;
 
 	len = maxlen = 30;
 	if ((cmdbuf = malloc(maxlen)) == NULL)
@@ -109,54 +153,8 @@ process_commands(void)
 		argslen = 0;
 		args = NULL;
 
-		do {
-			read_from_director(, sizeof type);
-			read_from_director(, sizeof len);
-
-			if (len >= 0) {
-tmpargs = realloc(args,
-(argslen + 1) * sizeof(char *));
-if (tmpargs == NULL)
-	err(1, "slave realloc of args array "
-	"failed");
-
-args = tmpargs;
-if (type != data_null) {
-	args[argslen] = malloc(len + 1);
-
-	if (args[argslen] == NULL)
-		err(1, "slave alloc of %d bytes"
-		" for args failed", len);
-}
-
-if (len == 0) {
-	if (type == data_null)
-		args[argslen] = NULL;
-	else
-		args[argslen][0] = '\0';
-} else {
-	read_from_director(args[argslen], len);
-	if (type != data_byte)
-		args[argslen][len] = '\0';
-
-	if (len == 6) {
-		if (strcmp(args[argslen],
-			   "STDSCR") == 0) {
-			ret = asprintf(,
- "%p",
- stdscr);
-			if (ret < 0)
-err(2,
-"asprintf of stdscr failed");
-			free(args[argslen]);
-			args[argslen] = tmpbuf;
-		}
-	}
-}
-
-argslen++;
-			}
-		} while (len >= 0);
+		while (read_command_argument(, argslen))
+			argslen++;
 
 		command_execute(cmdbuf, argslen, args);
 



CVS commit: src/tests/lib/libcurses/slave

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 10:03:49 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: slave.c

Log Message:
tests/libcurses: extract read_command_argument from process_commands

Having code indented so far to the right that each word gets its own
line is ridiculous.  Fix that.

While here, remove the cargo-cult realloc pattern, which is not needed
if the process exits immediately on error.

While here, reduce the indentation of the code by returning early.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libcurses/slave/slave.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 09:28:27 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: slave.c

Log Message:
tests/libcurses: fix reading from the parent process

In case of a short read, processing the incomplete data invoked
undefined behavior.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libcurses/slave/slave.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 09:28:27 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: slave.c

Log Message:
tests/libcurses: fix reading from the parent process

In case of a short read, processing the incomplete data invoked
undefined behavior.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libcurses/slave/slave.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/slave.c
diff -u src/tests/lib/libcurses/slave/slave.c:1.14 src/tests/lib/libcurses/slave/slave.c:1.15
--- src/tests/lib/libcurses/slave/slave.c:1.14	Sat Feb 13 09:18:12 2021
+++ src/tests/lib/libcurses/slave/slave.c	Sat Feb 13 09:28:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: slave.c,v 1.14 2021/02/13 09:18:12 rillig Exp $	*/
+/*	$NetBSD: slave.c,v 1.15 2021/02/13 09:28:27 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -50,6 +51,31 @@ static const char *returns_enum_names[] 
 };
 #endif
 
+static bool
+try_read_from_director(void *data, size_t n)
+{
+	ssize_t nread = read(from_director, data, n);
+	if (nread < 0)
+		err(2, "error reading from command pipe");
+	if (nread == 0)
+		return false;
+	if ((size_t)nread != n)
+		errx(2, "short read from command pipe: expected %zu, got %zu",
+		n, (size_t)nread);
+	return true;
+}
+
+static void
+read_from_director(void *data, size_t n)
+{
+	ssize_t nread = read(from_director, data, n);
+	if (nread < 0)
+		err(2, "error reading from command pipe");
+	if ((size_t)nread != n)
+		errx(2, "short read from command pipe: expected %zu, got %zu",
+		n, (size_t)nread);
+}
+
 /*
  * Read the command pipe for the function to execute, gather the args
  * and then process the command.
@@ -59,23 +85,16 @@ process_commands(void)
 {
 	int len, maxlen, argslen, i, ret, type;
 	char *cmdbuf, *tmpbuf, **args, **tmpargs;
-	ssize_t nread;
 
 	len = maxlen = 30;
 	if ((cmdbuf = malloc(maxlen)) == NULL)
 		err(1, "slave cmdbuf malloc failed");
 
-	for (;;) {
-		if ((nread = read(from_director, , sizeof(int))) < 0)
-			err(1, "slave command type read failed");
-		if (nread == 0)
-			break;
-
+	while (try_read_from_director(, sizeof type)) {
 		if (type != data_string)
 			errx(1, "Unexpected type for command, got %d", type);
 
-		if (read(from_director, , sizeof(int)) < 0)
-			err(1, "slave command len read failed");
+		read_from_director(, sizeof len);
 
 		if ((len + 1) > maxlen) {
 			maxlen = len + 1;
@@ -85,18 +104,14 @@ process_commands(void)
 			cmdbuf = tmpbuf;
 		}
 
-		if (read(from_director, cmdbuf, len) < 0)
-			err(1, "slave command read failed");
+		read_from_director(cmdbuf, len);
 		cmdbuf[len] = '\0';
 		argslen = 0;
 		args = NULL;
 
 		do {
-			if (read(from_director, , sizeof(int)) < 0)
-err(1, "slave arg type read failed");
-
-			if (read(from_director, , sizeof(int)) < 0)
-err(1, "slave arg len read failed");
+			read_from_director(, sizeof type);
+			read_from_director(, sizeof len);
 
 			if (len >= 0) {
 tmpargs = realloc(args,
@@ -120,8 +135,7 @@ process_commands(void)
 	else
 		args[argslen][0] = '\0';
 } else {
-	read(from_director, args[argslen],
-	 len);
+	read_from_director(args[argslen], len);
 	if (type != data_byte)
 		args[argslen][len] = '\0';
 



CVS commit: src/tests/lib/libcurses/slave

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 08:17:15 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: slave.c slave.h

Log Message:
tests/libcurses: clean up remaining include guard, comments

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libcurses/slave/slave.c
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libcurses/slave/slave.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-02-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 13 08:17:15 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: slave.c slave.h

Log Message:
tests/libcurses: clean up remaining include guard, comments

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libcurses/slave/slave.c
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libcurses/slave/slave.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/slave.c
diff -u src/tests/lib/libcurses/slave/slave.c:1.12 src/tests/lib/libcurses/slave/slave.c:1.13
--- src/tests/lib/libcurses/slave/slave.c:1.12	Sat Feb 13 06:45:42 2021
+++ src/tests/lib/libcurses/slave/slave.c	Sat Feb 13 08:17:15 2021
@@ -1,7 +1,8 @@
-/*	$NetBSD: slave.c,v 1.12 2021/02/13 06:45:42 rillig Exp $	*/
+/*	$NetBSD: slave.c,v 1.13 2021/02/13 08:17:15 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
+ * Copyright 2021 Roland Illig 
  *
  * All rights reserved.
  *
@@ -25,9 +26,8 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
  */
+
 #include 
 #include 
 #include 

Index: src/tests/lib/libcurses/slave/slave.h
diff -u src/tests/lib/libcurses/slave/slave.h:1.6 src/tests/lib/libcurses/slave/slave.h:1.7
--- src/tests/lib/libcurses/slave/slave.h:1.6	Sat Feb 13 06:45:42 2021
+++ src/tests/lib/libcurses/slave/slave.h	Sat Feb 13 08:17:15 2021
@@ -1,7 +1,8 @@
-/*	$NetBSD: slave.h,v 1.6 2021/02/13 06:45:42 rillig Exp $	*/
+/*	$NetBSD: slave.h,v 1.7 2021/02/13 08:17:15 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
+ * Copyright 2021 Roland Illig 
  *
  * All rights reserved.
  *
@@ -25,11 +26,10 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
  */
-#ifndef CURTEST_SLAVE_H
-#define CURTEST_SLAVE_H
+
+#ifndef CTF_SLAVE_H
+#define CTF_SLAVE_H
 
 #include 
 



CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 21:29:54 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: slave.c

Log Message:
tests/libcurses: format misleading do-while loop


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libcurses/slave/slave.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 21:29:54 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: slave.c

Log Message:
tests/libcurses: format misleading do-while loop


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libcurses/slave/slave.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/slave.c
diff -u src/tests/lib/libcurses/slave/slave.c:1.10 src/tests/lib/libcurses/slave/slave.c:1.11
--- src/tests/lib/libcurses/slave/slave.c:1.10	Tue Feb  9 20:42:31 2021
+++ src/tests/lib/libcurses/slave/slave.c	Fri Feb 12 21:29:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: slave.c,v 1.10 2021/02/09 20:42:31 rillig Exp $	*/
+/*	$NetBSD: slave.c,v 1.11 2021/02/12 21:29:54 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -64,7 +64,7 @@ process_commands(void)
 	if ((cmdbuf = malloc(maxlen)) == NULL)
 		err(1, "slave cmdbuf malloc failed");
 
-	while (1) {
+	for (;;) {
 		if (read(cmdpipe[READ_PIPE], , sizeof(int)) < 0)
 			err(1, "slave command type read failed");
 
@@ -139,8 +139,7 @@ process_commands(void)
 
 argslen++;
 			}
-		}
-		while (len >= 0);
+		} while (len >= 0);
 
 		command_execute(cmdbuf, argslen, args);
 



CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 21:29:03 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: command_table.h curses_commands.h

Log Message:
tests/libcurses: remove wrong comments


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libcurses/slave/command_table.h \
src/tests/lib/libcurses/slave/curses_commands.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/command_table.h
diff -u src/tests/lib/libcurses/slave/command_table.h:1.5 src/tests/lib/libcurses/slave/command_table.h:1.6
--- src/tests/lib/libcurses/slave/command_table.h:1.5	Mon Feb  8 19:15:21 2021
+++ src/tests/lib/libcurses/slave/command_table.h	Fri Feb 12 21:29:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: command_table.h,v 1.5 2021/02/08 19:15:21 rillig Exp $	*/
+/*	$NetBSD: command_table.h,v 1.6 2021/02/12 21:29:03 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -430,4 +430,4 @@ struct command_def commands[] = {
 
 size_t ncmds = sizeof(commands) / sizeof(struct command_def);
 
-#endif /* _COMMAND_TABLE_H */
+#endif
Index: src/tests/lib/libcurses/slave/curses_commands.h
diff -u src/tests/lib/libcurses/slave/curses_commands.h:1.5 src/tests/lib/libcurses/slave/curses_commands.h:1.6
--- src/tests/lib/libcurses/slave/curses_commands.h:1.5	Mon Feb  8 19:15:21 2021
+++ src/tests/lib/libcurses/slave/curses_commands.h	Fri Feb 12 21:29:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.h,v 1.5 2021/02/08 19:15:21 rillig Exp $	*/
+/*	$NetBSD: curses_commands.h,v 1.6 2021/02/12 21:29:03 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -458,4 +458,4 @@ void cmd_slk_set(int, char**);
 void cmd_slk_touch(int, char**);
 void cmd_slk_wset(int, char**);
 
-#endif /* !_CURSES_COMMAND_H_ */
+#endif



CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 21:29:03 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: command_table.h curses_commands.h

Log Message:
tests/libcurses: remove wrong comments


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libcurses/slave/command_table.h \
src/tests/lib/libcurses/slave/curses_commands.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 20:45:00 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: remove excess empty lines


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 20:45:00 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: remove excess empty lines


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.20 src/tests/lib/libcurses/slave/curses_commands.c:1.21
--- src/tests/lib/libcurses/slave/curses_commands.c:1.20	Fri Feb 12 20:41:37 2021
+++ src/tests/lib/libcurses/slave/curses_commands.c	Fri Feb 12 20:45:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.20 2021/02/12 20:41:37 rillig Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.21 2021/02/12 20:45:00 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -971,7 +971,6 @@ cmd_mvinstr(int nargs, char **args)
 }
 
 
-
 void
 cmd_mvwaddbytes(int nargs, char **args)
 {
@@ -3532,7 +3531,6 @@ cmd_winsstr(int nargs, char **args)
 }
 
 
-
 void
 cmd_chgat(int nargs, char **args)
 {
@@ -3645,7 +3643,6 @@ cmd_mvwadd_wch(int nargs, char **args)
 }
 
 
-
 void
 cmd_add_wchnstr(int nargs, char **args)
 {
@@ -3734,7 +3731,6 @@ cmd_mvwadd_wchstr(int nargs, char **args
 }
 
 
-
 void
 cmd_addnwstr(int nargs, char **args)
 {
@@ -3839,7 +3835,6 @@ cmd_waddwstr(int nargs, char **args)
 }
 
 
-
 void
 cmd_echo_wchar(int nargs, char **args)
 {
@@ -3875,7 +3870,6 @@ cmd_pecho_wchar(int nargs, char **args)
 }
 
 
-
 /* insert */
 void
 cmd_ins_wch(int nargs, char **args)
@@ -3927,7 +3921,6 @@ cmd_mvwins_wch(int nargs, char **args)
 }
 
 
-
 void
 cmd_ins_nwstr(int nargs, char **args)
 {
@@ -4032,7 +4025,6 @@ cmd_wins_wstr(int nargs, char **args)
 }
 
 
-
 /* input */
 void
 cmd_get_wch(int nargs, char **args)
@@ -4102,7 +4094,6 @@ cmd_wget_wch(int nargs, char **args)
 }
 
 
-
 void
 cmd_getn_wstr(int nargs, char **args)
 {
@@ -4221,7 +4212,6 @@ cmd_wget_wstr(int nargs, char **args)
 }
 
 
-
 void
 cmd_in_wch(int nargs, char **args)
 {
@@ -4367,7 +4357,6 @@ cmd_win_wchstr(int nargs, char **args)
 }
 
 
-
 void
 cmd_innwstr(int nargs, char **args)
 {
@@ -4487,7 +4476,6 @@ cmd_winwstr(int nargs, char **args)
 }
 
 
-
 /* cchar handling */
 void
 cmd_setcchar(int nargs, char **args)
@@ -4529,7 +4517,6 @@ cmd_getcchar(int nargs, char **args)
 }
 
 
-
 /* misc */
 void
 cmd_key_name(int nargs, char **args)



CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 20:41:37 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c
Added Files:
src/tests/lib/libcurses/slave: lint.lua

Log Message:
tests/libcurses: query function arguments in consistent order


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/tests/lib/libcurses/slave/curses_commands.c
cvs rdiff -u -r0 -r1.1 src/tests/lib/libcurses/slave/lint.lua

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 20:41:37 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c
Added Files:
src/tests/lib/libcurses/slave: lint.lua

Log Message:
tests/libcurses: query function arguments in consistent order


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/tests/lib/libcurses/slave/curses_commands.c
cvs rdiff -u -r0 -r1.1 src/tests/lib/libcurses/slave/lint.lua

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.19 src/tests/lib/libcurses/slave/curses_commands.c:1.20
--- src/tests/lib/libcurses/slave/curses_commands.c:1.19	Fri Feb 12 18:20:05 2021
+++ src/tests/lib/libcurses/slave/curses_commands.c	Fri Feb 12 20:41:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.19 2021/02/12 18:20:05 rillig Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.20 2021/02/12 20:41:37 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -150,6 +150,16 @@ set_scrn(char *arg, SCREEN **x)
 	if (set_scrn(args[i], ) != 0)\
 		return
 
+/*
+ * Required by the API, intended for future extensions, but this
+ * implementation does not support the extension.
+ */
+#define ARG_NULL(i) \
+	(void)0
+
+#define ARG_IGNORE(i) \
+	(void)0
+
 void
 cmd_DRAIN(int nargs, char **args)
 {
@@ -391,7 +401,7 @@ cmd_color_set(int nargs, char **args)
 {
 	ARGC(2);
 	ARG_SHORT(0, colour_pair);
-	/* TODO: arg 1 */
+	ARG_NULL(1);
 
 	report_count(1);
 	report_return(color_set(colour_pair, NULL));
@@ -1947,8 +1957,8 @@ cmd_mvhline(int nargs, char **args)
 	ARGC(4);
 	ARG_INT(0, y);
 	ARG_INT(1, x);
-	ARG_INT(3, n);
 	ARG_CHTYPE(2, ch);
+	ARG_INT(3, n);
 
 	report_count(1);
 	report_return(mvhline(y, x, ch, n));
@@ -1991,8 +2001,8 @@ cmd_mvvline(int nargs, char **args)
 	ARGC(4);
 	ARG_INT(0, y);
 	ARG_INT(1, x);
-	ARG_INT(3, n);
 	ARG_CHTYPE(2, ch);
+	ARG_INT(3, n);
 
 	report_count(1);
 	report_return(mvvline(y, x, ch, n));
@@ -2006,8 +2016,8 @@ cmd_mvwhline(int nargs, char **args)
 	ARG_WINDOW(0, win);
 	ARG_INT(1, y);
 	ARG_INT(2, x);
-	ARG_INT(4, n);
 	ARG_CHTYPE(3, ch);
+	ARG_INT(4, n);
 
 	report_count(1);
 	report_return(mvwhline(win, y, x, ch, n));
@@ -2021,8 +2031,8 @@ cmd_mvwvline(int nargs, char **args)
 	ARG_WINDOW(0, win);
 	ARG_INT(1, y);
 	ARG_INT(2, x);
-	ARG_INT(4, n);
 	ARG_CHTYPE(3, ch);
+	ARG_INT(4, n);
 
 	report_count(1);
 	report_return(mvwvline(win, y, x, ch, n));
@@ -3007,7 +3017,7 @@ cmd_wcolor_set(int nargs, char **args)
 	ARGC(3);
 	ARG_WINDOW(0, win);
 	ARG_SHORT(1, pair);
-	/* TODO: arg 2 */
+	ARG_NULL(2);
 
 	report_count(1);
 	report_return(wcolor_set(win, pair, NULL));
@@ -3107,8 +3117,8 @@ cmd_whline(int nargs, char **args)
 {
 	ARGC(3);
 	ARG_WINDOW(0, win);
-	ARG_INT(2, count);
 	ARG_CHTYPE(1, ch);
+	ARG_INT(2, count);
 
 	report_count(1);
 	report_return(whline(win, ch, count));
@@ -3409,8 +3419,8 @@ cmd_wvline(int nargs, char **args)
 {
 	ARGC(3);
 	ARG_WINDOW(0, win);
-	ARG_INT(2, n);
 	ARG_CHTYPE(1, ch);
+	ARG_INT(2, n);
 
 	report_count(1);
 	report_return(wvline(win, ch, n));
@@ -3530,8 +3540,8 @@ cmd_chgat(int nargs, char **args)
 	ARG_INT(0, n);
 	ARG_INT(1, attr);
 	ARG_INT(2, colour);
+	ARG_NULL(3);
 
-	/* Note: 4th argument unused in current curses implementation */
 	report_count(1);
 	report_return(chgat(n, attr, colour, NULL));
 }
@@ -3545,6 +3555,7 @@ cmd_wchgat(int nargs, char **args)
 	ARG_INT(1, n);
 	ARG_INT(2, attr);
 	ARG_SHORT(3, colour);
+	ARG_NULL(4);
 
 	report_count(1);
 	report_return(wchgat(win, n, attr, colour, NULL));
@@ -3560,6 +3571,7 @@ cmd_mvchgat(int nargs, char **args)
 	ARG_INT(2, n);
 	ARG_INT(3, attr);
 	ARG_SHORT(4, colour);
+	ARG_NULL(5);
 
 	report_count(1);
 	report_return(mvchgat(y, x, n, attr, colour, NULL));
@@ -3576,6 +3588,7 @@ cmd_mvwchgat(int nargs, char **args)
 	ARG_INT(3, n);
 	ARG_INT(4, attr);
 	ARG_SHORT(5, colour);
+	ARG_NULL(6);
 
 	report_count(1);
 	report_return(mvwchgat(win, y, x, n, attr, colour, NULL));
@@ -3637,6 +3650,7 @@ void
 cmd_add_wchnstr(int nargs, char **args)
 {
 	ARGC(1);
+	ARG_IGNORE(0);
 
 	report_count(1);
 	report_error("UNSUPPORTED");
@@ -3647,6 +3661,7 @@ void
 cmd_add_wchstr(int nargs, char **args)
 {
 	ARGC(1);
+	ARG_IGNORE(0);
 
 	report_count(1);
 	report_error("UNSUPPORTED");
@@ -3657,6 +3672,7 @@ void
 cmd_wadd_wchnstr(int nargs, char **args)
 {
 	ARGC(1);
+	ARG_IGNORE(0);
 
 	report_count(1);
 	report_error("UNSUPPORTED");
@@ -3667,6 +3683,7 @@ void
 cmd_wadd_wchstr(int nargs, char **args)
 {
 	ARGC(1);
+	ARG_IGNORE(0);
 
 	report_count(1);
 	report_error("UNSUPPORTED");
@@ -3677,6 +3694,7 @@ void
 cmd_mvadd_wchnstr(int nargs, char **args)
 {
 	ARGC(1);
+	ARG_IGNORE(0);
 
 	report_count(1);
 	report_error("UNSUPPORTED");
@@ -3687,6 +3705,7 @@ void
 cmd_mvadd_wchstr(int nargs, char **args)
 {
 	ARGC(1);
+	ARG_IGNORE(0);
 
 	

CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 18:20:05 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: don't access args directly

By providing declarative syntax for accessing the arguments, the
unnecessarily detailed boilerplate code is hidden.  This allows easy
inspection by tools and humans, to check for typos and other mistakes.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 18:20:05 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: don't access args directly

By providing declarative syntax for accessing the arguments, the
unnecessarily detailed boilerplate code is hidden.  This allows easy
inspection by tools and humans, to check for typos and other mistakes.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.18 src/tests/lib/libcurses/slave/curses_commands.c:1.19
--- src/tests/lib/libcurses/slave/curses_commands.c:1.18	Fri Feb 12 16:59:32 2021
+++ src/tests/lib/libcurses/slave/curses_commands.c	Fri Feb 12 18:20:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.18 2021/02/12 16:59:32 rillig Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.19 2021/02/12 18:20:05 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -119,10 +119,23 @@ set_scrn(char *arg, SCREEN **x)
 		return
 
 #define ARG_CHTYPE(i, arg) \
-	chtype arg = ((chtype *)args[i])[0]
+	chtype arg = ((const chtype *)args[i])[0]
+
+#define ARG_WCHAR(i, arg) \
+	wchar_t arg = ((const wchar_t *)args[i])[0]
+
+#define ARG_STRING(i, arg) \
+	const char *arg = args[i]
+
+/* Only used for legacy interfaces that are missing the 'const'. */
+#define ARG_MODIFIABLE_STRING(i, arg) \
+	char *arg = args[i]
+
+#define ARG_CHTYPE_STRING(i, arg) \
+	const chtype *arg = (const chtype *)args[i]
 
 #define ARG_CCHAR_STRING(i, arg) \
-	cchar_t *arg = (cchar_t *)args[i]
+	const cchar_t *arg = (const cchar_t *)args[i]
 
 #define ARG_WCHAR_STRING(i, arg) \
 	wchar_t *arg = (wchar_t *)args[i]
@@ -152,11 +165,11 @@ void
 cmd_addbytes(int nargs, char **args)
 {
 	ARGC(2);
-	/* TODO: arg 0 */
+	ARG_STRING(0, str);
 	ARG_INT(1, count);
 
 	report_count(1);
-	report_return(addbytes(args[0], count));
+	report_return(addbytes(str, count));
 }
 
 
@@ -175,11 +188,11 @@ void
 cmd_addchnstr(int nargs, char **args)
 {
 	ARGC(2);
-	/* TODO: arg 0 */
+	ARG_CHTYPE_STRING(0, chstr);
 	ARG_INT(1, count);
 
 	report_count(1);
-	report_return(addchnstr((chtype *) args[0], count));
+	report_return(addchnstr(chstr, count));
 }
 
 
@@ -187,10 +200,10 @@ void
 cmd_addchstr(int nargs, char **args)
 {
 	ARGC(1);
-	/* TODO: arg 0 */
+	ARG_CHTYPE_STRING(0, chstr);
 
 	report_count(1);
-	report_return(addchstr((chtype *) args[0]));
+	report_return(addchstr(chstr));
 }
 
 
@@ -198,11 +211,11 @@ void
 cmd_addnstr(int nargs, char **args)
 {
 	ARGC(2);
-	/* TODO: arg 0 */
+	ARG_STRING(0, str);
 	ARG_INT(1, count);
 
 	report_count(1);
-	report_return(addnstr(args[0], count));
+	report_return(addnstr(str, count));
 }
 
 
@@ -210,10 +223,10 @@ void
 cmd_addstr(int nargs, char **args)
 {
 	ARGC(1);
-	/* TODO: arg 0 */
+	ARG_STRING(0, str);
 
 	report_count(1);
-	report_return(addstr(args[0]));
+	report_return(addstr(str));
 }
 
 
@@ -684,11 +697,11 @@ cmd_waddbytes(int nargs, char **args)
 {
 	ARGC(3);
 	ARG_WINDOW(0, win);
-	/* TODO: arg 1 */
+	ARG_STRING(1, str);
 	ARG_INT(2, count);
 
 	report_count(1);
-	report_return(waddbytes(win, args[1], count));
+	report_return(waddbytes(win, str, count));
 }
 
 
@@ -697,10 +710,10 @@ cmd_waddstr(int nargs, char **args)
 {
 	ARGC(2);
 	ARG_WINDOW(0, win);
-	/* TODO: arg 1 */
+	ARG_STRING(1, str);
 
 	report_count(1);
-	report_return(waddstr(win, args[1]));
+	report_return(waddstr(win, str));
 }
 
 
@@ -710,11 +723,11 @@ cmd_mvaddbytes(int nargs, char **args)
 	ARGC(4);
 	ARG_INT(0, y);
 	ARG_INT(1, x);
-	/* TODO: arg 2 */
+	ARG_STRING(2, str);
 	ARG_INT(3, count);
 
 	report_count(1);
-	report_return(mvaddbytes(y, x, args[2], count));
+	report_return(mvaddbytes(y, x, str, count));
 }
 
 
@@ -737,11 +750,11 @@ cmd_mvaddchnstr(int nargs, char **args)
 	ARGC(4);
 	ARG_INT(0, y);
 	ARG_INT(1, x);
-	/* TODO: arg 2 */
+	ARG_CHTYPE_STRING(2, chstr);
 	ARG_INT(3, count);
 
 	report_count(1);
-	report_return(mvaddchnstr(y, x, (chtype *) args[2], count));
+	report_return(mvaddchnstr(y, x, chstr, count));
 }
 
 
@@ -751,10 +764,10 @@ cmd_mvaddchstr(int nargs, char **args)
 	ARGC(3);
 	ARG_INT(0, y);
 	ARG_INT(1, x);
-	/* TODO: arg 2 */
+	ARG_CHTYPE_STRING(2, chstr);
 
 	report_count(1);
-	report_return(mvaddchstr(y, x, (chtype *) args[2]));
+	report_return(mvaddchstr(y, x, chstr));
 }
 
 
@@ -764,11 +777,11 @@ cmd_mvaddnstr(int nargs, char **args)
 	ARGC(4);
 	ARG_INT(0, y);
 	ARG_INT(1, x);
-	/* TODO: arg 2 */
+	ARG_STRING(2, str);
 	ARG_INT(3, count);
 
 	report_count(1);
-	report_return(mvaddnstr(y, x, args[2], count));
+	report_return(mvaddnstr(y, x, str, count));
 }
 
 
@@ -778,10 +791,10 @@ cmd_mvaddstr(int nargs, char **args)
 	ARGC(3);
 	ARG_INT(0, y);
 	ARG_INT(1, x);
-	/* TODO: arg 2 */
+	

CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 16:59:32 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.17 src/tests/lib/libcurses/slave/curses_commands.c:1.18
--- src/tests/lib/libcurses/slave/curses_commands.c:1.17	Fri Feb 12 16:49:18 2021
+++ src/tests/lib/libcurses/slave/curses_commands.c	Fri Feb 12 16:59:32 2021
@@ -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 
@@ -118,8 +118,8 @@ set_scrn(char *arg, SCREEN **x)
 	if (set_uint(args[i], ) != 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 @@ void
 cmd_addch(int nargs, char **args)
 {
 	ARGC(1);
-	ARG_CHTYPE_STRING(0, ch);
+	ARG_CHTYPE(0, ch);
 
 	report_count(1);
-	report_return(addch(ch[0]));
+	report_return(addch(ch));
 }
 
 
@@ -306,10 +306,10 @@ void
 cmd_bkgd(int nargs, char **args)
 {
 	ARGC(1);
-	ARG_CHTYPE_STRING(0, ch);
+	ARG_CHTYPE(0, ch);
 
 	report_count(1);
-	report_return(bkgd(ch[0]));
+	report_return(bkgd(ch));
 }
 
 
@@ -317,9 +317,9 @@ void
 cmd_bkgdset(int nargs, char **args)
 {
 	ARGC(1);
-	ARG_CHTYPE_STRING(0, ch);
+	ARG_CHTYPE(0, ch);
 
-	bkgdset(ch[0]);		/* returns void */
+	bkgdset(ch);		/* returns void */
 	report_count(1);
 	report_return(OK);
 }
@@ -409,11 +409,11 @@ void
 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 @@ void
 cmd_insch(int nargs, char **args)
 {
 	ARGC(1);
-	ARG_CHTYPE_STRING(0, ch);
+	ARG_CHTYPE(0, ch);
 
 	report_count(1);
-	report_return(insch(ch[0]));
+	report_return(insch(ch));
 }
 
 
@@ -724,10 +724,10 @@ cmd_mvaddch(int nargs, char **args)
 	ARGC(3);
 	ARG_INT(0, y);
 	ARG_INT(1, x);
-	ARG_CHTYPE_STRING(2, ch);
+	ARG_CHTYPE(2, ch);
 
 	report_count(1);
-	report_return(mvaddch(y, x, ch[0]));
+	report_return(mvaddch(y, x, ch));
 }
 
 
@@ -926,10 +926,10 @@ cmd_mvinsch(int nargs, char **args)
 	ARGC(3);
 	ARG_INT(0, y);
 	ARG_INT(1, x);
-	ARG_CHTYPE_STRING(2, ch);
+	ARG_CHTYPE(2, ch);
 
 	report_count(1);
-	report_return(mvinsch(y, x, ch[0]));
+	report_return(mvinsch(y, x, ch));
 }
 
 
@@ -971,10 +971,10 @@ cmd_mvwaddch(int nargs, char **args)
 	ARG_WINDOW(0, win);
 	ARG_INT(1, y);
 	ARG_INT(2, x);
-	ARG_CHTYPE_STRING(3, ch);
+	ARG_CHTYPE(3, ch);
 
 	report_count(1);
-	report_return(mvwaddch(win, y, x, ch[0]));
+	report_return(mvwaddch(win, y, x, ch));
 }
 
 
@@ -1120,10 +1120,10 @@ cmd_mvwinsch(int nargs, char **args)
 	ARG_WINDOW(0, win);
 	ARG_INT(1, y);
 	ARG_INT(2, x);
-	ARG_CHTYPE_STRING(3, ch);
+	ARG_CHTYPE(3, ch);
 
 	report_count(1);
-	report_return(mvwinsch(win, y, x, ch[0]));
+	report_return(mvwinsch(win, y, x, ch));
 }
 
 
@@ -1697,11 +1697,11 @@ void
 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 @@ cmd_mvhline(int nargs, char **args)
 	ARG_INT(0, y);
 	ARG_INT(1, x);
 	ARG_INT(3, n);
-	ARG_CHTYPE_STRING(2, ch);
+	ARG_CHTYPE(2, ch);
 
 	report_count(1);
-	report_return(mvhline(y, x, ch[0], n));
+	report_return(mvhline(y, x, ch, n));
 }
 
 
@@ -1973,10 +1973,10 @@ cmd_mvvline(int nargs, char **args)
 	ARG_INT(0, y);
 	ARG_INT(1, x);
 	ARG_INT(3, n);
-	ARG_CHTYPE_STRING(2, ch);
+	ARG_CHTYPE(2, ch);
 
 	report_count(1);
-	report_return(mvvline(y, x, ch[0], n));
+	report_return(mvvline(y, x, ch, n));
 }
 
 
@@ -1988,10 +1988,10 @@ cmd_mvwhline(int nargs, char **args)
 	ARG_INT(1, y);
 	ARG_INT(2, x);
 	ARG_INT(4, n);
-	ARG_CHTYPE_STRING(3, ch);
+	ARG_CHTYPE(3, ch);
 
 	report_count(1);
-	report_return(mvwhline(win, y, x, ch[0], n));
+	report_return(mvwhline(win, y, x, ch, n));
 }
 
 
@@ -2003,10 +2003,10 @@ cmd_mvwvline(int nargs, char **args)
 	ARG_INT(1, y);
 	ARG_INT(2, x);
 	ARG_INT(4, n);
-	ARG_CHTYPE_STRING(3, 

CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 16:59:32 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 16:49:19 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: add shortcut macros for SCREEN and unsigned int


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.16 src/tests/lib/libcurses/slave/curses_commands.c:1.17
--- src/tests/lib/libcurses/slave/curses_commands.c:1.16	Fri Feb 12 14:05:57 2021
+++ src/tests/lib/libcurses/slave/curses_commands.c	Fri Feb 12 16:49:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.16 2021/02/12 14:05:57 rillig Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.17 2021/02/12 16:49:18 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -113,6 +113,11 @@ set_scrn(char *arg, SCREEN **x)
 	if (set_int(args[i], ) != 0)\
 		return
 
+#define ARG_UINT(i, arg) \
+	unsigned int arg;		\
+	if (set_uint(args[i], ) != 0)\
+		return
+
 #define ARG_CHTYPE_STRING(i, arg) \
 	chtype *arg = (chtype *)args[i]
 
@@ -127,6 +132,11 @@ set_scrn(char *arg, SCREEN **x)
 	if (set_win(args[i], ) != 0)\
 		return
 
+#define ARG_SCREEN(i, arg) \
+	SCREEN *arg;			\
+	if (set_scrn(args[i], ) != 0)\
+		return
+
 void
 cmd_DRAIN(int nargs, char **args)
 {
@@ -1200,15 +1210,14 @@ cmd_clearok(int nargs, char **args)
 void
 cmd_color_content(int nargs, char **args)
 {
-	short colour, red, green, blue;
-
 	ARGC(1);
+	ARG_SHORT(0, colour);
 
-	if (set_short(args[0], ) != 0)
-		return;
+	short red, green, blue;
+	int ret = color_content(colour, , , );
 
 	report_count(4);
-	report_return(color_content(colour, , , ));
+	report_return(ret);
 	report_int(red);
 	report_int(green);
 	report_int(blue);
@@ -1291,14 +1300,11 @@ cmd_delay_output(int nargs, char **args)
 void
 cmd_delscreen(int nargs, char **args)
 {
-	SCREEN *scrn;
-
 	ARGC(1);
-
-	if (set_scrn(args[0], ) != 0)
-		return;
+	ARG_SCREEN(0, scrn);
 
 	delscreen(scrn);	/* void return */
+
 	report_count(1);
 	report_return(OK);
 }
@@ -1841,12 +1847,8 @@ cmd_is_keypad(int nargs, char **args)
 void
 cmd_keyname(int nargs, char **args)
 {
-	unsigned int key;
-
 	ARGC(1);
-
-	if (set_uint(args[0], ) != 0)
-		return;
+	ARG_UINT(0, key);
 
 	report_count(1);
 	report_status(keyname(key));
@@ -2311,15 +2313,14 @@ cmd_overwrite(int nargs, char **args)
 void
 cmd_pair_content(int nargs, char **args)
 {
-	short pair, fore, back;
-
 	ARGC(1);
+	ARG_SHORT(0, pair);
 
-	if (set_short(args[0], ) != 0)
-		return;
+	short fore, back;
+	int ret = pair_content(pair, , );
 
 	report_count(3);
-	report_return(pair_content(pair, , ));
+	report_return(ret);
 	report_int(fore);
 	report_int(back);
 }
@@ -2536,11 +2537,8 @@ cmd_setterm(int nargs, char **args)
 void
 cmd_set_term(int nargs, char **args)
 {
-	SCREEN *scrn;
-
 	ARGC(1);
-
-	if (set_scrn(args[0], ) != 0) return;
+	ARG_SCREEN(0, scrn);
 
 	report_count(1);
 	report_ptr(set_term(scrn));



CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 16:49:19 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: add shortcut macros for SCREEN and unsigned int


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 14:05:57 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: remove redundant comments

There is nothing surprising about call2, call3 or call4.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.15 src/tests/lib/libcurses/slave/curses_commands.c:1.16
--- src/tests/lib/libcurses/slave/curses_commands.c:1.15	Fri Feb 12 12:58:52 2021
+++ src/tests/lib/libcurses/slave/curses_commands.c	Fri Feb 12 14:05:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.15 2021/02/12 12:58:52 rillig Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.16 2021/02/12 14:05:57 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -218,7 +218,6 @@ cmd_attr_get(int nargs, char **args)
 
 	retval = attr_get(, , NULL);
 
-	/*  - call3 */
 	report_count(3);
 	report_return(retval);
 	report_int(attrs);
@@ -442,7 +441,7 @@ cmd_getnstr(int nargs, char **args)
 		report_error("MALLOC_FAILED");
 		return;
 	}
-	/* XXX call2 */
+
 	report_count(2);
 	report_return(getnstr(string, limit));
 	report_status(string);
@@ -457,7 +456,6 @@ cmd_getstr(int nargs, char **args)
 
 	ARGC(0);
 
-	/* XXX call2 */
 	report_count(2);
 	report_return(getstr(string));
 	report_status(string);
@@ -487,7 +485,7 @@ cmd_inchnstr(int nargs, char **args)
 		report_error("MALLOC_FAILED");
 		return;
 	}
-	/* XXX call2 */
+
 	report_count(2);
 	report_return(inchnstr(string, limit));
 	report_nstr(string);
@@ -502,7 +500,6 @@ cmd_inchstr(int nargs, char **args)
 
 	ARGC(0);
 
-	/* XXX call2 */
 	report_count(2);
 	report_return(inchstr(string));
 	report_nstr(string);
@@ -522,7 +519,7 @@ cmd_innstr(int nargs, char **args)
 		report_error("MALLOC_FAILED");
 		return;
 	}
-	/* XXX call2 */
+
 	report_count(2);
 	report_int(innstr(string, limit));
 	report_status(string);
@@ -569,7 +566,6 @@ cmd_instr(int nargs, char **args)
 
 	ARGC(0);
 
-	/* XXX call2 */
 	report_count(2);
 	report_return(instr(string));
 	report_status(string);
@@ -818,7 +814,7 @@ cmd_mvgetnstr(int nargs, char **args)
 		report_error("MALLOC_FAILED");
 		return;
 	}
-	/* XXX call2 */
+
 	report_count(2);
 	report_return(mvgetnstr(y, x, string, count));
 	report_status(string);
@@ -835,7 +831,6 @@ cmd_mvgetstr(int nargs, char **args)
 	ARG_INT(0, y);
 	ARG_INT(1, x);
 
-	/* XXX call2 */
 	report_count(2);
 	report_return(mvgetstr(y, x, string));
 	report_status(string);
@@ -869,7 +864,7 @@ cmd_mvinchnstr(int nargs, char **args)
 		report_error("MALLOC_FAILED");
 		return;
 	}
-	/* XXX call2 */
+
 	report_count(2);
 	report_return(mvinchnstr(y, x, string, count));
 	report_nstr(string);
@@ -886,7 +881,6 @@ cmd_mvinchstr(int nargs, char **args)
 	ARG_INT(0, y);
 	ARG_INT(1, x);
 
-	/* XXX call2 */
 	report_count(2);
 	report_return(mvinchstr(y, x, string));
 	report_nstr(string);
@@ -908,7 +902,7 @@ cmd_mvinnstr(int nargs, char **args)
 		report_error("MALLOC_FAILED");
 		return;
 	}
-	/* XXX call2 */
+
 	report_count(2);
 	report_int(mvinnstr(y, x, string, count));
 	report_status(string);
@@ -1072,7 +1066,7 @@ cmd_mvwgetnstr(int nargs, char **args)
 		report_error("MALLOC_FAILED");
 		return;
 	}
-	/* XXX call2 */
+
 	report_count(2);
 	report_return(mvwgetnstr(win, y, x, string, count));
 	report_status(string);
@@ -1090,7 +1084,6 @@ cmd_mvwgetstr(int nargs, char **args)
 	ARG_INT(1, y);
 	ARG_INT(2, x);
 
-	/* XXX - call2 */
 	report_count(2);
 	report_return(mvwgetstr(win, y, x, string));
 	report_status(string);
@@ -1214,7 +1207,6 @@ cmd_color_content(int nargs, char **args
 	if (set_short(args[0], ) != 0)
 		return;
 
-	/* XXX - call4 */
 	report_count(4);
 	report_return(color_content(colour, , , ));
 	report_int(red);
@@ -1429,7 +1421,6 @@ cmd_fullname(int nargs, char **args)
 
 	ARGC(1);
 
-	/* XXX - call2 */
 	report_count(2);
 	report_status(fullname(args[0], string));
 	report_status(string);
@@ -1967,7 +1958,6 @@ cmd_mvscanw(int nargs, char **args)
 	ARG_INT(0, y);
 	ARG_INT(1, x);
 
-	/* XXX - call2 */
 	report_count(2);
 	report_return(mvscanw(y, x, args[2], ));
 	report_status(string);
@@ -2047,7 +2037,7 @@ cmd_mvwinchnstr(int nargs, char **args)
 		report_error("MALLOC_FAILED");
 		return;
 	}
-	/* XXX call2 */
+
 	report_count(2);
 	report_return(mvwinchnstr(win, y, x, string, count));
 	report_nstr(string);
@@ -2065,7 +2055,6 @@ cmd_mvwinchstr(int nargs, char **args)
 	ARG_INT(1, y);
 	ARG_INT(2, x);
 
-	/* XXX call2 */
 	report_count(2);
 	report_return(mvwinchstr(win, y, x, string));
 	report_nstr(string);
@@ -2078,7 +2067,6 @@ cmd_mvwinnstr(int nargs, char **args)
 	char *string;
 
 	ARGC(4);
-
 	ARG_WINDOW(0, win);
 	ARG_INT(1, y);
 	

CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 14:05:57 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: remove redundant comments

There is nothing surprising about call2, call3 or call4.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 12:58:52 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: reduce boilerplate in function dispatcher

No functional change.  The generated code for GCC 9.3 on NetBSD 9.99.80
x86_64 is exactly the same as before.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.14 src/tests/lib/libcurses/slave/curses_commands.c:1.15
--- src/tests/lib/libcurses/slave/curses_commands.c:1.14	Fri Feb 12 08:55:32 2021
+++ src/tests/lib/libcurses/slave/curses_commands.c	Fri Feb 12 12:58:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.14 2021/02/12 08:55:32 rillig Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.15 2021/02/12 12:58:52 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -103,11 +103,25 @@ set_scrn(char *arg, SCREEN **x)
 	if (check_arg_count(nargs, n) == 1)\
 		return
 
+#define ARG_SHORT(i, arg) \
+	short arg;			\
+	if (set_short(args[i], ) != 0)\
+		return
+
 #define ARG_INT(i, arg) \
 	int arg;			\
 	if (set_int(args[i], ) != 0)\
 		return
 
+#define ARG_CHTYPE_STRING(i, arg) \
+	chtype *arg = (chtype *)args[i]
+
+#define ARG_CCHAR_STRING(i, arg) \
+	cchar_t *arg = (cchar_t *)args[i]
+
+#define ARG_WCHAR_STRING(i, arg) \
+	wchar_t *arg = (wchar_t *)args[i]
+
 #define ARG_WINDOW(i, arg) \
 	WINDOW *arg;			\
 	if (set_win(args[i], ) != 0)\
@@ -128,6 +142,7 @@ void
 cmd_addbytes(int nargs, char **args)
 {
 	ARGC(2);
+	/* TODO: arg 0 */
 	ARG_INT(1, count);
 
 	report_count(1);
@@ -138,11 +153,9 @@ cmd_addbytes(int nargs, char **args)
 void
 cmd_addch(int nargs, char **args)
 {
-	chtype *ch;
-
 	ARGC(1);
+	ARG_CHTYPE_STRING(0, ch);
 
-	ch = (chtype *) args[0];
 	report_count(1);
 	report_return(addch(ch[0]));
 }
@@ -152,6 +165,7 @@ void
 cmd_addchnstr(int nargs, char **args)
 {
 	ARGC(2);
+	/* TODO: arg 0 */
 	ARG_INT(1, count);
 
 	report_count(1);
@@ -163,6 +177,7 @@ void
 cmd_addchstr(int nargs, char **args)
 {
 	ARGC(1);
+	/* TODO: arg 0 */
 
 	report_count(1);
 	report_return(addchstr((chtype *) args[0]));
@@ -173,6 +188,7 @@ void
 cmd_addnstr(int nargs, char **args)
 {
 	ARGC(2);
+	/* TODO: arg 0 */
 	ARG_INT(1, count);
 
 	report_count(1);
@@ -184,6 +200,7 @@ void
 cmd_addstr(int nargs, char **args)
 {
 	ARGC(1);
+	/* TODO: arg 0 */
 
 	report_count(1);
 	report_return(addstr(args[0]));
@@ -234,14 +251,9 @@ cmd_attr_on(int nargs, char **args)
 void
 cmd_attr_set(int nargs, char **args)
 {
-	int attrib;
-	short pair;
-
 	ARGC(2);
-
-	if ((set_int(args[0], ) != 0) ||
-	(set_short(args[1], ) != 0))
-		return;
+	ARG_INT(0, attrib);
+	ARG_SHORT(1, pair);
 
 	report_count(1);
 	report_return(attr_set(attrib, pair, NULL));
@@ -284,11 +296,9 @@ cmd_attrset(int nargs, char **args)
 void
 cmd_bkgd(int nargs, char **args)
 {
-	chtype *ch;
-
 	ARGC(1);
+	ARG_CHTYPE_STRING(0, ch);
 
-	ch = (chtype *) args[0];
 	report_count(1);
 	report_return(bkgd(ch[0]));
 }
@@ -297,11 +307,8 @@ cmd_bkgd(int nargs, char **args)
 void
 cmd_bkgdset(int nargs, char **args)
 {
-	chtype *ch;
-
 	ARGC(1);
-
-	ch = (chtype *) args[0];
+	ARG_CHTYPE_STRING(0, ch);
 
 	bkgdset(ch[0]);		/* returns void */
 	report_count(1);
@@ -312,19 +319,15 @@ cmd_bkgdset(int nargs, char **args)
 void
 cmd_border(int nargs, char **args)
 {
-	int ls, rs, ts, bs, tl, tr, bl, br;
-
 	ARGC(8);
-
-	if ((set_int(args[0], ) != 0) ||
-	(set_int(args[1], ) != 0) ||
-	(set_int(args[2], ) != 0) ||
-	(set_int(args[3], ) != 0) ||
-	(set_int(args[4], ) != 0) ||
-	(set_int(args[5], ) != 0) ||
-	(set_int(args[6], ) != 0) ||
-	(set_int(args[7], ) != 0))
-		return;
+	ARG_INT(0, ls);
+	ARG_INT(1, rs);
+	ARG_INT(2, ts);
+	ARG_INT(3, bs);
+	ARG_INT(4, tl);
+	ARG_INT(5, tr);
+	ARG_INT(6, bl);
+	ARG_INT(7, br);
 
 	report_count(1);
 	report_return(border(ls, rs, ts, bs, tl, tr, bl, br));
@@ -364,13 +367,9 @@ cmd_clrtoeol(int nargs, char **args)
 void
 cmd_color_set(int nargs, char **args)
 {
-	short colour_pair;
-
 	ARGC(2);
-
-	if (set_short(args[0], _pair) != 0)
-		return;
-	/* XXX: args[1] is unused */
+	ARG_SHORT(0, colour_pair);
+	/* TODO: arg 1 */
 
 	report_count(1);
 	report_return(color_set(colour_pair, NULL));
@@ -400,10 +399,9 @@ cmd_deleteln(int nargs, char **args)
 void
 cmd_echochar(int nargs, char **args)
 {
-	chtype *ch;
 	ARGC(1);
+	ARG_CHTYPE_STRING(0, ch);
 
-	ch = (chtype *) args[0];
 	/* XXX causes refresh */
 	report_count(1);
 	report_return(echochar(ch[0]));
@@ -535,10 +533,9 @@ cmd_innstr(int nargs, char **args)
 void
 cmd_insch(int nargs, char **args)
 {
-	chtype *ch;
 	ARGC(1);
+	ARG_CHTYPE_STRING(0, ch);
 
-	ch = (chtype *) args[0];
 	report_count(1);
 	

CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 12:58:52 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: reduce boilerplate in function dispatcher

No functional change.  The generated code for GCC 9.3 on NetBSD 9.99.80
x86_64 is exactly the same as before.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 08:55:32 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: reduce boilerplate in function dispatcher

This makes the code more declarative and easier to reason about.

The generated code stays exactly the same.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 12 08:55:32 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: reduce boilerplate in function dispatcher

This makes the code more declarative and easier to reason about.

The generated code stays exactly the same.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.13 src/tests/lib/libcurses/slave/curses_commands.c:1.14
--- src/tests/lib/libcurses/slave/curses_commands.c:1.13	Tue Feb  9 20:22:11 2021
+++ src/tests/lib/libcurses/slave/curses_commands.c	Fri Feb 12 08:55:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.13 2021/02/09 20:22:11 rillig Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.14 2021/02/12 08:55:32 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -99,16 +99,25 @@ set_scrn(char *arg, SCREEN **x)
 	return 0;
 }
 
+#define ARGC(n) \
+	if (check_arg_count(nargs, n) == 1)\
+		return
+
+#define ARG_INT(i, arg) \
+	int arg;			\
+	if (set_int(args[i], ) != 0)\
+		return
+
+#define ARG_WINDOW(i, arg) \
+	WINDOW *arg;			\
+	if (set_win(args[i], ) != 0)\
+		return
 
 void
 cmd_DRAIN(int nargs, char **args)
 {
-	WINDOW *win;
-	if (check_arg_count(nargs, 1) == 1)
-		return;
-
-	if (set_win(args[0], ) != 0)
-		return;
+	ARGC(1);
+	ARG_WINDOW(0, win);
 
 	while (wgetch(win) != ERR);
 	report_count(1);
@@ -118,13 +127,8 @@ cmd_DRAIN(int nargs, char **args)
 void
 cmd_addbytes(int nargs, char **args)
 {
-	int count;
-
-	if (check_arg_count(nargs, 2) == 1)
-		return;
-
-	if (set_int(args[1], ) != 0)
-		return;
+	ARGC(2);
+	ARG_INT(1, count);
 
 	report_count(1);
 	report_return(addbytes(args[0], count));
@@ -136,8 +140,7 @@ cmd_addch(int nargs, char **args)
 {
 	chtype *ch;
 
-	if (check_arg_count(nargs, 1) == 1)
-		return;
+	ARGC(1);
 
 	ch = (chtype *) args[0];
 	report_count(1);
@@ -148,13 +151,8 @@ cmd_addch(int nargs, char **args)
 void
 cmd_addchnstr(int nargs, char **args)
 {
-	int count;
-
-	if (check_arg_count(nargs, 2) == 1)
-		return;
-
-	if (set_int(args[1], ) != 0)
-		return;
+	ARGC(2);
+	ARG_INT(1, count);
 
 	report_count(1);
 	report_return(addchnstr((chtype *) args[0], count));
@@ -164,8 +162,7 @@ cmd_addchnstr(int nargs, char **args)
 void
 cmd_addchstr(int nargs, char **args)
 {
-	if (check_arg_count(nargs, 1) == 1)
-		return;
+	ARGC(1);
 
 	report_count(1);
 	report_return(addchstr((chtype *) args[0]));
@@ -175,13 +172,8 @@ cmd_addchstr(int nargs, char **args)
 void
 cmd_addnstr(int nargs, char **args)
 {
-	int count;
-
-	if (check_arg_count(nargs, 2) == 1)
-		return;
-
-	if (set_int(args[1], ) != 0)
-		return;
+	ARGC(2);
+	ARG_INT(1, count);
 
 	report_count(1);
 	report_return(addnstr(args[0], count));
@@ -191,8 +183,7 @@ cmd_addnstr(int nargs, char **args)
 void
 cmd_addstr(int nargs, char **args)
 {
-	if (check_arg_count(nargs, 1) == 1)
-		return;
+	ARGC(1);
 
 	report_count(1);
 	report_return(addstr(args[0]));
@@ -206,8 +197,7 @@ cmd_attr_get(int nargs, char **args)
 	short colours;
 	int retval;
 
-	if (check_arg_count(nargs, 0) == 1)
-		return;
+	ARGC(0);
 
 	retval = attr_get(, , NULL);
 
@@ -222,13 +212,8 @@ cmd_attr_get(int nargs, char **args)
 void
 cmd_attr_off(int nargs, char **args)
 {
-	int attrib;
-
-	if (check_arg_count(nargs, 1) == 1)
-		return;
-
-	if (set_int(args[0], ) != 0)
-		return;
+	ARGC(1);
+	ARG_INT(0, attrib);
 
 	report_count(1);
 	report_return(attr_off(attrib, NULL));
@@ -238,13 +223,8 @@ cmd_attr_off(int nargs, char **args)
 void
 cmd_attr_on(int nargs, char **args)
 {
-	int attrib;
-
-	if (check_arg_count(nargs, 1) == 1)
-		return;
-
-	if (set_int(args[0], ) != 0)
-		return;
+	ARGC(1);
+	ARG_INT(0, attrib);
 
 	report_count(1);
 	report_return(attr_on(attrib, NULL));
@@ -257,8 +237,7 @@ cmd_attr_set(int nargs, char **args)
 	int attrib;
 	short pair;
 
-	if (check_arg_count(nargs, 2) == 1)
-		return;
+	ARGC(2);
 
 	if ((set_int(args[0], ) != 0) ||
 	(set_short(args[1], ) != 0))
@@ -272,13 +251,8 @@ cmd_attr_set(int nargs, char **args)
 void
 cmd_attroff(int nargs, char **args)
 {
-	int attrib;
-
-	if (check_arg_count(nargs, 1) == 1)
-		return;
-
-	if (set_int(args[0], ) != 0)
-		return;
+	ARGC(1);
+	ARG_INT(0, attrib);
 
 	report_count(1);
 	report_return(attroff(attrib));
@@ -288,13 +262,8 @@ cmd_attroff(int nargs, char **args)
 void
 cmd_attron(int nargs, char **args)
 {
-	int attrib;
-
-	if (check_arg_count(nargs, 1) == 1)
-		return;
-
-	if (set_int(args[0], ) != 0)
-		return;
+	ARGC(1);
+	ARG_INT(0, attrib);
 
 	report_count(1);
 	report_return(attron(attrib));
@@ -304,13 +273,8 @@ cmd_attron(int nargs, char **args)
 void
 cmd_attrset(int nargs, char **args)
 {
-	int attrib;
-
-	if 

CVS commit: src/tests/lib/libcurses/slave

2021-02-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Feb  9 20:39:20 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: commands.c

Log Message:
tests/libcurses: replace remaining strcasecmp with strcmp

There is no reason to write special functions in a different case than
the canonical one, just like for the regular curses functions.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libcurses/slave/commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/commands.c
diff -u src/tests/lib/libcurses/slave/commands.c:1.8 src/tests/lib/libcurses/slave/commands.c:1.9
--- src/tests/lib/libcurses/slave/commands.c:1.8	Tue Feb  9 20:24:02 2021
+++ src/tests/lib/libcurses/slave/commands.c	Tue Feb  9 20:39:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.8 2021/02/09 20:24:02 rillig Exp $	*/
+/*	$NetBSD: commands.c,v 1.9 2021/02/09 20:39:20 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -61,12 +61,12 @@ command_execute(char *func, int nargs, c
 		if (strcmp(func, commands[i].name) == 0) {
 			/* Check only restricted set of functions is called before
 			 * initscr/newterm */
-			if(!initdone){
+			if (!initdone){
 j = 0;
-while(j < nrcmds) {
-	if(strcasecmp(func, restricted_commands[j]) == 0){
-		if(strcasecmp(func, "initscr") == 0  ||
-			strcasecmp(func, "newterm") == 0)
+while (j < nrcmds) {
+	if (strcmp(func, restricted_commands[j]) == 0) {
+		if (strcmp(func, "initscr") == 0  ||
+			strcmp(func, "newterm") == 0)
 			initdone = 1;
 		/* matched function */
 		commands[i].func(nargs, args);



CVS commit: src/tests/lib/libcurses/slave

2021-02-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Feb  9 20:39:20 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: commands.c

Log Message:
tests/libcurses: replace remaining strcasecmp with strcmp

There is no reason to write special functions in a different case than
the canonical one, just like for the regular curses functions.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libcurses/slave/commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-02-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Feb  9 20:24:02 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: commands.c

Log Message:
tests/libcurses: compare function names case-sensitive

There is absolutely no reason to write function names in upper case or
mixed case.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libcurses/slave/commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/commands.c
diff -u src/tests/lib/libcurses/slave/commands.c:1.7 src/tests/lib/libcurses/slave/commands.c:1.8
--- src/tests/lib/libcurses/slave/commands.c:1.7	Mon Feb  8 19:15:21 2021
+++ src/tests/lib/libcurses/slave/commands.c	Tue Feb  9 20:24:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.7 2021/02/08 19:15:21 rillig Exp $	*/
+/*	$NetBSD: commands.c,v 1.8 2021/02/09 20:24:02 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -58,7 +58,7 @@ command_execute(char *func, int nargs, c
 
 	i = 0;
 	while (i < ncmds) {
-		if (strcasecmp(func, commands[i].name) == 0) {
+		if (strcmp(func, commands[i].name) == 0) {
 			/* Check only restricted set of functions is called before
 			 * initscr/newterm */
 			if(!initdone){



CVS commit: src/tests/lib/libcurses/slave

2021-02-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Feb  9 20:24:02 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: commands.c

Log Message:
tests/libcurses: compare function names case-sensitive

There is absolutely no reason to write function names in upper case or
mixed case.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libcurses/slave/commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2021-02-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Feb  9 20:22:11 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: fix scanf parameter for unsigned int


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.12 src/tests/lib/libcurses/slave/curses_commands.c:1.13
--- src/tests/lib/libcurses/slave/curses_commands.c:1.12	Mon Feb  8 19:15:21 2021
+++ src/tests/lib/libcurses/slave/curses_commands.c	Tue Feb  9 20:22:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.12 2021/02/08 19:15:21 rillig Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.13 2021/02/09 20:22:11 rillig Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -54,7 +54,7 @@ set_int(char *arg, int *x)
 int
 set_uint(char *arg, unsigned int *x)
 {
-	if (sscanf(arg, "%d", x) == 0) {
+	if (sscanf(arg, "%u", x) == 0) {
 		report_count(1);
 		report_error("BAD ARGUMENT");
 		return -1;



CVS commit: src/tests/lib/libcurses/slave

2021-02-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Feb  9 20:22:11 UTC 2021

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
tests/libcurses: fix scanf parameter for unsigned int


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2019-05-26 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Sun May 26 07:47:37 UTC 2019

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
Start supporting wide char tests.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2019-05-26 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Sun May 26 07:47:37 UTC 2019

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
Start supporting wide char tests.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.8 src/tests/lib/libcurses/slave/curses_commands.c:1.9
--- src/tests/lib/libcurses/slave/curses_commands.c:1.8	Fri Apr 26 02:46:00 2019
+++ src/tests/lib/libcurses/slave/curses_commands.c	Sun May 26 07:47:37 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.8 2019/04/26 02:46:00 blymn Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.9 2019/05/26 07:47:37 blymn Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -6143,11 +6143,15 @@ cmd_mvwchgat(int nargs, char **args)
 void
 cmd_add_wch(int nargs, char **args)
 {
+	cchar_t *ch;
+
 	if (check_arg_count(nargs, 1) == 1)
 		return;
 
+	ch = (cchar_t *) args[0];
+
 	report_count(1);
-	report_error("UNSUPPORTED");
+	report_return(add_wch(ch));
 }
 
 



CVS commit: src/tests/lib/libcurses/slave

2019-04-25 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Fri Apr 26 02:46:00 UTC 2019

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
Fix argument parsing for mvinsch, last arg is a chtype not a string.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2019-04-25 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Fri Apr 26 02:46:00 UTC 2019

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
Fix argument parsing for mvinsch, last arg is a chtype not a string.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.7 src/tests/lib/libcurses/slave/curses_commands.c:1.8
--- src/tests/lib/libcurses/slave/curses_commands.c:1.7	Wed Sep 19 11:51:08 2012
+++ src/tests/lib/libcurses/slave/curses_commands.c	Fri Apr 26 02:46:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.7 2012/09/19 11:51:08 blymn Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.8 2019/04/26 02:46:00 blymn Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn 
@@ -1274,7 +1274,8 @@ cmd_mvinnstr(int nargs, char **args)
 void
 cmd_mvinsch(int nargs, char **args)
 {
-	int y, x, ch;
+	int y, x;
+	chtype *ch;
 
 	if (check_arg_count(nargs, 3) == 1)
 		return;
@@ -1291,14 +1292,10 @@ cmd_mvinsch(int nargs, char **args)
 		return;
 	}
 
-	if (sscanf(args[2], "%d", ) == 0) {
-		report_count(1);
-		report_error("BAD ARGUMENT");
-		return;
-	}
+	ch = (chtype *) args[2];
 
 	report_count(1);
-	report_return(mvinsch(y, x, ch));
+	report_return(mvinsch(y, x, ch[0]));
 }
 
 



CVS commit: src/tests/lib/libcurses/slave

2012-09-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Wed Sep 19 11:51:08 UTC 2012

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
* Fix mvscanw return
* Fix the *vline family of calls, one argument is chtype not int


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.6 src/tests/lib/libcurses/slave/curses_commands.c:1.7
--- src/tests/lib/libcurses/slave/curses_commands.c:1.6	Thu Sep 15 11:46:19 2011
+++ src/tests/lib/libcurses/slave/curses_commands.c	Wed Sep 19 11:51:08 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.6 2011/09/15 11:46:19 blymn Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.7 2012/09/19 11:51:08 blymn Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn bl...@netbsd.org
@@ -3005,7 +3005,8 @@ cmd_mvderwin(int nargs, char **args)
 void
 cmd_mvhline(int nargs, char **args)
 {
-	int y, x, ch, n;
+	int y, x, n;
+	chtype *ch;
 
 	if (check_arg_count(nargs, 4) == 1)
 		return;
@@ -3022,11 +3023,7 @@ cmd_mvhline(int nargs, char **args)
 		return;
 	}
 
-	if (sscanf(args[2], %d, ch) == 0) {
-		report_count(1);
-		report_error(BAD ARGUMENT);
-		return;
-	}
+	ch = (chtype *) args[2];
 
 	if (sscanf(args[3], %d, n) == 0) {
 		report_count(1);
@@ -3035,7 +3032,7 @@ cmd_mvhline(int nargs, char **args)
 	}
 
 	report_count(1);
-	report_return(mvhline(y, x, ch, n));
+	report_return(mvhline(y, x, ch[0], n));
 }
 
 
@@ -3087,7 +3084,7 @@ cmd_mvscanw(int nargs, char **args)
 
 	/* XXX - call2 */
 	report_count(2);
-	report_int(mvscanw(y, x, args[2], string));
+	report_return(mvscanw(y, x, args[2], string));
 	report_status(string);
 }
 
@@ -3095,7 +3092,8 @@ cmd_mvscanw(int nargs, char **args)
 void
 cmd_mvvline(int nargs, char **args)
 {
-	int y, x, ch, n;
+	int y, x, n;
+	chtype *ch;
 
 	if (check_arg_count(nargs, 4) == 1)
 		return;
@@ -3112,11 +3110,7 @@ cmd_mvvline(int nargs, char **args)
 		return;
 	}
 
-	if (sscanf(args[2], %d, ch) == 0) {
-		report_count(1);
-		report_error(BAD ARGUMENT);
-		return;
-	}
+	ch = (chtype *) args[2];
 
 	if (sscanf(args[3], %d, n) == 0) {
 		report_count(1);
@@ -3125,7 +3119,7 @@ cmd_mvvline(int nargs, char **args)
 	}
 
 	report_count(1);
-	report_return(mvvline(y, x, ch, n));
+	report_return(mvvline(y, x, ch[0], n));
 }
 
 
@@ -3176,8 +3170,9 @@ cmd_mvwhline(int nargs, char **args)
 void
 cmd_mvwvline(int nargs, char **args)
 {
-	int y, x, ch, n;
+	int y, x, n;
 	WINDOW *win;
+	chtype *ch;
 
 	if (check_arg_count(nargs, 5) == 1)
 		return;
@@ -3200,11 +3195,7 @@ cmd_mvwvline(int nargs, char **args)
 		return;
 	}
 
-	if (sscanf(args[3], %d, ch) == 0) {
-		report_count(1);
-		report_error(BAD ARGUMENT);
-		return;
-	}
+	ch = (chtype *) args[3];
 
 	if (sscanf(args[4], %d, n) == 0) {
 		report_count(1);
@@ -3213,7 +3204,7 @@ cmd_mvwvline(int nargs, char **args)
 	}
 
 	report_count(1);
-	report_return(mvwvline(win, y, x, ch, n));
+	report_return(mvwvline(win, y, x, ch[0], n));
 }
 
 
@@ -4421,16 +4412,13 @@ cmd_use_default_colors(int nargs, char *
 void
 cmd_vline(int nargs, char **args)
 {
-	int ch, count;
+	int count;
+	chtype *ch;
 
 	if (check_arg_count(nargs, 2) == 1)
 		return;
 
-	if (sscanf(args[0], %d, ch) == 0) {
-		report_count(1);
-		report_error(BAD ARGUMENT);
-		return;
-	}
+	ch = (chtype *) args[0];
 
 	if (sscanf(args[1], %d, count) == 0) {
 		report_count(1);
@@ -4439,7 +4427,7 @@ cmd_vline(int nargs, char **args)
 	}
 
 	report_count(1);
-	report_return(vline(ch, count));
+	report_return(vline(ch[0], count));
 }
 
 
@@ -5762,7 +5750,8 @@ void
 cmd_wvline(int nargs, char **args)
 {
 	WINDOW *win;
-	int ch, n;
+	int n;
+	chtype *ch;
 
 	if (check_arg_count(nargs, 3) == 1)
 		return;
@@ -5773,11 +5762,7 @@ cmd_wvline(int nargs, char **args)
 		return;
 	}
 
-	if (sscanf(args[1], %d, ch) == 0) {
-		report_count(1);
-		report_error(BAD ARGUMENT);
-		return;
-	}
+	ch = (chtype *) args[1];
 
 	if (sscanf(args[2], %d, n) == 0) {
 		report_count(1);
@@ -5786,7 +5771,7 @@ cmd_wvline(int nargs, char **args)
 	}
 
 	report_count(1);
-	report_return(wvline(win, ch, n));
+	report_return(wvline(win, ch[0], n));
 }
 
 



CVS commit: src/tests/lib/libcurses/slave

2012-09-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Wed Sep 19 11:51:08 UTC 2012

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
* Fix mvscanw return
* Fix the *vline family of calls, one argument is chtype not int


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2011-09-15 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu Sep 15 11:46:19 UTC 2011

Modified Files:
src/tests/lib/libcurses/slave: command_table.h commands.c
curses_commands.c curses_commands.h slave.c slave.h

Log Message:
- add support for getparyx and getyx calls
- allow a NULL pointer to be returned to the director
- add support for passing back a single chtype character
- fix some indentation
- fix a lot of curses command calls that were just plain wrong
- don't try to allocate storage for a NULL parameter, it doesn't need it


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/slave/command_table.h \
src/tests/lib/libcurses/slave/curses_commands.h \
src/tests/lib/libcurses/slave/slave.h
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/slave/commands.c
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libcurses/slave/curses_commands.c \
src/tests/lib/libcurses/slave/slave.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/command_table.h
diff -u src/tests/lib/libcurses/slave/command_table.h:1.2 src/tests/lib/libcurses/slave/command_table.h:1.3
--- src/tests/lib/libcurses/slave/command_table.h:1.2	Mon Apr 11 09:02:02 2011
+++ src/tests/lib/libcurses/slave/command_table.h	Thu Sep 15 11:46:19 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: command_table.h,v 1.2 2011/04/11 09:02:02 blymn Exp $	*/
+/*	$NetBSD: command_table.h,v 1.3 2011/09/15 11:46:19 blymn Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn bl...@netbsd.org
@@ -143,12 +143,14 @@
 	{getbkgd, cmd_getbkgd},
 	{getcury, cmd_getcury},
 	{getcurx, cmd_getcurx},
+	{getyx, cmd_getyx},
 	{getbegy, cmd_getbegy},
 	{getbegx, cmd_getbegx},
 	{getmaxy, cmd_getmaxy},
 	{getmaxx, cmd_getmaxx},
 	{getpary, cmd_getpary},
 	{getparx, cmd_getparx},
+	{getparyx, cmd_getparyx},
 	{gettmode, cmd_gettmode},
 	{getwin, cmd_getwin},
 	{halfdelay, cmd_halfdelay},
Index: src/tests/lib/libcurses/slave/curses_commands.h
diff -u src/tests/lib/libcurses/slave/curses_commands.h:1.2 src/tests/lib/libcurses/slave/curses_commands.h:1.3
--- src/tests/lib/libcurses/slave/curses_commands.h:1.2	Mon Apr 11 09:02:02 2011
+++ src/tests/lib/libcurses/slave/curses_commands.h	Thu Sep 15 11:46:19 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.h,v 1.2 2011/04/11 09:02:02 blymn Exp $	*/
+/*	$NetBSD: curses_commands.h,v 1.3 2011/09/15 11:46:19 blymn Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn bl...@netbsd.org
@@ -148,12 +148,14 @@
 void cmd_getbkgd(int, char **);
 void cmd_getcury(int, char **);
 void cmd_getcurx(int, char **);
+void cmd_getyx(int, char **);
 void cmd_getbegy(int, char **);
 void cmd_getbegx(int, char **);
 void cmd_getmaxy(int, char **);
 void cmd_getmaxx(int, char **);
 void cmd_getpary(int, char **);
 void cmd_getparx(int, char **);
+void cmd_getparyx(int, char **);
 void cmd_gettmode(int, char **);
 void cmd_getwin(int, char **);
 void cmd_halfdelay(int, char **);
Index: src/tests/lib/libcurses/slave/slave.h
diff -u src/tests/lib/libcurses/slave/slave.h:1.2 src/tests/lib/libcurses/slave/slave.h:1.3
--- src/tests/lib/libcurses/slave/slave.h:1.2	Sat Jun 11 18:03:18 2011
+++ src/tests/lib/libcurses/slave/slave.h	Thu Sep 15 11:46:19 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: slave.h,v 1.2 2011/06/11 18:03:18 christos Exp $	*/
+/*	$NetBSD: slave.h,v 1.3 2011/09/15 11:46:19 blymn Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn bl...@netbsd.org
@@ -40,6 +40,7 @@
 void report_count(int);
 void report_error(const char *);
 void report_int(int);
+void report_byte(chtype);
 void report_return(int);
 void report_nstr(chtype *);
 void report_status(const char *);

Index: src/tests/lib/libcurses/slave/commands.c
diff -u src/tests/lib/libcurses/slave/commands.c:1.3 src/tests/lib/libcurses/slave/commands.c:1.4
--- src/tests/lib/libcurses/slave/commands.c:1.3	Sat Jun 11 18:03:18 2011
+++ src/tests/lib/libcurses/slave/commands.c	Thu Sep 15 11:46:19 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.3 2011/06/11 18:03:18 christos Exp $	*/
+/*	$NetBSD: commands.c,v 1.4 2011/09/15 11:46:19 blymn Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn bl...@netbsd.org
@@ -76,7 +76,10 @@
 {
 	char *string;
 
-	asprintf(string, %p, ptr);
+	if (ptr == NULL)
+		asprintf(string, NULL);
+	else
+		asprintf(string, %p, ptr);
 	report_status(string);
 	free(string);
 }
@@ -181,6 +184,19 @@
  * Report a string of chtype back to the director via the command pipe.
  */
 void
+report_byte(chtype c)
+{
+	chtype string[2];
+
+	string[0] = c;
+	string[1] = A_NORMAL | '\0';
+	report_nstr(string);
+}
+
+/*
+ * Report a string of chtype back to the director via the command pipe.
+ */
+void
 report_nstr(chtype *string)
 {
 	int len, type;
@@ -193,6 +209,9 @@
 		len++;
 	}
 
+	len++; /* add in the termination chtype */
+	len *= sizeof(chtype);
+
 	type = ret_byte;
 	if (write(slvpipe[WRITE_PIPE], type, sizeof(int))  0)
 		err(1, %s: command pipe write for status type 

CVS commit: src/tests/lib/libcurses/slave

2011-09-15 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu Sep 15 11:46:19 UTC 2011

Modified Files:
src/tests/lib/libcurses/slave: command_table.h commands.c
curses_commands.c curses_commands.h slave.c slave.h

Log Message:
- add support for getparyx and getyx calls
- allow a NULL pointer to be returned to the director
- add support for passing back a single chtype character
- fix some indentation
- fix a lot of curses command calls that were just plain wrong
- don't try to allocate storage for a NULL parameter, it doesn't need it


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/slave/command_table.h \
src/tests/lib/libcurses/slave/curses_commands.h \
src/tests/lib/libcurses/slave/slave.h
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/slave/commands.c
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libcurses/slave/curses_commands.c \
src/tests/lib/libcurses/slave/slave.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2011-08-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Aug 29 12:46:04 UTC 2011

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
fix bug where we read the same argument twice. Name the timeout val the
same 'tval' in both timeout routines.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.4 src/tests/lib/libcurses/slave/curses_commands.c:1.5
--- src/tests/lib/libcurses/slave/curses_commands.c:1.4	Sat Jun 11 14:03:18 2011
+++ src/tests/lib/libcurses/slave/curses_commands.c	Mon Aug 29 08:46:03 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.4 2011/06/11 18:03:18 christos Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.5 2011/08/29 12:46:03 christos Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn bl...@netbsd.org
@@ -4088,7 +4088,7 @@
 		return;
 	}
 
-	if (sscanf(args[0], %d, flag) == 0) {
+	if (sscanf(args[1], %d, flag) == 0) {
 		report_count(1);
 		report_error(BAD ARGUMENT);
 		return;
@@ -5620,7 +5620,7 @@
 cmd_wtimeout(int nargs, char **args)
 {
 	WINDOW *win;
-	int delay;
+	int tval;
 
 	if (check_arg_count(nargs, 2) == 1)
 		return;
@@ -5631,13 +5631,13 @@
 		return;
 	}
 
-	if (sscanf(args[1], %d, delay) == 0) {
+	if (sscanf(args[1], %d, tval) == 0) {
 		report_count(1);
 		report_error(BAD ARGUMENT);
 		return;
 	}
 
-	wtimeout(win, delay); /* void return */
+	wtimeout(win, tval); /* void return */
 	report_count(1);
 	report_return(OK);
 }



CVS commit: src/tests/lib/libcurses/slave

2011-08-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 17 16:57:14 UTC 2011

Modified Files:
src/tests/lib/libcurses/slave: Makefile

Log Message:
document non-literal format strings


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libcurses/slave/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/Makefile
diff -u src/tests/lib/libcurses/slave/Makefile:1.4 src/tests/lib/libcurses/slave/Makefile:1.5
--- src/tests/lib/libcurses/slave/Makefile:1.4	Sat Jun 11 14:03:18 2011
+++ src/tests/lib/libcurses/slave/Makefile	Wed Aug 17 12:57:13 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.4 2011/06/11 18:03:18 christos Exp $
+#	$NetBSD: Makefile,v 1.5 2011/08/17 16:57:13 christos Exp $
 #
 .include bsd.own.mk
 
@@ -14,6 +14,7 @@
 CPPFLAGS+=	-g -I${.CURDIR} -I. -I${.CURDIR}/../director
 LDADD+=		-lcurses -lterminfo -Wl,--no-fatal-warnings
 
+COPTS.curses_commands.c += -Wno-format-nonliteral
 CWARNFLAGS.clang+=	-Wno-format
 
 .include bsd.test.mk



CVS commit: src/tests/lib/libcurses/slave

2011-08-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 17 16:57:14 UTC 2011

Modified Files:
src/tests/lib/libcurses/slave: Makefile

Log Message:
document non-literal format strings


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libcurses/slave/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2011-05-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 15 23:59:03 UTC 2011

Modified Files:
src/tests/lib/libcurses/slave: commands.c slave.c

Log Message:
add missing header files.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/slave/commands.c
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/slave/slave.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/commands.c
diff -u src/tests/lib/libcurses/slave/commands.c:1.1 src/tests/lib/libcurses/slave/commands.c:1.2
--- src/tests/lib/libcurses/slave/commands.c:1.1	Sun Apr 10 05:55:10 2011
+++ src/tests/lib/libcurses/slave/commands.c	Sun May 15 19:59:03 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.1 2011/04/10 09:55:10 blymn Exp $	*/
+/*	$NetBSD: commands.c,v 1.2 2011/05/15 23:59:03 christos Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn bl...@netbsd.org
@@ -33,6 +33,7 @@
 #include string.h
 #include stdlib.h
 #include stdio.h
+#include unistd.h
 #include sys/types.h
 #include returns.h
 #include slave.h

Index: src/tests/lib/libcurses/slave/slave.c
diff -u src/tests/lib/libcurses/slave/slave.c:1.2 src/tests/lib/libcurses/slave/slave.c:1.3
--- src/tests/lib/libcurses/slave/slave.c:1.2	Thu Apr 21 06:23:50 2011
+++ src/tests/lib/libcurses/slave/slave.c	Sun May 15 19:59:03 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: slave.c,v 1.2 2011/04/21 10:23:50 blymn Exp $	*/
+/*	$NetBSD: slave.c,v 1.3 2011/05/15 23:59:03 christos Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn bl...@netbsd.org
@@ -30,6 +30,8 @@
  */
 #include fcntl.h
 #include sys/ioctl.h
+#include unistd.h
+#include err.h
 #include stdio.h
 #include stdlib.h
 #include string.h



CVS commit: src/tests/lib/libcurses/slave

2011-05-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 15 23:59:03 UTC 2011

Modified Files:
src/tests/lib/libcurses/slave: commands.c slave.c

Log Message:
add missing header files.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/slave/commands.c
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/slave/slave.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2011-04-13 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Wed Apr 13 09:46:38 UTC 2011

Modified Files:
src/tests/lib/libcurses/slave: Makefile

Log Message:
Explicitly list -lterminfo after -lcurses, to support static builds.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/slave/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/Makefile
diff -u src/tests/lib/libcurses/slave/Makefile:1.1 src/tests/lib/libcurses/slave/Makefile:1.2
--- src/tests/lib/libcurses/slave/Makefile:1.1	Sun Apr 10 09:55:10 2011
+++ src/tests/lib/libcurses/slave/Makefile	Wed Apr 13 09:46:38 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1 2011/04/10 09:55:10 blymn Exp $
+#	$NetBSD: Makefile,v 1.2 2011/04/13 09:46:38 he Exp $
 #
 .include bsd.own.mk
 
@@ -12,6 +12,6 @@
 SRCS=	slave.c commands.c curses_commands.c
 
 CPPFLAGS+=	-g -I${.CURDIR} -I. -I${.CURDIR}/../director
-LDADD+=		-lcurses
+LDADD+=		-lcurses -lterminfo
 
 .include bsd.test.mk



CVS commit: src/tests/lib/libcurses/slave

2011-04-13 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Wed Apr 13 09:46:38 UTC 2011

Modified Files:
src/tests/lib/libcurses/slave: Makefile

Log Message:
Explicitly list -lterminfo after -lcurses, to support static builds.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/slave/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/tests/lib/libcurses/slave

2011-04-12 Thread Alan Barrett

On Tue, 12 Apr 2011, matthew green wrote:

+static int
+internal_vw_printw(WINDOW *win, char *arg1, ...)

This code looks identical to that in wprintw().  Why does it 
need to be duplicated under another name?


well, the test is about testing vw_printw() directly, not 
wprintw().


Ah, of course.

--apb (Alan Barrett)


Re: CVS commit: src/tests/lib/libcurses/slave

2011-04-11 Thread Alan Barrett

On Mon, 11 Apr 2011, Brett Lymn wrote:

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

+static int
+internal_vw_printw(WINDOW *win, char *arg1, ...)
+{
+   va_list va;
+   int rv;
+
+   va_start(va, arg1);
+   rv = vw_printw(win, arg1, va);
+   va_end(va);
+
+   return rv;
+}


This code looks identical to that in wprintw().  Why does it need to
be duplicated under another name?

--apb (Alan Barrett)


re: CVS commit: src/tests/lib/libcurses/slave

2011-04-11 Thread matthew green

 On Mon, 11 Apr 2011, Brett Lymn wrote:
 Modified Files:
  src/tests/lib/libcurses/slave: curses_commands.c
  
 +static int
 +internal_vw_printw(WINDOW *win, char *arg1, ...)
 +{
 +va_list va;
 +int rv;
 +
 +va_start(va, arg1);
 +rv = vw_printw(win, arg1, va);
 +va_end(va);
 +
 +return rv;
 +}
 
 This code looks identical to that in wprintw().  Why does it need to
 be duplicated under another name?

well, the test is about testing vw_printw() directly, not
wprintw().


.mrg.


CVS commit: src/tests/lib/libcurses/slave

2011-04-11 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Apr 11 09:02:03 UTC 2011

Modified Files:
src/tests/lib/libcurses/slave: command_table.h curses_commands.h

Log Message:
Incorrect licence was applied - fix this.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/slave/command_table.h \
src/tests/lib/libcurses/slave/curses_commands.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/command_table.h
diff -u src/tests/lib/libcurses/slave/command_table.h:1.1 src/tests/lib/libcurses/slave/command_table.h:1.2
--- src/tests/lib/libcurses/slave/command_table.h:1.1	Sun Apr 10 09:55:10 2011
+++ src/tests/lib/libcurses/slave/command_table.h	Mon Apr 11 09:02:02 2011
@@ -1,34 +1,31 @@
-/*	$NetBSD: command_table.h,v 1.1 2011/04/10 09:55:10 blymn Exp $	*/
+/*	$NetBSD: command_table.h,v 1.2 2011/04/11 09:02:02 blymn Exp $	*/
 
-/*
- * Copyright (c) 1981, 1993, 1994
- *	The Regents of the University of California.  All rights reserved.
+/*-
+ * Copyright 2009 Brett Lymn bl...@netbsd.org
+ *
+ * All rights reserved.
+ *
+ * This code has been donated to The NetBSD Foundation by the Author.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *may be used to endorse or promote products derived from this software
- *without specific prior written permission.
+ * 2. The name of the author may not be used to endorse or promote products
+ *derived from this software withough specific prior written permission
  *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- *	@(#)curses.h	8.5 (Berkeley) 4/29/95
  *
  */
 
Index: src/tests/lib/libcurses/slave/curses_commands.h
diff -u src/tests/lib/libcurses/slave/curses_commands.h:1.1 src/tests/lib/libcurses/slave/curses_commands.h:1.2
--- src/tests/lib/libcurses/slave/curses_commands.h:1.1	Sun Apr 10 09:55:10 2011
+++ src/tests/lib/libcurses/slave/curses_commands.h	Mon Apr 11 09:02:02 2011
@@ -1,34 +1,31 @@
-/*	$NetBSD: curses_commands.h,v 1.1 2011/04/10 09:55:10 blymn Exp $	*/
+/*	$NetBSD: curses_commands.h,v 1.2 2011/04/11 09:02:02 blymn Exp $	*/
 
-/*
- * Copyright (c) 1981, 1993, 1994
- *	The Regents of the University of California.  All rights reserved.
+/*-
+ * Copyright 2009 Brett Lymn bl...@netbsd.org
+ *
+ * All rights reserved.
+ *
+ * This code has been donated to The NetBSD Foundation by the Author.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the 

CVS commit: src/tests/lib/libcurses/slave

2011-04-11 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Apr 11 09:06:24 UTC 2011

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
Apply patch provided by mrg to fix bad calls to vw_printw and vw_scanw


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.2 src/tests/lib/libcurses/slave/curses_commands.c:1.3
--- src/tests/lib/libcurses/slave/curses_commands.c:1.2	Sun Apr 10 23:31:30 2011
+++ src/tests/lib/libcurses/slave/curses_commands.c	Mon Apr 11 09:06:24 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.2 2011/04/10 23:31:30 dholland Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.3 2011/04/11 09:06:24 blymn Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn bl...@netbsd.org
@@ -34,6 +34,8 @@
 #include stdlib.h
 #include string.h
 #include termios.h
+#include stdarg.h
+
 #include slave.h
 #include curses_commands.h
 
@@ -4398,6 +4400,19 @@
 }
 
 
+static int
+internal_vw_printw(WINDOW *win, char *arg1, ...)
+{
+	va_list va;
+	int rv;
+
+	va_start(va, arg1);
+	rv = vw_printw(win, arg1, va);
+	va_end(va);
+
+	return rv;
+}
+
 void
 cmd_vw_printw(int nargs, char **args)
 {
@@ -4413,10 +4428,23 @@
 	}
 
 	report_count(1);
-	report_return(vw_printw(win, args[1], args[2]));
+	report_return(internal_vw_printw(win, args[1], args[2]));
 }
 
 
+static int
+internal_vw_scanw(WINDOW *win, char *arg1, ...)
+{
+	va_list va;
+	int rv;
+
+	va_start(va, arg1);
+	rv = vw_scanw(win, arg1, va);
+	va_end(va);
+
+	return rv;
+}
+
 void
 cmd_vw_scanw(int nargs, char **args)
 {
@@ -4434,7 +4462,7 @@
 
 	/* XXX - call2 */
 	report_count(2);
-	report_int(vw_scanw(win, args[1], string));
+	report_int(internal_vw_scanw(win, args[1], string));
 	report_status(string);
 }
 



CVS commit: src/tests/lib/libcurses/slave

2011-04-11 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Apr 11 09:02:03 UTC 2011

Modified Files:
src/tests/lib/libcurses/slave: command_table.h curses_commands.h

Log Message:
Incorrect licence was applied - fix this.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/slave/command_table.h \
src/tests/lib/libcurses/slave/curses_commands.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2011-04-11 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Apr 11 09:06:24 UTC 2011

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
Apply patch provided by mrg to fix bad calls to vw_printw and vw_scanw


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libcurses/slave

2011-04-10 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Apr 10 23:31:30 UTC 2011

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
Fix obvious bug.
(note: this file still doesn't build on amd64)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/curses_commands.c
diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.1 src/tests/lib/libcurses/slave/curses_commands.c:1.2
--- src/tests/lib/libcurses/slave/curses_commands.c:1.1	Sun Apr 10 09:55:10 2011
+++ src/tests/lib/libcurses/slave/curses_commands.c	Sun Apr 10 23:31:30 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_commands.c,v 1.1 2011/04/10 09:55:10 blymn Exp $	*/
+/*	$NetBSD: curses_commands.c,v 1.2 2011/04/10 23:31:30 dholland Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn bl...@netbsd.org
@@ -4442,7 +4442,7 @@
 void
 cmd_vwprintw(int nargs, char **args)
 {
-	cmd_vwprintw(nargs, args);
+	cmd_vw_printw(nargs, args);
 }
 
 



CVS commit: src/tests/lib/libcurses/slave

2011-04-10 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Apr 10 23:31:30 UTC 2011

Modified Files:
src/tests/lib/libcurses/slave: curses_commands.c

Log Message:
Fix obvious bug.
(note: this file still doesn't build on amd64)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/slave/curses_commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.