Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libpp/ppdata.c
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1986-2012 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#pragma prototyped
21
/*
22
* Glenn Fowler
23
* AT&T Research
24
*
25
* preprocessor data
26
*
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.
30
*
31
* STANDARD INTERPRETATION:
32
*
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
36
*
37
* ID"..." produces two tokens: {ID}{"..."}
38
* ID'...' produces two tokens: {ID}{'...'}
39
*
40
* COMPATIBILITY:
41
*
42
* only sane Reiser compatibility is implemented
43
*
44
* strange handling of `\newline', especially in directives,
45
* is not implemented
46
*
47
* dissappearing comments used as concatenation operators work
48
* only within macro bodies
49
*/
50
51
static const char id[] = "\n@(#)$Id: libpp (AT&T Research) 2012-06-06 $\0\n";
52
53
#include "pplib.h"
54
55
#ifndef IDNAME
56
#define IDNAME "pp"
57
#endif
58
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 */
68
69
static char optflags[X_last_option+1];/* OPT_* flags indexed by X_* */
70
71
static char null[1];
72
73
static struct ppinstk instack = /* input stream stack */
74
{
75
&null[0] /* nextchr */
76
};
77
78
static struct ppdirs stddir = /* standard include directory */
79
{
80
PPSTANDARD, 0, 1, INC_STANDARD, TYPE_INCLUDE|TYPE_DIRECTORY|TYPE_HOSTED
81
};
82
83
static struct ppdirs firstdir = /* first include directory */
84
{
85
"", &stddir, 0, INC_PREFIX, TYPE_INCLUDE|TYPE_DIRECTORY
86
};
87
88
struct ppglobals pp =
89
{
90
/* public globals */
91
92
&id[10], /* version */
93
"", /* lineid */
94
"/dev/stdout", /* outfile */
95
IDNAME, /* pass */
96
&tokbuf[0], /* token */
97
0, /* symbol */
98
99
/* exposed for the output macros */
100
101
&outbuf[0], /* outb */
102
&outbuf[0], /* outbuf */
103
&outbuf[0], /* outp */
104
&outbuf[PPBUFSIZ], /* oute */
105
0, /* offset */
106
107
/* public context */
108
109
&firstdir, /* lcldirs */
110
&firstdir, /* stddirs */
111
0, /* flags */
112
0, /* symtab */
113
114
/* private context */
115
116
0, /* context */
117
0, /* state */
118
ALLMULTIPLE|CATLITERAL, /* mode */
119
PREFIX, /* option */
120
0, /* test */
121
0, /* filedeps.sp */
122
0, /* filedeps.flags */
123
&firstdir, /* firstdir */
124
&firstdir, /* lastdir */
125
0, /* hide */
126
0, /* column */
127
-1, /* pending */
128
0, /* firstfile */
129
0, /* lastfile */
130
0, /* ignore */
131
0, /* probe */
132
0, /* filtab */
133
0, /* prdtab */
134
0, /* date */
135
0, /* time */
136
0, /* maps */
137
0, /* ro_state */
138
0, /* ro_mode */
139
0, /* ro_option */
140
{0}, /* ro_op[] */
141
{0}, /* cdir */
142
{0}, /* hostdir */
143
0, /* ppdefault */
144
0, /* firstindex */
145
0, /* lastindex */
146
0, /* firstop */
147
0, /* lastop */
148
0, /* firsttx */
149
0, /* lasttx */
150
0, /* arg_file */
151
0, /* arg_mode */
152
0, /* arg_style */
153
0, /* c */
154
0, /* hosted */
155
0, /* ignoresrc */
156
0, /* initialized */
157
0, /* standalone */
158
0, /* spare_1 */
159
160
/* library private globals */
161
162
"\"08/11/94\"", /* checkpoint (with quotes!) */
163
128, /* constack */
164
&instack, /* in */
165
&addbuf[0], /* addp */
166
&argsbuf[0], /* args */
167
&addbuf[0], /* addbuf */
168
&catbuf[0], /* catbuf */
169
0, /* hdrbuf */
170
&hidebuf[0], /* hidebuf */
171
&pathbuf[0], /* path */
172
&tmpbuf[0], /* tmpbuf */
173
&valbuf[0], /* valbuf */
174
&optflags[0], /* optflags */
175
'\n', /* lastout */
176
177
/* the rest are implicitly initialized */
178
};
179
180
char ppctype[UCHAR_MAX+1];
181
182