/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1986-2012 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* *18***********************************************************************/19#pragma prototyped20/*21* Glenn Fowler22* AT&T Research23*24* preprocessor data25*26* intended to be a conforming implementation of the translation phases27* (2.1.1.2) 1,2,3,4 and 6 of the "American National Standard for28* Information Systems -- Programming Language -- C", ANSI X3.159-1989.29*30* STANDARD INTERPRETATION:31*32* include files are forced to preserve #if nesting levels33* support for this is found in the recursive description for34* include file processing in the translation phases35*36* ID"..." produces two tokens: {ID}{"..."}37* ID'...' produces two tokens: {ID}{'...'}38*39* COMPATIBILITY:40*41* only sane Reiser compatibility is implemented42*43* strange handling of `\newline', especially in directives,44* is not implemented45*46* dissappearing comments used as concatenation operators work47* only within macro bodies48*/4950static const char id[] = "\n@(#)$Id: libpp (AT&T Research) 2012-06-06 $\0\n";5152#include "pplib.h"5354#ifndef IDNAME55#define IDNAME "pp"56#endif5758static char addbuf[MAXTOKEN+1]; /* ADD buffer */59static char argsbuf[MAXTOKEN+1]; /* predicate args */60static char catbuf[MAXTOKEN+1]; /* catenation buffer */61static char hidebuf[MAXTOKEN+1]; /* pp:hide buffer */62static char outbuf[2*(PPBUFSIZ+MAXTOKEN)];/* output buffer */63static char pathbuf[MAXTOKEN+1]; /* full path of last #include */64static char tmpbuf[MAXTOKEN+1]; /* very temporary buffer */65static char tokbuf[2*MAXTOKEN+1]; /* token buffer */66static char valbuf[MAXTOKEN+1]; /* builtin macro value buffer */6768static char optflags[X_last_option+1];/* OPT_* flags indexed by X_* */6970static char null[1];7172static struct ppinstk instack = /* input stream stack */73{74&null[0] /* nextchr */75};7677static struct ppdirs stddir = /* standard include directory */78{79PPSTANDARD, 0, 1, INC_STANDARD, TYPE_INCLUDE|TYPE_DIRECTORY|TYPE_HOSTED80};8182static struct ppdirs firstdir = /* first include directory */83{84"", &stddir, 0, INC_PREFIX, TYPE_INCLUDE|TYPE_DIRECTORY85};8687struct ppglobals pp =88{89/* public globals */9091&id[10], /* version */92"", /* lineid */93"/dev/stdout", /* outfile */94IDNAME, /* pass */95&tokbuf[0], /* token */960, /* symbol */9798/* exposed for the output macros */99100&outbuf[0], /* outb */101&outbuf[0], /* outbuf */102&outbuf[0], /* outp */103&outbuf[PPBUFSIZ], /* oute */1040, /* offset */105106/* public context */107108&firstdir, /* lcldirs */109&firstdir, /* stddirs */1100, /* flags */1110, /* symtab */112113/* private context */1141150, /* context */1160, /* state */117ALLMULTIPLE|CATLITERAL, /* mode */118PREFIX, /* option */1190, /* test */1200, /* filedeps.sp */1210, /* filedeps.flags */122&firstdir, /* firstdir */123&firstdir, /* lastdir */1240, /* hide */1250, /* column */126-1, /* pending */1270, /* firstfile */1280, /* lastfile */1290, /* ignore */1300, /* probe */1310, /* filtab */1320, /* prdtab */1330, /* date */1340, /* time */1350, /* maps */1360, /* ro_state */1370, /* ro_mode */1380, /* ro_option */139{0}, /* ro_op[] */140{0}, /* cdir */141{0}, /* hostdir */1420, /* ppdefault */1430, /* firstindex */1440, /* lastindex */1450, /* firstop */1460, /* lastop */1470, /* firsttx */1480, /* lasttx */1490, /* arg_file */1500, /* arg_mode */1510, /* arg_style */1520, /* c */1530, /* hosted */1540, /* ignoresrc */1550, /* initialized */1560, /* standalone */1570, /* spare_1 */158159/* library private globals */160161"\"08/11/94\"", /* checkpoint (with quotes!) */162128, /* constack */163&instack, /* in */164&addbuf[0], /* addp */165&argsbuf[0], /* args */166&addbuf[0], /* addbuf */167&catbuf[0], /* catbuf */1680, /* hdrbuf */169&hidebuf[0], /* hidebuf */170&pathbuf[0], /* path */171&tmpbuf[0], /* tmpbuf */172&valbuf[0], /* valbuf */173&optflags[0], /* optflags */174'\n', /* lastout */175176/* the rest are implicitly initialized */177};178179char ppctype[UCHAR_MAX+1];180181182