History

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

Christian Jullien committed 6 years ago

Commit e640ed11 parent bbb3f792 files · +16 −6Browse files

Unified · Split

2 files
  1. libtcc.c +15 −5
  2. tcc.c +1 −1
libtcc.c+15−5
@@ -1723,6 +1723,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int *pargc, char ***pargv, int optind) · 1722 unmodified lines
17231723 int tool = 0, arg_start = 0, noaction = optind;
17241724 char **argv = *pargv;
17251725 int argc = *pargc;
1726+ int help = 0; /* remember if -h/--help has been seen */
17261727
17271728 cstr_new(&linker_arg);
17281729
@@ -1773,12 +1774,13 @@ reparse: · 44 unmodified lines
17731774
17741775 switch(popt->index) {
17751776 case TCC_OPTION_HELP:
1776− if (s->verbose > 0)
1777− return OPT_VERBOSE_HELP;
1778− else
1779− return OPT_HELP;
1777+ /* help is requested, postpone return to check for -v */
1778+ help = OPT_HELP;
1779+ break;
17801780 case TCC_OPTION_HELP2:
1781− return OPT_HELP2;
1781+ /* help is requested, postpone return to check for -v */
1782+ help = OPT_HELP2;
1783+ break;
17821784 case TCC_OPTION_I:
17831785 tcc_add_include_path(s, optarg);
17841786 break;
@@ -2064,6 +2066,14 @@ unsupported_option: · 279 unmodified lines
20642066 break;
20652067 }
20662068 }
2069+
2070+ if (help) {
2071+ if (s->verbose > 0)
2072+ return OPT_VERBOSE_HELP;
2073+ else
2074+ return help;
2075+ }
2076+
20672077 if (last_o > 0)
20682078 tcc_define_symbol(s, "__OPTIMIZE__", NULL);
20692079 if (linker_arg.size) {
tcc.c+1−1
@@ -273,7 +273,7 @@ redo: · 272 unmodified lines
273273 return 0;
274274 }
275275 if (opt == OPT_HELP2) {
276− fputs(help, stdout);
276+ fputs(help2, stdout);
277277 return 0;
278278 }
279279 if (opt == OPT_VERBOSE_HELP) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t