ppdata.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa/***********************************************************************
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa* *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa* This software is part of the ast package *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa* Copyright (c) 1986-2012 AT&T Intellectual Property *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa* and is licensed under the *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa* Eclipse Public License, Version 1.0 *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa* by AT&T Intellectual Property *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa* *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa* A copy of the License is available at *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa* http://www.eclipse.org/org/documents/epl-v10.html *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa* *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa* Information and Software Systems Research *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa* AT&T Research *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa* Florham Park NJ *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa* *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa* Glenn Fowler <gsf@research.att.com> *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa* *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa***********************************************************************/
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa#pragma prototyped
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa/*
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa * Glenn Fowler
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa * AT&T Research
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa * preprocessor data
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa * intended to be a conforming implementation of the translation phases
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa * (2.1.1.2) 1,2,3,4 and 6 of the "American National Standard for
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa * Information Systems -- Programming Language -- C", ANSI X3.159-1989.
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa * STANDARD INTERPRETATION:
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa * include files are forced to preserve #if nesting levels
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa * support for this is found in the recursive description for
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa * include file processing in the translation phases
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa * ID"..." produces two tokens: {ID}{"..."}
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa * ID'...' produces two tokens: {ID}{'...'}
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa *
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa * COMPATIBILITY:
649fdc0d0502d62d160c150684356fef2c273484Eugen Kuksa *
* only sane Reiser compatibility is implemented
*
* strange handling of `\newline', especially in directives,
* is not implemented
*
* dissappearing comments used as concatenation operators work
* only within macro bodies
*/
static const char id[] = "\n@(#)$Id: libpp (AT&T Research) 2012-06-06 $\0\n";
#include "pplib.h"
#ifndef IDNAME
#define IDNAME "pp"
#endif
static char addbuf[MAXTOKEN+1]; /* ADD buffer */
static char argsbuf[MAXTOKEN+1]; /* predicate args */
static char catbuf[MAXTOKEN+1]; /* catenation buffer */
static char hidebuf[MAXTOKEN+1]; /* pp:hide buffer */
static char outbuf[2*(PPBUFSIZ+MAXTOKEN)];/* output buffer */
static char pathbuf[MAXTOKEN+1]; /* full path of last #include */
static char tmpbuf[MAXTOKEN+1]; /* very temporary buffer */
static char tokbuf[2*MAXTOKEN+1]; /* token buffer */
static char valbuf[MAXTOKEN+1]; /* builtin macro value buffer */
static char optflags[X_last_option+1];/* OPT_* flags indexed by X_* */
static char null[1];
static struct ppinstk instack = /* input stream stack */
{
&null[0] /* nextchr */
};
static struct ppdirs stddir = /* standard include directory */
{
PPSTANDARD, 0, 1, INC_STANDARD, TYPE_INCLUDE|TYPE_DIRECTORY|TYPE_HOSTED
};
static struct ppdirs firstdir = /* first include directory */
{
"", &stddir, 0, INC_PREFIX, TYPE_INCLUDE|TYPE_DIRECTORY
};
struct ppglobals pp =
{
/* public globals */
&id[10], /* version */
"", /* lineid */
"/dev/stdout", /* outfile */
IDNAME, /* pass */
&tokbuf[0], /* token */
0, /* symbol */
/* exposed for the output macros */
&outbuf[0], /* outb */
&outbuf[0], /* outbuf */
&outbuf[0], /* outp */
&outbuf[PPBUFSIZ], /* oute */
0, /* offset */
/* public context */
&firstdir, /* lcldirs */
&firstdir, /* stddirs */
0, /* flags */
0, /* symtab */
/* private context */
0, /* context */
0, /* state */
ALLMULTIPLE|CATLITERAL, /* mode */
PREFIX, /* option */
0, /* test */
0, /* filedeps.sp */
0, /* filedeps.flags */
&firstdir, /* firstdir */
&firstdir, /* lastdir */
0, /* hide */
0, /* column */
-1, /* pending */
0, /* firstfile */
0, /* lastfile */
0, /* ignore */
0, /* probe */
0, /* filtab */
0, /* prdtab */
0, /* date */
0, /* time */
0, /* maps */
0, /* ro_state */
0, /* ro_mode */
0, /* ro_option */
{0}, /* ro_op[] */
{0}, /* cdir */
{0}, /* hostdir */
0, /* ppdefault */
0, /* firstindex */
0, /* lastindex */
0, /* firstop */
0, /* lastop */
0, /* firsttx */
0, /* lasttx */
0, /* arg_file */
0, /* arg_mode */
0, /* arg_style */
0, /* c */
0, /* hosted */
0, /* ignoresrc */
0, /* initialized */
0, /* standalone */
0, /* spare_1 */
/* library private globals */
"\"08/11/94\"", /* checkpoint (with quotes!) */
128, /* constack */
&instack, /* in */
&addbuf[0], /* addp */
&argsbuf[0], /* args */
&addbuf[0], /* addbuf */
&catbuf[0], /* catbuf */
0, /* hdrbuf */
&hidebuf[0], /* hidebuf */
&pathbuf[0], /* path */
&tmpbuf[0], /* tmpbuf */
&valbuf[0], /* valbuf */
&optflags[0], /* optflags */
'\n', /* lastout */
/* the rest are implicitly initialized */
};
char ppctype[UCHAR_MAX+1];