1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1986-2009 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
19 ***********************************************************************/
27 * intended to be a conforming implementation of the translation phases
28 * (2.1.1.2) 1,2,3,4 and 6 of the "American National Standard for
29 * Information Systems -- Programming Language -- C", ANSI X3.159-1989.
31 * STANDARD INTERPRETATION:
33 * include files are forced to preserve #if nesting levels
34 * support for this is found in the recursive description for
35 * include file processing in the translation phases
37 * ID"..." produces two tokens: {ID}{"..."}
38 * ID'...' produces two tokens: {ID}{'...'}
42 * only sane Reiser compatibility is implemented
44 * strange handling of `\newline', especially in directives,
47 * dissappearing comments used as concatenation operators work
48 * only within macro bodies
51 static const char id
[] = "\n@(#)$Id: libpp (AT&T Research) 2009-02-02 $\0\n";
59 static char addbuf
[MAXTOKEN
+1]; /* ADD buffer */
60 static char argsbuf
[MAXTOKEN
+1]; /* predicate args */
61 static char catbuf
[MAXTOKEN
+1]; /* catenation buffer */
62 static char hidebuf
[MAXTOKEN
+1]; /* pp:hide buffer */
63 static char outbuf
[2*(PPBUFSIZ
+MAXTOKEN
)];/* output buffer */
64 static char pathbuf
[MAXTOKEN
+1]; /* full path of last #include */
65 static char tmpbuf
[MAXTOKEN
+1]; /* very temporary buffer */
66 static char tokbuf
[2*MAXTOKEN
+1]; /* token buffer */
67 static char valbuf
[MAXTOKEN
+1]; /* builtin macro value buffer */
69 static char optflags
[X_last_option
+1];/* OPT_* flags indexed by X_* */
73 static struct ppinstk instack
= /* input stream stack */
75 &null
[0] /* nextchr */
78 static struct ppdirs stddir
= /* standard include directory */
80 PPSTANDARD
, 0, 1, INC_STANDARD
, TYPE_INCLUDE
|TYPE_DIRECTORY
|TYPE_HOSTED
83 static struct ppdirs firstdir
= /* first include directory */
85 "", &stddir
, 0, INC_PREFIX
, TYPE_INCLUDE
|TYPE_DIRECTORY
92 &id
[10], /* version */
94 "/dev/stdout", /* outfile */
96 &tokbuf
[0], /* token */
99 /* exposed for the output macros */
101 &outbuf
[0], /* outb */
102 &outbuf
[0], /* outbuf */
103 &outbuf
[0], /* outp */
104 &outbuf
[PPBUFSIZ
], /* oute */
109 &firstdir
, /* lcldirs */
110 &firstdir
, /* stddirs */
114 /* private context */
118 ALLMULTIPLE
|CATLITERAL
, /* mode */
122 0, /* filedeps.flags */
123 &firstdir
, /* firstdir */
124 &firstdir
, /* lastdir */
159 /* library private globals */
161 "\"08/11/94\"", /* checkpoint (with quotes!) */
164 &addbuf
[0], /* addp */
165 &argsbuf
[0], /* args */
166 &addbuf
[0], /* addbuf */
167 &catbuf
[0], /* catbuf */
169 &hidebuf
[0], /* hidebuf */
170 &pathbuf
[0], /* path */
171 &tmpbuf
[0], /* tmpbuf */
172 &valbuf
[0], /* valbuf */
173 &optflags
[0], /* optflags */
176 /* the rest are implicitly initialized */
179 char ppctype
[UCHAR_MAX
+1];