Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.7
 
1.8
 
MAIN:ragge:20040823065413
 
cpp.c
_>110110         struct symtab *sp;
 111111 };
 112112 
<>113 -static struct symtab *defloc;
 114 -static struct symtab *eifloc;
 115 -static struct symtab *elfloc;
 116 -static struct symtab *elsloc;
 117 -static struct symtab *ifdloc;
 118 -static struct symtab *ifloc;
 119 -static struct symtab *ifnloc;
 120 -static struct symtab *incloc;
 121 -static struct symtab *undloc;
122113 static struct symtab *filloc;
 123114 static struct symtab *linloc;
 124115 static int      trulvl;
     
 !
235226 
 236227         prtline();
 237228 
<>238 -        insym(&defloc, "define");
 239 -        insym(&incloc, "include");
 240 -        insym(&eifloc, "endif");
 241 -        insym(&ifdloc, "ifdef");
 242 -        insym(&ifnloc, "ifndef");
 243 -        insym(&elsloc, "else");
 244 -        insym(&elfloc, "elif");
 245 -        insym(&undloc, "undef");
246229         insym(&filloc, "__FILE__");
 247230         insym(&linloc, "__LINE__");
<>248 -        trulvl = 0;
 249 -        flslvl = 0;
250231 
 251232         thisnl = NULL;
 252233         while ((c = yylex()) != 0) {
     
 !
261242                         error("special: %d\n", c);
 262243 
 263244                 case IDENT:
<> 245+                        if (flslvl)
  246+                                break;
264247                         osp = stringbuf;
 265248                         nl = lookup(yytext, FIND);
 266249                         if (nl == 0 || thisnl == 0)
     
 !
304287                 case WSPACE:
 305288                 case NL:
 306289                 default:
<>307 -                        fputs(yytext, obuf);
  290+                        if (flslvl == 0)
  291+                                fputs(yytext, obuf);
308292                         break;
 309293                 }
 310294         }
     
 !
321305         struct symtab *np;
 322306         int t;
 323307 
<> 308+#define CHECK(x) (yytext[0] == #x[0]) && strcmp(yytext, #x) == 0
  309+
324310         if ((t = yylex()) == WSPACE)
 325311                 t = yylex();
 326312         if (t != IDENT)
 327313                 return error("bad control '%s'", yytext);
 328314 
<>329 -        np = lookup(yytext, FIND);
 330 -        if (np == 0)
 331 -                error("bad control %s", yytext);
 332 -        if (np == incloc) {
  315+        if (CHECK(include)) {
333316                 if (flslvl)
 334317                         goto exit;
 335318                 include();
 336319                 return;
<>337 -        } else if (np == elsloc) {
  320+        } else if (CHECK(else)) {
338321                 if (flslvl) {
<>339 -                        if (--flslvl!=0)
  322+                        if (--flslvl!=0) {
340323                                 flslvl++;
<>341 -                        else
  324+                        } else {
342325                                 trulvl++;
<> 326+                                prtline();
  327+                        }
343328                 } else if (trulvl) {
 344329                         flslvl++;
 345330                         trulvl--;
 346331                 } else
 347332                         error("If-less else");
<> 333+        } else if (CHECK(endif)) {
  334+                if (flslvl) {
  335+                        flslvl--;
  336+                        if (flslvl == 0)
  337+                                prtline();
  338+                } else if (trulvl)
  339+                        trulvl--;
  340+                else
  341+                        error("If-less endif");
  342+        } else if (CHECK(error)) {
  343+                usch *ch = stringbuf;
  344+                while (yylex() != NL)
  345+                        savstr(yytext);
  346+                savch('\n');
  347+                error("error: %s", ch);
348348         } else {
 349349                 if (yylex() != WSPACE || yylex() != IDENT)
<>350 -                        return error("bad control2");
 351 -                
 352 -                if (np == defloc) {
  350+                        error("control line syntax error");
  351+                if (CHECK(define)) {
353352                         define();
<>354 -                        return;
 355 -                } else if (np == ifdloc) {
  353+                } else if (CHECK(ifdef)) {
356354                         if (flslvl == 0 && lookup(yytext, FIND) != 0)
 357355                                 trulvl++;
 358356                         else
 359357                                 flslvl++;
<>360 -                } else if (np == ifnloc) {
  358+                } else if (CHECK(ifndef)) {
361359                         if (flslvl == 0 && lookup(yytext, FIND) == 0)
 362360                                 trulvl++;
 363361                         else
 364362                                 flslvl++;
<>365 -                } else if (np == eifloc) {
 366 -                        if (flslvl)
 367 -                                flslvl--;
 368 -                        else if (trulvl)
 369 -                                trulvl--;
 370 -                        else
 371 -                                error("If-less endif");
 372 -                } else if (np == undloc) {
  363+                } else if (CHECK(undef)) {
373364                         if (flslvl == 0 && (np = lookup(yytext, FIND)))
 374365                                 np->value = 0;
<>375 -                } else if (np == elfloc) {
 376 -
 377 -                } else if (np == ifloc) {
 378 -
379366                 } else
 380367                         error("undefined control '%s'", np->namep);
 381368         }
 382369 
 383370 exit:
 384371         while (yylex() != NL)
 385372                 ;
<> 373+#undef CHECK
386374 }
 387375 
 388376 void
     
 !
443431                         strcpy(args[narg], yytext);
 444432                         narg++;
 445433                 }
<> 434+        } else if (c == NL) {
  435+                /* #define foo */
  436+                cunput('\n');
<_446437         } else if (c != WSPACE)
 447438                 error("bad define");
 448439 
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-21 00:06 +0200