Commit 7f126019 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

Allow the user to stick the option and its argument together.

parent 4b43b4d5
...@@ -167,21 +167,40 @@ static void do_lib( const char *arg ) ...@@ -167,21 +167,40 @@ static void do_lib( const char *arg )
static void parse_options( char *argv[] ) static void parse_options( char *argv[] )
{ {
const struct option *opt; const struct option *opt;
int i; char * const * ptr;
const char* arg=NULL;
for (i = 1; argv[i]; i++) ptr=argv+1;
while (*ptr != NULL)
{ {
for (opt = option_table; opt->name; opt++) for (opt = option_table; opt->name; opt++)
if (!strcmp( argv[i], opt->name )) break; {
if (opt->has_arg && !strncmp( *ptr, opt->name, strlen(opt->name) ))
{
arg=*ptr+strlen(opt->name);
if (*arg=='\0')
{
ptr++;
arg=*ptr;
}
break;
}
if (!strcmp( *ptr, opt->name ))
{
arg=NULL;
break;
}
}
if (!opt->name) if (!opt->name)
{ {
fprintf( stderr, "Unrecognized option '%s'\n", argv[i] ); fprintf( stderr, "Unrecognized option '%s'\n", *ptr );
do_usage(); do_usage();
} }
if (opt->has_arg && argv[i+1]) opt->func( argv[++i] ); if (opt->has_arg && arg!=NULL) opt->func( arg );
else opt->func( "" ); else opt->func( "" );
ptr++;
} }
} }
......
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