Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: curses tweaks, maybe



On Sat, Oct 20, 2007 at 09:37:09AM -0400, Clint Adams wrote:
> This needs the checking bit and a doc update.

This is probably not the most efficient.

Index: Src/Modules/curses.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/curses.c,v
retrieving revision 1.15
diff -u -r1.15 curses.c
--- Src/Modules/curses.c	20 Oct 2007 13:40:02 -0000	1.15
+++ Src/Modules/curses.c	21 Oct 2007 21:08:54 -0000
@@ -281,7 +281,7 @@
 {
     char **saargs;
     struct zcurses_subcommand *zcsc;
-    int sc;
+    int sc, num_args;
 
     struct zcurses_subcommand scs[] = {
 	{{"init", ZCURSES_SC_INIT}, 0, 0},
@@ -310,7 +310,13 @@
 	return 1;
     }
 
-    /* here would be a good place to validate number of args */
+    saargs = args;
+    while (*saargs++);
+    num_args = saargs - (args + 2);
+
+    if (num_args < zcsc->minargs || num_args > zcsc->maxargs)
+	return 1;
+
     saargs = args + 1;
 
     /* Initialise curses */



Messages sorted by: Reverse Date, Date, Thread, Author