Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.78
 
1.79
 
MAIN:ragge:20080412171427
 
cpp.c
_>110110 int Cflag, Mflag, dMflag;
 111111 usch *Mfile;
 112112 struct initar *initar;
<> 113+int readmac;
113114 
 114115 /* avoid recursion */
 115116 struct recur {
     
 !
169170 void line(void);
 170171 void flbuf(void);
 171172 void usage(void);
<> 173+static void getcmnt(void);
172174 
 173175 int
 174176 main(int argc, char **argv)
     
 !
320322 
 321323         thisnl = NULL;
 322324         slow = 1;
<> 325+        readmac++;
323326         base = osp = stringbuf;
 324327         goto found;
 325328 
     
 !
382385                         thisnl = NULL;
 383386                         break;
 384387 
<> 388+                case CMNT:
  389+                        getcmnt();
  390+                        break;
  391+
385392                 case STRING:
 386393                 case '\n':
 387394                 case NUMBER:
     
 !
399406                 }
 400407                 if (thisnl == NULL) {
 401408                         slow = 0;
<> 409+                        readmac--;
402410                         savch(0);
 403411                         return base;
 404412                 }
     
 !
554562         return c;
 555563 }
 556564 
<> 565+static void
  566+getcmnt(void)
  567+{
  568+        int c;
  569+
  570+        savstr((usch *)yytext);
  571+        for (;;) {
  572+                c = cinput();
  573+                if (c == '*') {
  574+                        c = cinput();
  575+                        if (c == '/') {
  576+                                savstr((usch *)"*/");
  577+                                return;
  578+                        }
  579+                        cunput(c);
  580+                        c = '*';
  581+                }
  582+                savch(c);
  583+        }
  584+}
  585+
  586+/*
  587+ * Compare two replacement lists, taking in account comments etc.
  588+ */
  589+static int
  590+cmprepl(usch *o, usch *n)
  591+{
  592+        for (; *o; o--, n--) {
  593+                /* comment skip */
  594+                if (*o == '/' && o[-1] == '*') {
  595+                        while (*o != '*' || o[-1] != '/')
  596+                                o--;
  597+                        o -= 2;
  598+                }
  599+                if (*n == '/' && n[-1] == '*') {
  600+                        while (*n != '*' || n[-1] != '/')
  601+                                n--;
  602+                        n -= 2;
  603+                }
  604+                while (*o == ' ' || *o == '\t')
  605+                        o--;
  606+                while (*n == ' ' || *n == '\t')
  607+                        n--;
  608+                if (*o != *n)
  609+                        return 1;
  610+        }
  611+        return 0;
  612+}
  613+
557614 void
 558615 define()
 559616 {
     
 !
576633         np = lookup((usch *)yytext, ENTER);
 577634         redef = np->value != NULL;
 578635 
<> 636+        readmac = 1;
579637         sbeg = stringbuf;
 580638         if ((c = yylex()) == '(') {
 581639                 narg = 0;
     
 !
690748                                 savch(SNUFF), mkstr = 0;
 691749                         break;
 692750 
<> 751+                case CMNT: /* save comments */
  752+                        getcmnt();
  753+                        break;
  754+
693755                 default:
 694756 id:                     savstr((usch *)yytext);
 695757                         break;
 696758                 }
 697759                 c = yylex();
 698760         }
<> 761+        readmac = 0;
699762         /* remove trailing whitespace */
 700763         while (stringbuf > sbeg) {
 701764                 if (stringbuf[-1] == ' ' || stringbuf[-1] == '\t')
     
 !
712775         } else
 713776                 savch(narg < 0 ? OBJCT : narg);
 714777         if (redef) {
<>715 -                usch *o = np->value, *n = stringbuf-1;
 716 -
 717 -                /* Redefinition to identical replacement-list is allowed */
 718 -                while (*o && *o == *n)
 719 -                        o--, n--;
 720 -                if (*o || *o != *n)
  778+                if (cmprepl(np->value, stringbuf-1))
721779                         error("%s redefined\nprevious define: %s:%d",
 722780                             np->namep, np->file, np->line);
 723781                 stringbuf = sbeg/* forget this space */
     
 !
9631021                 }
 9641022         }
 9651023 #endif
<> 1024+        readmac++;
9661025         while ((c = yylex()) != WARN) {
 9671026                 switch (c) {
 9681027                 case NOEXP: noexp++; break;
     
 !
10731132                         }
 10741133                         break;
 10751134 
<> 1135+                case CMNT:
  1136+                        getcmnt();
  1137+                        break;
  1138+
10761139                 case STRING:
 10771140                         /* remove EXPAND/NOEXP from strings */
 10781141                         if (yytext[1] == NOEXP) {
     
 !
10921155         }
 10931156         if (noexp)
 10941157                 error("expmac noexp=%d", noexp);
<> 1158+        readmac--;
10951159         DPRINT(("return from expmac\n"));
 10961160 }
 10971161 
     
 !
11471211                         savstr((usch *)yytext);
 11481212                         while ((c = yylex()) == '\n')
 11491213                                 savch('\n');
<> 1214+                        while (c == CMNT) {
  1215+                                getcmnt();
  1216+                                c = yylex();
  1217+                        }
<_11501218                         if (c == EXPAND)
 11511219                                 instr = 0;
 11521220                 }
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-08-22 23:40 +0200