Lines Matching refs:pp

33 #define REFONE	(pp.truncate?(Hash_table_t*)0:pp.symtab)
34 #define REFALL (pp.truncate?pp.dirtab:pp.symtab)
48 r = p == &pp.state ? &pp.ro_state : p == &pp.mode ? &pp.ro_mode : &pp.ro_option;
49 if ((pp.mode & INIT) && pp.in->type == IN_FILE && (*r & op))
51 debug((-7, "set %s %s skipped -- readonly", p == &pp.state ? "state" : p == &pp.mode ? "mode" : "option", p == &pp.state ? ppstatestr(*r) : p == &pp.mode ? ppmodestr(*r) : ppoptionstr(*r)));
54 if (!pp.initialized && (!(pp.mode & INIT) || !(pp.mode & BUILTIN)) && (p != &pp.mode || !(op & BUILTIN)) && (p != &pp.option || !(op & PREDEFINED)))
57 debug((-7, "set %s %s readonly", p == &pp.state ? "state" : p == &pp.mode ? "mode" : "option", p == &pp.state ? ppstatestr(*r) : p == &pp.mode ? ppmodestr(*r) : ppoptionstr(*r)));
63 debug((-7, "set %s %s", p == &pp.state ? "state" : p == &pp.mode ? "mode" : "option", p == &pp.state ? ppstatestr(*r) : p == &pp.mode ? ppmodestr(*r) : ppoptionstr(*r)));
125 old_state = pp.state;
137 s = t = strcopy(pp.tmpbuf, error_info.file);
141 if (s <= pp.tmpbuf || *s == '/')
151 file = pp.tmpbuf;
160 pp.state |= (COMPILE|FILEPOP|HEADER|JOINING|STRIP|NOSPACE|PASSEOF);
162 pp.state |= (COMPILE|FILEPOP|HEADER|STRIP|NOSPACE|PASSEOF);
164 pp.level++;
177 for (dp = pp.firstdir->next; dp; dp = dp->next)
186 pathcanon(pp.token, 0, 0);
187 fp = ppsetfile(pp.token);
209 if (streq(pp.token, "all"))
214 else if (streq(pp.token, "hosted"))
219 else if (streq(pp.token, "nohosted"))
226 error(3, "%s unexpected in %s map list", pptokstr(pp.token, 0), dirname(INCLUDE));
231 pp.level--;
233 pp.state = old_state;
250 * compare up to pp.truncate chars
258 return !strchr(b, ' ') && !strneq(b, "__STD", 5) ? strncmp(a, b, pp.truncate) : strcmp(a, b);
262 * hash up to pp.truncate chars
272 return memhash(a, (n = strlen(a)) > pp.truncate && !strchr(a, ' ') && !strneq(a, "__STD", 5) ? pp.truncate : n);
287 if (error_info.trace <= -10 && pp.state != state)
289 state = pp.state;
290 sfprintf(sp, " %s", ppstatestr(pp.state));
337 r = &pp.ro_op[op >> 5];
339 if ((pp.mode & INIT) && pp.in->type == IN_FILE && (*r & n))
344 else if (!pp.initialized && (!(pp.mode & INIT) || !(pp.mode & BUILTIN)))
355 * pp operations
393 if (pp.initialized)
397 if (pp.lastop)
398 pp.lastop = (pp.lastop->next = newof(0, struct oplist, 1, 0));
400 pp.firstop = pp.lastop = newof(0, struct oplist, 1, 0);
401 pp.lastop->op = op;
402 pp.lastop->value = p;
406 pp.builtin = va_arg(ap, PPBUILTIN);
411 pp.cdir.path = 0;
413 pp.c = c;
416 pp.c = c;
417 for (dp = pp.firstdir; dp; dp = dp->next)
420 else if (!pp.c)
423 pp.c = c;
426 for (dp = pp.firstdir; dp; dp = dp->next)
428 if (!pp.c && (dp->c || dp->name && SAMEID(&dp->id, &st)))
429 pp.c = 1;
430 dp->c = pp.c == 1;
432 if (!pp.c)
434 pp.cdir.path = p;
435 SAVEID(&pp.cdir.id, &st);
460 xp->next = pp.chop;
461 pp.chop = xp;
465 if (pp.comment = va_arg(ap, PPCOMMENT))
466 pp.flags |= PP_comment;
468 pp.flags &= ~PP_comment;
471 if (ppset(&pp.state, COMPATIBILITY, va_arg(ap, int)))
474 if (pp.initialized)
477 if (pp.state & COMPATIBILITY)
480 if (pp.state & COMPATIBILITY)
481 pp.flags |= PP_compatibility;
483 pp.flags &= ~PP_compatibility;
487 if (pp.initialized)
489 pp.state |= COMPILE;
490 if (!pp.symtab)
491 pp.symtab = hashalloc(NiL, HASH_name, "symbols", 0);
503 if (!(pp.option & PLUSPLUS))
510 if (key = ppkeyset(pp.symtab, s))
523 if (pp.ppdefault)
524 free(pp.ppdefault);
525 pp.ppdefault = p;
529 if (pp.mode & DUMP)
532 if (pp.mode & FILEDEPS)
534 sfputc(pp.filedeps.sp, '\n');
535 if (pp.filedeps.sp == sfstdout)
536 sfsync(pp.filedeps.sp);
538 sfclose(pp.filedeps.sp);
540 if (pp.state & STANDALONE)
542 if ((pp.state & (NOTEXT|HIDDEN)) == HIDDEN && pplastout() != '\n')
549 ppset(&pp.mode, DUMP, va_arg(ap, int));
551 if (pp.mode & DUMP)
557 pp.filedeps.flags |= n;
559 pp.filedeps.flags = 0;
565 if (!(pp.mode & INIT))
566 pp.ro_mode |= HOSTED;
567 else if (pp.ro_mode & HOSTED)
569 pp.ro_mode |= INIT;
572 pp.hostdir.path = 0;
574 pp.hosted = c;
577 if (pp.initialized)
578 ppset(&pp.mode, HOSTED, c);
581 pp.hosted = c ? 1 : 2;
582 for (dp = pp.firstdir; dp; dp = dp->next)
583 if (pp.hosted == 1)
589 else if (!pp.hosted)
592 pp.hosted = 1;
595 for (dp = pp.firstdir; dp; dp = dp->next)
597 if (!pp.hosted && ((dp->type & TYPE_HOSTED) || dp->name && SAMEID(&dp->id, &st)))
598 pp.hosted = 1;
599 if (pp.hosted == 1)
604 if (!pp.hosted)
606 pp.hostdir.path = p;
607 SAVEID(&pp.hostdir.id, &st);
627 if (pp.initialized)
629 pp.ignore = va_arg(ap, char*);
637 for (dp = pp.stddirs; dp = dp->next;)
640 if (pp.cdir.path && SAMEID(&pp.cdir.id, &st))
642 pp.cdir.path = 0;
643 pp.c = 1;
645 if (pp.hostdir.path && SAMEID(&pp.hostdir.id, &st))
647 pp.hostdir.path = 0;
648 pp.hosted = 1;
650 if ((pp.mode & INIT) && !(pp.ro_mode & INIT))
651 pp.hosted = 1;
652 c = dp && dp->c || pp.c == 1;
653 n = dp && (dp->type & TYPE_HOSTED) || pp.hosted == 1;
654 if (!dp || dp == pp.lastdir->next)
665 dp->index = INC_LOCAL + pp.ignoresrc != 0;
666 dp->next = pp.lastdir->next;
667 pp.lastdir = pp.lastdir->next = dp;
677 pp.incref = va_arg(ap, PPINCREF);
680 pp.reset.on = 1;
683 if (pp.initialized)
706 error_info.version = (char*)pp.version;
722 pp.macp = newof(0, struct ppmacstk, DEFMACSTACK, 0);
723 pp.macp->next = pp.macp + 1;
724 pp.maxmac = (char*)pp.macp + DEFMACSTACK;
731 pp.control = newof(0, long, pp.constack, 0);
732 pp.maxcon = pp.control + pp.constack - 1;
739 switch (pp.arg_mode)
775 if (!(pp.state & WARN) && !(pp.arg_style & STYLE_gnu))
777 if (pp.state & PASSTHROUGH)
779 if (pp.state & COMPILE)
781 pp.state &= ~PASSTHROUGH;
789 ppset(&pp.state, DISABLE, va_arg(ap, int));
797 if (!pp.symtab)
798 pp.symtab = hashalloc(NiL, HASH_name, "symbols", 0);
799 if (!pp.dirtab)
801 pp.dirtab = hashalloc(REFONE, HASH_name, "directives", 0);
802 inithash(pp.dirtab, directives);
804 if (!pp.filtab)
805 pp.filtab = hashalloc(REFALL, HASH_name, "files", 0);
806 if (!pp.prdtab)
807 pp.prdtab = hashalloc(REFALL, HASH_name, "predicates", 0);
808 if (!pp.strtab)
810 pp.strtab = hashalloc(REFALL, HASH_name, "strings", 0);
811 inithash(pp.strtab, options);
812 inithash(pp.strtab, predicates);
813 inithash(pp.strtab, variables);
815 pp.optflags[X_PROTOTYPED] = OPT_GLOBAL;
816 pp.optflags[X_SYSTEM_HEADER] = OPT_GLOBAL|OPT_PASS;
833 hashset(pp.dirtab, HASH_ALLOCATE);
834 hashset(pp.filtab, HASH_ALLOCATE);
835 hashset(pp.prdtab, HASH_ALLOCATE);
836 hashset(pp.strtab, HASH_ALLOCATE);
837 hashset(pp.symtab, HASH_ALLOCATE);
838 if (pp.test & TEST_nonoise)
844 if (!(pp.test & TEST_noinit))
860 pp.pass,
864 pp.pass,
867 if (pp.ppdefault && *pp.ppdefault)
869 if (pp.probe)
871 c = pp.lastdir->next->type;
872 pp.lastdir->next->type = 0;
874 if (ppsearch(pp.ppdefault, T_STRING, SEARCH_EXISTS) < 0)
876 free(pp.ppdefault);
877 if (!(pp.ppdefault = pathprobe("C", pp.pass, pp.probe ? pp.probe : PPPROBE, 0, pp.path, MAXTOKEN + 1, NiL, 0)))
878 error(1, "cannot determine default definitions for %s", pp.probe ? pp.probe : PPPROBE);
880 if (pp.probe)
881 pp.lastdir->next->type = c;
883 while (pp.firstop)
885 switch (pp.firstop->op)
888 sfprintf(sp, "#%s #%s\n", dirname(DEFINE), pp.firstop->value);
891 if (*pp.firstop->value == '#')
892 sfprintf(sp, "#%s %s\n", dirname(DEFINE), pp.firstop->value);
895 if (s = strchr(pp.firstop->value, '='))
896 sfprintf(sp, "#%s %-.*s %s\n", dirname(DEFINE), s - pp.firstop->value, pp.firstop->value, s + 1);
898 sfprintf(sp, "#%s %s 1\n", dirname(DEFINE), pp.firstop->value);
902 sfprintf(sp, "#%s\n", pp.firstop->value);
905 if (s = strchr(pp.firstop->value, '='))
906 sfprintf(sp, "#%s %s:%-.*s %s\n", dirname(PRAGMA), pp.pass, s - pp.firstop->value, pp.firstop->value, s + 1);
908 sfprintf(sp, "#%s %s:%s\n", dirname(PRAGMA), pp.pass, pp.firstop->value);
911 sfprintf(sp, "#%s \"%s\"\n", dirname(INCLUDE), pp.firstop->value);
914 sfprintf(sp, "#%s %s\n", dirname(UNDEF), pp.firstop->value);
917 pp.lastop = pp.firstop;
918 pp.firstop = pp.firstop->next;
919 free(pp.lastop);
929 , pp.pass
932 , pp.pass
956 , pp.pass
959 , pp.pass
980 , pp.pass
983 if (!pp.truncate)
1003 , pp.pass
1006 , pp.pass
1009 if (pp.ppdefault && *pp.ppdefault)
1010 sfprintf(sp, "#%s \"%s\"\n", dirname(INCLUDE), pp.ppdefault);
1023 ppcomment = pp.comment;
1024 pp.comment = 0;
1025 pplinesync = pp.linesync;
1026 pp.linesync = 0;
1027 PUSH_INIT(pp.pass, t);
1028 pp.mode |= INIT;
1030 pp.mode &= ~INIT;
1031 pp.comment = ppcomment;
1032 pp.linesync = pplinesync;
1033 pp.prefix = 0;
1036 for (dp = pp.firstdir; dp; dp = dp->next)
1040 if (pp.test & TEST_nonoise)
1052 if ((preroot = (struct pplist*)hashget(pp.prdtab, "preroot")))
1056 if (pp.ignoresrc)
1058 if (pp.ignoresrc > 1 && pp.stddirs != pp.firstdir)
1059 error(1, "directories up to and including %s are for \"...\" include files only", pp.stddirs->name);
1060 pp.lcldirs = pp.lcldirs->next;
1062 if (pp.ignore)
1064 if (*pp.ignore)
1065 ppmapinclude(pp.ignore, NiL);
1067 pp.ignore = 0;
1069 if (pp.standalone)
1070 pp.state |= STANDALONE;
1075 pp.initialized = 1;
1076 if (pp.reset.on)
1078 pp.reset.symtab = pp.symtab;
1079 pp.symtab = 0;
1080 pp.reset.ro_state = pp.ro_state;
1081 pp.reset.ro_mode = pp.ro_mode;
1082 pp.reset.ro_option = pp.ro_option;
1085 if (pp.reset.on)
1087 if (pp.symtab)
1089 hashwalk(pp.filtab, 0, unguard, NiL);
1090 hashfree(pp.symtab);
1092 pp.symtab = hashalloc(NiL, HASH_name, "symbols", HASH_free, undefine, HASH_set, HASH_ALLOCATE|HASH_BUCKET, 0);
1093 hashview(pp.symtab, pp.reset.symtab);
1094 pp.ro_state = pp.reset.ro_state;
1095 pp.ro_mode = pp.reset.ro_mode;
1096 pp.ro_option = pp.reset.ro_option;
1099 if (pp.mode & DUMP)
1101 if (!pp.pragma)
1103 (*pp.pragma)(dirname(PRAGMA), pp.pass, keyname(X_CHECKPOINT), pp.checkpoint, 1);
1106 if (n = pp.filedeps.flags)
1110 pp.state |= NOTEXT;
1111 pp.option |= KEEPNOTEXT;
1112 pp.linesync = 0;
1115 pp.mode |= GENDEPS;
1117 pp.mode &= ~HEADERDEPS;
1118 else if (!(pp.mode & FILEDEPS))
1119 pp.mode |= HEADERDEPS;
1120 pp.mode |= FILEDEPS;
1127 if (pp.firstdir->type & TYPE_HOSTED)
1128 pp.mode |= MARKHOSTED;
1130 pp.mode &= ~MARKHOSTED;
1132 if (!(pp.mode & DUMP))
1148 if (pp.mode & FILEDEPS)
1156 s = strcpy(pp.tmpbuf, s);
1172 if (pp.state & NOTEXT)
1173 pp.filedeps.sp = sfstdout;
1177 if (!(pp.filedeps.sp = sfopen(NiL, s, "w")))
1181 pp.column = sfprintf(pp.filedeps.sp, "%s :", s);
1183 pp.column += sfprintf(pp.filedeps.sp, " %s", error_info.file);
1185 if (xp = pp.firsttx)
1201 if (!(pp.mode & DUMP) || pp.pool.input)
1204 if (!(pp.mode & DUMP))
1207 if (pp.pool.input)
1220 ppset(&pp.mode, CATLITERAL, 0);
1227 if (pp.initialized)
1231 if (pp.lasttx)
1232 pp.lasttx = pp.lasttx->next = newof(0, struct oplist, 1, 0);
1234 pp.firsttx = pp.lasttx = newof(0, struct oplist, 1, 0);
1235 pp.lasttx->op = op;
1236 pp.lasttx->value = p;
1240 if (pp.initialized)
1242 ppset(&pp.option, KEYARGS, va_arg(ap, int));
1243 if (pp.option & KEYARGS)
1245 ppset(&pp.mode, CATLITERAL, 1);
1252 pp.linesync = va_arg(ap, PPLINESYNC);
1258 pp.flags |= PP_linebase;
1260 pp.flags &= ~PP_linebase;
1267 pp.flags |= PP_linefile;
1269 pp.flags &= ~PP_linefile;
1276 pp.lineid = "";
1278 pp.lineid = strdup(p);
1280 pp.option |= IGNORELINE;
1287 pp.flags |= PP_linetype;
1289 pp.flags &= ~PP_linetype;
1291 pp.flags |= PP_linehosted;
1293 pp.flags &= ~PP_linehosted;
1297 if (pp.initialized)
1299 pp.ignoresrc++;
1300 pp.stddirs = pp.lastdir;
1301 if (!(pp.ro_option & PREFIX))
1302 pp.option &= ~PREFIX;
1305 pp.macref = va_arg(ap, PPMACREF);
1308 ppset(&pp.mode, ALLMULTIPLE, va_arg(ap, int));
1311 ppset(&pp.option, NOHASH, va_arg(ap, int));
1315 ppset(&pp.option, NOISE, op);
1316 ppset(&pp.option, NOISEFILTER, op < 0);
1319 pp.optarg = va_arg(ap, PPOPTARG);
1322 pp.outfile = va_arg(ap, char*);
1323 if (identical(pp.outfile, 0))
1324 error(3, "%s: identical to input", pp.outfile);
1326 if (open(pp.outfile, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) != 1)
1327 error(ERROR_SYSTEM|3, "%s: cannot create", pp.outfile);
1330 if (!(pp.state & COMPILE))
1331 ppset(&pp.state, PASSTHROUGH, va_arg(ap, int));
1334 ppset(&pp.mode, PEDANTIC, va_arg(ap, int));
1337 if (ppset(&pp.option, PLUSCOMMENT, va_arg(ap, int)) && pp.initialized)
1341 if (ppset(&pp.option, PLUSPLUS, va_arg(ap, int)) && ppset(&pp.option, PLUSCOMMENT, va_arg(ap, int)) && pp.initialized)
1345 if (pp.initialized)
1350 pp.pool.input = dup(0);
1351 pp.pool.output = dup(1);
1365 pp.pragma = va_arg(ap, PPPRAGMA);
1375 if ((c = (int)hashref(pp.strtab, p)) > 0 && c <= X_last_option)
1376 pp.optflags[c] = n;
1380 pp.probe = va_arg(ap, char*);
1389 ppset(&pp.option, REGUARD, va_arg(ap, int));
1392 if ((pp.state & COMPILE) && (p = va_arg(ap, char*)))
1409 op = ((key = ppkeyref(pp.symtab, s)) && (key->sym.flags & SYM_LEX)) ? key->lex : T_NOISE;
1410 if (pp.test & 0x0400)
1414 if (!(key = ppkeyget(pp.symtab, p)))
1415 key = ppkeyset(pp.symtab, NiL);
1421 hashlook(pp.symtab, p, HASH_DELETE, NiL);
1422 key = ppkeyset(pp.symtab, NiL);
1432 if (pp.test & 0x0400)
1439 ppset(&pp.state, SPACEOUT, va_arg(ap, int));
1442 if (pp.initialized)
1444 pp.standalone = 1;
1447 if ((pp.lastdir->next->name = ((p = va_arg(ap, char*)) && *p) ? p : NiL) && !stat(p, &st))
1448 SAVEID(&pp.lastdir->next->id, &st);
1449 for (dp = pp.firstdir; dp; dp = dp->next)
1451 for (hp = pp.firstdir; hp != dp; hp = hp->next)
1462 if (ppset(&pp.state, STRICT, va_arg(ap, int)))
1464 if (ppset(&pp.state, TRANSITION, 0))
1465 pp.flags &= ~PP_transition;
1466 if (pp.state & STRICT)
1467 pp.flags |= PP_strict;
1469 pp.flags &= ~PP_strict;
1520 pp.test |= n;
1522 pp.test &= ~n;
1524 debug((-4, "test = 0%o", pp.test));
1528 if (ppset(&pp.state, TRANSITION, va_arg(ap, int)))
1530 if (ppset(&pp.state, STRICT, 0))
1531 pp.flags &= ~PP_strict;
1532 if (pp.state & TRANSITION)
1533 pp.flags |= PP_transition;
1535 pp.flags &= ~PP_transition;
1539 if (pp.initialized)
1543 ppset(&pp.option, TRUNCATE, op);
1544 if (pp.option & TRUNCATE)
1551 pp.truncate = op;
1552 tab = pp.symtab;
1553 pp.symtab = hashalloc(NiL, HASH_set, tab ? HASH_ALLOCATE : 0, HASH_compare, trunccomp, HASH_hash, trunchash, HASH_name, "truncate", 0);
1560 hashlook(pp.symtab, (char*)p, HASH_BUCKET|HASH_INSTALL, NiL);
1566 pp.truncate = 0;
1572 for (dp = pp.firstdir; dp; dp = dp->next)
1576 for (dp = pp.firstdir; dp; dp = dp->next)
1585 for (dp = pp.firstdir; dp; dp = dp->next)
1597 ppset(&pp.state, WARN, va_arg(ap, int));