Differences From:
File
src/main.c
part of check-in
[dbfe682b92]
- Make sure fossil_panic() text is given a proper header in CGI mode.
by
drh on
2008-05-22 12:49:31.
[view]
To:
File
src/main.c
part of check-in
[be758137b0]
- Allow command-line options of the form "--name=value".
by
drh on
2008-05-25 11:50:31.
[view]
@@ -312,10 +312,12 @@
** 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++;
@@ -325,9 +327,19 @@
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;
}