Ticket #8666: longoptions.patch
File longoptions.patch, 1.1 KB (added by , 17 years ago) |
---|
-
base/commandLine.cpp
245 245 } \ 246 246 const char *option = s; \ 247 247 if (*s == '\0' && !isLongCmd) { option = s2; i++; } \ 248 if (!option ) option = defaultVal; \248 if (!option || *option == '\0') option = defaultVal; \ 249 249 if (option) settings[longCmd] = option; 250 250 251 251 // Use this for options which have a required (string) value 252 252 #define DO_OPTION(shortCmd, longCmd) \ 253 253 DO_OPTION_OPT(shortCmd, longCmd, 0) \ 254 if (!option) usage("Option '%s' requires an argument", argv[i -1]);254 if (!option) usage("Option '%s' requires an argument", argv[isLongCmd ? i : i-1]); 255 255 256 256 // Use this for options which have a required integer value 257 257 #define DO_OPTION_INT(shortCmd, longCmd) \ 258 DO_OPTION_OPT(shortCmd, longCmd, 0) \ 259 if (!option) usage("Option '%s' requires an argument", argv[i-1]); \ 258 DO_OPTION(shortCmd, longCmd) \ 260 259 char *endptr = 0; \ 261 260 int intValue; intValue = (int)strtol(option, &endptr, 0); \ 262 261 if (endptr == NULL || *endptr != 0) usage("--%s: Invalid number '%s'", longCmd, option);