1 /* Part of CPP library. (Macro handling.)
2 Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1998,
3 1999, 2000 Free Software Foundation, Inc.
4 Written by Per Bothner, 1994.
5 Based on CCCP program by Paul Rubin, June 1986
6 Adapted to ANSI C, Richard Stallman, Jan 1987
8 This program is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 2, or (at your option) any
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 In other words, you are welcome to use, share and improve this program.
23 You are forbidden to forbid anyone else to use, share and improve
24 what you give them. Help stamp out software-hoarding! */
34 /* Structure allocated for every #define. For a simple replacement
38 we allocate an object_defn structure; the expansion field points
39 to the replacement text. For a function-like macro we allocate a
40 funct_defn structure; nargs is the number of arguments - it can be zero,
42 #define getchar() getc (stdin)
44 When there are args, the expansion is the replacement text with the
45 args squashed out, and the reflist is a list describing how to
46 build the output from the input: e.g., "3 chars, then the 1st arg,
47 then 9 chars, then the 3rd arg, then 0 chars, then the 2nd arg".
48 The chars here come from the expansion. Whatever is left of the
49 expansion after the last arg-occurrence is copied after that arg.
50 Note that the reflist can be arbitrarily long---
51 its length depends on the number of times the arguments appear in
52 the replacement text, not how many args there are. Example:
53 #define f(x) x+x+x+x+x+x+x would have replacement text "++++++" and
55 { (0, 1), (1, 1), (1, 1), ..., (1, 1), NULL }
56 where (x, y) means (nchars, argno).
58 Note that EMPTY and IDENTITY macros have object_defn structures too,
59 but they're just used to hold the file, line, and column. The
60 expansion field will be NULL. */
64 const U_CHAR *expansion;
67 const char *file; /* File, line, column of definition */
74 const struct reflist *next;
75 char stringify; /* nonzero if this arg was preceded by a
77 char raw_before; /* Nonzero if a ## operator before arg. */
78 char raw_after; /* Nonzero if a ## operator after arg. */
79 char rest_args; /* Nonzero if this arg. absorbs the rest */
80 int nchars; /* Number of literal chars to copy before
81 this arg occurrence. */
82 int argno; /* Number of arg to substitute (origin-0) */
88 int length; /* length of expansion string */
89 const U_CHAR *expansion;
90 char rest_args; /* Nonzero if last arg. absorbs the rest */
91 const struct reflist *pattern;
93 /* Names of macro args, concatenated in order with \0 between
94 them. The only use of this is that we warn on redefinition if
95 this differs between the old and new definitions. */
98 const char *file; /* File, line, column of definition */
103 static unsigned int hash_HASHNODE PARAMS ((const void *));
104 static int eq_HASHNODE PARAMS ((const void *, const void *));
105 static void del_HASHNODE PARAMS ((void *));
106 static HASHNODE *make_HASHNODE PARAMS ((const U_CHAR *, size_t,
107 enum node_type, unsigned int));
109 static void dump_funlike_macro PARAMS ((cpp_reader *,
110 const struct funct_defn *));
111 static int dump_hash_helper PARAMS ((void **, void *));
113 static void push_macro_expansion PARAMS ((cpp_reader *, const U_CHAR *,
115 static int unsafe_chars PARAMS ((cpp_reader *, int, int));
116 static enum cpp_ttype macarg PARAMS ((cpp_reader *, int));
117 static void special_symbol PARAMS ((cpp_reader *, HASHNODE *));
118 static int compare_defs PARAMS ((cpp_reader *,
119 const struct funct_defn *,
120 const struct funct_defn *));
122 /* Initial hash table size. (It can grow if necessary - see hashtab.c.) */
125 /* The arglist structure is built by collect_params to tell
126 collect_funlike_expansion where the argument names begin. That is,
127 for a define like "#define f(x,y,z) foo+x-bar*y", the arglist would
128 contain pointers to the strings x, y, and z.
129 collect_funlike_expansion would then build a funct_defn node, with
130 reflist nodes pointing to the places x, y, and z had appeared.
132 The arglist is just convenience data passed between these two
133 routines. It is not kept around after the current #define has been
134 processed and entered into the hash table. */
146 const struct arg *argv;
151 static struct object_defn *
152 collect_objlike_expansion PARAMS ((cpp_reader *, cpp_toklist *));
153 static struct funct_defn *
154 collect_funlike_expansion PARAMS ((cpp_reader *, cpp_toklist *,
155 struct arglist *, unsigned int));
156 static unsigned int collect_params PARAMS ((cpp_reader *, cpp_toklist *,
159 static void warn_trad_stringify PARAMS ((cpp_reader *, U_CHAR *, size_t,
160 unsigned int, const struct arg *));
161 static unsigned int trad_stringify PARAMS ((cpp_reader *, U_CHAR *, size_t,
162 unsigned int, const struct arg *,
164 struct reflist **, unsigned int));
165 static int duplicate_arg_p PARAMS ((U_CHAR *, U_CHAR *));
166 static void add_pat PARAMS ((struct reflist **, struct reflist **,
167 unsigned int, unsigned int, int, int, int, int));
169 /* This structure represents one parsed argument in a macro call.
170 `raw' points to the argument text as written (`raw_length' is its length).
171 `expanded' points to the argument's macro-expansion
172 (its length is `expand_length').
173 `stringified_length' is the length the argument would have
176 /* raw and expanded are relative to ARG_BASE */
177 #define ARG_BASE ((pfile)->token_buffer)
181 /* Strings relative to pfile->token_buffer */
182 long raw, expanded, stringified;
183 int raw_length, expand_length;
184 int stringified_length;
187 static void scan_arguments PARAMS ((cpp_reader *,
188 const struct funct_defn *,
189 struct argdata *, const U_CHAR *));
190 static void stringify PARAMS ((cpp_reader *, struct argdata *));
191 static void funlike_macroexpand PARAMS ((cpp_reader *, HASHNODE *,
194 /* Calculate hash of a string of length LEN. */
196 _cpp_calc_hash (str, len)
204 r = r * 67 + (*str++ - 113);
209 /* Calculate hash of a HASHNODE structure. */
214 const HASHNODE *h = (const HASHNODE *)x;
218 /* Compare two HASHNODE structures. */
224 const HASHNODE *a = (const HASHNODE *)x;
225 const HASHNODE *b = (const HASHNODE *)y;
227 return (a->length == b->length
228 && !ustrncmp (a->name, b->name, a->length));
231 /* Destroy a HASHNODE. */
236 HASHNODE *h = (HASHNODE *)x;
238 _cpp_free_definition (h);
242 /* Allocate and initialize a HASHNODE structure.
243 Caller must fill in the value field. */
246 make_HASHNODE (name, len, type, hash)
252 HASHNODE *hp = (HASHNODE *) xmalloc (sizeof (HASHNODE) + len + 1);
253 U_CHAR *p = (U_CHAR *)hp + sizeof (HASHNODE);
261 memcpy (p, name, len);
267 /* Find the hash node for name "name", of length LEN. */
270 _cpp_lookup (pfile, name, len)
276 HASHNODE *new, **slot;
280 dummy.hash = _cpp_calc_hash (name, len);
283 htab_find_slot_with_hash (pfile->hashtab, (void *)&dummy,
288 new = make_HASHNODE (name, len, T_VOID, dummy.hash);
289 new->value.cpval = NULL;
294 /* Init the hash table. In here so it can see the hash and eq functions. */
296 _cpp_init_macro_hash (pfile)
299 pfile->hashtab = htab_create (HASHSIZE, hash_HASHNODE,
300 eq_HASHNODE, del_HASHNODE);
303 /* Free the definition of macro H. */
306 _cpp_free_definition (h)
309 if (h->type == T_XCONST)
310 free ((PTR) h->value.cpval);
311 else if (h->type == T_MACRO)
313 if (h->value.odefn->expansion)
314 free ((PTR) h->value.odefn->expansion);
315 free ((PTR) h->value.odefn);
317 else if (h->type == T_FMACRO)
319 const struct funct_defn *d = h->value.fdefn;
320 const struct reflist *ap, *nextap;
322 for (ap = d->pattern; ap != NULL; ap = nextap)
328 free ((PTR) d->argnames);
331 h->value.cpval = NULL;
334 /* Create pat nodes. */
337 add_pat (pat, endpat, nchars, argno, raw_before, raw_after, strize, rest)
338 struct reflist **pat, **endpat;
341 int raw_before, raw_after, strize, rest;
343 struct reflist *tpat;
344 tpat = (struct reflist *) xmalloc (sizeof (struct reflist));
346 tpat->raw_before = raw_before;
347 tpat->raw_after = raw_after;
348 tpat->stringify = strize;
349 tpat->rest_args = rest;
351 tpat->nchars = nchars;
356 (*endpat)->next = tpat;
360 /* Issue warnings for macro argument names seen inside strings. */
362 warn_trad_stringify (pfile, p, len, argc, argv)
367 const struct arg *argv;
375 while (p < limit && !is_idstart (*p)) p++;
379 for (i = 0; i < argc; i++)
380 if (!ustrncmp (p, argv[i].name, argv[i].len)
381 && ! is_idchar (p[argv[i].len]))
384 "macro argument \"%s\" would be stringified in traditional C",
389 while (p < limit && is_idchar (*p)) p++;
395 /* Generate pat nodes for macro arguments seen inside strings. */
397 trad_stringify (pfile, base, len, argc, argv, pat, endpat, last)
402 const struct arg *argv;
403 struct reflist **pat, **endpat;
414 while (p < limit && !is_idstart (*p)) p++;
418 for (i = 0; i < argc; i++)
419 if (!ustrncmp (p, argv[i].name, argv[i].len)
420 && ! is_idchar (p[argv[i].len]))
422 if (CPP_WTRADITIONAL (pfile))
423 cpp_warning (pfile, "macro argument \"%s\" is stringified",
425 /* Write out the string up to this point, and add a pat
426 node for the argument. Note that the argument is NOT
428 CPP_PUTS (pfile, base, p - base);
429 add_pat (pat, endpat, CPP_WRITTEN (pfile) - last, i /* argno */,
430 !is_hspace (p[-1]) /* raw_before */,
431 !is_hspace (p[argv[i].len]) /* raw_after */,
434 last = CPP_WRITTEN (pfile);
435 base = p + argv[i].len;
440 while (p < limit && is_idchar (*p)) p++;
444 CPP_PUTS (pfile, base, p - base);
448 /* Read a replacement list for an object-like macro, and build the
449 object_defn structure. LIST contains the replacement list,
451 static struct object_defn *
452 collect_objlike_expansion (pfile, list)
456 struct object_defn *defn;
459 int last_was_paste = 0;
463 /* We copy the expansion text into the token_buffer, then out to
465 start = CPP_WRITTEN (pfile);
466 CPP_PUTS (pfile, "\r ", 2);
468 for (i = 1; i < list->tokens_used; i++)
470 switch (TOK_TYPE (list, i))
473 cpp_ice (pfile, "EOF in collect_expansion");
479 /* ## is not special if it appears right after another ##;
480 nor is it special if -traditional. */
481 if (last_was_paste || CPP_TRADITIONAL (pfile))
484 cpp_error (pfile, "`##' at start of macro definition");
492 if (i > 1 && !last_was_paste && TOK_PREV_WHITE (list, i))
493 CPP_PUTC (pfile, ' ');
495 CPP_PUTS (pfile, TOK_NAME (list, i), TOK_LEN (list, i));
501 cpp_error (pfile, "`##' at end of macro definition");
503 CPP_PUTS (pfile, "\r ", 2);
504 len = CPP_WRITTEN (pfile) - start;
505 CPP_SET_WRITTEN (pfile, start);
508 cpp_ice (pfile, "empty object-like macro went through full #define");
510 exp = (U_CHAR *) xmalloc (len + 1);
511 memcpy (exp, pfile->token_buffer + start, len);
514 defn = (struct object_defn *) xmalloc (sizeof (struct object_defn));
516 defn->expansion = exp;
521 /* Read a replacement list for a function-like macro, and build the
522 funct_defn structure. LIST contains the replacement list,
523 beginning at REPLACEMENT. ARGLIST specifies the formal parameters
524 to look for in the text of the definition. */
526 static struct funct_defn *
527 collect_funlike_expansion (pfile, list, arglist, replacement)
530 struct arglist *arglist;
531 unsigned int replacement;
533 struct funct_defn *defn;
534 struct reflist *pat = 0, *endpat = 0;
535 enum cpp_ttype token;
536 unsigned int start, last;
540 const struct arg *argv;
542 enum { START = 0, NORM, ARG, STRIZE, PASTE } last_token = START;
544 argv = arglist->argv;
545 argc = arglist->argc;
547 /* We copy the expansion text into the token_buffer, then out to
549 last = start = CPP_WRITTEN (pfile);
550 CPP_PUTS (pfile, "\r ", 2);
552 for (i = replacement; i < list->tokens_used; i++)
554 token = TOK_TYPE (list, i);
555 tok = TOK_NAME (list, i);
556 len = TOK_LEN (list, i);
560 cpp_ice (pfile, "EOF in collect_expansion");
566 /* # is special in function-like macros with no args.
567 (6.10.3.2 para 1.) However, it is not special after
568 PASTE. (Implied by 6.10.3.3 para 4.) Nor is it special
570 if (last_token == PASTE || CPP_TRADITIONAL (pfile))
576 /* ## is not special if it appears right after another ##;
577 nor is it special if -traditional. */
578 if (last_token == PASTE || CPP_TRADITIONAL (pfile))
581 if (last_token == START)
582 cpp_error (pfile, "`##' at start of macro definition");
583 else if (last_token == ARG)
584 /* If the last token was an argument, mark it raw_after. */
585 endpat->raw_after = 1;
586 else if (last_token == STRIZE)
587 /* Oops - that wasn't a stringify operator. */
588 CPP_PUTC (pfile, '#');
596 if (last_token != PASTE && last_token != START
597 && TOK_PREV_WHITE (list, i))
598 CPP_PUTC (pfile, ' ');
599 if (last_token == ARG && CPP_TRADITIONAL (pfile)
600 && !TOK_PREV_WHITE (list, i))
601 endpat->raw_after = 1;
609 if (CPP_TRADITIONAL (pfile))
611 last = trad_stringify (pfile, tok, len, argc, argv,
612 &pat, &endpat, last);
617 if (CPP_WTRADITIONAL (pfile))
618 warn_trad_stringify (pfile, tok, len, argc, argv);
623 for (j = 0; j < argc; j++)
624 if (argv[j].len == len
625 && !ustrncmp (tok, argv[j].name, argv[j].len))
631 if (last_token == STRIZE)
632 cpp_error (pfile, "# is not followed by a macro argument name");
633 CPP_PUTS (pfile, tok, len);
640 int raw_before = (last_token == PASTE
641 || (CPP_TRADITIONAL (pfile)
642 && ! TOK_PREV_WHITE (list, j)));
644 add_pat (&pat, &endpat,
645 CPP_WRITTEN (pfile) - last /* nchars */, j /* argno */,
646 raw_before, 0 /* raw_after */,
647 (last_token == STRIZE), argv[j].rest_arg);
649 last = CPP_WRITTEN (pfile);
655 if (last_token == STRIZE)
656 cpp_error (pfile, "`#' is not followed by a macro argument name");
657 else if (last_token == PASTE)
658 cpp_error (pfile, "`##' at end of macro definition");
660 CPP_PUTS (pfile, "\r ", 2);
661 len = CPP_WRITTEN (pfile) - start;
662 CPP_SET_WRITTEN (pfile, start);
664 exp = (U_CHAR *) xmalloc (len + 1);
665 memcpy (exp, pfile->token_buffer + start, len);
668 defn = (struct funct_defn *) xmalloc (sizeof (struct funct_defn));
670 defn->expansion = exp;
672 defn->rest_args = argc && argv[argc - 1].rest_arg;
674 defn->argnames = arglist->namebuf;
680 /* Is argument NEW, which has just been added to the argument list,
681 a duplicate of a previous argument name? */
683 duplicate_arg_p (args, new)
686 size_t newlen = ustrlen (new) + 1;
691 oldlen = ustrlen (args) + 1;
692 if (!memcmp (args, new, MIN (oldlen, newlen)))
700 collect_params (pfile, list, arglist)
703 struct arglist *arglist;
705 struct arg *argv = 0;
706 U_CHAR *namebuf, *p, *tok;
707 unsigned int len, argslen;
708 unsigned int argc, a, i, j;
710 /* The formal parameters list starts at token 1. */
711 if (TOK_TYPE (list, 1) != CPP_OPEN_PAREN)
713 cpp_ice (pfile, "first token = %d not %d in collect_formal_parameters",
714 TOK_TYPE (list, 1), CPP_OPEN_PAREN);
718 /* Scan once and count the number of parameters; also check for
719 syntax errors here. */
722 for (i = 2; i < list->tokens_used; i++)
723 switch (TOK_TYPE (list, i))
726 argslen += TOK_LEN (list, i) + 1;
731 case CPP_CLOSE_PAREN:
734 cpp_error_with_line (pfile, list->line, TOK_COL (list, i),
735 "missing right paren in macro argument list");
739 cpp_error_with_line (pfile, list->line, TOK_COL (list, i),
740 "illegal token in macro argument list");
744 if (TOK_TYPE (list, i-1) != CPP_NAME)
746 argslen += sizeof "__VA_ARGS__";
750 if (TOK_TYPE (list, i) != CPP_CLOSE_PAREN)
752 cpp_error_with_line (pfile, list->line, TOK_COL (list, i),
753 "another parameter follows \"...\"");
759 cpp_ice (pfile, "collect_params: unreachable - i=%d, ntokens=%d, type=%d",
760 i, list->tokens_used, TOK_TYPE (list, i-1));
764 if (argc == 0) /* function-like macro, no arguments */
768 arglist->namebuf = 0;
773 cpp_ice (pfile, "collect_params: argc=%d argslen=0", argc);
777 /* Now allocate space and copy the suckers. */
778 argv = (struct arg *) xmalloc (argc * sizeof (struct arg));
779 namebuf = (U_CHAR *) xmalloc (argslen);
782 for (j = 2; j < i; j++)
783 switch (TOK_TYPE (list, j))
786 tok = TOK_NAME (list, j);
787 len = TOK_LEN (list, j);
788 memcpy (p, tok, len);
790 if (duplicate_arg_p (namebuf, p))
792 cpp_error (pfile, "duplicate macro argument name \"%s\"", tok);
796 if (CPP_PEDANTIC (pfile) && CPP_OPTION (pfile, c99)
797 && len == sizeof "__VA_ARGS__" - 1
798 && !ustrcmp (p, U"__VA_ARGS__"))
800 "C99 does not permit use of __VA_ARGS__ as a macro argument name");
803 argv[a].rest_arg = 0;
812 if (TOK_TYPE (list, j-1) != CPP_NAME)
814 if (CPP_PEDANTIC (pfile) && ! CPP_OPTION (pfile, c99))
815 cpp_pedwarn (pfile, "C89 does not permit varargs macros");
817 argv[a].len = sizeof "__VA_ARGS__" - 1;
819 argv[a].rest_arg = 1;
820 strcpy ((char *)p, "__VA_ARGS__");
824 if (CPP_PEDANTIC (pfile))
826 "ISO C does not permit named varargs macros");
827 argv[a-1].rest_arg = 1;
832 cpp_ice (pfile, "collect_params: impossible token type %d",
836 arglist->argc = argc;
837 arglist->argv = argv;
838 arglist->namebuf = namebuf;
842 /* Create a definition for a macro. The replacement text (including
843 formal parameters if present) is in LIST. If FUNLIKE is true, this
844 is a function-like macro. */
847 _cpp_create_definition (pfile, list, hp)
852 struct funct_defn *fdefn = 0;
853 struct object_defn *odefn = 0;
854 enum node_type ntype;
857 /* Special-case a few simple and common idioms:
858 #define TOKEN // nothing
861 Might also be good to special-case these:
863 #define FUNC() // nothing
864 #define FUNC(a, b, ...) // nothing
865 #define FUNC(a, b, c) FUNC(a, b, c) */
867 if (list->tokens_used == 2)
868 ntype = T_EMPTY; /* Empty definition of object-like macro. */
869 else if (list->tokens_used == 3 && TOK_TYPE (list, 1) == CPP_NAME
870 && TOK_LEN (list, 0) == TOK_LEN (list, 1)
871 && !ustrncmp (TOK_NAME (list, 0), TOK_NAME (list, 1),
873 ntype = T_IDENTITY; /* Object like macro defined to itself. */
875 /* The macro is function-like only if the next character,
876 with no intervening whitespace, is '('. */
877 else if (TOK_TYPE (list, 1) == CPP_OPEN_PAREN
878 && ! TOK_PREV_WHITE (list, 1))
883 replacement = collect_params (pfile, list, &args);
884 if (replacement == 0)
886 fdefn = collect_funlike_expansion (pfile, list, &args, replacement);
893 /* Otherwise it is an object-like macro, and C99 requires
894 whitespace after the name (6.10.3 para 3). */
897 if (! TOK_PREV_WHITE (list, 1))
899 "The C standard requires whitespace after #define %s",
902 odefn = collect_objlike_expansion (pfile, list);
909 if (ntype == T_EMPTY || ntype == T_IDENTITY)
911 odefn = xmalloc (sizeof (struct object_defn));
913 odefn->expansion = 0;
916 /* Check for a redefinition, and its legality. Redefining a macro
917 of whatever stripe is ok if the definitions are the same.
918 Redefining a built-in _constant_ (T_CONST or T_XCONST) is ok only
919 with -D. Otherwise a redefinition is not ok. */
923 case T_VOID: ok = 1; break;
924 default: ok = 0; break;
927 ok = (ntype == hp->type
928 && odefn->length == hp->value.odefn->length
929 && !ustrncmp (odefn->expansion, hp->value.odefn->expansion,
933 ok = (ntype == hp->type
934 && !compare_defs (pfile, fdefn, hp->value.fdefn));
938 ok = (ntype == hp->type);
942 ok = ! pfile->done_initializing;
946 /* Print the warning or error if it's not ok. */
949 cpp_pedwarn (pfile, "\"%s\" redefined", hp->name);
950 if (pfile->done_initializing)
953 unsigned int line, col;
954 if (hp->type == T_FMACRO)
956 file = hp->value.fdefn->file;
957 line = hp->value.fdefn->line;
958 col = hp->value.fdefn->col;
962 file = hp->value.odefn->file;
963 line = hp->value.odefn->line;
964 col = hp->value.odefn->col;
966 cpp_pedwarn_with_file_and_line (pfile, file, line, col,
967 "this is the location of the previous definition");
971 /* And replace the old definition (if any). */
973 _cpp_free_definition (hp);
976 if (ntype == T_FMACRO)
978 fdefn->file = CPP_BUFFER (pfile)->nominal_fname;
979 fdefn->line = list->line;
980 fdefn->col = TOK_COL (list, 0);
981 hp->value.fdefn = fdefn;
985 odefn->file = CPP_BUFFER (pfile)->nominal_fname;
986 odefn->line = list->line;
987 odefn->col = TOK_COL (list, 0);
988 hp->value.odefn = odefn;
994 * Parse a macro argument and append the info on PFILE's token_buffer.
995 * REST_ARGS means to absorb the rest of the args.
996 * Return nonzero to indicate a syntax error.
999 static enum cpp_ttype
1000 macarg (pfile, rest_args)
1005 enum cpp_ttype token;
1007 /* Try to parse as much of the argument as exists at this
1008 input stack level. */
1011 token = cpp_get_token (pfile);
1015 /* We've hit end of file; this is an error.
1016 Caller will report it. */
1018 case CPP_OPEN_PAREN:
1021 case CPP_CLOSE_PAREN:
1026 /* if we've returned to lowest level and
1027 we aren't absorbing all args */
1028 if (paren == 0 && rest_args == 0)
1032 /* Remove ',' or ')' from argument buffer. */
1033 CPP_ADJUST_WRITTEN (pfile, -1);
1041 static const char * const monthnames[] =
1043 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
1044 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
1047 /* Place into PFILE a quoted string representing the string SRC.
1048 Caller must reserve enough space in pfile->token_buffer. */
1051 _cpp_quote_string (pfile, src)
1057 CPP_PUTC_Q (pfile, '\"');
1059 switch ((c = *src++))
1063 CPP_PUTC_Q (pfile, c);
1066 sprintf ((char *)CPP_PWRITTEN (pfile), "\\%03o", c);
1067 CPP_ADJUST_WRITTEN (pfile, 4);
1073 CPP_PUTC_Q (pfile, '\\');
1074 CPP_PUTC_Q (pfile, c);
1078 CPP_PUTC_Q (pfile, '\"');
1084 * expand things like __FILE__. Place the expansion into the output
1085 * buffer *without* rescanning.
1088 #define DSC(str) (const U_CHAR *)str, sizeof str - 1
1090 special_symbol (pfile, hp)
1102 ip = cpp_file_buffer (pfile);
1105 CPP_PUTS (pfile, "\"\"", 2);
1108 if (hp->type == T_BASE_FILE)
1109 while (CPP_PREV_BUFFER (ip) != NULL)
1110 ip = CPP_PREV_BUFFER (ip);
1112 buf = (const U_CHAR *) ip->nominal_fname;
1113 len = ustrlen (buf);
1114 CPP_RESERVE (pfile, 3 + 4 * len);
1115 _cpp_quote_string (pfile, buf);
1118 case T_INCLUDE_LEVEL:
1120 int true_indepth = 0;
1121 ip = cpp_file_buffer (pfile);
1125 ip = CPP_PREV_BUFFER (ip);
1128 CPP_RESERVE (pfile, 10);
1129 sprintf ((char *)CPP_PWRITTEN (pfile), "%d", true_indepth);
1130 len = ustrlen (CPP_PWRITTEN (pfile));
1131 CPP_ADJUST_WRITTEN (pfile, len);
1136 #ifdef STDC_0_IN_SYSTEM_HEADERS
1137 ip = cpp_file_buffer (pfile);
1138 if (ip && ip->system_header_p
1139 && !cpp_defined (pfile, DSC("__STRICT_ANSI__")))
1141 CPP_PUTC (pfile, '0');
1146 buf = hp->value.cpval;
1147 if (!buf || *buf == '\0')
1150 len = ustrlen (buf);
1151 CPP_PUTS (pfile, buf, len);
1155 ip = cpp_file_buffer (pfile);
1158 CPP_PUTC (pfile, '0');
1161 CPP_RESERVE (pfile, 10);
1162 sprintf ((char *)CPP_PWRITTEN (pfile), "%u", CPP_BUF_LINE (ip));
1163 len = ustrlen (CPP_PWRITTEN (pfile));
1164 CPP_ADJUST_WRITTEN (pfile, len);
1169 /* Generate both __DATE__ and __TIME__, stuff them into their
1170 respective hash nodes, and mark the nodes T_XCONST so we
1171 don't have to do this again. We don't generate these strings
1172 at init time because time() and localtime() are very slow on
1175 time_t tt = time (NULL);
1176 struct tm *tb = localtime (&tt);
1179 if (hp->type == T_DATE)
1180 d = hp, t = _cpp_lookup (pfile, DSC("__TIME__"));
1182 t = hp, d = _cpp_lookup (pfile, DSC("__DATE__"));
1184 d->value.cpval = xmalloc (sizeof "'Oct 11 1347'");
1185 sprintf ((char *)d->value.cpval, "\"%s %2d %4d\"",
1186 monthnames[tb->tm_mon], tb->tm_mday, tb->tm_year + 1900);
1189 t->value.cpval = xmalloc (sizeof "'12:34:56'");
1190 sprintf ((char *)t->value.cpval, "\"%02d:%02d:%02d\"",
1191 tb->tm_hour, tb->tm_min, tb->tm_sec);
1197 cpp_error (pfile, "attempt to use poisoned `%s'.", hp->name);
1198 CPP_PUTC (pfile, '0');
1202 cpp_ice (pfile, "invalid special hash type");
1208 /* Expand a macro call.
1209 HP points to the symbol that is the macro being called.
1210 Put the result of expansion onto the input stack
1211 so that subsequent input by our caller will use it.
1213 If macro wants arguments, caller has already verified that
1214 an argument list follows; arguments come from the input stack. */
1217 _cpp_macroexpand (pfile, hp)
1221 const struct funct_defn *defn;
1222 struct argdata *args;
1223 unsigned int old_written;
1226 /* Object like macro - most common case. */
1227 if (hp->type == T_MACRO)
1229 push_macro_expansion (pfile, hp->value.odefn->expansion,
1230 hp->value.odefn->length, hp);
1234 /* Or might it be a constant string? */
1235 if (hp->type == T_CONST || hp->type == T_XCONST)
1237 const U_CHAR *cpval = hp->value.cpval;
1238 if (cpval && *cpval != '\0')
1239 push_macro_expansion (pfile, cpval, ustrlen (cpval), hp);
1243 /* Or a special symbol? */
1244 if (hp->type != T_FMACRO)
1249 old_written = CPP_WRITTEN (pfile);
1250 special_symbol (pfile, hp);
1251 len = CPP_WRITTEN (pfile) - old_written;
1252 CPP_SET_WRITTEN (pfile, old_written);
1256 xbuf = (U_CHAR *) xmalloc (len + 1);
1257 memcpy (xbuf, CPP_PWRITTEN (pfile), len);
1259 push_macro_expansion (pfile, xbuf, len, hp);
1263 /* Okay, it's a full-on function-like macro... */
1264 old_written = CPP_WRITTEN (pfile);
1265 defn = hp->value.fdefn;
1267 args = alloca (MAX (defn->nargs, 1) * sizeof (struct argdata));
1268 for (i = 0; i < MAX (defn->nargs, 1); i++)
1270 args[i].raw = args[i].expanded = 0;
1271 args[i].raw_length = 0;
1272 args[i].expand_length = args[i].stringified_length = -1;
1275 pfile->output_escapes++;
1276 scan_arguments (pfile, defn, args, hp->name);
1278 /* If macro wants zero args, we parsed the arglist for checking only.
1279 Read directly from the macro definition. */
1280 if (defn->nargs == 0 || defn->pattern == 0)
1282 /* If the defn is the empty string, don't bother pushing it. */
1283 if (defn->length > 4)
1284 push_macro_expansion (pfile, defn->expansion, defn->length, hp);
1287 funlike_macroexpand (pfile, hp, args);
1289 CPP_SET_WRITTEN (pfile, old_written);
1290 pfile->output_escapes--;
1294 scan_arguments (pfile, defn, args, name)
1296 const struct funct_defn *defn;
1297 struct argdata *args;
1300 enum cpp_ttype token;
1301 unsigned int start_line, start_column;
1302 unsigned int nargs = defn->nargs;
1305 cpp_buffer *ip = cpp_file_buffer (pfile);
1308 start_line = CPP_BUF_LINE (ip);
1309 start_column = CPP_BUF_COL (ip);
1312 start_line = start_column = 0;
1314 /* Parse all the macro args that are supplied. I counts them. The
1315 first NARGS args are stored in ARGS. The rest are discarded. If
1316 rest_args is set then we assume macarg absorbed the rest of the
1320 /* Skip over the opening parenthesis. */
1321 CPP_OPTION (pfile, discard_comments)++;
1322 pfile->no_macro_expand++;
1323 pfile->no_directives++;
1325 token = cpp_get_non_space_token (pfile);
1326 if (token != CPP_OPEN_PAREN)
1327 cpp_ice (pfile, "macroexpand: unexpected token %d (wanted LPAREN)",
1329 CPP_ADJUST_WRITTEN (pfile, -1);
1334 if (i < MAX (nargs, 1))
1336 args[i].raw = CPP_WRITTEN (pfile);
1337 token = macarg (pfile, (i == nargs - 1 && defn->rest_args));
1338 args[i].raw_length = CPP_WRITTEN (pfile) - args[i].raw;
1341 token = macarg (pfile, 0);
1342 if (token == CPP_EOF)
1343 cpp_error_with_line (pfile, start_line, start_column,
1344 "unterminated macro call");
1347 while (token == CPP_COMMA);
1348 CPP_OPTION (pfile, discard_comments)--;
1349 pfile->no_macro_expand--;
1350 pfile->no_directives--;
1351 if (token != CPP_CLOSE_PAREN)
1354 /* foo ( ) is equivalent to foo () unless foo takes exactly one
1355 argument, in which case the former is allowed and the latter
1356 is not. XXX C99 is silent on this rule, but it seems
1357 inconsistent to me. */
1358 if (i == 1 && nargs == 0)
1360 register U_CHAR *bp = ARG_BASE + args[0].raw;
1361 register U_CHAR *lim = bp + args[0].raw_length;
1362 while (bp != lim && is_space(*bp))
1368 /* Don't output an error message if we have already output one for
1369 a parse error above. */
1370 if (nargs == 0 && i > 0)
1372 cpp_error (pfile, "arguments given to macro `%s'", name);
1376 /* traditional C allows foo() if foo wants one argument. */
1377 if (nargs == 1 && i == 0 && CPP_TRADITIONAL (pfile))
1379 /* the rest args token is allowed to absorb 0 tokens */
1380 else if (i == nargs - 1 && defn->rest_args)
1383 cpp_error (pfile, "macro `%s' used without args", name);
1385 cpp_error (pfile, "macro `%s' used with just one arg", name);
1387 cpp_error (pfile, "macro `%s' used with only %d args", name, i);
1391 cpp_error (pfile, "macro `%s' used with too many (%d) args", name, i);
1396 stringify (pfile, arg)
1398 struct argdata *arg;
1400 int arglen = arg->raw_length;
1405 /* Initially need_space is -1. Otherwise, 1 means the previous
1406 character was a space, but we suppressed it; 0 means the previous
1407 character was a non-space. */
1408 int need_space = -1;
1410 arg->stringified = CPP_WRITTEN (pfile);
1411 CPP_PUTC (pfile, '\"'); /* insert beginning quote */
1412 for (; i < arglen; i++)
1414 c = (ARG_BASE + arg->raw)[i];
1418 /* Delete "\r " and "\r-" escapes. */
1424 /* Internal sequences of whitespace are replaced by one
1425 space except within a string or char token. */
1426 else if (is_space(c))
1428 if (need_space == 0)
1432 else if (need_space > 0)
1433 CPP_PUTC (pfile, ' ');
1448 else if (c == '\"' || c == '\'')
1452 /* Escape these chars */
1453 if (c == '\"' || (in_string && c == '\\'))
1454 CPP_PUTC (pfile, '\\');
1456 CPP_PUTC (pfile, c);
1459 CPP_RESERVE (pfile, 4);
1460 sprintf ((char *) CPP_PWRITTEN (pfile), "\\%03o", (unsigned int) c);
1461 CPP_ADJUST_WRITTEN (pfile, 4);
1464 CPP_PUTC (pfile, '\"'); /* insert ending quote */
1465 arg->stringified_length = CPP_WRITTEN (pfile) - arg->stringified;
1469 funlike_macroexpand (pfile, hp, args)
1472 struct argdata *args;
1474 const struct funct_defn *defn = hp->value.fdefn;
1475 register U_CHAR *xbuf;
1477 const U_CHAR *exp = defn->expansion;
1478 int offset; /* offset in expansion, copied a piece at a time */
1479 int totlen; /* total amount of exp buffer filled so far */
1480 const struct reflist *ap, *last_ap;
1483 /* Compute length in characters of the macro's expansion.
1484 Also count number of times each arg is used. */
1485 xbuf_len = defn->length;
1486 for (ap = defn->pattern; ap != NULL; ap = ap->next)
1490 /* Stringify if it hasn't already been */
1491 if (args[ap->argno].stringified_length < 0)
1492 stringify (pfile, &args[ap->argno]);
1493 xbuf_len += args[ap->argno].stringified_length;
1495 else if (ap->raw_before || ap->raw_after)
1496 /* Add 4 for two \r-space markers to prevent
1497 token concatenation. */
1498 xbuf_len += args[ap->argno].raw_length + 4;
1501 /* We have an ordinary (expanded) occurrence of the arg.
1502 So compute its expansion, if we have not already. */
1503 if (args[ap->argno].expand_length < 0)
1505 args[ap->argno].expanded = CPP_WRITTEN (pfile);
1506 _cpp_expand_to_buffer (pfile, ARG_BASE + args[ap->argno].raw,
1507 args[ap->argno].raw_length);
1509 args[ap->argno].expand_length
1510 = CPP_WRITTEN (pfile) - args[ap->argno].expanded;
1513 /* Add 4 for two \r-space markers to prevent
1514 token concatenation. */
1515 xbuf_len += args[ap->argno].expand_length + 4;
1519 xbuf = (U_CHAR *) xmalloc (xbuf_len + 1);
1521 /* Generate in XBUF the complete expansion with arguments
1522 substituted in. TOTLEN is the total size generated so far.
1523 OFFSET is the index in the definition of where we are copying
1525 offset = totlen = 0;
1526 for (last_ap = NULL, ap = defn->pattern; ap != NULL;
1527 last_ap = ap, ap = ap->next)
1529 register struct argdata *arg = &args[ap->argno];
1530 int count_before = totlen;
1532 /* Add chars to XBUF. */
1534 memcpy (&xbuf[totlen], &exp[offset], i);
1538 /* If followed by an empty rest arg with concatenation,
1539 delete the last run of nonwhite chars. */
1540 if (arg->raw_length == 0 && totlen > count_before
1541 && ((ap->rest_args && ap->raw_before)
1542 || (last_ap != NULL && last_ap->rest_args
1543 && last_ap->raw_after)))
1545 /* Delete final whitespace. */
1546 while (totlen > count_before && is_space(xbuf[totlen - 1]))
1549 /* Delete the nonwhites before them. */
1550 while (totlen > count_before && !is_space(xbuf[totlen - 1]))
1554 if (ap->stringify != 0)
1556 memcpy (xbuf + totlen, ARG_BASE + arg->stringified,
1557 arg->stringified_length);
1558 totlen += arg->stringified_length;
1560 else if (ap->raw_before || ap->raw_after)
1562 U_CHAR *p1 = ARG_BASE + arg->raw;
1563 U_CHAR *l1 = p1 + arg->raw_length;
1566 /* Arg is concatenated before: delete leading whitespace,
1567 whitespace markers, and no-reexpansion markers. */
1570 if (is_space(p1[0]))
1572 else if (p1[0] == '\r')
1580 /* Arg is concatenated after: delete trailing whitespace,
1581 whitespace markers, and no-reexpansion markers. */
1584 if (is_space(l1[-1]))
1586 else if (l1[-1] == '\r')
1588 else if (l1[-1] == '-')
1590 if (l1 != p1 + 1 && l1[-2] == '\r')
1600 /* Delete any no-reexpansion marker that precedes
1601 an identifier at the beginning of the argument. */
1602 if (p1[0] == '\r' && p1[1] == '-')
1605 memcpy (xbuf + totlen, p1, l1 - p1);
1610 U_CHAR *expanded = ARG_BASE + arg->expanded;
1611 if (!ap->raw_before && totlen > 0 && arg->expand_length
1612 && unsafe_chars (pfile, xbuf[totlen - 1], expanded[0]))
1614 xbuf[totlen++] = '\r';
1615 xbuf[totlen++] = ' ';
1618 memcpy (xbuf + totlen, expanded, arg->expand_length);
1619 totlen += arg->expand_length;
1621 if (!ap->raw_after && totlen > 0 && offset < defn->length
1622 && unsafe_chars (pfile, xbuf[totlen - 1], exp[offset]))
1624 xbuf[totlen++] = '\r';
1625 xbuf[totlen++] = ' ';
1630 /* if there is anything left of the definition
1631 after handling the arg list, copy that in too. */
1633 for (i = offset; i < defn->length; i++)
1634 xbuf[totlen++] = exp[i];
1637 if (totlen > xbuf_len)
1638 /* Just die - we've trashed the heap at this point. */
1641 /* Now put the expansion on the input stack
1642 so our caller will commence reading from it. */
1643 push_macro_expansion (pfile, xbuf, totlen, hp);
1645 /* Overload buffer->mapped to indicate that xbuf needs to be freed. */
1646 CPP_BUFFER (pfile)->mapped = 1;
1649 /* Return 1 iff a token ending in C1 followed directly by a token C2
1650 could cause mis-tokenization. */
1653 unsafe_chars (pfile, c1, c2)
1657 /* If c2 is EOF, that's always safe. */
1664 /* We don't know what the previous character was. We do know
1665 that it can't have been an idchar (or else it would have been
1666 pasted with the idchars of the macro name), and there are a
1667 number of second characters for which it doesn't matter what
1669 if (is_idchar (c2) || c2 == '\'' || c2 == '\"'
1670 || c2 == '(' || c2 == '[' || c2 == '{'
1671 || c2 == ')' || c2 == ']' || c2 == '}')
1676 if (c2 == c1 || c2 == '=')
1680 case 'e': case 'E': case 'p': case 'P':
1681 if (c2 == '-' || c2 == '+')
1682 return 1; /* could extend a pre-processing number */
1686 if (CPP_OPTION (pfile, dollars_in_ident))
1691 if (c2 == '\'' || c2 == '\"')
1692 return 1; /* Could turn into L"xxx" or L'xxx'. */
1695 case '.': case '0': case '1': case '2': case '3':
1696 case '4': case '5': case '6': case '7': case '8': case '9':
1697 case '_': case 'a': case 'b': case 'c': case 'd': case 'f':
1698 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
1699 case 'm': case 'n': case 'o': case 'q': case 'r': case 's':
1700 case 't': case 'u': case 'v': case 'w': case 'x': case 'y':
1701 case 'z': case 'A': case 'B': case 'C': case 'D': case 'F':
1702 case 'G': case 'H': case 'I': case 'J': case 'K': case 'M':
1703 case 'N': case 'O': case 'Q': case 'R': case 'S': case 'T':
1704 case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
1706 /* We're in the middle of either a name or a pre-processing number. */
1707 return (is_idchar(c2) || c2 == '.');
1709 case '<': case '>': case '!': case '%': case '#': case ':':
1710 case '^': case '&': case '|': case '*': case '/': case '=':
1711 return (c2 == c1 || c2 == '=');
1717 push_macro_expansion (pfile, xbuf, len, hp)
1724 int advance_cur = 0;
1726 /* The first chars of the expansion should be a "\r " added by
1727 collect_expansion. This is to prevent accidental token-pasting
1728 between the text preceding the macro invocation, and the macro
1731 We would like to avoid adding unneeded spaces (for the sake of
1732 tools that use cpp, such as imake). In some common cases we can
1733 tell that it is safe to omit the space. */
1735 if (xbuf[0] == '\r' && xbuf[1] == ' '
1736 && !unsafe_chars (pfile, EOF, xbuf[2]))
1739 /* Likewise, avoid the extra space at the end of the macro expansion
1740 if this is safe. We can do a better job here since we can know
1741 what the next char will be. */
1742 if (len >= 3 && xbuf[len-2] == '\r' && xbuf[len-1] == ' '
1743 && !unsafe_chars (pfile, xbuf[len-3], CPP_BUF_PEEK (CPP_BUFFER (pfile))))
1746 /* If the total expansion is "\r \r ", we must not trim both escapes. */
1747 if (len == 2 && advance_cur)
1750 mbuf = cpp_push_buffer (pfile, xbuf, len);
1756 mbuf->has_escapes = 1;
1758 /* In C89, a macro cannot be expanded recursively. Traditional C
1759 permits it, but any use in an object-like macro must lead to
1760 infinite recursion, so always follow C89 in object-like macros.
1761 Likewise, in a function-like macro it must cause infinite
1762 recursion unless we are actually doing something with the
1765 Even that criterion is too weak. The only example known where
1766 macro recursion isn't infinite is:
1767 #define bar(x,y) foo(x(y, 0))
1769 which expands to foo(bar(baz, 0)) in C89 and
1770 foo(foo(baz(0, 0)) in K+R. This looks pathological to me.
1771 If someone has a real-world example I would love to see it. */
1772 if (hp->type != T_FMACRO
1773 || hp->value.fdefn->nargs == 0
1774 || hp->value.fdefn->pattern == 0
1775 || !CPP_TRADITIONAL (pfile))
1779 /* Return zero if two funct_defns are isomorphic. */
1782 compare_defs (pfile, d1, d2)
1784 const struct funct_defn *d1, *d2;
1786 const struct reflist *a1, *a2;
1788 if (d1->nargs != d2->nargs)
1790 if (ustrcmp (d1->expansion, d2->expansion))
1792 if (CPP_PEDANTIC (pfile)
1793 && d1->argnames && d2->argnames)
1795 U_CHAR *arg1 = d1->argnames;
1796 U_CHAR *arg2 = d2->argnames;
1801 len = ustrlen (arg1) + 1;
1802 if (ustrcmp (arg1, arg2))
1808 for (a1 = d1->pattern, a2 = d2->pattern; a1 && a2;
1809 a1 = a1->next, a2 = a2->next)
1811 if (a1->nchars != a2->nchars
1812 || a1->argno != a2->argno
1813 || a1->stringify != a2->stringify
1814 || a1->raw_before != a2->raw_before
1815 || a1->raw_after != a2->raw_after)
1824 /* Dump the definition of macro MACRO on stdout. The format is suitable
1825 to be read back in again. */
1828 _cpp_dump_definition (pfile, hp)
1832 CPP_RESERVE (pfile, hp->length + sizeof "#define ");
1833 CPP_PUTS_Q (pfile, "#define ", sizeof "#define " - 1);
1834 CPP_PUTS_Q (pfile, hp->name, hp->length);
1836 if (hp->type == T_EMPTY)
1838 else if (hp->type == T_FMACRO)
1839 dump_funlike_macro (pfile, hp->value.fdefn);
1842 CPP_PUTC_Q (pfile, ' ');
1844 if (hp->type == T_IDENTITY)
1845 CPP_PUTS (pfile, hp->name, hp->length);
1846 else if (hp->type == T_MACRO)
1848 /* The first and last two characters of a macro expansion are
1849 always "\r "; this needs to be trimmed out.
1850 So we need length-4 chars of space, plus one for the NUL. */
1851 CPP_RESERVE (pfile, hp->value.odefn->length - 4 + 1);
1852 CPP_PUTS_Q (pfile, hp->value.odefn->expansion + 2,
1853 hp->value.odefn->length - 4);
1856 cpp_ice (pfile, "invalid hash type %d in dump_definition", hp->type);
1858 if (CPP_BUFFER (pfile) == 0 || ! pfile->done_initializing)
1859 CPP_PUTC (pfile, '\n');
1863 dump_funlike_macro (pfile, defn)
1865 const struct funct_defn *defn;
1867 const struct reflist *r;
1868 const U_CHAR **argv = (const U_CHAR **) alloca (defn->nargs *
1869 sizeof(const U_CHAR *));
1870 int *argl = (int *) alloca (defn->nargs * sizeof(int));
1874 /* First extract the argument list. */
1876 for (i = 0; i < defn->nargs; i++)
1879 argl[i] = ustrlen (x);
1883 /* Now print out the argument list. */
1884 CPP_PUTC_Q (pfile, '(');
1885 for (i = 0; i < defn->nargs; i++)
1887 CPP_RESERVE (pfile, argl[i] + 2);
1888 if (!(i == defn->nargs-1 && defn->rest_args
1889 && !ustrcmp (argv[i], U"__VA_ARGS__")))
1890 CPP_PUTS_Q (pfile, argv[i], argl[i]);
1891 if (i < defn->nargs-1)
1892 CPP_PUTS_Q (pfile, ", ", 2);
1894 if (defn->rest_args)
1895 CPP_PUTS (pfile, "...", 3);
1896 CPP_PUTS (pfile, ") ", 2);
1898 /* Now the definition. */
1899 x = defn->expansion;
1900 for (r = defn->pattern; r; r = r->next)
1903 if (*x == '\r') x += 2, i -= 2;
1904 /* i chars for macro text, plus the length of the macro
1905 argument name, plus one for a stringify marker, plus two for
1906 each concatenation marker. */
1908 i + argl[r->argno] + r->stringify
1909 + (r->raw_before + r->raw_after) * 2);
1911 if (i > 0) CPP_PUTS_Q (pfile, x, i);
1913 CPP_PUTS_Q (pfile, "##", 2);
1915 CPP_PUTC_Q (pfile, '#');
1916 CPP_PUTS_Q (pfile, argv[r->argno], argl[r->argno]);
1917 if (r->raw_after && !(r->next && r->next->nchars == 0
1918 && r->next->raw_before))
1919 CPP_PUTS_Q (pfile, "##", 2);
1924 i = defn->length - (x - defn->expansion) - 2;
1925 if (*x == '\r') x += 2, i -= 2;
1926 if (i > 0) CPP_PUTS (pfile, x, i);
1929 /* Dump out the hash table. */
1931 dump_hash_helper (h, p)
1935 HASHNODE *hp = (HASHNODE *)*h;
1936 cpp_reader *pfile = (cpp_reader *)p;
1938 if (hp->type == T_MACRO || hp->type == T_FMACRO
1939 || hp->type == T_IDENTITY || hp->type == T_EMPTY)
1940 _cpp_dump_definition (pfile, hp);
1945 _cpp_dump_macro_hash (pfile)
1948 htab_traverse (pfile->hashtab, dump_hash_helper, pfile);