1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1986-2009 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
19 ***********************************************************************/
22 * cpp predefined symbol detection support
24 * with no args stdin is treated as an a.out for
25 * a Reiser derived cpp -- all strings that may
26 * be identifiers are listed on fd 3 (1 if no 3)
28 * with args the -D argument values are listed on fd 3 (1 if no 3)
35 main(int argc
, char** argv
)
43 if (dup(3) < 0 || !(out
= sfnew(NiL
, NiL
, -1, 3, SF_WRITE
)))
48 if (*s
++ == '-' && *s
++ == 'D' && isalpha(*s
))
50 while (*s
&& *s
!= '=') sfputc(out
, *s
++);
58 switch (c
= sfgetc(sfstdin
))
62 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
63 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
64 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
65 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
66 case 'y': case 'z': case '_':
67 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
68 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
69 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
70 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
75 case '0': case '1': case '2': case '3': case '4': case '5':
76 case '6': case '7': case '8': case '9':