Fossil SCM
fix option/argument parsing for the case where an option is missing a required argument.
Commit
f80303ac73628dbfe30abd5964792ae99e638dca
Parent
8be6204607fd787…
1 file changed
+2
-1
+2
-1
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -331,10 +331,11 @@ | ||
| 331 | 331 | int nLong; |
| 332 | 332 | const char *zReturn = 0; |
| 333 | 333 | assert( hasArg==0 || hasArg==1 ); |
| 334 | 334 | nLong = strlen(zLong); |
| 335 | 335 | for(i=2; i<g.argc; i++){ |
| 336 | + if (i+hasArg >= g.argc) break; | |
| 336 | 337 | char *z = g.argv[i]; |
| 337 | 338 | if( z[0]!='-' ) continue; |
| 338 | 339 | z++; |
| 339 | 340 | if( z[0]=='-' ){ |
| 340 | 341 | if( z[1]==0 ){ |
| @@ -369,11 +370,11 @@ | ||
| 369 | 370 | */ |
| 370 | 371 | void verify_all_options(void){ |
| 371 | 372 | int i; |
| 372 | 373 | for(i=1; i<g.argc; i++){ |
| 373 | 374 | if( g.argv[i][0]=='-' ){ |
| 374 | - fossil_fatal("unrecognized command-line option: %s", g.argv[i]); | |
| 375 | + fossil_fatal("unrecognized command-line option, or missing argument: %s", g.argv[i]); | |
| 375 | 376 | } |
| 376 | 377 | } |
| 377 | 378 | } |
| 378 | 379 | |
| 379 | 380 | /* |
| 380 | 381 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -331,10 +331,11 @@ | |
| 331 | int nLong; |
| 332 | const char *zReturn = 0; |
| 333 | assert( hasArg==0 || hasArg==1 ); |
| 334 | nLong = strlen(zLong); |
| 335 | for(i=2; i<g.argc; i++){ |
| 336 | char *z = g.argv[i]; |
| 337 | if( z[0]!='-' ) continue; |
| 338 | z++; |
| 339 | if( z[0]=='-' ){ |
| 340 | if( z[1]==0 ){ |
| @@ -369,11 +370,11 @@ | |
| 369 | */ |
| 370 | void verify_all_options(void){ |
| 371 | int i; |
| 372 | for(i=1; i<g.argc; i++){ |
| 373 | if( g.argv[i][0]=='-' ){ |
| 374 | fossil_fatal("unrecognized command-line option: %s", g.argv[i]); |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | /* |
| 380 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -331,10 +331,11 @@ | |
| 331 | int nLong; |
| 332 | const char *zReturn = 0; |
| 333 | assert( hasArg==0 || hasArg==1 ); |
| 334 | nLong = strlen(zLong); |
| 335 | for(i=2; i<g.argc; i++){ |
| 336 | if (i+hasArg >= g.argc) break; |
| 337 | char *z = g.argv[i]; |
| 338 | if( z[0]!='-' ) continue; |
| 339 | z++; |
| 340 | if( z[0]=='-' ){ |
| 341 | if( z[1]==0 ){ |
| @@ -369,11 +370,11 @@ | |
| 370 | */ |
| 371 | void verify_all_options(void){ |
| 372 | int i; |
| 373 | for(i=1; i<g.argc; i++){ |
| 374 | if( g.argv[i][0]=='-' ){ |
| 375 | fossil_fatal("unrecognized command-line option, or missing argument: %s", g.argv[i]); |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | /* |
| 381 |