Also support --help -v, i.e. arguments in different order.

This commit is contained in:
Christian Jullien 2020-06-01 18:01:12 +02:00
parent bbb3f79bb8
commit e640ed1aeb
2 changed files with 16 additions and 6 deletions

View File

@ -1723,6 +1723,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int *pargc, char ***pargv, int optind)
int tool = 0, arg_start = 0, noaction = optind;
char **argv = *pargv;
int argc = *pargc;
int help = 0; /* remember if -h/--help has been seen */
cstr_new(&linker_arg);
@ -1773,12 +1774,13 @@ reparse:
switch(popt->index) {
case TCC_OPTION_HELP:
if (s->verbose > 0)
return OPT_VERBOSE_HELP;
else
return OPT_HELP;
/* help is requested, postpone return to check for -v */
help = OPT_HELP;
break;
case TCC_OPTION_HELP2:
return OPT_HELP2;
/* help is requested, postpone return to check for -v */
help = OPT_HELP2;
break;
case TCC_OPTION_I:
tcc_add_include_path(s, optarg);
break;
@ -2064,6 +2066,14 @@ unsupported_option:
break;
}
}
if (help) {
if (s->verbose > 0)
return OPT_VERBOSE_HELP;
else
return help;
}
if (last_o > 0)
tcc_define_symbol(s, "__OPTIMIZE__", NULL);
if (linker_arg.size) {

2
tcc.c
View File

@ -273,7 +273,7 @@ redo:
return 0;
}
if (opt == OPT_HELP2) {
fputs(help, stdout);
fputs(help2, stdout);
return 0;
}
if (opt == OPT_VERBOSE_HELP) {