[Scummvm-cvs-logs] SF.net SVN: scummvm: [26961] scummvm/trunk/base/commandLine.cpp

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun May 27 09:37:09 CEST 2007


Revision: 26961
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26961&view=rev
Author:   fingolfin
Date:     2007-05-27 00:37:08 -0700 (Sun, 27 May 2007)

Log Message:
-----------
Patch #1726251: Reject long commandline parameters that lack the option

Modified Paths:
--------------
    scummvm/trunk/base/commandLine.cpp

Modified: scummvm/trunk/base/commandLine.cpp
===================================================================
--- scummvm/trunk/base/commandLine.cpp	2007-05-27 07:32:32 UTC (rev 26960)
+++ scummvm/trunk/base/commandLine.cpp	2007-05-27 07:37:08 UTC (rev 26961)
@@ -245,18 +245,17 @@
 		} \
 		const char *option = s; \
 		if (*s == '\0' && !isLongCmd) { option = s2; i++; } \
-		if (!option) option = defaultVal; \
+		if (!option || *option == '\0') option = defaultVal; \
 		if (option) settings[longCmd] = option;
 
 // Use this for options which have a required (string) value
 #define DO_OPTION(shortCmd, longCmd) \
 	DO_OPTION_OPT(shortCmd, longCmd, 0) \
-	if (!option) usage("Option '%s' requires an argument", argv[i-1]);
+	if (!option) usage("Option '%s' requires an argument", argv[isLongCmd ? i : i-1]);
 
 // Use this for options which have a required integer value
 #define DO_OPTION_INT(shortCmd, longCmd) \
-	DO_OPTION_OPT(shortCmd, longCmd, 0) \
-	if (!option) usage("Option '%s' requires an argument", argv[i-1]); \
+	DO_OPTION(shortCmd, longCmd) \
 	char *endptr = 0; \
 	int intValue; intValue = (int)strtol(option, &endptr, 0); \
 	if (endptr == NULL || *endptr != 0) usage("--%s: Invalid number '%s'", longCmd, option);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list