changeset 105:3e9057059a43

Even more command line parser fixing
author lost@l-w.ca
date Sat, 06 Aug 2011 23:20:10 -0600
parents bc82df7f6bbe
children 43a3f1068027
files lwlib/lw_cmdline.c
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lwlib/lw_cmdline.c	Sat Aug 06 22:50:54 2011 -0600
+++ b/lwlib/lw_cmdline.c	Sat Aug 06 23:20:10 2011 -0600
@@ -395,7 +395,9 @@
 				break;
 		cch++;
 		tstr = argv[i] + cch;
-		if (!*tstr && (parser -> options[j].flags & lw_cmdline_opt_optional) == 0)
+		if (*tstr == 0)
+			tstr = NULL;
+		if (!tstr && (parser -> options[j].flags & lw_cmdline_opt_optional) == 0)
 		{
 			/* only consume the next arg if the argument is optional */
 			if (nextarg < argc)
@@ -429,6 +431,8 @@
 		}
 		lw_free(tstr);
 		tstr = argv[i] + cch;
+		if (*tstr == 0)
+			tstr = NULL;
 		cch = 0;
 		i++;
 		
@@ -450,8 +454,8 @@
 			if (tstr && cch && argv[i][cch] == 0)
 				nextarg++;
 			
-			if (!*tstr)
-				tstr = NULL;
+			//if (!*tstr)
+			//	tstr = NULL;
 			
 			/* move on to next argument if we have an arg specified */
 			if (tstr && cch && argv[i][cch] != 0)