annotate main.c @ 35:b30f69cab9bc

Add another test. Joerg says that #define foo()x is legal in traditional cpp, so let's make it a test case.
author David A. Holland
date Sat, 30 Mar 2013 20:39:03 -0400
parents 76c114899f63
children 70902cac4170
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
1 /*-
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
2 * Copyright (c) 2010 The NetBSD Foundation, Inc.
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
3 * All rights reserved.
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
4 *
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
5 * This code is derived from software contributed to The NetBSD Foundation
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
6 * by David A. Holland.
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
7 *
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
8 * Redistribution and use in source and binary forms, with or without
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
9 * modification, are permitted provided that the following conditions
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
10 * are met:
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
11 * 1. Redistributions of source code must retain the above copyright
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
12 * notice, this list of conditions and the following disclaimer.
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
13 * 2. Redistributions in binary form must reproduce the above copyright
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
14 * notice, this list of conditions and the following disclaimer in the
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
15 * documentation and/or other materials provided with the distribution.
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
16 *
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
27 * POSSIBILITY OF SUCH DAMAGE.
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
28 */
76c114899f63 copyrights
David A. Holland
parents: 18
diff changeset
29
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
30 #include <stdbool.h>
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
31 #include <stdio.h>
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
32 #include <stdlib.h>
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
33 #include <string.h>
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
34 #include <errno.h>
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
35 #include <err.h>
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
36
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
37 #include "version.h"
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
38 #include "config.h"
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
39 #include "utils.h"
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
40 #include "array.h"
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
41 #include "mode.h"
8
97243badae69 split place stuff to its own file
David A. Holland
parents: 7
diff changeset
42 #include "place.h"
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
43 #include "files.h"
15
f6177d3ed5c2 handle directives
David A. Holland
parents: 14
diff changeset
44 #include "directive.h"
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
45 #include "macro.h"
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 struct mode mode = {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
48 .werror = false,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
49
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
50 .input_allow_dollars = false,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
51 .input_tabstop = 8,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
52
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
53 .do_stdinc = true,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
54 .do_stddef = true,
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 .do_output = true,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
57 .output_linenumbers = true,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
58 .output_retain_comments = false,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
59 .output_file = NULL,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
60
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
61 .do_depend = false,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
62 .depend_report_system = false,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
63 .depend_assume_generated = false,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
64 .depend_issue_fakerules = false,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
65 .depend_quote_target = true,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
66 .depend_target = NULL,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
67 .depend_file = NULL,
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 .do_macrolist = false,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
70 .macrolist_include_stddef = false,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
71 .macrolist_include_expansions = false,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
72
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
73 .do_trace = false,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
74 .trace_namesonly = false,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
75 .trace_indented = false,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
76 };
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 struct warns warns = {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
79 .endiflabels = true,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
80 .nestcomment = false,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
81 .undef = false,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
82 .unused = false,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
83 };
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 ////////////////////////////////////////////////////////////
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
86 // commandline macros
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
87
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
88 struct commandline_macro {
11
b9d50e786322 simplify places
David A. Holland
parents: 10
diff changeset
89 struct place where;
15
f6177d3ed5c2 handle directives
David A. Holland
parents: 14
diff changeset
90 struct place where2;
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
91 const char *macro;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
92 const char *expansion;
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
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
95 static struct array commandline_macros;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
96
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
97 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
98 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
99 commandline_macros_init(void)
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 array_init(&commandline_macros);
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_macros_cleanup(void)
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 array_cleanup(&commandline_macros);
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
15
f6177d3ed5c2 handle directives
David A. Holland
parents: 14
diff changeset
113 commandline_macro_add(const struct place *p, const char *macro,
f6177d3ed5c2 handle directives
David A. Holland
parents: 14
diff changeset
114 const struct place *p2, const char *expansion)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
115 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
116 struct commandline_macro *cm;
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 cm = domalloc(sizeof(*cm));
11
b9d50e786322 simplify places
David A. Holland
parents: 10
diff changeset
119 cm->where = *p;
15
f6177d3ed5c2 handle directives
David A. Holland
parents: 14
diff changeset
120 cm->where2 = *p2;
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
121 cm->macro = macro;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
122 cm->expansion = expansion;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
123 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
124
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
125 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
126 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
127 commandline_def(const struct place *p, char *str)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
128 {
15
f6177d3ed5c2 handle directives
David A. Holland
parents: 14
diff changeset
129 struct place p2;
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
130 char *val;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
131
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
132 val = strchr(str, '=');
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
133 if (val != NULL) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
134 *val = '\0';
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
135 val++;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
136 }
15
f6177d3ed5c2 handle directives
David A. Holland
parents: 14
diff changeset
137
f6177d3ed5c2 handle directives
David A. Holland
parents: 14
diff changeset
138 if (val) {
f6177d3ed5c2 handle directives
David A. Holland
parents: 14
diff changeset
139 p2 = *p;
f6177d3ed5c2 handle directives
David A. Holland
parents: 14
diff changeset
140 p2.column += strlen(str);
f6177d3ed5c2 handle directives
David A. Holland
parents: 14
diff changeset
141 } else {
f6177d3ed5c2 handle directives
David A. Holland
parents: 14
diff changeset
142 place_setbuiltin(&p2, 1);
f6177d3ed5c2 handle directives
David A. Holland
parents: 14
diff changeset
143 }
f6177d3ed5c2 handle directives
David A. Holland
parents: 14
diff changeset
144 commandline_macro_add(p, str, &p2, val ? val : "1");
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
145 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
146
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
147 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
148 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
149 commandline_undef(const struct place *p, char *str)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
150 {
15
f6177d3ed5c2 handle directives
David A. Holland
parents: 14
diff changeset
151 commandline_macro_add(p, str, p, NULL);
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
152 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
153
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
154 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
155 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
156 apply_commandline_macros(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
157 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
158 struct commandline_macro *cm;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
159 unsigned i, num;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
160
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
161 num = array_num(&commandline_macros);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
162 for (i=0; i<num; i++) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
163 cm = array_get(&commandline_macros, i);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
164 if (cm->expansion != NULL) {
18
c08a947d8f30 deal with macro parameters
David A. Holland
parents: 17
diff changeset
165 macro_define_plain(&cm->where, cm->macro,
c08a947d8f30 deal with macro parameters
David A. Holland
parents: 17
diff changeset
166 &cm->where2, cm->expansion);
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
167 } else {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
168 macro_undef(cm->macro);
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 free(cm);
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 array_setsize(&commandline_macros, 0);
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
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
175 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
176 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
177 apply_builtin_macro(unsigned num, const char *name, const char *val)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
178 {
11
b9d50e786322 simplify places
David A. Holland
parents: 10
diff changeset
179 struct place p;
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
180
11
b9d50e786322 simplify places
David A. Holland
parents: 10
diff changeset
181 place_setbuiltin(&p, num);
18
c08a947d8f30 deal with macro parameters
David A. Holland
parents: 17
diff changeset
182 macro_define_plain(&p, name, &p, val);
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
183 }
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 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
186 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
187 apply_builtin_macros(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
188 {
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
189 unsigned n = 1;
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
190
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
191 #ifdef CONFIG_OS
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
192 apply_builtin_macro(n++, CONFIG_OS, "1");
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
193 #endif
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
194 #ifdef CONFIG_OS_2
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
195 apply_builtin_macro(n++, CONFIG_OS_2, "1");
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
196 #endif
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
197
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
198 #ifdef CONFIG_CPU
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
199 apply_builtin_macro(n++, CONFIG_CPU, "1");
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
200 #endif
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
201 #ifdef CONFIG_CPU_2
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
202 apply_builtin_macro(n++, CONFIG_CPU_2, "1");
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
203 #endif
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
204
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
205 #ifdef CONFIG_SIZE
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
206 apply_builtin_macro(n++, CONFIG_SIZE, "1");
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
207 #endif
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
208 #ifdef CONFIG_BINFMT
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
209 apply_builtin_macro(n++, CONFIG_BINFMT, "1");
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
210 #endif
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
211
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
212 #ifdef CONFIG_COMPILER
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
213 apply_builtin_macro(n++, CONFIG_COMPILER, VERSION_MAJOR);
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
214 apply_builtin_macro(n++, CONFIG_COMPILER_MINOR, VERSION_MINOR);
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
215 apply_builtin_macro(n++, "__VERSION__", VERSION_LONG);
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
216 #endif
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
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 // extra included files
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
221
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
222 struct commandline_file {
11
b9d50e786322 simplify places
David A. Holland
parents: 10
diff changeset
223 struct place where;
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
224 char *name;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
225 bool suppress_output;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
226 };
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
227
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
228 static struct array commandline_files;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
229
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
230 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
231 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
232 commandline_files_init(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
233 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
234 array_init(&commandline_files);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
235 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
236
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
237 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
238 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
239 commandline_files_cleanup(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
240 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
241 array_cleanup(&commandline_files);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
242 }
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 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
245 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
246 commandline_addfile(const struct place *p, char *name, bool suppress_output)
4
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 struct commandline_file *cf;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
249
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
250 cf = domalloc(sizeof(*cf));
11
b9d50e786322 simplify places
David A. Holland
parents: 10
diff changeset
251 cf->where = *p;
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
252 cf->name = name;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
253 cf->suppress_output = suppress_output;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
254 array_add(&commandline_files, cf, NULL);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
255 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
256
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
257 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
258 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
259 commandline_addfile_output(const struct place *p, char *name)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
260 {
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
261 commandline_addfile(p, name, false);
4
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
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
266 commandline_addfile_nooutput(const struct place *p, char *name)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
267 {
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
268 commandline_addfile(p, name, true);
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
269 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
270
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
271 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
272 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
273 read_commandline_files(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
274 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
275 struct commandline_file *cf;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
276 unsigned i, num;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
277 bool save = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
278
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
279 num = array_num(&commandline_files);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
280 for (i=0; i<num; i++) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
281 cf = array_get(&commandline_files, i);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
282 if (cf->suppress_output) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
283 save = mode.do_output;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
284 mode.do_output = false;
11
b9d50e786322 simplify places
David A. Holland
parents: 10
diff changeset
285 file_readquote(&cf->where, cf->name);
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
286 mode.do_output = save;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
287 } else {
11
b9d50e786322 simplify places
David A. Holland
parents: 10
diff changeset
288 file_readquote(&cf->where, cf->name);
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
289 }
5
7c489c73d62b Clear commandline_files after processing it.
David A. Holland
parents: 4
diff changeset
290 free(cf);
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
291 }
5
7c489c73d62b Clear commandline_files after processing it.
David A. Holland
parents: 4
diff changeset
292 array_setsize(&commandline_files, 0);
4
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 ////////////////////////////////////////////////////////////
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
296 // include path accumulation
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
297
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
298 static struct stringarray incpath_quote;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
299 static struct stringarray incpath_user;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
300 static struct stringarray incpath_system;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
301 static struct stringarray incpath_late;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
302 static const char *sysroot;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
303
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
304 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
305 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
306 incpath_init(void)
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 stringarray_init(&incpath_quote);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
309 stringarray_init(&incpath_user);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
310 stringarray_init(&incpath_system);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
311 stringarray_init(&incpath_late);
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
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
314 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
315 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
316 incpath_cleanup(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
317 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
318 stringarray_cleanup(&incpath_quote);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
319 stringarray_cleanup(&incpath_user);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
320 stringarray_cleanup(&incpath_system);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
321 stringarray_cleanup(&incpath_late);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
322 }
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 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
325 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
326 commandline_isysroot(const struct place *p, char *dir)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
327 {
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
328 (void)p;
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
329 sysroot = dir;
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
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
332 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
333 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
334 commandline_addincpath(struct stringarray *arr, char *s)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
335 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
336 stringarray_add(arr, s, NULL);
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
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
339 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
340 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
341 commandline_addincpath_quote(const struct place *p, char *dir)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
342 {
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
343 (void)p;
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
344 commandline_addincpath(&incpath_quote, dir);
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
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
347 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
348 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
349 commandline_addincpath_user(const struct place *p, char *dir)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
350 {
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
351 (void)p;
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
352 commandline_addincpath(&incpath_user, dir);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
353 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
354
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
355 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
356 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
357 commandline_addincpath_system(const struct place *p, char *dir)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
358 {
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
359 (void)p;
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
360 commandline_addincpath(&incpath_system, dir);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
361 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
362
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
363 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
364 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
365 commandline_addincpath_late(const struct place *p, char *dir)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
366 {
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
367 (void)p;
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
368 commandline_addincpath(&incpath_late, dir);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
369 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
370
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
371 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
372 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
373 loadincludepath(void)
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 unsigned i, num;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
376 const char *dir;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
377 char *t;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
378
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
379 num = stringarray_num(&incpath_quote);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
380 for (i=0; i<num; i++) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
381 dir = stringarray_get(&incpath_quote, i);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
382 files_addquotepath(dir, false);
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 files_addquotepath(".", false);
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 num = stringarray_num(&incpath_user);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
387 for (i=0; i<num; i++) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
388 dir = stringarray_get(&incpath_user, i);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
389 files_addquotepath(dir, false);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
390 files_addbracketpath(dir, false);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
391 }
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 (mode.do_stdinc) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
394 if (sysroot != NULL) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
395 t = dostrdup3(sysroot, "/", CONFIG_LOCALINCLUDE);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
396 freestringlater(t);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
397 dir = t;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
398 } else {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
399 dir = CONFIG_LOCALINCLUDE;
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 files_addquotepath(dir, true);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
402 files_addbracketpath(dir, true);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
403
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
404 if (sysroot != NULL) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
405 t = dostrdup3(sysroot, "/", CONFIG_SYSTEMINCLUDE);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
406 freestringlater(t);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
407 dir = t;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
408 } else {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
409 dir = CONFIG_SYSTEMINCLUDE;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
410 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
411 files_addquotepath(dir, true);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
412 files_addbracketpath(dir, true);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
413 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
414
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
415 num = stringarray_num(&incpath_system);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
416 for (i=0; i<num; i++) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
417 dir = stringarray_get(&incpath_system, i);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
418 files_addquotepath(dir, true);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
419 files_addbracketpath(dir, true);
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
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
422 num = stringarray_num(&incpath_late);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
423 for (i=0; i<num; i++) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
424 dir = stringarray_get(&incpath_late, i);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
425 files_addquotepath(dir, false);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
426 files_addbracketpath(dir, false);
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 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
429
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
430 ////////////////////////////////////////////////////////////
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
431 // silly commandline stuff
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
432
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
433 static const char *commandline_prefix;
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 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
436 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
437 commandline_setprefix(const struct place *p, char *prefix)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
438 {
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
439 (void)p;
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
440 commandline_prefix = prefix;
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
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
443 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
444 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
445 commandline_addincpath_user_withprefix(const struct place *p, char *dir)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
446 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
447 char *s;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
448
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
449 if (commandline_prefix == NULL) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
450 warnx("-iprefix needed");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
451 die();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
452 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
453 s = dostrdup3(commandline_prefix, "/", dir);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
454 freestringlater(s);
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
455 commandline_addincpath_user(p, s);
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
456 }
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 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
459 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
460 commandline_addincpath_late_withprefix(const struct place *p, char *dir)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
461 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
462 char *s;
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 if (commandline_prefix == NULL) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
465 warnx("-iprefix needed");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
466 die();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
467 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
468 s = dostrdup3(commandline_prefix, "/", dir);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
469 freestringlater(s);
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
470 commandline_addincpath_late(p, s);
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
471 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
472
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
473 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
474 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
475 commandline_setstd(const struct place *p, char *std)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
476 {
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
477 (void)p;
6
0601b6e8e53d checkpoint - can find files
David A. Holland
parents: 5
diff changeset
478
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
479 if (!strcmp(std, "krc")) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
480 return;
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 warnx("Standard %s not supported by this preprocessor", std);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
483 die();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
484 }
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 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
487 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
488 commandline_setlang(const struct place *p, char *lang)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
489 {
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
490 (void)p;
6
0601b6e8e53d checkpoint - can find files
David A. Holland
parents: 5
diff changeset
491
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
492 if (!strcmp(lang, "c") || !strcmp(lang, "assembler-with-cpp")) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
493 return;
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 warnx("Language %s not supported by this preprocessor", lang);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
496 die();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
497 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
498
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 // complex modes
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
501
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
502 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
503 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
504 commandline_iremap(const struct place *p, char *str)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
505 {
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
506 (void)p;
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
507 /* XXX */
6
0601b6e8e53d checkpoint - can find files
David A. Holland
parents: 5
diff changeset
508 (void)str;
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
509 warnx("-iremap not supported");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
510 die();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
511 }
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 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
514 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
515 commandline_tabstop(const struct place *p, char *s)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
516 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
517 char *t;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
518 unsigned long val;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
519
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
520 (void)p;
6
0601b6e8e53d checkpoint - can find files
David A. Holland
parents: 5
diff changeset
521
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
522 t = strchr(s, '=');
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
523 if (t == NULL) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
524 /* should not happen */
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
525 warnx("Invalid tabstop");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
526 die();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
527 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
528 t++;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
529 errno = 0;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
530 val = strtoul(t, &t, 10);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
531 if (errno || *t != '\0') {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
532 warnx("Invalid tabstop");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
533 die();
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 if (val > 64) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
536 warnx("Preposterously large tabstop");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
537 die();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
538 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
539 mode.input_tabstop = val;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
540 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
541
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 * macrolist
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
544 */
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
545
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
546 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
547 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
548 commandline_dD(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
549 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
550 mode.do_macrolist = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
551 mode.macrolist_include_stddef = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
552 mode.macrolist_include_expansions = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
553 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
554
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
555 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
556 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
557 commandline_dM(void)
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 mode.do_macrolist = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
560 mode.macrolist_include_stddef = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
561 mode.macrolist_include_expansions = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
562 mode.do_output = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
563 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
564
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
565 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
566 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
567 commandline_dN(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
568 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
569 mode.do_macrolist = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
570 mode.macrolist_include_stddef = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
571 mode.macrolist_include_expansions = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
572 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
573
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
574 /*
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
575 * include trace
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
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
578 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
579 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
580 commandline_dI(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
581 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
582 mode.do_trace = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
583 mode.trace_namesonly = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
584 mode.trace_indented = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
585 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
586
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
587 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
588 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
589 commandline_H(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
590 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
591 mode.do_trace = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
592 mode.trace_namesonly = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
593 mode.trace_indented = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
594 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
595
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 * depend
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
598 */
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
599
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
600 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
601 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
602 commandline_setdependtarget(const struct place *p, char *str)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
603 {
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
604 (void)p;
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
605 mode.depend_target = str;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
606 mode.depend_quote_target = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
607 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
608
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
609 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
610 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
611 commandline_setdependtarget_quoted(const struct place *p, char *str)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
612 {
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
613 (void)p;
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
614 mode.depend_target = str;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
615 mode.depend_quote_target = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
616 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
617
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
618 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
619 void
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
620 commandline_setdependoutput(const struct place *p, char *str)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
621 {
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
622 (void)p;
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
623 mode.depend_file = str;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
624 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
625
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
626 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
627 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
628 commandline_M(void)
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 mode.do_depend = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
631 mode.depend_report_system = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
632 mode.do_output = false;
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 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
636 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
637 commandline_MM(void)
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 mode.do_depend = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
640 mode.depend_report_system = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
641 mode.do_output = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
642 }
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 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
645 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
646 commandline_MD(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
647 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
648 mode.do_depend = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
649 mode.depend_report_system = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
650 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
651
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
652 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
653 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
654 commandline_MMD(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
655 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
656 mode.do_depend = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
657 mode.depend_report_system = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
658 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
659
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
660 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
661 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
662 commandline_wall(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
663 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
664 warns.nestcomment = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
665 warns.undef = true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
666 warns.unused = true;
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
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
669 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
670 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
671 commandline_wnoall(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
672 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
673 warns.nestcomment = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
674 warns.undef = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
675 warns.unused = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
676 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
677
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
678 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
679 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
680 commandline_wnone(void)
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 warns.nestcomment = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
683 warns.endiflabels = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
684 warns.undef = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
685 warns.unused = false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
686 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
687
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
688 ////////////////////////////////////////////////////////////
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
689 // options
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 struct flag_option {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
692 const char *string;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
693 bool *flag;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
694 bool setto;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
695 };
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
696
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
697 struct act_option {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
698 const char *string;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
699 void (*func)(void);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
700 };
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
701
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
702 struct prefix_option {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
703 const char *string;
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
704 void (*func)(const struct place *, char *);
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
705 };
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
706
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
707 struct arg_option {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
708 const char *string;
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
709 void (*func)(const struct place *, char *);
4
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
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
712 static const struct flag_option flag_options[] = {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
713 { "C", &mode.output_retain_comments, true },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
714 { "CC", &mode.output_retain_comments, true },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
715 { "fdollars-in-identifiers", &mode.input_allow_dollars, true },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
716 { "fno-dollars-in-identifiers", &mode.input_allow_dollars, false },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
717 { "MG", &mode.depend_assume_generated, true },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
718 { "MP", &mode.depend_issue_fakerules, true },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
719 { "nostdinc", &mode.do_stdinc, false },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
720 { "P", &mode.output_linenumbers, false },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
721 { "undef", &mode.do_stddef, false },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
722 { "Wcomment", &warns.nestcomment, true },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
723 { "Wendif-labels", &warns.endiflabels, true },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
724 { "Werror", &mode.werror, true },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
725 { "Wno-comment", &warns.nestcomment, false },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
726 { "Wno-endif-labels", &warns.endiflabels, false },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
727 { "Wno-error", &mode.werror, false },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
728 { "Wno-undef", &warns.undef, false },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
729 { "Wno-unused-macros", &warns.unused, false },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
730 { "Wundef", &warns.undef, true },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
731 { "Wunused-macros", &warns.unused, true },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
732 };
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
733 static const unsigned num_flag_options = HOWMANY(flag_options);
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 static const struct act_option act_options[] = {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
736 { "dD", commandline_dD },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
737 { "dI", commandline_dI },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
738 { "dM", commandline_dM },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
739 { "dN", commandline_dN },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
740 { "H", commandline_H },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
741 { "M", commandline_M },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
742 { "MD", commandline_MD },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
743 { "MM", commandline_MM },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
744 { "MMD", commandline_MMD },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
745 { "Wall", commandline_wall },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
746 { "Wno-all", commandline_wnoall },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
747 { "w", commandline_wnone },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
748 };
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
749 static const unsigned num_act_options = HOWMANY(act_options);
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 const struct prefix_option prefix_options[] = {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
752 { "D", commandline_def },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
753 { "ftabstop=", commandline_tabstop },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
754 { "I", commandline_addincpath_user },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
755 { "std=", commandline_setstd },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
756 { "U", commandline_undef },
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 static const unsigned num_prefix_options = HOWMANY(prefix_options);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
759
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
760 static const struct arg_option arg_options[] = {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
761 { "idirafter", commandline_addincpath_late },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
762 { "imacros", commandline_addfile_nooutput },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
763 { "include", commandline_addfile_output },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
764 { "iprefix", commandline_setprefix },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
765 { "iquote", commandline_addincpath_quote },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
766 { "iremap", commandline_iremap },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
767 { "isysroot", commandline_isysroot },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
768 { "isystem", commandline_addincpath_system },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
769 { "iwithprefix", commandline_addincpath_late_withprefix },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
770 { "iwithprefixbefore", commandline_addincpath_user_withprefix },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
771 { "MF", commandline_setdependoutput },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
772 { "MT", commandline_setdependtarget },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
773 { "MQ", commandline_setdependtarget_quoted },
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
774 { "x", commandline_setlang },
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 static const unsigned num_arg_options = HOWMANY(arg_options);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
777
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
778 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
779 bool
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
780 check_flag_option(const char *opt)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
781 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
782 unsigned i;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
783 int r;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
784
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
785 for (i=0; i<num_flag_options; i++) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
786 r = strcmp(opt, flag_options[i].string);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
787 if (r == 0) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
788 *flag_options[i].flag = flag_options[i].setto;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
789 return true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
790 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
791 if (r < 0) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
792 break;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
793 }
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 return false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
796 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
797
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
798 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
799 bool
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
800 check_act_option(const char *opt)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
801 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
802 unsigned i;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
803 int r;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
804
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
805 for (i=0; i<num_act_options; i++) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
806 r = strcmp(opt, act_options[i].string);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
807 if (r == 0) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
808 act_options[i].func();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
809 return true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
810 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
811 if (r < 0) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
812 break;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
813 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
814 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
815 return false;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
816 }
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 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
819 bool
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
820 check_prefix_option(const struct place *p, char *opt)
4
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 unsigned i;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
823 int r;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
824
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
825 for (i=0; i<num_prefix_options; i++) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
826 r = strncmp(opt, prefix_options[i].string,
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
827 strlen(prefix_options[i].string));
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
828 if (r == 0) {
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
829 prefix_options[i].func(p, opt);
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
830 return true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
831 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
832 if (r < 0) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
833 break;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
834 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
835 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
836 return false;
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
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
839 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
840 bool
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
841 check_arg_option(const char *opt, const struct place *argplace, char *arg)
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
842 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
843 unsigned i;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
844 int r;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
845
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
846 for (i=0; i<num_arg_options; i++) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
847 r = strcmp(opt, arg_options[i].string);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
848 if (r == 0) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
849 if (arg == NULL) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
850 warnx("Option -%s requires an argument", opt);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
851 die();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
852 }
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
853 arg_options[i].func(argplace, arg);
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
854 return true;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
855 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
856 if (r < 0) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
857 break;
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 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
860 return false;
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
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
863 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
864 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
865 usage(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
866 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
867 fprintf(stderr, "Usage: %s [options] [infile [outfile]]\n",
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
868 getprogname());
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
869 fprintf(stderr, "Common options:\n");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
870 fprintf(stderr, " -C Retain comments\n");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
871 fprintf(stderr, " -Dmacro[=def] Predefine macro\n");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
872 fprintf(stderr, " -Idir Add to include path\n");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
873 fprintf(stderr, " -M Issue depend info\n");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
874 fprintf(stderr, " -MD Issue depend info and output\n");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
875 fprintf(stderr, " -MM -M w/o system headers\n");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
876 fprintf(stderr, " -MMD -MD w/o system headers\n");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
877 fprintf(stderr, " -nostdinc Drop default include path\n");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
878 fprintf(stderr, " -Umacro Undefine macro\n");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
879 fprintf(stderr, " -undef Undefine everything\n");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
880 fprintf(stderr, " -Wall Enable all warnings\n");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
881 fprintf(stderr, " -Werror Make warnings into errors\n");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
882 fprintf(stderr, " -w Disable all warnings\n");
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
883 die();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
884 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
885
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 // exit and cleanup
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
888
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
889 static struct stringarray freestrings;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
890
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
891 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
892 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
893 init(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
894 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
895 stringarray_init(&freestrings);
6
0601b6e8e53d checkpoint - can find files
David A. Holland
parents: 5
diff changeset
896
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
897 incpath_init();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
898 commandline_macros_init();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
899 commandline_files_init();
6
0601b6e8e53d checkpoint - can find files
David A. Holland
parents: 5
diff changeset
900
10
800f3a560a3b move seenfiles to place.c too
David A. Holland
parents: 8
diff changeset
901 place_init();
6
0601b6e8e53d checkpoint - can find files
David A. Holland
parents: 5
diff changeset
902 files_init();
15
f6177d3ed5c2 handle directives
David A. Holland
parents: 14
diff changeset
903 directive_init();
17
76da41da923f added macro table
David A. Holland
parents: 15
diff changeset
904 macros_init();
4
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
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
907 static
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
908 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
909 cleanup(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
910 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
911 unsigned i, num;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
912
17
76da41da923f added macro table
David A. Holland
parents: 15
diff changeset
913 macros_cleanup();
15
f6177d3ed5c2 handle directives
David A. Holland
parents: 14
diff changeset
914 directive_cleanup();
6
0601b6e8e53d checkpoint - can find files
David A. Holland
parents: 5
diff changeset
915 files_cleanup();
10
800f3a560a3b move seenfiles to place.c too
David A. Holland
parents: 8
diff changeset
916 place_cleanup();
6
0601b6e8e53d checkpoint - can find files
David A. Holland
parents: 5
diff changeset
917
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
918 commandline_files_cleanup();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
919 commandline_macros_cleanup();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
920 incpath_cleanup();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
921
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
922 num = stringarray_num(&freestrings);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
923 for (i=0; i<num; i++) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
924 free(stringarray_get(&freestrings, i));
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
925 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
926 stringarray_setsize(&freestrings, 0);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
927 stringarray_cleanup(&freestrings);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
928 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
929
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
930 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
931 die(void)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
932 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
933 cleanup();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
934 exit(EXIT_FAILURE);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
935 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
936
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
937 void
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
938 freestringlater(char *s)
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
939 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
940 stringarray_add(&freestrings, s, NULL);
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
941 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
942
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
943 ////////////////////////////////////////////////////////////
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
944 // main
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
945
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
946 int
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
947 main(int argc, char *argv[])
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
948 {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
949 const char *inputfile = NULL;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
950 const char *outputfile = NULL;
11
b9d50e786322 simplify places
David A. Holland
parents: 10
diff changeset
951 struct place cmdplace;
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
952 int i;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
953
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
954 init();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
955
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
956 for (i=1; i<argc; i++) {
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
957 if (argv[i][0] != '-') {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
958 break;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
959 }
14
David A. Holland
parents: 11
diff changeset
960 place_setcommandline(&cmdplace, i, 1);
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
961 if (check_flag_option(argv[i]+1)) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
962 continue;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
963 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
964 if (check_act_option(argv[i]+1)) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
965 continue;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
966 }
11
b9d50e786322 simplify places
David A. Holland
parents: 10
diff changeset
967 if (check_prefix_option(&cmdplace, argv[i]+1)) {
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
968 continue;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
969 }
14
David A. Holland
parents: 11
diff changeset
970 place_setcommandline(&cmdplace, i+1, 1);
11
b9d50e786322 simplify places
David A. Holland
parents: 10
diff changeset
971 if (check_arg_option(argv[i]+1, &cmdplace, argv[i+1])) {
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
972 i++;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
973 continue;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
974 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
975 usage();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
976 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
977 if (i < argc) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
978 inputfile = argv[i++];
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
979 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
980 if (i < argc) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
981 outputfile = argv[i++];
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
982 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
983 if (i < argc) {
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
984 usage();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
985 }
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
986
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
987 mode.output_file = outputfile;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
988
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
989 loadincludepath();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
990 apply_builtin_macros();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
991 apply_commandline_macros();
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
992 read_commandline_files();
11
b9d50e786322 simplify places
David A. Holland
parents: 10
diff changeset
993 place_setnowhere(&cmdplace);
b9d50e786322 simplify places
David A. Holland
parents: 10
diff changeset
994 file_readabsolute(&cmdplace, inputfile);
7
b8167949474a make places work better
David A. Holland
parents: 6
diff changeset
995
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
996 cleanup();
6
0601b6e8e53d checkpoint - can find files
David A. Holland
parents: 5
diff changeset
997 if (complain_failed()) {
0601b6e8e53d checkpoint - can find files
David A. Holland
parents: 5
diff changeset
998 return EXIT_FAILURE;
0601b6e8e53d checkpoint - can find files
David A. Holland
parents: 5
diff changeset
999 }
4
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
1000 return EXIT_SUCCESS;
ee9a66b87c70 Initial version of toplevel and options handling.
David A. Holland
parents:
diff changeset
1001 }