1da2e3ebdSchin /*********************************************************************** 2da2e3ebdSchin * * 3da2e3ebdSchin * This software is part of the ast package * 4*7c2fbfb3SApril Chin * Copyright (c) 1986-2008 AT&T Intellectual Property * 5da2e3ebdSchin * and is licensed under the * 6da2e3ebdSchin * Common Public License, Version 1.0 * 7*7c2fbfb3SApril Chin * by AT&T Intellectual Property * 8da2e3ebdSchin * * 9da2e3ebdSchin * A copy of the License is available at * 10da2e3ebdSchin * http://www.opensource.org/licenses/cpl1.0.txt * 11da2e3ebdSchin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 12da2e3ebdSchin * * 13da2e3ebdSchin * Information and Software Systems Research * 14da2e3ebdSchin * AT&T Research * 15da2e3ebdSchin * Florham Park NJ * 16da2e3ebdSchin * * 17da2e3ebdSchin * Glenn Fowler <gsf@research.att.com> * 18da2e3ebdSchin * * 19da2e3ebdSchin ***********************************************************************/ 20da2e3ebdSchin #pragma prototyped 21da2e3ebdSchin /* 22da2e3ebdSchin * cpp predefined symbol detection support 23da2e3ebdSchin * 24da2e3ebdSchin * with no args stdin is treated as an a.out for 25da2e3ebdSchin * a Reiser derived cpp -- all strings that may 26da2e3ebdSchin * be identifiers are listed on fd 3 (1 if no 3) 27da2e3ebdSchin * 28da2e3ebdSchin * with args the -D argument values are listed on fd 3 (1 if no 3) 29da2e3ebdSchin */ 30da2e3ebdSchin 31da2e3ebdSchin #include <ast.h> 32da2e3ebdSchin #include <ctype.h> 33da2e3ebdSchin 34da2e3ebdSchin int 35da2e3ebdSchin main(int argc, char** argv) 36da2e3ebdSchin { 37da2e3ebdSchin register int state; 38da2e3ebdSchin register int c; 39da2e3ebdSchin register char* s; 40da2e3ebdSchin Sfio_t* out; 41da2e3ebdSchin 42da2e3ebdSchin NoP(argc); 43da2e3ebdSchin if (dup(3) < 0 || !(out = sfnew(NiL, NiL, -1, 3, SF_WRITE))) 44da2e3ebdSchin out = sfstdout; 45da2e3ebdSchin if (*++argv) 46da2e3ebdSchin { 47da2e3ebdSchin while (s = *argv++) 48da2e3ebdSchin if (*s++ == '-' && *s++ == 'D' && isalpha(*s)) 49da2e3ebdSchin { 50da2e3ebdSchin while (*s && *s != '=') sfputc(out, *s++); 51da2e3ebdSchin sfputc(out, '\n'); 52da2e3ebdSchin } 53da2e3ebdSchin return 0; 54da2e3ebdSchin } 55da2e3ebdSchin state = 0; 56da2e3ebdSchin for (;;) 57da2e3ebdSchin { 58da2e3ebdSchin switch (c = sfgetc(sfstdin)) 59da2e3ebdSchin { 60da2e3ebdSchin case EOF: 61da2e3ebdSchin break; 62da2e3ebdSchin case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': 63da2e3ebdSchin case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': 64da2e3ebdSchin case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': 65da2e3ebdSchin case 's': case 't': case 'u': case 'v': case 'w': case 'x': 66da2e3ebdSchin case 'y': case 'z': case '_': 67da2e3ebdSchin case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': 68da2e3ebdSchin case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': 69da2e3ebdSchin case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': 70da2e3ebdSchin case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': 71da2e3ebdSchin case 'Y': case 'Z': 72da2e3ebdSchin state++; 73da2e3ebdSchin sfputc(out, c); 74da2e3ebdSchin continue; 75da2e3ebdSchin case '0': case '1': case '2': case '3': case '4': case '5': 76da2e3ebdSchin case '6': case '7': case '8': case '9': 77da2e3ebdSchin if (state) 78da2e3ebdSchin { 79da2e3ebdSchin sfputc(out, c); 80da2e3ebdSchin continue; 81da2e3ebdSchin } 82da2e3ebdSchin /*FALLTHROUGH*/ 83da2e3ebdSchin default: 84da2e3ebdSchin if (state) 85da2e3ebdSchin { 86da2e3ebdSchin sfputc(out, '\n'); 87da2e3ebdSchin state = 0; 88da2e3ebdSchin } 89da2e3ebdSchin continue; 90da2e3ebdSchin } 91da2e3ebdSchin break; 92da2e3ebdSchin } 93da2e3ebdSchin return 0; 94da2e3ebdSchin } 95