Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.96
 
1.97
 
MAIN:ragge:20090801155306
 
cpp.c
_>107107 
 108108 int ofd;
 109109 usch outbuf[CPPBUF];
<>110 -int obufp, istty, inmac;
  110+int obufp, istty;
111111 int Cflag, Mflag, dMflag, Pflag;
 112112 usch *Mfile;
 113113 struct initar *initar;
     
 !
348348         int c;
 349349 
 350350         thisnl = NULL;
<>351 -        slow = 1;
352351         readmac++;
 353352         base = osp = stringbuf;
 354353         goto found;
 355354 
<>356 -        while ((c = yylex()) != 0) {
  355+        while ((c = sloscan()) != 0) {
357356                 switch (c) {
 358357                 case IDENT:
 359358                         if (flslvl)
     
 !
369368                                 goto found;
 370369                         }
 371370                         ss2 = stringbuf;
<>372 -                        if ((c = yylex()) == WSPACE) {
  371+                        if ((c = sloscan()) == WSPACE) {
373372                                 savstr((usch *)yytext);
<>374 -                                c = yylex();
  373+                                c = sloscan();
375374                         }
 376375                         if (c != EXPAND) {
 377376                                 unpstr((usch *)yytext);
 378377                                 if (ss2 != stringbuf)
 379378                                         unpstr(ss2);
 380379                                 unpstr(nl->namep);
<>381 -                                (void)yylex(); /* get yytext correct */
  380+                                (void)sloscan(); /* get yytext correct */
382381                                 nl = 0; /* ignore */
 383382                         } else {
 384383                                 thisnl = NULL;
 385384                                 if (nl->value[0] == OBJCT) {
 386385                                         unpstr(nl->namep);
<>387 -                                        (void)yylex(); /* get yytext correct */
  386+                                        (void)sloscan(); /* get yytext correct */
388387                                         nl = 0;
 389388                                 }
 390389                         }
     
 !
416415                         getcmnt();
 417416                         break;
 418417 
<>419 -                case STRING:
420418                 case '\n':
<> 419+                        /* sloscan() will not eat */
  420+                        (void)cinput();
  421+                        savch(c);
  422+                        break;
  423+
  424+                case STRING:
421425                 case NUMBER:
<>422 -                case FPOINT:
423426                 case WSPACE:
 424427                         savstr((usch *)yytext);
 425428                         break;
     
 !
432435                         break;
 433436                 }
 434437                 if (thisnl == NULL) {
<>435 -                        slow = 0;
436438                         readmac--;
 437439                         savch(0);
 438440                         return base;
     
 !
448450 {
 449451         static usch *lbuf;
 450452         static int llen;
<> 453+        usch *p;
451454         int c;
 452455 
<>453 -        slow = 1;
 454 -        if (yylex() != WSPACE)
  456+        if ((c = yylex()) != NUMBER)
455457                 goto bad;
<>456 -        if ((c = yylex()) != IDENT || !isdigit((int)yytext[0]))
 457 -                goto bad;
 458 -        ifiles->lineno = atoi(yytext);
  458+        ifiles->lineno = yylval.node.nd_val - 1;
459459 
<>460 -        if ((c = yylex()) != '\n' && c != WSPACE)
 461 -                goto bad;
 462 -        if (c == '\n') {
 463 -                slow = 0;
  460+        if ((c = yylex()) == '\n')
464461                 return;
<>465 -        }
 466 -        if (yylex() != STRING || yytext[0] == 'L')
  462+
  463+        if (c != STRING)
467464                 goto bad;
<>468 -        c = strlen((char *)yytext);
  465+
  466+        p = (usch *)yytext;
  467+        if (*p == 'L')
  468+                p++;
  469+        c = strlen((char *)p);
469470         if (llen < c) {
 470471                 /* XXX may loose heap space */
 471472                 lbuf = stringbuf;
 472473                 stringbuf += c;
 473474                 llen = c;
 474475         }
<>475 -        yytext[strlen(yytext)-1] = 0;
 476 -        if (strlcpy((char *)lbuf, &yytext[1], SBSIZE) >= SBSIZE)
  476+        p[strlen((char *)p)-1] = 0;
  477+        if (strlcpy((char *)lbuf, (char *)&p[1], SBSIZE) >= SBSIZE)
477478                 error("line exceeded buffer size");
 478479 
 479480         ifiles->fname = lbuf;
<>480 -        if (yylex() != '\n')
 481 -                goto bad;
 482 -        slow = 0;
 483 -        return;
  481+        if (yylex() == '\n')
  482+                return;
484483 
 485484 bad:    error("bad line directive");
 486485 }
     
 !
494493 include()
 495494 {
 496495         struct incs *w;
<>497 -        struct symtab *nl;
498496         usch *osp;
 499497         usch *fn, *safefn;
 500498         int i, c, it;
 501499 
 502500         if (flslvl)
 503501                 return;
 504502         osp = stringbuf;
<>505 -        slow = 1;
 506 -again:
 507 -        if ((c = yylex()) == WSPACE)
 508 -                c = yylex();
 509 -        if (c != STRING && c != '<' && c != IDENT)
  503+
  504+        if ((c = yylex()) != STRING && c != '<')
510505                 goto bad;
 511506 
<>512 -        if (c == IDENT) {
 513 -                if ((nl = lookup((usch *)yytext, FIND)) == NULL)
 514 -                        goto bad;
 515 -                if (subst(nl, NULL) == 0)
 516 -                        goto bad;
 517 -                savch('\0');
 518 -                unpstr(osp);
 519 -                goto again;
 520 -        } else if (c == '<') {
  507+        if (c == '<') {
521508                 fn = stringbuf;
<>522 -                while ((c = yylex()) != '>' && c != '\n') {
  509+                while ((c = sloscan()) != '>' && c != '\n') {
523510                         if (c == '\n')
 524511                                 goto bad;
 525512                         savstr((usch *)yytext);
 526513                 }
 527514                 savch('\0');
<>528 -                while ((c = yylex()) == WSPACE)
  515+                while ((c = sloscan()) == WSPACE)
529516                         ;
 530517                 if (c != '\n')
 531518                         goto bad;
     
 !
548535                 }
 549536                 safefn = stringbuf;
 550537                 savstr(fn); savch(0);
<>551 -                while ((c = yylex()) == WSPACE)
 552 -                        ;
  538+                c = yylex();
553539                 if (c != '\n')
 554540                         goto bad;
<>555 -                slow = 0;
556541                 if (pushfile(nm) == 0)
<>557 -                        return;
  542+                        goto okret;
558543                 /* XXX may loose stringbuf space */
 559544         }
 560545 
 561546         /* create search path and try to open file */
<>562 -        slow = 0;
563547         for (i = 0; i < 2; i++) {
 564548                 for (w = incdir[i]; w; w = w->next) {
 565549                         usch *nm = stringbuf;
 566550 
 567551                         savstr(w->dir); savch('/');
 568552                         savstr(safefn); savch(0);
 569553                         if (pushfile(nm) == 0)
<>570 -                                return;
  554+                                goto okret;
571555                         stringbuf = nm;
 572556                 }
 573557         }
     
 !
576560 
 577561 bad:    error("bad include");
 578562         /* error() do not return */
<> 563+okret:
  564+        prtline();
579565 }
 580566 
 581567 static int
     
 !
584570         int c;
 585571 
 586572         do
<>587 -                c = yylex();
  573+                c = sloscan();
588574         while (c == WSPACE);
 589575         return c;
 590576 }
     
 !
638624         return 0;
 639625 }
 640626 
<> 627+static int
  628+isell(void)
  629+{
  630+        int ch;
  631+
  632+        if ((ch = cinput()) != '.') {
  633+                cunput(ch);
  634+                return 0;
  635+        }
  636+        if ((ch = cinput()) != '.') {
  637+                cunput(ch);
  638+                cunput('.');
  639+                return 0;
  640+        }
  641+        return 1;
  642+}
  643+
641644 void
 642645 define()
 643646 {
     
 !
653656 
 654657         if (flslvl)
 655658                 return;
<>656 -        slow = 1;
 657 -        if (yylex() != WSPACE || yylex() != IDENT)
  659+        if (sloscan() != WSPACE || sloscan() != IDENT)
658660                 goto bad;
 659661 
 660662         if (isdigit((int)yytext[0]))
     
 !
665667 
 666668         readmac = 1;
 667669         sbeg = stringbuf;
<>668 -        if ((c = yylex()) == '(') {
  670+        if ((c = sloscan()) == '(') {
669671                 narg = 0;
 670672                 /* function-like macros, deal with identifiers */
 671673                 c = definp();
 672674                 for (;;) {
 673675                         if (c == ')')
 674676                                 break;
<>675 -                        if (c == ELLIPS) {
  677+                        if (c == '.' && isell()) {
676678                                 ellips = 1;
 677679                                 if (definp() != ')')
 678680                                         goto bad;
     
 !
691693                                         continue;
 692694                                 }
 693695 #ifdef GCC_VARI
<>694 -                                if (c == ELLIPS) {
  696+                                if (c == '.' && isell()) {
695697                                         if (definp() != ')')
 696698                                                 goto bad;
 697699                                         gccvari = args[--narg];
     
 !
703705                         }
 704706                         goto bad;
 705707                 }
<>706 -                c = yylex();
  708+                c = sloscan();
707709         } else if (c == '\n') {
 708710                 /* #define foo */
 709711                 ;
 710712         } else if (c != WSPACE)
 711713                 goto bad;
 712714 
 713715         while (c == WSPACE)
<>714 -                c = yylex();
  716+                c = sloscan();
715717 
 716718         /* replacement list cannot start with ## operator */
<>717 -        if (c == CONCAT)
 718 -                goto bad;
  719+        if (c == '#') {
  720+                if ((c = sloscan()) == '#')
  721+                        goto bad;
  722+                savch('\0');
  723+#ifdef GCC_VARI
  724+                wascon = 0;
  725+#endif
  726+                goto in2;
  727+        }
719728 
 720729         /* parse replacement-list, substituting arguments */
 721730         savch('\0');
     
 !
729738                         /* remove spaces if it surrounds a ## directive */
 730739                         ubuf = stringbuf;
 731740                         savstr((usch *)yytext);
<>732 -                        c = yylex();
 733 -                        if (c == CONCAT) {
  741+                        c = sloscan();
  742+                        if (c == '#') {
  743+                                if ((c = sloscan()) != '#')
  744+                                        goto in2;
734745                                 stringbuf = ubuf;
 735746                                 savch(CONC);
<>736 -                                if ((c = yylex()) == WSPACE)
 737 -                                        c = yylex();
  747+                                if ((c = sloscan()) == WSPACE)
  748+                                        c = sloscan();
738749 #ifdef GCC_VARI
 739750                                 if (c == '\n')
 740751                                         break;
     
 !
744755                         }
 745756                         continue;
 746757 
<>747 -                case CONCAT:
 748 -                        /* No spaces before concat op */
 749 -                        savch(CONC);
 750 -                        if ((c = yylex()) == WSPACE)
 751 -                                c = yylex();
  758+                case '#':
  759+                        c = sloscan();
  760+                        if (c == '#') {
  761+                                /* concat op */
  762+                                savch(CONC);
  763+                                if ((c = sloscan()) == WSPACE)
  764+                                        c = sloscan();
752765 #ifdef GCC_VARI
<>753 -                        if (c == '\n')
 754 -                                break;
 755 -                        wascon = 1;
 756 -                        goto loop;
  766+                                if (c == '\n')
  767+                                        break;
  768+                                wascon = 1;
  769+                                goto loop;
757770 #else
<>758 -                        continue;
  771+                                continue;
759772 #endif
<>760 -
 761 -                case MKSTR:
 762 -                        if (narg < 0) {
  773+                        }
  774+in2:                    if (narg < 0) {
763775                                 /* no meaning in object-type macro */
 764776                                 savch('#');
<>765 -                                break;
  777+                                continue;
766778                         }
 767779                         /* remove spaces between # and arg */
 768780                         savch(SNUFF);
<>769 -                        if ((c = yylex()) == WSPACE)
 770 -                                c = yylex(); /* whitespace, ignore */
  781+                        if (c == WSPACE)
  782+                                c = sloscan(); /* whitespace, ignore */
771783                         mkstr = 1;
<>772 -                        if (c == VA_ARGS)
  784+                        if (c == IDENT && strcmp(yytext, "__VA_ARGS__") == 0)
773785                                 continue;
 774786 
 775787                         /* FALLTHROUGH */
 776788                 case IDENT:
<> 789+                        if (strcmp(yytext, "__VA_ARGS__") == 0) {
  790+                                if (ellips == 0)
  791+                                        error("unwanted %s", yytext);
  792+                                savch(VARG);
  793+                                savch(WARN);
  794+                                if (mkstr)
  795+                                        savch(SNUFF), mkstr = 0;
  796+                                break;
  797+                        }
777798                         if (narg < 0)
 778799                                 goto id; /* just add it if object */
 779800                         /* check if its an argument */
     
 !
801822                                 savch(SNUFF), mkstr = 0;
 802823                         break;
 803824 
<>804 -                case VA_ARGS:
 805 -                        if (ellips == 0)
 806 -                                error("unwanted %s", yytext);
 807 -                        savch(VARG);
 808 -                        savch(WARN);
 809 -                        if (mkstr)
 810 -                                savch(SNUFF), mkstr = 0;
 811 -                        break;
 812 -
813825                 case CMNT: /* save comments */
 814826                         getcmnt();
 815827                         break;
     
 !
818830 id:                     savstr((usch *)yytext);
 819831                         break;
 820832                 }
<>821 -                c = yylex();
  833+                c = sloscan();
822834         }
 823835         readmac = 0;
 824836         /* remove trailing whitespace */
     
 !
870882                 putchar('\n');
 871883         }
 872884 #endif
<>873 -        slow = 0;
874885         for (i = 0; i < narg; i++)
 875886                 free(args[i]);
 876887         return;
     
 !
936947         usch *opb;
 937948         int t, plev;
 938949 
<>939 -        slow++;
 940 -        if ((t = yylex()) == WSPACE)
 941 -                t = yylex();
  950+        if ((t = sloscan()) == WSPACE)
  951+                t = sloscan();
942952         if (t != '(')
 943953                 goto bad;
<>944 -        if ((t = yylex()) == WSPACE)
 945 -                t = yylex();
  954+        if ((t = sloscan()) == WSPACE)
  955+                t = sloscan();
946956         opb = stringbuf;
<>947 -        for (plev = 0; ; t = yylex()) {
  957+        for (plev = 0; ; t = sloscan()) {
948958                 if (t == '(')
 949959                         plev++;
 950960                 if (t == ')')
     
 !
963973         while (stringbuf > opb)
 964974                 cunput(*--stringbuf);
 965975         savch(PRAGS);
<>966 -        while ((t = yylex()) != '\n') {
  976+        while ((t = sloscan()) != '\n') {
967977                 if (t == WSPACE)
 968978                         continue;
 969979                 if (t != STRING)
     
 !
974984         savch(PRAGE);
 975985         while (stringbuf > opb)
 976986                 cunput(*--stringbuf);
<>977 -        slow--;
978987         return;
 979988 bad:    error("bad pragma operator");
 980989 }
     
 !
10421051                         *stringbuf = 0;
 10431052                         unpstr(obp);
 10441053                         unpstr(sp->namep);
<>1045 -                        if ((c = yylex()) != IDENT)
  1054+                        if ((c = sloscan()) != IDENT)
10461055                                 error("internal sync error");
 10471056                         stringbuf = obp;
 10481057                         return 0;
     
 !
10841093         }
 10851094 #endif
 10861095         readmac++;
<>1087 -        while ((c = yylex()) != WARN) {
  1096+        while ((c = sloscan()) != WARN) {
10881097                 switch (c) {
 10891098                 case NOEXP: noexp++; break;
 10901099                 case EXPAND: noexp--; break;
     
 !
10951104                          * If an identifier is found and directly
 10961105                          * after EXPAND or NOEXP then push the
 10971106                          * identifier back on the input stream and
<>1098 -                         * call yylex() again.
  1107+                         * call sloscan() again.
10991108                          * Be careful to keep the noexp balance.
 11001109                          */
 11011110                         och = stringbuf;
 11021111                         savstr((usch *)yytext);
 11031112                         DDPRINT(("id: str %s\n", och));
 11041113 
 11051114                         orgexp = 0;
<>1106 -                        while ((c = yylex()) == EXPAND || c == NOEXP)
  1115+                        while ((c = sloscan()) == EXPAND || c == NOEXP)
11071116                                 if (c == EXPAND)
 11081117                                         orgexp--;
 11091118                                 else
     
 !
11521161                         stringbuf = och;
 11531162 
 11541163 
<>1155 -                        yylex(); /* XXX reget last identifier */
  1164+                        sloscan(); /* XXX reget last identifier */
11561165 
 11571166                         if ((nl = lookup((usch *)yytext, FIND)) == NULL)
 11581167                                 goto def;
     
 !
11751184                         if (noexp != 1)
 11761185                                 error("bad noexp %d", noexp);
 11771186                         stksv = NULL;
<>1178 -                        if ((c = yylex()) == WSPACE) {
  1187+                        if ((c = sloscan()) == WSPACE) {
11791188                                 stksv = xstrdup(yytext);
<>1180 -                                c = yylex();
  1189+                                c = sloscan();
11811190                         }
 11821191                         /* only valid for expansion if fun macro */
 11831192                         if (c == EXPAND && *nl->value != OBJCT) {
     
 !
12011210                         getcmnt();
 12021211                         break;
 12031212 
<> 1213+                case '\n':
  1214+                        cinput();
  1215+                        break;
  1216+
12041217                 case STRING:
 12051218                         /* remove EXPAND/NOEXP from strings */
 12061219                         if (yytext[1] == NOEXP) {
     
 !
12271240 /*
 12281241  * expand a function-like macro.
 12291242  * vp points to end of replacement-list
<>1230 - * reads function arguments from yylex()
  1243+ * reads function arguments from sloscan()
12311244  * result is written on top of heap
 12321245  */
 12331246 void
     
 !
12381251         int ellips = 0;
 12391252 
 12401253         DPRINT(("expdef rp %s\n", (rp ? (char *)rp->sp->namep : "")));
<>1241 -        if ((c = yylex()) != '(')
  1254+        if ((c = sloscan()) != '(')
12421255                 error("got %c, expected (", c);
 12431256         if (vp[1] == VARG) {
 12441257                 narg = *vp--;
     
 !
12521265          * read arguments and store them on heap.
 12531266          * will be removed just before return from this function.
 12541267          */
<>1255 -        inmac = 1;
12561268         sptr = stringbuf;
 12571269         instr = 0;
 12581270         for (i = 0; i < narg && c != ')'; i++) {
 12591271                 args[i] = stringbuf;
 12601272                 plev = 0;
<>1261 -                while ((c = yylex()) == WSPACE || c == '\n')
 1262 -                        ;
  1273+                while ((c = sloscan()) == WSPACE || c == '\n')
  1274+                        if (c == '\n')
  1275+                                putch(cinput());
12631276                 DDPRINT((":AAA (%d)", c));
 12641277                 if (instr == -1)
 12651278                         savch(NOEXP), instr = 1;
     
 !
12731286                         if (c == ')')
 12741287                                 plev--;
 12751288                         savstr((usch *)yytext);
<>1276 -                        while ((c = yylex()) == '\n')
  1289+                        while ((c = sloscan()) == '\n') {
  1290+                                putch(cinput());
12771291                                 savch('\n');
<> 1292+                        }
12781293                         while (c == CMNT) {
 12791294                                 getcmnt();
<>1280 -                                c = yylex();
  1295+                                c = sloscan();
12811296                         }
 12821297                         if (c == EXPAND)
 12831298                                 instr = 0;
     
 !
12971312                 args[i] = stringbuf;
 12981313                 plev = 0;
 12991314                 instr = 0;
<>1300 -                while ((c = yylex()) == WSPACE)
  1315+                while ((c = sloscan()) == WSPACE)
13011316                         ;
 13021317                 if (c == NOEXP)
 13031318                         instr++;
     
 !
13151330                                 savch(NOEXP);
 13161331                         } else
 13171332                                 savstr((usch *)yytext);
<>1318 -                        while ((c = yylex()) == '\n')
  1333+                        while ((c = sloscan()) == '\n') {
  1334+                                cinput();
13191335                                 savch('\n');
<> 1336+                        }
13201337                         if (c == EXPAND)
 13211338                                 instr--;
 13221339                 }
     
 !
13271344                 
 13281345         }
 13291346         if (narg == 0 && ellips == 0)
<>1330 -                while ((c = yylex()) == WSPACE || c == '\n')
 1331 -                        ;
  1347+                while ((c = sloscan()) == WSPACE || c == '\n')
  1348+                        if (c == '\n')
  1349+                                cinput();
13321350 
 13331351         if (c != ')' || (i != narg && ellips == 0) || (i < narg && ellips == 1))
 13341352                 error("wrong arg count");
 13351353 
<>1336 -        inmac = 0;
<_13371354         while (gotwarn--)
 13381355                 cunput(WARN);
 13391356 
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 11:50 +0200