Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.42
 
1.43
 
MAIN:ragge:20110109152539
 
token.c
_>7878 extern int yyget_lineno (void);
 7979 extern void yyset_lineno (int);
 8080 
 8181 static int inch(void);
 8282 
 8383 int inif;
<> 84+extern int dflag;
8485 
 8586 #define PUTCH(ch) if (!flslvl) putch(ch)
 8687 /* protection against recursion in #include */
 8788 #define MAX_INCLEVEL    100
 8889 static int inclevel;
 8990 
     
 !
9495 static char buf[CPPBUF];
 9596 char *yytext = buf;
 9697 #else
 9798 char yytext[CPPBUF];
 9899 #endif
 99100 
<>100 -#define C_SPEC  1
 101 -#define C_EP    2
 102 -#define C_ID    4
 103 -#define C_I     (C_SPEC|C_ID)
 104 -#define C_2     8               /* for yylex() tokenizing */
 105 -static char spechr[256] = {
  101+char spechr[256] = {
  102+        0,      0,      0,      0,      C_SPEC, C_SPEC, 0,      0,
  103+        0,      C_WSNL, C_SPEC|C_WSNL,  0,
  104+        0,      C_WSNL, 0,      0,
106105         0,      0,      0,      0,      0,      0,      0,      0,
<>107 -        0,      0,      C_SPEC0,      0,      0,      0,      0,
108106         0,      0,      0,      0,      0,      0,      0,      0,
<>109 -        0,      0,      0,      0,      0,      0,      0,      0,
110107 
<>111 -        0,      C_2,    C_SPEC0,      0,      0,      C_2,    C_SPEC,
  108+        C_WSNLC_2,    C_SPEC0,      0,      0,      C_2,    C_SPEC,
112109         0,      0,      0,      C_2,    0,      C_2,    0,      C_SPEC|C_2,
 113110         C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,
 114111         C_I,    C_I,    0,      0,      C_2,    C_2,    C_2,    C_SPEC,
 115112 
 116113         0,      C_I,    C_I,    C_I,    C_I,    C_I|C_EP, C_I,  C_I,
 117114         C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,
     
 !
122119         C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,
 123120         C_I|C_EP, C_I,  C_I,    C_I,    C_I,    C_I,    C_I,    C_I,
 124121         C_I,    C_I,    C_I,    0,      C_2,    0,      0,      0,
 125122 
 126123 };
 127124 
<> 125+/*
  126+ * No-replacement array.  If a macro is found and exists in this array
  127+ * then no replacement shall occur.  This is a stack.
  128+ */
  129+struct symtab *norep[RECMAX];   /* Symbol table index table */
  130+int norepptr = 1;                       /* Top of index table */
  131+unsigned char bptr[RECMAX];     /* currently active noexpand macro stack */
  132+int bidx;                       /* Top of bptr stack */
  133+
128134 static void
 129135 unch(int c)
 130136 {
 131137                 
 132138         --ifiles->curptr;
 133139         if (ifiles->curptr < ifiles->bbuf)
     
 !
146152  *      TODO: Only print out strings before calling other functions.
 147153  */
 148154 static void
 149155 fastscan(void)
 150156 {
 151157         struct symtab *nl;
<>152 -        int ch, i;
  158+        int ch, i, ccnt, onemore;
153159 
 154160         goto run;
 155161         for (;;) {
 156162                 ch = NXTCH();
 157163 xloop:          if (ch == -1)
 158164                         return;
<> 165+                if (dflag>1)
  166+                        printf("fastscan ch %d (%c)\n", ch, ch > 31 ? ch : '@');
159167                 if ((spechr[ch] & C_SPEC) == 0) {
 160168                         PUTCH(ch);
 161169                         continue;
 162170                 }
 163171                 switch (ch) {
<> 172+                case EXP:
  173+                case NEX:
  174+                case WARN:
  175+                case CONC:
  176+                        error("bad char passed");
  177+                        break;
  178+
164179                 case '/': /* Comments */
 165180                         if ((ch = inch()) == '/') {
 166181                                 if (Cflag) { PUTCH(ch); } else { PUTCH(' '); }
 167182                                 do {
 168183                                         if (Cflag) PUTCH(ch);
 169184                                         ch = inch();
     
 !
236251                         }
 237252                         goto xloop;
 238253 
 239254                 case '\"': /* strings */
 240255 str:                    PUTCH(ch);
 241256                         while ((ch = inch()) != '\"') {
<>242 -                                PUTCH(ch);
  257+                                if (ch == EXP)
  258+                                        doexp();
  259+                                else if (ch == NEX)
  260+                                        donex();
  261+                                else if (ch != CONC) /* XXX ??? */
  262+                                        PUTCH(ch);
243263                                 if (ch == '\\') {
 244264                                         ch = inch();
 245265                                         PUTCH(ch);
 246266                                 }
 247267                                 if (ch < 0)
 248268                                         return;
     
 !
305325                                 error("fastscan");
 306326                         if (flslvl) {
 307327                                 while (spechr[ch] & C_ID)
 308328                                         ch = NXTCH();
 309329                                 goto xloop;
 310330                         }
<>311 -                        i = 0;
  331+                        onemore = i = ccnt = 0;
312332                         do {
 313333                                 yytext[i++] = (usch)ch;
 314334                                 ch = NXTCH();
 315335                                 if (ch == '\\') {
 316336                                         ch = NXTCH();
 317337                                         if (ch != '\n') {
     
 !
322342                                                 ch = NXTCH();
 323343                                         }
 324344                                 }
 325345                                 if (ch < 0)
 326346                                         return;
 327347                         } while (spechr[ch] & C_ID);
<> 348+
328349                         yytext[i] = 0;
 329350                         unch(ch);
<>330 -                        if ((nl = lookup((usch *)yytext, FIND)) != 0) {
 331 -                                usch *op = stringbuf;
 332 -                                putstr(gotident(nl));
 333 -                                stringbuf = op;
  351+
  352+                        if ((nl = lookup((usch *)yytext, FIND)) && kfind(nl)) {
  353+                                putstr(stringbuf);
334354                         } else
 335355                                 putstr((usch *)yytext);
<> 356+
336357                         break;
 337358                 }
 338359         }
 339360 }
 340361 
 341362 int
     
 !
602623                 }
 603624                 nl = lookup((usch *)yytext, FIND);
 604625                 if (ifdef) {
 605626                         yylval.node.nd_val = nl != NULL;
 606627                         ifdef = 0;
 607628                 } else if (nl && noex == 0) {
<>608 -                        usch *c, *och = stringbuf;
  629+                        usch *och = stringbuf;
  630+                        int i;
609631 
<>610 -                        c = gotident(nl);
 611 -                        unch(1);
 612 -                        unpstr(c);
  632+                        i = kfind(nl);
  633+                        unch(WARN);
  634+                        if (i)
  635+                                unpstr(stringbuf);
  636+                        else
  637+                                unpstr(nl->namep);
613638                         stringbuf = och;
 614639                         noex = 1;
 615640                         return yylex();
 616641                 } else {
 617642                         yylval.node.nd_val = 0;
 618643                 }
 619644                 yylval.node.op = NUMBER;
 620645                 return NUMBER;
<>621 -        case 1: /* WARN */
  646+        case WARN:
622647                 noex = 0;
 623648                 return yylex();
 624649         default:
 625650                 return ch;
 626651         }
 627652         unch(c2);
     
 !
800825 }
 801826 
 802827 void
 803828 cunput(int c)
 804829 {
 805830 #ifdef CPP_DEBUG
<>806 -        extern int dflag;
 807 -        if (dflag)printf(": '%c'(%d)", c > 31 ? c : ' ', c);
  831+//      extern int dflag;
  832+//      if (dflag)printf(": '%c'(%d)\n", c > 31 ? c : ' ', c);
<_808833 #endif
 809834 #if 0
 810835 if (c == 10) {
 811836         printf("c == 10!!!\n");
 812837 }
 813838 #endif
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-17 13:34 +0200