Check-in [f80303ac73]
Not logged in
Overview

SHA1 Hash:f80303ac73628dbfe30abd5964792ae99e638dca
Date: 2009-02-09 18:09:03
User: bharder
Comment:fix option/argument parsing for the case where an option is missing a required argument.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/main.c from [ea151948ee] to [c2e4729e31].

@@ -331,10 +331,11 @@
   int nLong;
   const char *zReturn = 0;
   assert( hasArg==0 || hasArg==1 );
   nLong = strlen(zLong);
   for(i=2; i<g.argc; i++){
+    if (i+hasArg >= g.argc) break;
     char *z = g.argv[i];
     if( z[0]!='-' ) continue;
     z++;
     if( z[0]=='-' ){
       if( z[1]==0 ){
@@ -369,11 +370,11 @@
 */
 void verify_all_options(void){
   int i;
   for(i=1; i<g.argc; i++){
     if( g.argv[i][0]=='-' ){
-      fossil_fatal("unrecognized command-line option: %s", g.argv[i]);
+      fossil_fatal("unrecognized command-line option, or missing argument: %s", g.argv[i]);
     }
   }
 }
 
 /*