From 7f12601969a83d2b5f255782c8f19e740add995d Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Wed, 15 Nov 2000 23:12:06 +0000 Subject: [PATCH] Allow the user to stick the option and its argument together. --- tools/winebuild/main.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c index 559c7963ab..da75bdc49a 100644 --- a/tools/winebuild/main.c +++ b/tools/winebuild/main.c @@ -167,21 +167,40 @@ static void do_lib( const char *arg ) static void parse_options( char *argv[] ) { 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++) - 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) { - fprintf( stderr, "Unrecognized option '%s'\n", argv[i] ); + fprintf( stderr, "Unrecognized option '%s'\n", *ptr ); 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( "" ); + ptr++; } }