Mercurial > ~dholland > hg > tradcpp > index.cgi
annotate main.c @ 5:7c489c73d62b
Clear commandline_files after processing it.
author | David A. Holland |
---|---|
date | Sun, 19 Dec 2010 17:53:49 -0500 |
parents | ee9a66b87c70 |
children | 0601b6e8e53d |
rev | line source |
---|---|
4
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
1 #include <stdbool.h> |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
2 #include <stdio.h> |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
3 #include <stdlib.h> |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
4 #include <string.h> |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
5 #include <errno.h> |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
6 #include <err.h> |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
7 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
8 #include "inlinedefs.h" // XXX |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
9 #include "version.h" |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
10 #include "config.h" |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
11 #include "utils.h" |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
12 #include "array.h" |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
13 #include "mode.h" |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
14 #include "files.h" |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
15 #include "macro.h" |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
16 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
17 struct mode mode = { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
18 .werror = false, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
19 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
20 .input_allow_dollars = false, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
21 .input_tabstop = 8, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
22 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
23 .do_stdinc = true, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
24 .do_stddef = true, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
25 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
26 .do_output = true, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
27 .output_linenumbers = true, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
28 .output_retain_comments = false, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
29 .output_file = NULL, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
30 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
31 .do_depend = false, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
32 .depend_report_system = false, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
33 .depend_assume_generated = false, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
34 .depend_issue_fakerules = false, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
35 .depend_quote_target = true, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
36 .depend_target = NULL, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
37 .depend_file = NULL, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
38 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
39 .do_macrolist = false, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
40 .macrolist_include_stddef = false, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
41 .macrolist_include_expansions = false, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
42 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
43 .do_trace = false, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
44 .trace_namesonly = false, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
45 .trace_indented = false, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
46 }; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
47 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
48 struct warns warns = { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
49 .endiflabels = true, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
50 .nestcomment = false, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
51 .undef = false, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
52 .unused = false, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
53 }; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
54 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
55 //////////////////////////////////////////////////////////// |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
56 // commandline macros |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
57 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
58 struct commandline_macro { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
59 const char *macro; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
60 const char *expansion; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
61 }; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
62 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
63 static struct array commandline_macros; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
64 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
65 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
66 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
67 commandline_macros_init(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
68 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
69 array_init(&commandline_macros); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
70 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
71 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
72 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
73 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
74 commandline_macros_cleanup(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
75 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
76 array_cleanup(&commandline_macros); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
77 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
78 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
79 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
80 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
81 commandline_macro_add(const char *macro, const char *expansion) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
82 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
83 struct commandline_macro *cm; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
84 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
85 cm = domalloc(sizeof(*cm)); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
86 cm->macro = macro; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
87 cm->expansion = expansion; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
88 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
89 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
90 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
91 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
92 commandline_def(char *str) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
93 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
94 char *val; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
95 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
96 val = strchr(str, '='); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
97 if (val != NULL) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
98 *val = '\0'; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
99 val++; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
100 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
101 commandline_macro_add(str, val ? val : "1"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
102 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
103 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
104 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
105 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
106 commandline_undef(char *str) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
107 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
108 commandline_macro_add(str, NULL); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
109 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
110 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
111 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
112 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
113 apply_commandline_macros(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
114 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
115 struct commandline_macro *cm; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
116 unsigned i, num; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
117 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
118 num = array_num(&commandline_macros); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
119 for (i=0; i<num; i++) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
120 cm = array_get(&commandline_macros, i); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
121 if (cm->expansion != NULL) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
122 macro_define(NULL, cm->macro, cm->expansion); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
123 } else { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
124 macro_undef(cm->macro); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
125 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
126 free(cm); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
127 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
128 array_setsize(&commandline_macros, 0); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
129 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
130 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
131 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
132 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
133 apply_builtin_macro(const char *name, const char *val) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
134 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
135 /* XXX distinguish builtin-place and commandline-place and nowhere */ |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
136 macro_define(NULL, name, val); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
137 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
138 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
139 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
140 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
141 apply_builtin_macros(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
142 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
143 #ifdef CONFIG_OS |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
144 apply_builtin_macro(CONFIG_OS, "1"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
145 #endif |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
146 #ifdef CONFIG_OS_2 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
147 apply_builtin_macro(CONFIG_OS_2, "1"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
148 #endif |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
149 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
150 #ifdef CONFIG_CPU |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
151 apply_builtin_macro(CONFIG_CPU, "1"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
152 #endif |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
153 #ifdef CONFIG_CPU_2 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
154 apply_builtin_macro(CONFIG_CPU_2, "1"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
155 #endif |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
156 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
157 #ifdef CONFIG_SIZE |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
158 apply_builtin_macro(CONFIG_SIZE, "1"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
159 #endif |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
160 #ifdef CONFIG_BINFMT |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
161 apply_builtin_macro(CONFIG_BINFMT, "1"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
162 #endif |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
163 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
164 #ifdef CONFIG_COMPILER |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
165 apply_builtin_macro(CONFIG_COMPILER, VERSION_MAJOR); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
166 apply_builtin_macro(CONFIG_COMPILER_MINOR, VERSION_MINOR); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
167 apply_builtin_macro("__VERSION__", VERSION_LONG); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
168 #endif |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
169 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
170 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
171 //////////////////////////////////////////////////////////// |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
172 // extra included files |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
173 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
174 struct commandline_file { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
175 char *name; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
176 bool suppress_output; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
177 }; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
178 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
179 static struct array commandline_files; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
180 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
181 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
182 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
183 commandline_files_init(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
184 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
185 array_init(&commandline_files); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
186 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
187 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
188 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
189 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
190 commandline_files_cleanup(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
191 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
192 array_cleanup(&commandline_files); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
193 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
194 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
195 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
196 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
197 commandline_addfile(char *name, bool suppress_output) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
198 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
199 struct commandline_file *cf; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
200 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
201 cf = domalloc(sizeof(*cf)); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
202 cf->name = name; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
203 cf->suppress_output = suppress_output; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
204 array_add(&commandline_files, cf, NULL); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
205 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
206 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
207 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
208 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
209 commandline_addfile_output(char *name) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
210 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
211 commandline_addfile(name, false); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
212 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
213 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
214 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
215 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
216 commandline_addfile_nooutput(char *name) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
217 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
218 commandline_addfile(name, true); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
219 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
220 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
221 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
222 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
223 read_commandline_files(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
224 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
225 struct commandline_file *cf; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
226 unsigned i, num; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
227 bool save = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
228 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
229 num = array_num(&commandline_files); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
230 for (i=0; i<num; i++) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
231 cf = array_get(&commandline_files, i); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
232 if (cf->suppress_output) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
233 save = mode.do_output; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
234 mode.do_output = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
235 files_read(NULL, cf->name); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
236 mode.do_output = save; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
237 } else { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
238 files_read(NULL, cf->name); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
239 } |
5
7c489c73d62b
Clear commandline_files after processing it.
David A. Holland
parents:
4
diff
changeset
|
240 free(cf); |
4
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
241 } |
5
7c489c73d62b
Clear commandline_files after processing it.
David A. Holland
parents:
4
diff
changeset
|
242 array_setsize(&commandline_files, 0); |
4
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
243 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
244 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
245 //////////////////////////////////////////////////////////// |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
246 // include path accumulation |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
247 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
248 static struct stringarray incpath_quote; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
249 static struct stringarray incpath_user; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
250 static struct stringarray incpath_system; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
251 static struct stringarray incpath_late; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
252 static const char *sysroot; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
253 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
254 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
255 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
256 incpath_init(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
257 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
258 stringarray_init(&incpath_quote); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
259 stringarray_init(&incpath_user); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
260 stringarray_init(&incpath_system); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
261 stringarray_init(&incpath_late); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
262 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
263 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
264 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
265 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
266 incpath_cleanup(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
267 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
268 stringarray_cleanup(&incpath_quote); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
269 stringarray_cleanup(&incpath_user); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
270 stringarray_cleanup(&incpath_system); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
271 stringarray_cleanup(&incpath_late); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
272 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
273 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
274 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
275 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
276 commandline_isysroot(char *dir) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
277 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
278 sysroot = dir; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
279 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
280 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
281 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
282 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
283 commandline_addincpath(struct stringarray *arr, char *s) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
284 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
285 stringarray_add(arr, s, NULL); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
286 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
287 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
288 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
289 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
290 commandline_addincpath_quote(char *dir) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
291 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
292 commandline_addincpath(&incpath_quote, dir); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
293 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
294 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
295 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
296 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
297 commandline_addincpath_user(char *dir) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
298 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
299 commandline_addincpath(&incpath_user, dir); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
300 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
301 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
302 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
303 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
304 commandline_addincpath_system(char *dir) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
305 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
306 commandline_addincpath(&incpath_system, dir); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
307 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
308 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
309 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
310 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
311 commandline_addincpath_late(char *dir) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
312 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
313 commandline_addincpath(&incpath_late, dir); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
314 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
315 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
316 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
317 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
318 loadincludepath(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
319 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
320 unsigned i, num; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
321 const char *dir; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
322 char *t; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
323 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
324 num = stringarray_num(&incpath_quote); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
325 for (i=0; i<num; i++) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
326 dir = stringarray_get(&incpath_quote, i); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
327 files_addquotepath(dir, false); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
328 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
329 files_addquotepath(".", false); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
330 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
331 num = stringarray_num(&incpath_user); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
332 for (i=0; i<num; i++) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
333 dir = stringarray_get(&incpath_user, i); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
334 files_addquotepath(dir, false); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
335 files_addbracketpath(dir, false); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
336 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
337 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
338 if (mode.do_stdinc) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
339 if (sysroot != NULL) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
340 t = dostrdup3(sysroot, "/", CONFIG_LOCALINCLUDE); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
341 freestringlater(t); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
342 dir = t; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
343 } else { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
344 dir = CONFIG_LOCALINCLUDE; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
345 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
346 files_addquotepath(dir, true); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
347 files_addbracketpath(dir, true); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
348 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
349 if (sysroot != NULL) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
350 t = dostrdup3(sysroot, "/", CONFIG_SYSTEMINCLUDE); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
351 freestringlater(t); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
352 dir = t; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
353 } else { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
354 dir = CONFIG_SYSTEMINCLUDE; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
355 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
356 files_addquotepath(dir, true); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
357 files_addbracketpath(dir, true); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
358 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
359 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
360 num = stringarray_num(&incpath_system); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
361 for (i=0; i<num; i++) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
362 dir = stringarray_get(&incpath_system, i); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
363 files_addquotepath(dir, true); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
364 files_addbracketpath(dir, true); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
365 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
366 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
367 num = stringarray_num(&incpath_late); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
368 for (i=0; i<num; i++) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
369 dir = stringarray_get(&incpath_late, i); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
370 files_addquotepath(dir, false); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
371 files_addbracketpath(dir, false); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
372 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
373 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
374 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
375 //////////////////////////////////////////////////////////// |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
376 // silly commandline stuff |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
377 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
378 static const char *commandline_prefix; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
379 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
380 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
381 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
382 commandline_setprefix(char *prefix) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
383 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
384 commandline_prefix = prefix; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
385 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
386 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
387 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
388 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
389 commandline_addincpath_user_withprefix(char *dir) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
390 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
391 char *s; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
392 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
393 if (commandline_prefix == NULL) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
394 warnx("-iprefix needed"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
395 die(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
396 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
397 s = dostrdup3(commandline_prefix, "/", dir); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
398 freestringlater(s); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
399 commandline_addincpath_user(s); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
400 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
401 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
402 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
403 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
404 commandline_addincpath_late_withprefix(char *dir) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
405 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
406 char *s; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
407 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
408 if (commandline_prefix == NULL) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
409 warnx("-iprefix needed"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
410 die(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
411 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
412 s = dostrdup3(commandline_prefix, "/", dir); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
413 freestringlater(s); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
414 commandline_addincpath_late(s); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
415 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
416 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
417 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
418 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
419 commandline_setstd(char *std) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
420 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
421 if (!strcmp(std, "krc")) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
422 return; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
423 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
424 warnx("Standard %s not supported by this preprocessor", std); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
425 die(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
426 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
427 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
428 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
429 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
430 commandline_setlang(char *lang) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
431 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
432 if (!strcmp(lang, "c") || !strcmp(lang, "assembler-with-cpp")) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
433 return; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
434 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
435 warnx("Language %s not supported by this preprocessor", lang); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
436 die(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
437 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
438 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
439 //////////////////////////////////////////////////////////// |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
440 // complex modes |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
441 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
442 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
443 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
444 commandline_iremap(char *str) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
445 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
446 /* XXX */ |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
447 warnx("-iremap not supported"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
448 die(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
449 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
450 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
451 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
452 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
453 commandline_tabstop(char *s) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
454 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
455 char *t; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
456 unsigned long val; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
457 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
458 t = strchr(s, '='); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
459 if (t == NULL) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
460 /* should not happen */ |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
461 warnx("Invalid tabstop"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
462 die(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
463 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
464 t++; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
465 errno = 0; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
466 val = strtoul(t, &t, 10); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
467 if (errno || *t != '\0') { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
468 warnx("Invalid tabstop"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
469 die(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
470 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
471 if (val > 64) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
472 warnx("Preposterously large tabstop"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
473 die(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
474 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
475 mode.input_tabstop = val; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
476 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
477 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
478 /* |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
479 * macrolist |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
480 */ |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
481 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
482 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
483 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
484 commandline_dD(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
485 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
486 mode.do_macrolist = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
487 mode.macrolist_include_stddef = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
488 mode.macrolist_include_expansions = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
489 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
490 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
491 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
492 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
493 commandline_dM(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
494 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
495 mode.do_macrolist = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
496 mode.macrolist_include_stddef = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
497 mode.macrolist_include_expansions = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
498 mode.do_output = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
499 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
500 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
501 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
502 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
503 commandline_dN(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
504 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
505 mode.do_macrolist = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
506 mode.macrolist_include_stddef = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
507 mode.macrolist_include_expansions = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
508 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
509 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
510 /* |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
511 * include trace |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
512 */ |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
513 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
514 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
515 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
516 commandline_dI(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
517 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
518 mode.do_trace = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
519 mode.trace_namesonly = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
520 mode.trace_indented = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
521 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
522 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
523 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
524 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
525 commandline_H(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
526 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
527 mode.do_trace = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
528 mode.trace_namesonly = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
529 mode.trace_indented = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
530 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
531 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
532 /* |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
533 * depend |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
534 */ |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
535 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
536 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
537 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
538 commandline_setdependtarget(char *str) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
539 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
540 mode.depend_target = str; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
541 mode.depend_quote_target = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
542 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
543 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
544 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
545 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
546 commandline_setdependtarget_quoted(char *str) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
547 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
548 mode.depend_target = str; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
549 mode.depend_quote_target = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
550 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
551 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
552 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
553 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
554 commandline_setdependoutput(char *str) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
555 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
556 mode.depend_file = str; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
557 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
558 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
559 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
560 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
561 commandline_M(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
562 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
563 mode.do_depend = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
564 mode.depend_report_system = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
565 mode.do_output = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
566 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
567 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
568 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
569 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
570 commandline_MM(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
571 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
572 mode.do_depend = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
573 mode.depend_report_system = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
574 mode.do_output = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
575 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
576 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
577 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
578 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
579 commandline_MD(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
580 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
581 mode.do_depend = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
582 mode.depend_report_system = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
583 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
584 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
585 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
586 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
587 commandline_MMD(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
588 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
589 mode.do_depend = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
590 mode.depend_report_system = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
591 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
592 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
593 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
594 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
595 commandline_wall(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
596 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
597 warns.nestcomment = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
598 warns.undef = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
599 warns.unused = true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
600 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
601 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
602 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
603 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
604 commandline_wnoall(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
605 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
606 warns.nestcomment = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
607 warns.undef = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
608 warns.unused = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
609 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
610 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
611 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
612 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
613 commandline_wnone(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
614 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
615 warns.nestcomment = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
616 warns.endiflabels = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
617 warns.undef = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
618 warns.unused = false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
619 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
620 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
621 //////////////////////////////////////////////////////////// |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
622 // options |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
623 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
624 struct flag_option { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
625 const char *string; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
626 bool *flag; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
627 bool setto; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
628 }; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
629 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
630 struct act_option { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
631 const char *string; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
632 void (*func)(void); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
633 }; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
634 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
635 struct prefix_option { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
636 const char *string; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
637 void (*func)(char *); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
638 }; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
639 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
640 struct arg_option { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
641 const char *string; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
642 void (*func)(char *); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
643 }; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
644 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
645 static const struct flag_option flag_options[] = { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
646 { "C", &mode.output_retain_comments, true }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
647 { "CC", &mode.output_retain_comments, true }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
648 { "fdollars-in-identifiers", &mode.input_allow_dollars, true }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
649 { "fno-dollars-in-identifiers", &mode.input_allow_dollars, false }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
650 { "MG", &mode.depend_assume_generated, true }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
651 { "MP", &mode.depend_issue_fakerules, true }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
652 { "nostdinc", &mode.do_stdinc, false }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
653 { "P", &mode.output_linenumbers, false }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
654 { "undef", &mode.do_stddef, false }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
655 { "Wcomment", &warns.nestcomment, true }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
656 { "Wendif-labels", &warns.endiflabels, true }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
657 { "Werror", &mode.werror, true }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
658 { "Wno-comment", &warns.nestcomment, false }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
659 { "Wno-endif-labels", &warns.endiflabels, false }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
660 { "Wno-error", &mode.werror, false }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
661 { "Wno-undef", &warns.undef, false }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
662 { "Wno-unused-macros", &warns.unused, false }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
663 { "Wundef", &warns.undef, true }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
664 { "Wunused-macros", &warns.unused, true }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
665 }; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
666 static const unsigned num_flag_options = HOWMANY(flag_options); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
667 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
668 static const struct act_option act_options[] = { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
669 { "dD", commandline_dD }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
670 { "dI", commandline_dI }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
671 { "dM", commandline_dM }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
672 { "dN", commandline_dN }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
673 { "H", commandline_H }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
674 { "M", commandline_M }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
675 { "MD", commandline_MD }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
676 { "MM", commandline_MM }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
677 { "MMD", commandline_MMD }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
678 { "Wall", commandline_wall }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
679 { "Wno-all", commandline_wnoall }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
680 { "w", commandline_wnone }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
681 }; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
682 static const unsigned num_act_options = HOWMANY(act_options); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
683 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
684 static const struct prefix_option prefix_options[] = { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
685 { "D", commandline_def }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
686 { "ftabstop=", commandline_tabstop }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
687 { "I", commandline_addincpath_user }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
688 { "std=", commandline_setstd }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
689 { "U", commandline_undef }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
690 }; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
691 static const unsigned num_prefix_options = HOWMANY(prefix_options); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
692 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
693 static const struct arg_option arg_options[] = { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
694 { "idirafter", commandline_addincpath_late }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
695 { "imacros", commandline_addfile_nooutput }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
696 { "include", commandline_addfile_output }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
697 { "iprefix", commandline_setprefix }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
698 { "iquote", commandline_addincpath_quote }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
699 { "iremap", commandline_iremap }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
700 { "isysroot", commandline_isysroot }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
701 { "isystem", commandline_addincpath_system }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
702 { "iwithprefix", commandline_addincpath_late_withprefix }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
703 { "iwithprefixbefore", commandline_addincpath_user_withprefix }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
704 { "MF", commandline_setdependoutput }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
705 { "MT", commandline_setdependtarget }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
706 { "MQ", commandline_setdependtarget_quoted }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
707 { "x", commandline_setlang }, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
708 }; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
709 static const unsigned num_arg_options = HOWMANY(arg_options); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
710 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
711 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
712 bool |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
713 check_flag_option(const char *opt) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
714 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
715 unsigned i; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
716 int r; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
717 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
718 for (i=0; i<num_flag_options; i++) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
719 r = strcmp(opt, flag_options[i].string); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
720 if (r == 0) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
721 *flag_options[i].flag = flag_options[i].setto; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
722 return true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
723 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
724 if (r < 0) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
725 break; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
726 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
727 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
728 return false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
729 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
730 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
731 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
732 bool |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
733 check_act_option(const char *opt) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
734 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
735 unsigned i; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
736 int r; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
737 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
738 for (i=0; i<num_act_options; i++) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
739 r = strcmp(opt, act_options[i].string); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
740 if (r == 0) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
741 act_options[i].func(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
742 return true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
743 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
744 if (r < 0) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
745 break; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
746 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
747 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
748 return false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
749 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
750 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
751 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
752 bool |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
753 check_prefix_option(char *opt) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
754 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
755 unsigned i; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
756 int r; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
757 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
758 for (i=0; i<num_prefix_options; i++) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
759 r = strncmp(opt, prefix_options[i].string, |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
760 strlen(prefix_options[i].string)); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
761 if (r == 0) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
762 prefix_options[i].func(opt); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
763 return true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
764 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
765 if (r < 0) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
766 break; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
767 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
768 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
769 return false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
770 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
771 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
772 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
773 bool |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
774 check_arg_option(const char *opt, char *arg) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
775 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
776 unsigned i; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
777 int r; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
778 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
779 for (i=0; i<num_arg_options; i++) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
780 r = strcmp(opt, arg_options[i].string); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
781 if (r == 0) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
782 if (arg == NULL) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
783 warnx("Option -%s requires an argument", opt); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
784 die(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
785 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
786 arg_options[i].func(arg); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
787 return true; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
788 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
789 if (r < 0) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
790 break; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
791 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
792 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
793 return false; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
794 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
795 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
796 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
797 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
798 usage(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
799 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
800 fprintf(stderr, "Usage: %s [options] [infile [outfile]]\n", |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
801 getprogname()); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
802 fprintf(stderr, "Common options:\n"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
803 fprintf(stderr, " -C Retain comments\n"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
804 fprintf(stderr, " -Dmacro[=def] Predefine macro\n"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
805 fprintf(stderr, " -Idir Add to include path\n"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
806 fprintf(stderr, " -M Issue depend info\n"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
807 fprintf(stderr, " -MD Issue depend info and output\n"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
808 fprintf(stderr, " -MM -M w/o system headers\n"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
809 fprintf(stderr, " -MMD -MD w/o system headers\n"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
810 fprintf(stderr, " -nostdinc Drop default include path\n"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
811 fprintf(stderr, " -Umacro Undefine macro\n"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
812 fprintf(stderr, " -undef Undefine everything\n"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
813 fprintf(stderr, " -Wall Enable all warnings\n"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
814 fprintf(stderr, " -Werror Make warnings into errors\n"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
815 fprintf(stderr, " -w Disable all warnings\n"); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
816 die(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
817 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
818 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
819 //////////////////////////////////////////////////////////// |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
820 // exit and cleanup |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
821 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
822 static struct stringarray freestrings; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
823 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
824 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
825 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
826 init(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
827 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
828 stringarray_init(&freestrings); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
829 incpath_init(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
830 commandline_macros_init(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
831 commandline_files_init(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
832 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
833 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
834 static |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
835 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
836 cleanup(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
837 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
838 unsigned i, num; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
839 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
840 commandline_files_cleanup(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
841 commandline_macros_cleanup(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
842 incpath_cleanup(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
843 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
844 num = stringarray_num(&freestrings); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
845 for (i=0; i<num; i++) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
846 free(stringarray_get(&freestrings, i)); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
847 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
848 stringarray_setsize(&freestrings, 0); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
849 stringarray_cleanup(&freestrings); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
850 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
851 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
852 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
853 die(void) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
854 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
855 cleanup(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
856 exit(EXIT_FAILURE); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
857 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
858 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
859 void |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
860 freestringlater(char *s) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
861 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
862 stringarray_add(&freestrings, s, NULL); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
863 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
864 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
865 //////////////////////////////////////////////////////////// |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
866 // main |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
867 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
868 int |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
869 main(int argc, char *argv[]) |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
870 { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
871 const char *inputfile = NULL; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
872 const char *outputfile = NULL; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
873 int i; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
874 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
875 init(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
876 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
877 for (i=1; i<argc; i++) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
878 if (argv[i][0] != '-') { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
879 break; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
880 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
881 if (check_flag_option(argv[i]+1)) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
882 continue; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
883 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
884 if (check_act_option(argv[i]+1)) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
885 continue; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
886 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
887 if (check_prefix_option(argv[i]+1)) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
888 continue; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
889 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
890 if (check_arg_option(argv[i]+1, argv[i+1])) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
891 i++; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
892 continue; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
893 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
894 usage(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
895 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
896 if (i < argc) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
897 inputfile = argv[i++]; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
898 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
899 if (i < argc) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
900 outputfile = argv[i++]; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
901 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
902 if (i < argc) { |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
903 usage(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
904 } |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
905 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
906 mode.output_file = outputfile; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
907 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
908 loadincludepath(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
909 apply_builtin_macros(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
910 apply_commandline_macros(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
911 read_commandline_files(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
912 files_read(NULL, inputfile); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
913 |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
914 cleanup(); |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
915 return EXIT_SUCCESS; |
ee9a66b87c70
Initial version of toplevel and options handling.
David A. Holland
parents:
diff
changeset
|
916 } |