Mercurial > hg > index.cgi
comparison lwasm/input.c @ 219:afd50d6b4113
Add --preprocess option
Add --preprocess option which expands macros, resolves conditions, and
resolves include files if possible. If an include file is not available, it
the include directive is retained.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 10 Jun 2012 18:24:31 -0600 |
parents | 1824cabf25ce |
children | 3864d96ee8c7 |
comparison
equal
deleted
inserted
replaced
218:b0c9df865b25 | 219:afd50d6b4113 |
---|---|
39 | 39 |
40 /* | 40 /* |
41 Data type for storing input buffers | 41 Data type for storing input buffers |
42 */ | 42 */ |
43 | 43 |
44 #define IGNOREERROR (errno == ENOENT && (as -> flags & FLAG_DEPENDNOERR)) | 44 #define IGNOREERROR (errno == ENOENT && (as -> preprocess || as -> flags & FLAG_DEPENDNOERR)) |
45 | 45 |
46 enum input_types_e | 46 enum input_types_e |
47 { | 47 { |
48 input_type_file, // regular file, no search path | 48 input_type_file, // regular file, no search path |
49 input_type_include, // include path, start from "local" | 49 input_type_include, // include path, start from "local" |
193 debug_message(as, 1, "Opening (abs) %s", s); | 193 debug_message(as, 1, "Opening (abs) %s", s); |
194 if (!IS -> data && !IGNOREERROR) | 194 if (!IS -> data && !IGNOREERROR) |
195 { | 195 { |
196 lw_error("Cannot open file '%s': %s\n", s, strerror(errno)); | 196 lw_error("Cannot open file '%s': %s\n", s, strerror(errno)); |
197 } | 197 } |
198 else | |
199 { | |
200 as -> fileerr = 1; | |
201 } | |
198 input_pushpath(as, s); | 202 input_pushpath(as, s); |
199 return; | 203 return; |
200 } | 204 } |
201 | 205 |
202 /* relative path, check relative to "current file" directory */ | 206 /* relative path, check relative to "current file" directory */ |
231 lw_stringlist_next(as -> include_list); | 235 lw_stringlist_next(as -> include_list); |
232 } | 236 } |
233 if (IGNOREERROR) | 237 if (IGNOREERROR) |
234 { | 238 { |
235 input_pushpath(as, s); | 239 input_pushpath(as, s); |
240 as -> fileerr = 1; | |
236 return; | 241 return; |
237 } | 242 } |
238 lw_error("Cannot open include file '%s': %s\n", s, strerror(errno)); | 243 lw_error("Cannot open include file '%s': %s\n", s, strerror(errno)); |
239 break; | 244 break; |
240 | 245 |