--- ./client/civclient.c 2001/08/11 07:43:46 1.1 +++ ./client/civclient.c 2001/08/11 07:47:17 @@ -88,7 +88,7 @@ **************************************************************************/ int main(int argc, char *argv[]) { - int i; + int i, n; int loglevel; char *logfile=NULL; char *option=NULL; @@ -145,9 +145,13 @@ } } else if ((option = get_option("--tiles",argv,&i,argc)) != NULL) { tile_set_name=option; - } else { - fprintf(stderr, _("Unrecognized option: \"%s\"\n"), argv[i]); - exit(1); + } else { + n = ui_valid_option(argc - i, &argv[i]); + if (n < 1) { + fprintf(stderr, _("Unrecognized option: \"%s\"\n"), argv[i]); + exit(1); + } + i += (n - 1); } i++; } /* of while */ --- ./client/gui-stub/gui_main.c 2001/08/11 07:43:46 1.1 +++ ./client/gui-stub/gui_main.c 2001/08/11 07:47:18 @@ -4,6 +4,31 @@ #include "gui_main.h" +static char *ui_single_options[] = { + "--help", + NULL +}; + +static char *ui_arg_options[] = { + NULL +}; + +int +ui_valid_option(int argc, char *argv[]) +{ + char **optptr = NULL; + int i = 0; + + for (optptr = ui_single_options ; *optptr ; ++optptr) { + if (is_option(*optptr, argv[0])) return 1; + } + for (optptr = ui_arg_options ; *optptr ; ++optptr) { + if (get_option(*optptr, argv, &i, argc)) + return (i + 1); + } + return 0; +} + void ui_main(int argc, char *argv[]) --- ./client/gui-gtk/gui_main.c 2001/08/11 07:43:46 1.1 +++ ./client/gui-gtk/gui_main.c 2001/08/11 07:47:18 @@ -148,12 +148,38 @@ fprintf(stderr, _("Report bugs to <%s>.\n"), BUG_EMAIL_ADDRESS); } + +static char *ui_single_options[] = { + "--help", + NULL +}; + +static char *ui_arg_options[] = { + NULL +}; + +int ui_valid_option(int argc, char *argv[]) +{ + char **optptr = NULL; + int i = 0; + + for (optptr = ui_single_options ; *optptr ; ++optptr) { + if (is_option(*optptr, argv[0])) return 1; + } + for (optptr = ui_arg_options ; *optptr ; ++optptr) { + if (get_option(*optptr, argv, &i, argc)) + return (i + 1); + } + return 0; +} + /************************************************************************** ... **************************************************************************/ static void parse_options(int argc, char **argv) { int i; + char *option = NULL; i = 1; while (i < argc) --- ./client/gui-mui/gui_main.c 2001/08/11 07:43:46 1.1 +++ ./client/gui-mui/gui_main.c 2001/08/11 07:47:19 @@ -103,6 +103,33 @@ /************************************************************************** ... **************************************************************************/ +static char *ui_single_options[] = { + "--help", + NULL +}; + +static char *ui_arg_options[] = { + NULL +}; + +int ui_valid_option(int argc, char *argv[]) +{ + char **optptr = NULL; + int i = 0; + + for (optptr = ui_single_options ; *optptr ; ++optptr) { + if (is_option(*optptr, argv[0])) return 1; + } + for (optptr = ui_arg_options ; *optptr ; ++optptr) { + if (get_option(*optptr, argv, &i, argc)) + return (i + 1); + } + return 0; +} + +/************************************************************************** +... +**************************************************************************/ static void parse_options(int argc, char **argv) { int i; --- ./client/gui-xaw/gui_main.c 2001/08/11 07:43:46 1.1 +++ ./client/gui-xaw/gui_main.c 2001/08/11 07:47:19 @@ -225,6 +225,35 @@ fprintf(stderr, _("Report bugs to <%s>.\n"), BUG_EMAIL_ADDRESS); } + +/************************************************************************** +... +**************************************************************************/ + +static char *ui_single_options[] = { + "--help", + NULL +}; + +static char *ui_arg_options[] = { + NULL +}; + +int ui_valid_option(int argc, char *argv[]) +{ + char **optptr = NULL; + int i = 0; + + for (optptr = ui_single_options ; *optptr ; ++optptr) { + if (is_option(*optptr, argv[0])) return 1; + } + for (optptr = ui_arg_options ; *optptr ; ++optptr) { + if (get_option(*optptr, argv, &i, argc)) + return (i + 1); + } + return 0; +} + /************************************************************************** ... **************************************************************************/ --- ./client/include/gui_main_g.h 2001/08/11 07:43:46 1.1 +++ ./client/include/gui_main_g.h 2001/08/11 07:47:19 @@ -16,6 +16,7 @@ struct unit; void ui_main(int argc, char *argv[]); +int ui_valid_option(int argc, char *argv[]); void sound_bell(void); void enable_turn_done_button(void); void add_net_input(int);