Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.6
 
1.7
 
MAIN:ragge:20040822145925
 
cpp.c
_>9696 #ifdef CPP_DEBUG
 9797 int dflag;      /* debug printouts */
 9898 #endif
<> 99+char *sysinc = "/usr/include"; /* default header files */
99100 FILE *obuf;
 100101 static int exfail;
 101102 static struct symtab {
     
 !
152153 static int subst(char *, struct symtab *, struct recur *);
 153154 static void savch(int c);
 154155 static void insym(struct symtab **sp, char *namep);
<>155 -static void expand(char *, char *);
156156 static struct symtab *lookup(char *namep, int enterf);
 157157 static void control(void);
 158158 static usch *savstr(usch *str);
     
 !
165165 int
 166166 main(int argc, char **argv)
 167167 {
<>168 -        char *infil = NULL, *utfil = NULL;
 169 -        int ch;
  168+        struct symtab *nl, *thisnl;
  169+        register int c, gotspc, ch;
  170+        usch *osp;
170171 
<>171 -        while ((ch = getopt(argc, argv, "I:U:td")) != -1)
  172+        while ((ch = getopt(argc, argv, "D:I:S:U:td")) != -1)
172173                 switch (ch) {
<> 174+                case 'D': /* Define something */
  175+                        osp = optarg;
  176+                        while (*osp && *osp != '=')
  177+                                osp++;
  178+                        if (*osp == '=') {
  179+                                *osp = 0;
  180+                        } else {
  181+                                static char c[3] = { 0, '1', 0 };
  182+                                osp = c;
  183+                        }
  184+                        osp++;
  185+                        while (*osp)
  186+                                osp++;
  187+                        *osp = OBJCT;
  188+                        nl = lookup(optarg, ENTER);
  189+                        if (nl->value)
  190+                                error("%s redefined", optarg);
  191+                        nl->value = osp;
  192+                        break;
  193+
  194+                case 'S':
  195+                        sysinc = optarg;
  196+                        break;
  197+
  198+                case 'U':
  199+                        nl = lookup(optarg, FIND);
  200+                        if (nl && nl->value)
  201+                                nl->value = NULL;
  202+                        break;
173203 #ifdef CPP_DEBUG
 174204                 case 'd':
 175205                         dflag = 1;
     
 !
186216         argc -= optind;
 187217         argv += optind;
 188218 
<>189 -        if (argc)
 190 -                infil = argv[0];
 191 -        if (argc == 2)
 192 -                utfil = argv[1];
 193 -        expand(infil, utfil);
 194 -        return exfail;
 195 -}
 196 -
 197 -void
 198 -expand(char *infil, char *utfil)
 199 -{
 200 -        struct symtab *nl, *thisnl;
 201 -        register int c, gotspc;
 202 -        usch *osp;
 203 -
204219         exfail = 0;
<>205 -        if (infil != NULL) {
 206 -                if (freopen(infil, "r", stdin) == NULL) {
 207 -                        fprintf(stderr, "Can't open %s", infil);
  220+        if (argc) {
  221+                if (freopen(argv[0], "r", stdin) == NULL) {
  222+                        fprintf(stderr, "Can't open %s", argv[0]);
208223                         exit(8);
 209224                 }
 210225         }
<>211 -        pushfile(infil ? infil : "<stdin>");
  226+        pushfile(argc ? argv[0] : "<stdin>");
212227 
<>213 -        if (utfil != NULL) {
 214 -                if ((obuf = fopen(utfil, "w")) == 0) {
 215 -                        fprintf(stderr, "Can't creat %s\n", utfil);
  228+        if (argc == 2) {
  229+                if ((obuf = fopen(argv[1], "w")) == 0) {
  230+                        fprintf(stderr, "Can't creat %s\n", argv[1]);
216231                         exit(8);
 217232                 }
 218233         } else
     
 !
294309                 }
 295310         }
 296311         fclose(obuf);
<> 312+        return exfail;
297313 }
 298314 
 299315 /*
     
 !
312328 
 313329         np = lookup(yytext, FIND);
 314330         if (np == 0)
<>315 -                return; /* ignore empty controls */
  331+                error("bad control %s", yytext);
316332         if (np == incloc) {
 317333                 if (flslvl)
 318334                         goto exit;
     
 !
409425         int mkstr = 0, narg = -1;
 410426 
 411427         np = lookup(yytext, ENTER);
<> 428+        if (np->value)
  429+                error("%s redefined", np->namep);
412430 
 413431         if ((c = yylex()) == '(') {
 414432                 narg = 0;
     
 !
526544         register struct symtab *np;
 527545 
 528546         *sp = np = lookup(namep, ENTER);
<>529 -        np->value = np->namep; /* XXX */
  547+        np->value = NULL;
530548 }
 531549 
 532550 void
     
 !
586604                                 sp = symtab;
 587605                 }
 588606         }
<>589 -        if (enterf == ENTER)
  607+        if (enterf == ENTER) {
590608                 sp->namep = savstr(namep), savch('\0');
<> 609+        }
<_591610         return(sp->namep ? sp : 0);
 592611 }
 593612 
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-09-23 14:23 +0200