Check-in [be758137b0]
Not logged in
Overview

SHA1 Hash:be758137b0189740217bac71db3e77012323f204
Date: 2008-05-25 11:50:31
User: drh
Comment:Allow command-line options of the form "--name=value".
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/main.c from [5193badb96] to [8f6eeea4b5].

@@ -311,12 +311,14 @@
 ** hasArg==1 means the option has an argument.  Return a pointer to the
 ** argument.
 */
 const char *find_option(const char *zLong, const char *zShort, int hasArg){
   int i;
+  int nLong;
   const char *zReturn = 0;
   assert( hasArg==0 || hasArg==1 );
+  nLong = strlen(zLong);
   for(i=2; i<g.argc; i++){
     char *z = g.argv[i];
     if( z[0]!='-' ) continue;
     z++;
     if( z[0]=='-' ){
@@ -324,11 +326,21 @@
         remove_from_argv(i, 1);
         break;
       }
       z++;
     }
-    if( strcmp(z,zLong)==0 || (zShort!=0 && strcmp(z,zShort)==0) ){
+    if( strncmp(z,zLong,nLong)==0 ){
+      if( hasArg && z[nLong]=='=' ){
+        zReturn = &z[nLong+1];
+        remove_from_argv(i, 1);
+        break;
+      }else if( z[nLong]==0 ){
+        zReturn = g.argv[i+hasArg];
+        remove_from_argv(i, 1+hasArg);
+        break;
+      }
+    }else if( zShort!=0 && strcmp(z,zShort)==0 ){
       zReturn = g.argv[i+hasArg];
       remove_from_argv(i, 1+hasArg);
       break;
     }
   }