30 #pragma warning(disable : 4996)
46 while ((line =
getline(filep))) {
47 switch(type =
deftype(line, filep, file_red, file,
true)) {
51 file_red, recursion+1, failOK);
54 type =
gobble(filep, file, file_red);
56 gobble(filep, file, file_red);
65 type =
gobble(filep, file, file_red);
68 file_red, recursion+1, recfailOK);
81 "line %d: %s !def'd in %s via %s%s\n" :
"",
85 file_red, recursion+1, failOK);
87 type =
gobble(filep, file, file_red);
89 gobble(filep, file, file_red);
93 "line %d: %s !def'd in %s via %s%s\n" :
"",
96 type =
gobble(filep, file, file_red);
99 file_red, recursion+1, failOK);
100 else if (type ==
ELIF)
111 gobble(filep, file, file_red);
123 warning(
"%s, line %d: incomplete undef == \"%s\"\n",
130 add_include(filep, file, file_red, line,
false, failOK);
133 add_include(filep, file, file_red, line,
true, failOK);
148 if (file_red != file)
150 warning1(
", line %d: unknown directive == \"%s\"\n",
155 if (file_red != file)
157 warning1(
", line %d: incomplete include == \"%s\"\n",
171 while ((line =
getline(filep))) {
172 switch(type =
deftype(line, filep, file_red, file,
false)) {
178 type =
gobble(filep, file, file_red);
181 type =
gobble(filep, file, file_red);
183 (void)
gobble(filep, file, file_red);
187 debug(0,(
"%s, line %d: #%s\n",
207 warning(
"%s, line %d: unknown directive == \"%s\"\n",
223 char *directive, savechar;
230 while (*directive ==
' ' || *directive ==
'\t')
234 while (*p >=
'a' && *p <=
'z')
247 if (ret ==
ELIF && !parse_it)
249 while (*p ==
' ' || *p ==
'\t')
254 debug(0,(
"%s, line %d: #elif %s ",
259 debug(0,(
"false...\n"));
267 debug(0,(
"true...\n"));
272 if (ret < 0 || ! parse_it)
278 while (*p ==
' ' || *p ==
'\t')
286 debug(0,(
"%s, line %d: %s #if %s\n",
291 debug(0,(
"%s, line %d: #%s %s\n",
298 while (isalnum(*p) || *p ==
'_')
303 debug(2,(
"%s, line %d: #include %s\n",
311 debug(3,(
"%s : #includes SYMBOL %s = %s\n",
324 while (*p && *p !=
'"' && *p !=
'<')
330 while (*p && *p !=
'"')
333 while (*p && *p !=
'>')
352 debug(0,(
"%s, line %d: #%s\n",
365 register struct symtab *val;
368 debug(1,(
"%s defined on command line\n", symbol));
372 if ((val =
fdefined(symbol, file, srcfile)))
374 debug(1,(
"%s not defined in %s\n", symbol, file->
i_file));
381 register struct symtab *val;
383 static int recurse_lvl = 0;
388 if ((val =
slookup(symbol, file)))
390 if (val == NULL && file->
i_list)
392 for (ip = file->
i_list, i=0; i < file->i_listlen; i++, ip++)
393 if ((val =
fdefined(symbol, *ip, srcfile))) {
397 else if (val != NULL && srcfile != NULL) *srcfile = file;
422 while (isalnum(*val) || *val ==
'_')
426 while (*val ==
' ' || *val ==
'\t')
436 int first, last, below;
437 register struct symtab *sp = NULL, *dest;
453 fatalerr(
"malloc()/realloc() failure in insert_defn()\n");
457 while (last >= first)
462 register int middle = (first + last) / 2;
467 while (*s1++ == *s2++)
468 if (s2[-1] ==
'\0')
break;
473 sp = file->
i_defs + middle;
486 below = last = middle - 1;
500 dest = file->
i_defs + below + 1;
512 register int first = 0;
513 register int last = file->
i_ndefs - 1;
515 if (file)
while (last >= first)
520 register int middle = (first + last) / 2;
525 while (*s1++ == *s2++)
526 if (s2[-1] ==
'\0')
break;
531 return file->
i_defs + middle;
550 register struct symtab *ptr;
552 while ((ptr =
isdefined(symbol, file, &srcfile)) != NULL)
int cppsetup(register char *line, register struct filepointer *filep, register inclist *inc)
char * getline(register filepointer *filep)
#define debug(level, arg)
define DEBUG
void add_include(filepointer *filep, inclist *file, inclist *file_red, char *include, bool dot, bool failOK)
int match(register const char *str, register const char **list)
char * copy(register char *str)
void warning1(const char *msg, x1, x2, x3, x4, x5, x6, x7, x8, x9)
void fatalerr(char *msg, x1, x2, x3, x4, x5, x6, x7, x8, x9)
void warning(const char *msg, x1, x2, x3, x4, x5, x6, x7, x8, x9)
symtab * isdefined(register char *symbol, inclist *file, inclist **srcfile)
int zero_value(register char *exp, register struct filepointer *filep, register inclist *file_red)
int find_includes(struct filepointer *filep, inclist *file, inclist *file_red, int recursion, bool failOK)
const char * directives[]
int gobble(register struct filepointer *filep, inclist *file, inclist *file_red)
void define2(char *name, char *val, inclist *file)
void undefine(char *symbol, register inclist *file)
struct symtab * fdefined(register char *symbol, inclist *file, inclist **srcfile)
void define(char *def, inclist *file)
int deftype(register char *line, register struct filepointer *filep, register inclist *file_red, register inclist *file, int parse_it)
struct symtab * slookup(register char *symbol, register inclist *file)