Commit 87093f53 authored by Morten Welinder's avatar Morten Welinder Committed by Alexandre Julliard

(parse_options): Allow GNU-like option arguments like

"--desktop=800x600". (Not perfect -- we don't allow shorthands.)
parent 35d288bc
...@@ -248,6 +248,7 @@ static void parse_options( char *argv[] ) ...@@ -248,6 +248,7 @@ static void parse_options( char *argv[] )
for (i = 0; argv[i]; i++) for (i = 0; argv[i]; i++)
{ {
const char *equalarg = NULL;
char *p = argv[i]; char *p = argv[i];
if (*p++ != '-') continue; /* not an option */ if (*p++ != '-') continue; /* not an option */
if (*p && !p[1]) /* short name */ if (*p && !p[1]) /* short name */
...@@ -257,14 +258,31 @@ static void parse_options( char *argv[] ) ...@@ -257,14 +258,31 @@ static void parse_options( char *argv[] )
} }
else /* long name */ else /* long name */
{ {
const char *equal = strchr (p, '=');
if (*p == '-') p++; if (*p == '-') p++;
/* check for the long name */ /* check for the long name */
for (opt = option_table; opt->longname; opt++) for (opt = option_table; opt->longname; opt++) {
/* Plain --option */
if (!strcmp( p, opt->longname )) break; if (!strcmp( p, opt->longname )) break;
/* --option=value */
if (opt->has_arg &&
equal &&
strlen (opt->longname) == equal - p &&
!strncmp (p, opt->longname, equal - p)) {
equalarg = equal + 1;
break;
}
}
} }
if (!opt->longname) continue; if (!opt->longname) continue;
if (opt->has_arg && argv[i+1]) if (equalarg)
{
opt->func( equalarg );
remove_options( argv, i, 1, opt->inherit );
}
else if (opt->has_arg && argv[i+1])
{ {
opt->func( argv[i+1] ); opt->func( argv[i+1] );
remove_options( argv, i, 2, opt->inherit ); remove_options( argv, i, 2, opt->inherit );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment