History

fix options in C scripts after -run

grischka committed 18 years ago

Commit f2698681 parent 5247bbc1 file · +14 −17Browse files

Unified · Split

tcc.c+14−17
@@ -10761,15 +10761,8 @@ int parse_args(TCCState *s, int argc, char **argv) · 10760 unmodified lines
1076110761 char *r;
1076210762
1076310763 optind = 0;
10764− while (1) {
10765− if (optind >= argc) {
10766− if (nb_files == 0 && !print_search_dirs) {
10767− if (verbose)
10768− exit(0);
10769− goto show_help;
10770− }
10771− break;
10772− }
10764+ while (optind < argc) {
10765+
1077310766 r = argv[optind++];
1077410767 if (r[0] != '-' || r[1] == '\0') {
1077510768 /* add a new file */
@@ -10808,15 +10801,14 @@ int parse_args(TCCState *s, int argc, char **argv) · 32 unmodified lines
1080810801 }
1080910802 } else {
1081010803 if (*r1 != '\0')
10811− goto show_help;
10804+ return 0;
1081210805 optarg = NULL;
1081310806 }
1081410807
1081510808 switch(popt->index) {
1081610809 case TCC_OPTION_HELP:
10817− show_help:
10818− help();
10819− exit(1);
10810+ return 0;
10811+
1082010812 case TCC_OPTION_I:
1082110813 if (tcc_add_include_path(s, optarg) < 0)
1082210814 error("too many include paths");
@@ -10963,7 +10955,7 @@ int parse_args(TCCState *s, int argc, char **argv) · 140 unmodified lines
1096310955 }
1096410956 }
1096510957 }
10966− return optind;
10958+ return optind + 1;
1096710959 }
1096810960
1096910961 int main(int argc, char **argv)
@@ -10989,14 +10981,19 @@ int main(int argc, char **argv) · 19 unmodified lines
1098910981 print_search_dirs = 0;
1099010982 ret = 0;
1099110983
10992− optind = parse_args(s, argc - 1, argv + 1) + 1;
10993−
10984+ optind = parse_args(s, argc - 1, argv + 1);
1099410985 if (print_search_dirs) {
1099510986 /* enough for Linux kernel */
1099610987 printf("install: %s/\n", tcc_lib_path);
1099710988 return 0;
1099810989 }
10999−
10990+ if (optind == 0 || nb_files == 0) {
10991+ if (optind && verbose)
10992+ return 0;
10993+ help();
10994+ return 1;
10995+ }
10996+
1100010997 nb_objfiles = nb_files - nb_libraries;
1100110998
1100210999 /* if outfile provided without other options, we output an

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