dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / libpp / common / ppsym.c
blob1fd5ea91059ad80e17ec52707e3a8c8bee7e9659
1 /***********************************************************************
2 * *
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 *
8 * *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
12 * *
13 * Information and Software Systems Research *
14 * AT&T Research *
15 * Florham Park NJ *
16 * *
17 * Glenn Fowler <gsf@research.att.com> *
18 * *
19 ***********************************************************************/
20 #pragma prototyped
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)
31 #include <ast.h>
32 #include <ctype.h>
34 int
35 main(int argc, char** argv)
37 register int state;
38 register int c;
39 register char* s;
40 Sfio_t* out;
42 NoP(argc);
43 if (dup(3) < 0 || !(out = sfnew(NiL, NiL, -1, 3, SF_WRITE)))
44 out = sfstdout;
45 if (*++argv)
47 while (s = *argv++)
48 if (*s++ == '-' && *s++ == 'D' && isalpha(*s))
50 while (*s && *s != '=') sfputc(out, *s++);
51 sfputc(out, '\n');
53 return 0;
55 state = 0;
56 for (;;)
58 switch (c = sfgetc(sfstdin))
60 case EOF:
61 break;
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':
71 case 'Y': case 'Z':
72 state++;
73 sfputc(out, c);
74 continue;
75 case '0': case '1': case '2': case '3': case '4': case '5':
76 case '6': case '7': case '8': case '9':
77 if (state)
79 sfputc(out, c);
80 continue;
82 /*FALLTHROUGH*/
83 default:
84 if (state)
86 sfputc(out, '\n');
87 state = 0;
89 continue;
91 break;
93 return 0;