changeset 52:51c840679a0e

Fixed off by one bug parsing long options
author lost@l-w.ca
date Tue, 05 Apr 2011 21:48:22 -0600
parents fd1ecc5d6e69
children cb4efc47ce9d
files lwlib/lw_cmdline.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lwlib/lw_cmdline.c	Tue Apr 05 00:17:17 2011 -0600
+++ b/lwlib/lw_cmdline.c	Tue Apr 05 21:48:22 2011 -0600
@@ -413,15 +413,16 @@
 			goto do_version;
 		/* look up name */
 		
+		fprintf(stderr, "option string: %s\n", argv[i]);
 		for (j = 2; argv[i][j] && argv[i][j] != '='; j++)
 			/* do nothing */ ;
 		tstr = lw_alloc(j - 1);
 		strncpy(tstr, argv[i] + 2, j - 2);
-		tstr[j - 1] = 0;
+		tstr[j - 2] = 0;
 		if (argv[i][j] == '=')
 			j++;
 		cch = j;
-		
+		fprintf(stderr, "Option: %s, Arg: %s\n", tstr, argv[i]+j);
 		for (j = 0; parser -> options[j].name; j++)
 		{
 			if (strcmp(parser -> options[j].name, tstr) == 0)