|
|
1.1 ! root 1: /* Definitions for CPP library. ! 2: Copyright (C) 1995 Free Software Foundation, Inc. ! 3: Written by Per Bothner, 1994-95. ! 4: ! 5: This program is free software; you can redistribute it and/or modify it ! 6: under the terms of the GNU General Public License as published by the ! 7: Free Software Foundation; either version 2, or (at your option) any ! 8: later version. ! 9: ! 10: This program is distributed in the hope that it will be useful, ! 11: but WITHOUT ANY WARRANTY; without even the implied warranty of ! 12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! 13: GNU General Public License for more details. ! 14: ! 15: You should have received a copy of the GNU General Public License ! 16: along with this program; if not, write to the Free Software ! 17: Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! 18: ! 19: In other words, you are welcome to use, share and improve this program. ! 20: You are forbidden to forbid anyone else to use, share and improve ! 21: what you give them. Help stamp out software-hoarding! */ ! 22: ! 23: #include <sys/types.h> ! 24: #include <sys/stat.h> ! 25: ! 26: #ifdef __cplusplus ! 27: extern "C" { ! 28: #endif ! 29: ! 30: #define STATIC_BUFFERS ! 31: ! 32: typedef unsigned char U_CHAR; ! 33: ! 34: struct parse_file; ! 35: typedef struct cpp_reader cpp_reader; ! 36: typedef struct cpp_buffer cpp_buffer; ! 37: typedef struct cpp_options cpp_options; ! 38: typedef struct hashnode cpp_hashnode; ! 39: ! 40: enum cpp_token { ! 41: CPP_EOF = -1, ! 42: CPP_OTHER = 0, ! 43: CPP_COMMENT = 1, ! 44: CPP_HSPACE, ! 45: CPP_VSPACE, /* newlines and #line directives */ ! 46: CPP_NAME, ! 47: CPP_NUMBER, ! 48: CPP_CHAR, ! 49: CPP_STRING, ! 50: CPP_DIRECTIVE, ! 51: CPP_LPAREN, /* "(" */ ! 52: CPP_RPAREN, /* ")" */ ! 53: CPP_LBRACE, /* "{" */ ! 54: CPP_RBRACE, /* "}" */ ! 55: CPP_COMMA, /* "," */ ! 56: CPP_SEMICOLON,/* ";" */ ! 57: CPP_3DOTS, /* "..." */ ! 58: #if 0 ! 59: CPP_ANDAND, /* "&&" */ ! 60: CPP_OROR, /* "||" */ ! 61: CPP_LSH, /* "<<" */ ! 62: CPP_RSH, /* ">>" */ ! 63: CPP_EQL, /* "==" */ ! 64: CPP_NEQ, /* "!=" */ ! 65: CPP_LEQ, /* "<=" */ ! 66: CPP_GEQ, /* ">=" */ ! 67: CPP_PLPL, /* "++" */ ! 68: CPP_MINMIN, /* "--" */ ! 69: #endif ! 70: /* POP_TOKEN is returned when we've popped a cpp_buffer. */ ! 71: CPP_POP ! 72: }; ! 73: ! 74: #ifndef PARAMS ! 75: #ifdef __STDC ! 76: #define PARAMS(P) P ! 77: #else ! 78: #define PARAMS(P) () ! 79: #endif ! 80: #endif /* !PARAMS */ ! 81: ! 82: typedef enum cpp_token (*parse_underflow_t) PARAMS((cpp_reader*)); ! 83: typedef int (*parse_cleanup_t) PARAMS((cpp_buffer *, cpp_reader*)); ! 84: ! 85: /* A parse_marker indicates a previous position, ! 86: which we can backtrack to. */ ! 87: ! 88: struct parse_marker { ! 89: cpp_buffer *buf; ! 90: struct parse_marker *next; ! 91: int position; ! 92: }; ! 93: ! 94: extern void parse_set_mark PARAMS ((struct parse_marker*, cpp_reader*)); ! 95: extern void parse_clear_mark PARAMS ((struct parse_marker*)); ! 96: extern void parse_goto_mark PARAMS((struct parse_marker*, cpp_reader*)); ! 97: extern void parse_move_mark PARAMS((struct parse_marker*, cpp_reader*)); ! 98: ! 99: extern int cpp_handle_options PARAMS ((cpp_reader*, int, char**)); ! 100: extern enum cpp_token cpp_get_token PARAMS ((struct parse_marker*)); ! 101: extern void cpp_skip_hspace PARAMS((cpp_reader*)); ! 102: extern enum cpp_token cpp_get_non_space_token PARAMS ((cpp_reader *)); ! 103: ! 104: ! 105: /* Maintain and search list of included files, for #import. */ ! 106: ! 107: #define IMPORT_HASH_SIZE 31 ! 108: ! 109: struct import_file { ! 110: char *name; ! 111: ino_t inode; ! 112: dev_t dev; ! 113: struct import_file *next; ! 114: }; ! 115: ! 116: /* If we have a huge buffer, may need to cache more recent counts */ ! 117: #define CPP_LINE_BASE(BUF) ((BUF)->buf + (BUF)->line_base) ! 118: ! 119: struct cpp_buffer { ! 120: unsigned char *buf; ! 121: unsigned char *cur; ! 122: unsigned char *rlimit; /* end of valid data */ ! 123: unsigned char *alimit; /* end of allocated buffer */ ! 124: unsigned char *prev; /* start of current token */ ! 125: ! 126: char *fname; ! 127: /* Filename specified with #line command. */ ! 128: char *nominal_fname; ! 129: ! 130: /* Record where in the search path this file was found. ! 131: For #include_next. */ ! 132: struct file_name_list *dir; ! 133: ! 134: long line_base; ! 135: long lineno; /* Line number at CPP_LINE_BASE. */ ! 136: long colno; /* Column number at CPP_LINE_BASE. */ ! 137: #ifndef STATIC_BUFFERS ! 138: cpp_buffer *chain; ! 139: #endif ! 140: parse_underflow_t underflow; ! 141: parse_cleanup_t cleanup; ! 142: void *data; ! 143: struct parse_marker *marks; ! 144: /* Value of if_stack at start of this file. ! 145: Used to prohibit unmatched #endif (etc) in an include file. */ ! 146: struct if_stack *if_stack; ! 147: ! 148: /* True if this is a header file included using <FILENAME>. */ ! 149: char system_header_p; ! 150: char seen_eof; ! 151: ! 152: /* True if buffer contains escape sequences. ! 153: Currently there are are only two kind: ! 154: "@-" means following identifier should not be macro-expanded. ! 155: "@ " means a token-separator. This turns into " " in final output ! 156: if not stringizing and needed to separate tokens; otherwise nothing. ! 157: "@@" means a normal '@'. ! 158: (An '@' inside a string stands for itself and is never an escape.) */ ! 159: char has_escapes; ! 160: }; ! 161: ! 162: struct cpp_pending; /* Forward declaration - for C++. */ ! 163: struct file_name_map_list; ! 164: ! 165: typedef struct assertion_hashnode ASSERTION_HASHNODE; ! 166: #define ASSERTION_HASHSIZE 37 ! 167: ! 168: #ifdef STATIC_BUFFERS ! 169: /* Maximum nesting of cpp_buffers. We use a static limit, partly for ! 170: efficiency, and partly to limit runaway recursion. */ ! 171: #define CPP_STACK_MAX 200 ! 172: #endif ! 173: ! 174: struct cpp_reader { ! 175: unsigned char *limit; ! 176: parse_underflow_t get_token; ! 177: cpp_buffer *buffer; ! 178: #ifdef STATIC_BUFFERS ! 179: cpp_buffer buffer_stack[CPP_STACK_MAX]; ! 180: #endif ! 181: ! 182: int errors; /* Error counter for exit code */ ! 183: void *data; ! 184: ! 185: U_CHAR *token_buffer; ! 186: int token_buffer_size; ! 187: ! 188: /* Line where a newline was first seen in a string constant. */ ! 189: int multiline_string_line; ! 190: ! 191: /* Current depth in #include directives that use <...>. */ ! 192: int system_include_depth; ! 193: ! 194: /* List of included files that contained #pragma once. */ ! 195: struct file_name_list *dont_repeat_files; ! 196: ! 197: /* List of other included files. ! 198: If ->control_macro if nonzero, the file had a #ifndef ! 199: around the entire contents, and ->control_macro gives the macro name. */ ! 200: struct file_name_list *all_include_files; ! 201: ! 202: /* Current maximum length of directory names in the search path ! 203: for include files. (Altered as we get more of them.) */ ! 204: int max_include_len; ! 205: ! 206: /* Hash table of files already included with #include or #import. */ ! 207: struct import_file *import_hash_table[IMPORT_HASH_SIZE]; ! 208: ! 209: struct if_stack *if_stack; ! 210: ! 211: /* Nonzero means we are inside an IF during a -pcp run. In this mode ! 212: macro expansion is done, and preconditions are output for all macro ! 213: uses requiring them. */ ! 214: char pcp_inside_if; ! 215: ! 216: /* Nonzero means we have printed (while error reporting) a list of ! 217: containing files that matches the current status. */ ! 218: char input_stack_listing_current; ! 219: ! 220: /* If non-zero, macros are not expanded. */ ! 221: char no_macro_expand; ! 222: ! 223: /* Print column number in error messages. */ ! 224: char show_column; ! 225: ! 226: /* We're printed a warning recommending against using #import. */ ! 227: char import_warning; ! 228: ! 229: /* If true, character between '<' and '>' are a single (string) token. */ ! 230: char parsing_include_directive; ! 231: ! 232: /* True if escape sequences (as described for has_escapes in ! 233: parse_buffer) should be emitted. */ ! 234: char output_escapes; ! 235: ! 236: /* 0: Have seen non-white-space on this line. ! 237: 1: Only seen white space so far on this line. ! 238: 2: Only seen white space so far in this file. */ ! 239: char only_seen_white; ! 240: ! 241: /* Nonzero means this file was included with a -imacros or -include ! 242: command line and should not be recorded as an include file. */ ! 243: ! 244: int no_record_file; ! 245: ! 246: long lineno; ! 247: ! 248: struct tm *timebuf; ! 249: ! 250: ASSERTION_HASHNODE *assertion_hashtab[ASSERTION_HASHSIZE]; ! 251: ! 252: /* Buffer of -M output. */ ! 253: char *deps_buffer; ! 254: ! 255: /* Number of bytes allocated in above. */ ! 256: int deps_allocated_size; ! 257: ! 258: /* Number of bytes used. */ ! 259: int deps_size; ! 260: ! 261: /* Number of bytes since the last newline. */ ! 262: int deps_column; ! 263: }; ! 264: ! 265: #define CPP_BUF_PEEK(BUFFER) \ ! 266: ((BUFFER)->cur < (BUFFER)->rlimit ? *(BUFFER)->cur : EOF) ! 267: #define CPP_BUF_GET(BUFFER) \ ! 268: ((BUFFER)->cur < (BUFFER)->rlimit ? *(BUFFER)->cur++ : EOF) ! 269: #define CPP_FORWARD(BUFFER, N) ((BUFFER)->cur += (N)) ! 270: ! 271: /* Number of characters currently in PFILE's output buffer. */ ! 272: #define CPP_WRITTEN(PFILE) ((PFILE)->limit - (PFILE)->token_buffer) ! 273: #define CPP_PWRITTEN(PFILE) ((PFILE)->limit) ! 274: ! 275: /* Make sure PFILE->token_buffer has space for at least N more characters. */ ! 276: #define CPP_RESERVE(PFILE, N) \ ! 277: (CPP_WRITTEN (PFILE) + N > (PFILE)->token_buffer_size \ ! 278: && (cpp_grow_buffer (PFILE, N), 0)) ! 279: ! 280: /* Append string STR (of length N) to PFILE's output buffer. ! 281: Assume there is enough space. */ ! 282: #define CPP_PUTS_Q(PFILE, STR, N) \ ! 283: (bcopy (STR, (PFILE)->limit, (N)), (PFILE)->limit += (N)) ! 284: /* Append string STR (of length N) to PFILE's output buffer. Make space. */ ! 285: #define CPP_PUTS(PFILE, STR, N) CPP_RESERVE(PFILE, N), CPP_PUTS_Q(PFILE, STR,N) ! 286: /* Append character CH to PFILE's output buffer. Assume sufficient space. */ ! 287: #define CPP_PUTC_Q(PFILE, CH) (*(PFILE)->limit++ = (CH)) ! 288: /* Append character CH to PFILE's output buffer. Make space if need be. */ ! 289: #define CPP_PUTC(PFILE, CH) (CPP_RESERVE (PFILE, 1), CPP_PUTC_Q (PFILE, CH)) ! 290: /* Make sure PFILE->limit is followed by '\0'. */ ! 291: #define CPP_NUL_TERMINATE_Q(PFILE) (*(PFILE)->limit = 0) ! 292: #define CPP_NUL_TERMINATE(PFILE) (CPP_RESERVE(PFILE, 1), *(PFILE)->limit = 0) ! 293: #define CPP_ADJUST_WRITTEN(PFILE,DELTA) ((PFILE)->limit += (DELTA)) ! 294: #define CPP_SET_WRITTEN(PFILE,N) ((PFILE)->limit = (PFILE)->token_buffer + (N)) ! 295: ! 296: #define CPP_OPTIONS(PFILE) ((cpp_options*)(PFILE)->data) ! 297: #define CPP_BUFFER(PFILE) ((PFILE)->buffer) ! 298: #ifdef STATIC_BUFFERS ! 299: #define CPP_PREV_BUFFER(BUFFER) ((BUFFER)+1) ! 300: #define CPP_NULL_BUFFER(PFILE) (&(PFILE)->buffer_stack[CPP_STACK_MAX]) ! 301: #else ! 302: #define CPP_PREV_BUFFER(BUFFER) ((BUFFER)->chain) ! 303: #define CPP_NULL_BUFFER(PFILE) ((cpp_buffer*)0) ! 304: #endif ! 305: ! 306: /* Pointed to by parse_file::data. */ ! 307: struct cpp_options { ! 308: char *in_fname; ! 309: ! 310: /* Name of output file, for error messages. */ ! 311: char *out_fname; ! 312: ! 313: struct file_name_map_list *map_list; ! 314: ! 315: /* Non-0 means -v, so print the full set of include dirs. */ ! 316: char verbose; ! 317: ! 318: /* Nonzero means use extra default include directories for C++. */ ! 319: ! 320: char cplusplus; ! 321: ! 322: /* Nonzero means handle cplusplus style comments */ ! 323: ! 324: char cplusplus_comments; ! 325: ! 326: /* Nonzero means handle #import, for objective C. */ ! 327: ! 328: char objc; ! 329: ! 330: /* Nonzero means this is an assembly file, and allow ! 331: unknown directives, which could be comments. */ ! 332: ! 333: int lang_asm; ! 334: ! 335: /* Nonzero means turn NOTREACHED into #pragma NOTREACHED etc */ ! 336: ! 337: char for_lint; ! 338: ! 339: /* Nonzero means handle CHILL comment syntax ! 340: and output CHILL string delimiter for __DATE___ etc. */ ! 341: ! 342: char chill; ! 343: ! 344: /* Nonzero means copy comments into the output file. */ ! 345: ! 346: char put_out_comments; ! 347: ! 348: /* Nonzero means don't process the ANSI trigraph sequences. */ ! 349: ! 350: char no_trigraphs; ! 351: ! 352: /* Nonzero means print the names of included files rather than ! 353: the preprocessed output. 1 means just the #include "...", ! 354: 2 means #include <...> as well. */ ! 355: ! 356: char print_deps; ! 357: ! 358: /* Nonzero if missing .h files in -M output are assumed to be generated ! 359: files and not errors. */ ! 360: ! 361: char print_deps_missing_files; ! 362: ! 363: /* If true, fopen (deps_file, "a") else fopen (deps_file, "w"). */ ! 364: char print_deps_append; ! 365: ! 366: /* Nonzero means print names of header files (-H). */ ! 367: ! 368: char print_include_names; ! 369: ! 370: /* Nonzero means try to make failure to fit ANSI C an error. */ ! 371: ! 372: char pedantic_errors; ! 373: ! 374: /* Nonzero means don't print warning messages. -w. */ ! 375: ! 376: char inhibit_warnings; ! 377: ! 378: /* Nonzero means warn if slash-star appears in a comment. */ ! 379: ! 380: char warn_comments; ! 381: ! 382: /* Nonzero means warn if there are any trigraphs. */ ! 383: ! 384: char warn_trigraphs; ! 385: ! 386: /* Nonzero means warn if #import is used. */ ! 387: ! 388: char warn_import; ! 389: ! 390: /* Nonzero means warn if a macro argument is (or would be) ! 391: stringified with -traditional. */ ! 392: ! 393: char warn_stringify; ! 394: ! 395: /* Nonzero means turn warnings into errors. */ ! 396: ! 397: char warnings_are_errors; ! 398: ! 399: /* Nonzero causes output not to be done, ! 400: but directives such as #define that have side effects ! 401: are still obeyed. */ ! 402: ! 403: char no_output; ! 404: ! 405: /* Nonzero means don't output line number information. */ ! 406: ! 407: char no_line_commands; ! 408: ! 409: /* Nonzero means output the text in failing conditionals, ! 410: inside #failed ... #endfailed. */ ! 411: ! 412: char output_conditionals; ! 413: ! 414: /* Nonzero means -I- has been seen, ! 415: so don't look for #include "foo" the source-file directory. */ ! 416: char ignore_srcdir; ! 417: ! 418: /* Zero means dollar signs are punctuation. ! 419: -$ stores 0; -traditional may store 1. Default is 1 for VMS, 0 otherwise. ! 420: This must be 0 for correct processing of this ANSI C program: ! 421: #define foo(a) #a ! 422: #define lose(b) foo (b) ! 423: #define test$ ! 424: lose (test) */ ! 425: char dollars_in_ident; ! 426: #ifndef DOLLARS_IN_IDENTIFIERS ! 427: #define DOLLARS_IN_IDENTIFIERS 1 ! 428: #endif ! 429: ! 430: /* Nonzero means try to imitate old fashioned non-ANSI preprocessor. */ ! 431: char traditional; ! 432: ! 433: /* Nonzero means give all the error messages the ANSI standard requires. */ ! 434: char pedantic; ! 435: ! 436: char done_initializing; ! 437: ! 438: struct file_name_list *include; /* First dir to search */ ! 439: /* First dir to search for <file> */ ! 440: /* This is the first element to use for #include <...>. ! 441: If it is 0, use the entire chain for such includes. */ ! 442: struct file_name_list *first_bracket_include; ! 443: /* This is the first element in the chain that corresponds to ! 444: a directory of system header files. */ ! 445: struct file_name_list *first_system_include; ! 446: struct file_name_list *last_include; /* Last in chain */ ! 447: ! 448: /* Chain of include directories to put at the end of the other chain. */ ! 449: struct file_name_list *after_include; ! 450: struct file_name_list *last_after_include; /* Last in chain */ ! 451: ! 452: /* Chain to put at the start of the system include files. */ ! 453: struct file_name_list *before_system; ! 454: struct file_name_list *last_before_system; /* Last in chain */ ! 455: ! 456: /* Directory prefix that should replace `/usr' in the standard ! 457: include file directories. */ ! 458: char *include_prefix; ! 459: ! 460: char inhibit_predefs; ! 461: char no_standard_includes; ! 462: char no_standard_cplusplus_includes; ! 463: ! 464: /* dump_only means inhibit output of the preprocessed text ! 465: and instead output the definitions of all user-defined ! 466: macros in a form suitable for use as input to cccp. ! 467: dump_names means pass #define and the macro name through to output. ! 468: dump_definitions means pass the whole definition (plus #define) through ! 469: */ ! 470: ! 471: enum {dump_none = 0, dump_only, dump_names, dump_definitions} ! 472: dump_macros; ! 473: ! 474: /* Nonzero means pass all #define and #undef directives which we actually ! 475: process through to the output stream. This feature is used primarily ! 476: to allow cc1 to record the #defines and #undefs for the sake of ! 477: debuggers which understand about preprocessor macros, but it may ! 478: also be useful with -E to figure out how symbols are defined, and ! 479: where they are defined. */ ! 480: int debug_output; ! 481: ! 482: /* Pending -D, -U and -A options, in reverse order. */ ! 483: struct cpp_pending *pending; ! 484: ! 485: /* File name which deps are being written to. ! 486: This is 0 if deps are being written to stdout. */ ! 487: char *deps_file; ! 488: ! 489: /* Target-name to write with the dependency information. */ ! 490: char *deps_target; ! 491: }; ! 492: ! 493: #define CPP_TRADITIONAL(PFILE) (CPP_OPTIONS(PFILE)-> traditional) ! 494: #define CPP_PEDANTIC(PFILE) (CPP_OPTIONS (PFILE)->pedantic) ! 495: #define CPP_PRINT_DEPS(PFILE) (CPP_OPTIONS (PFILE)->print_deps) ! 496: ! 497: /* Name under which this program was invoked. */ ! 498: ! 499: extern char *progname; ! 500: ! 501: /* The structure of a node in the hash table. The hash table ! 502: has entries for all tokens defined by #define commands (type T_MACRO), ! 503: plus some special tokens like __LINE__ (these each have their own ! 504: type, and the appropriate code is run when that type of node is seen. ! 505: It does not contain control words like "#define", which are recognized ! 506: by a separate piece of code. */ ! 507: ! 508: /* different flavors of hash nodes --- also used in keyword table */ ! 509: enum node_type { ! 510: T_DEFINE = 1, /* the `#define' keyword */ ! 511: T_INCLUDE, /* the `#include' keyword */ ! 512: T_INCLUDE_NEXT, /* the `#include_next' keyword */ ! 513: T_IMPORT, /* the `#import' keyword */ ! 514: T_IFDEF, /* the `#ifdef' keyword */ ! 515: T_IFNDEF, /* the `#ifndef' keyword */ ! 516: T_IF, /* the `#if' keyword */ ! 517: T_ELSE, /* `#else' */ ! 518: T_PRAGMA, /* `#pragma' */ ! 519: T_ELIF, /* `#elif' */ ! 520: T_UNDEF, /* `#undef' */ ! 521: T_LINE, /* `#line' */ ! 522: T_ERROR, /* `#error' */ ! 523: T_WARNING, /* `#warning' */ ! 524: T_ENDIF, /* `#endif' */ ! 525: T_SCCS, /* `#sccs', used on system V. */ ! 526: T_IDENT, /* `#ident', used on system V. */ ! 527: T_ASSERT, /* `#assert', taken from system V. */ ! 528: T_UNASSERT, /* `#unassert', taken from system V. */ ! 529: T_SPECLINE, /* special symbol `__LINE__' */ ! 530: T_DATE, /* `__DATE__' */ ! 531: T_FILE, /* `__FILE__' */ ! 532: T_BASE_FILE, /* `__BASE_FILE__' */ ! 533: T_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */ ! 534: T_VERSION, /* `__VERSION__' */ ! 535: T_SIZE_TYPE, /* `__SIZE_TYPE__' */ ! 536: T_PTRDIFF_TYPE, /* `__PTRDIFF_TYPE__' */ ! 537: T_WCHAR_TYPE, /* `__WCHAR_TYPE__' */ ! 538: T_USER_LABEL_PREFIX_TYPE, /* `__USER_LABEL_PREFIX__' */ ! 539: T_REGISTER_PREFIX_TYPE, /* `__REGISTER_PREFIX__' */ ! 540: T_TIME, /* `__TIME__' */ ! 541: T_CONST, /* Constant value, used by `__STDC__' */ ! 542: T_MACRO, /* macro defined by `#define' */ ! 543: T_DISABLED, /* macro temporarily turned off for rescan */ ! 544: T_SPEC_DEFINED, /* special `defined' macro for use in #if statements */ ! 545: T_PCSTRING, /* precompiled string (hashval is KEYDEF *) */ ! 546: T_UNUSED /* Used for something not defined. */ ! 547: }; ! 548: ! 549: /* Structure returned by create_definition */ ! 550: typedef struct macrodef MACRODEF; ! 551: struct macrodef ! 552: { ! 553: struct definition *defn; ! 554: U_CHAR *symnam; ! 555: int symlen; ! 556: }; ! 557: ! 558: /* Structure allocated for every #define. For a simple replacement ! 559: such as ! 560: #define foo bar , ! 561: nargs = -1, the `pattern' list is null, and the expansion is just ! 562: the replacement text. Nargs = 0 means a functionlike macro with no args, ! 563: e.g., ! 564: #define getchar() getc (stdin) . ! 565: When there are args, the expansion is the replacement text with the ! 566: args squashed out, and the reflist is a list describing how to ! 567: build the output from the input: e.g., "3 chars, then the 1st arg, ! 568: then 9 chars, then the 3rd arg, then 0 chars, then the 2nd arg". ! 569: The chars here come from the expansion. Whatever is left of the ! 570: expansion after the last arg-occurrence is copied after that arg. ! 571: Note that the reflist can be arbitrarily long--- ! 572: its length depends on the number of times the arguments appear in ! 573: the replacement text, not how many args there are. Example: ! 574: #define f(x) x+x+x+x+x+x+x would have replacement text "++++++" and ! 575: pattern list ! 576: { (0, 1), (1, 1), (1, 1), ..., (1, 1), NULL } ! 577: where (x, y) means (nchars, argno). */ ! 578: ! 579: typedef struct definition DEFINITION; ! 580: struct definition { ! 581: int nargs; ! 582: int length; /* length of expansion string */ ! 583: int predefined; /* True if the macro was builtin or */ ! 584: /* came from the command line */ ! 585: U_CHAR *expansion; ! 586: int line; /* Line number of definition */ ! 587: char *file; /* File of definition */ ! 588: char rest_args; /* Nonzero if last arg. absorbs the rest */ ! 589: struct reflist { ! 590: struct reflist *next; ! 591: char stringify; /* nonzero if this arg was preceded by a ! 592: # operator. */ ! 593: char raw_before; /* Nonzero if a ## operator before arg. */ ! 594: char raw_after; /* Nonzero if a ## operator after arg. */ ! 595: char rest_args; /* Nonzero if this arg. absorbs the rest */ ! 596: int nchars; /* Number of literal chars to copy before ! 597: this arg occurrence. */ ! 598: int argno; /* Number of arg to substitute (origin-0) */ ! 599: } *pattern; ! 600: union { ! 601: /* Names of macro args, concatenated in reverse order ! 602: with comma-space between them. ! 603: The only use of this is that we warn on redefinition ! 604: if this differs between the old and new definitions. */ ! 605: U_CHAR *argnames; ! 606: } args; ! 607: }; ! 608: ! 609: extern U_CHAR is_idchar[256]; ! 610: ! 611: /* Stack of conditionals currently in progress ! 612: (including both successful and failing conditionals). */ ! 613: ! 614: struct if_stack { ! 615: struct if_stack *next; /* for chaining to the next stack frame */ ! 616: char *fname; /* copied from input when frame is made */ ! 617: int lineno; /* similarly */ ! 618: int if_succeeded; /* true if a leg of this if-group ! 619: has been passed through rescan */ ! 620: U_CHAR *control_macro; /* For #ifndef at start of file, ! 621: this is the macro name tested. */ ! 622: enum node_type type; /* type of last directive seen in this group */ ! 623: }; ! 624: typedef struct if_stack IF_STACK_FRAME; ! 625: ! 626: extern void cpp_buf_line_and_col PARAMS((cpp_buffer*, long*, long*)); ! 627: extern cpp_buffer* cpp_file_buffer PARAMS((cpp_reader*)); ! 628: extern void cpp_define PARAMS ((cpp_reader*, U_CHAR*)); ! 629: ! 630: extern void cpp_error (); ! 631: extern void cpp_warning (); ! 632: extern void cpp_pedwarn (); ! 633: extern void cpp_error_with_line (); ! 634: extern void cpp_pedwarn_with_line (); ! 635: extern void cpp_pedwarn_with_file_and_line (); ! 636: extern void fatal (); ! 637: extern void cpp_error_from_errno (); ! 638: extern void cpp_perror_with_name (); ! 639: extern void cpp_pfatal_with_name (); ! 640: ! 641: extern void cpp_grow_buffer PARAMS ((cpp_reader*, long)); ! 642: extern int cpp_parse_escape PARAMS ((cpp_reader*, char**)); ! 643: extern cpp_buffer* cpp_push_buffer PARAMS ((cpp_reader *, U_CHAR*, long)); ! 644: extern cpp_buffer* cpp_pop_buffer PARAMS ((cpp_reader *)); ! 645: ! 646: extern cpp_hashnode* cpp_lookup PARAMS ((cpp_reader*, const U_CHAR*, ! 647: int, int)); ! 648: ! 649: #ifdef __cplusplus ! 650: } ! 651: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.