ppdata.c revision da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/***********************************************************************
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* This software is part of the ast package *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* and is licensed under the *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Common Public License, Version 1.0 *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* by AT&T Knowledge Ventures *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* A copy of the License is available at *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Information and Software Systems Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* AT&T Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Florham Park NJ *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Glenn Fowler <gsf@research.att.com> *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin***********************************************************************/
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Glenn Fowler
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * AT&T Research
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * preprocessor data
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * intended to be a conforming implementation of the translation phases
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * (2.1.1.2) 1,2,3,4 and 6 of the "American National Standard for
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Information Systems -- Programming Language -- C", ANSI X3.159-1989.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * STANDARD INTERPRETATION:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * include files are forced to preserve #if nesting levels
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * support for this is found in the recursive description for
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * include file processing in the translation phases
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * ID"..." produces two tokens: {ID}{"..."}
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * ID'...' produces two tokens: {ID}{'...'}
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * COMPATIBILITY:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * only sane Reiser compatibility is implemented
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * strange handling of `\newline', especially in directives,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * is not implemented
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * dissappearing comments used as concatenation operators work
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * only within macro bodies
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic const char id[] = "\n@(#)$Id: libpp (AT&T Research) 2006-11-23 $\0\n";
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic char outbuf[2*(PPBUFSIZ+MAXTOKEN)];/* output buffer */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic char pathbuf[MAXTOKEN+1]; /* full path of last #include */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic char tmpbuf[MAXTOKEN+1]; /* very temporary buffer */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic char valbuf[MAXTOKEN+1]; /* builtin macro value buffer */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic char optflags[X_last_option+1];/* OPT_* flags indexed by X_* */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic struct ppinstk instack = /* input stream stack */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic struct ppdirs stddir = /* standard include directory */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin PPSTANDARD, 0, 1, INC_STANDARD, TYPE_INCLUDE|TYPE_DIRECTORY|TYPE_HOSTED
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic struct ppdirs firstdir = /* first include directory */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "", &stddir, 0, INC_PREFIX, TYPE_INCLUDE|TYPE_DIRECTORY
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* public globals */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* symbol */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* exposed for the output macros */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* offset */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* public context */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* flags */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* symtab */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* private context */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* context */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* state */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* test */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* filedeps.flags */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* hide */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* column */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* firstfile */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* lastfile */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* ignore */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* probe */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* filtab */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* prdtab */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* date */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* time */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* maps */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* ro_state */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* ro_mode */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* ro_option */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin {0}, /* cdir */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin {0}, /* hostdir */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* ppdefault */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* firstindex */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* lastindex */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* firstop */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* lastop */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* firsttx */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* lasttx */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* arg_file */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* arg_mode */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* arg_style */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* c */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* hosted */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* ignoresrc */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* initialized */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* standalone */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* spare_1 */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* library private globals */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, /* hdrbuf */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* the rest are implicitly initialized */