Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.192
 
1.193
 
MAIN:plunky:20140530192701
 
cpp.c
_>528528         error("premature EOF");
 529529 }
 530530 
<> 531+static usch *
  532+incfn(int e)
  533+{
  534+        usch *sb = stringbuf;
  535+        int c;
  536+
  537+        while ((c = cinput()) != e) {
  538+                if (c == -1)
  539+                        prem();
  540+                if (c == '\n') {
  541+                        stringbuf = sb;
  542+                        return NULL;
  543+                }
  544+                savch(c);
  545+        }
  546+        savch(0);
  547+
  548+        while ((c = sloscan()) == WSPACE)
  549+                ;
  550+        if (c == 0)
  551+                prem();
  552+        if (c != '\n') {
  553+                stringbuf = sb;
  554+                return NULL;
  555+        }
  556+
  557+        return sb;
  558+}
  559+
531560 /*
 532561  * Include a file. Include order:
 533562  * - For <...> files, first search -I directories, then system directories.
     
 !
537566 include(void)
 538567 {
 539568         struct symtab *nl;
<>540 -        usch *osp;
 541 -        usch *fn, *safefn;
  569+        usch *fn, *nm;
542570         int c;
 543571 
 544572         if (flslvl)
 545573                 return;
<>546 -        osp = stringbuf;
547574 
<>548 -        while ((c = sloscan()) == WSPACE)
  575+        while ((c = cinput()) == ' ' || c == '\t')
549576                 ;
<>550 -        if (c == IDENT) {
 551 -                /* sloscan() will not expand idents */
  577+
  578+        if (c != -1 && (spechr[c] & C_ID0)) {
  579+                usch *sb;
  580+
  581+                /* use sloscan() to read the identifier, then expand it */
  582+                cunput(c);
  583+                c = sloscan();
552584                 if ((nl = lookup(yytext, FIND)) == NULL)
 553585                         goto bad;
<> 586+
  587+                sb = stringbuf;
554588                 if (kfind(nl))
 555589                         unpstr(stringbuf);
 556590                 else
 557591                         unpstr(nl->namep);
<>558 -                stringbuf = osp;
 559 -                c = yylex();
  592+                stringbuf = sb;
  593+
  594+                c = cinput();
560595         }
 561596 
 562597         if (c == '<') {
<>563 -                fn = stringbuf;
 564 -                while ((c = sloscan()) != '>') {
 565 -                        if (c == 0)
 566 -                                prem();
 567 -                        if (c == '\n')
 568 -                                goto bad;
 569 -                        savstr(yytext);
 570 -                }
 571 -                savch('\0');
 572 -                while ((c = sloscan()) == WSPACE)
 573 -                        ;
 574 -                if (c == 0)
 575 -                        prem();
 576 -                if (c != '\n')
  598+                if ((fn = incfn('>')) == NULL)
577599                         goto bad;
<>578 -                safefn = fn;
 579 -        } else if (c == STRING) {
 580 -                usch *nm = stringbuf;
  600+        } else if (c == '\"') {
  601+                if ((fn = incfn('\"')) == NULL)
  602+                        goto bad;
581603 
<>582 -                fn = yytext;
 583 -                if (*fn++ == 'L')
 584 -                        fn++;
 585 -                fn[strlen((char *)fn) - 1] = 0;
586604                 /* first try to open file relative to previous file */
 587605                 /* but only if it is not an absolute path */
<> 606+                nm = stringbuf;
588607                 if (*fn != '/') {
 589608                         savstr(ifiles->orgfn);
<>590 -                        if ((stringbuf =
 591 -                            (usch *)strrchr((char *)nm, '/')) == NULL)
  609+                        stringbuf = (usch *)strrchr((char *)nm, '/');
  610+                        if (stringbuf == NULL)
592611                                 stringbuf = nm;
 593612                         else
 594613                                 stringbuf++;
 595614                 }
<>596 -                safefn = stringbuf;
 597 -                savstr(fn); savch(0);
 598 -                c = yylex();
 599 -                if (c == 0)
 600 -                        prem();
 601 -                if (c != '\n')
 602 -                        goto bad;
 603 -                if (pushfile(nm, safefn, 0, NULL) == 0)
  615+                savstr(fn);
  616+                savch(0);
  617+
  618+                if (pushfile(nm, fn, 0, NULL) == 0)
604619                         goto okret;
<> 620+
605621                 /* XXX may lose stringbuf space */
 606622         } else
 607623                 goto bad;
 608624 
<>609 -        if (fsrch(safefn, 0, incdir[0]))
  625+        if (fsrch(fn, 0, incdir[0]))
610626                 goto okret;
 611627 
<>612 -        error("cannot find '%s'", safefn);
  628+        error("cannot find '%s'", fn);
613629         /* error() do not return */
 614630 
 615631 bad:    error("bad #include");
     
 !
622638 include_next(void)
 623639 {
 624640         struct symtab *nl;
<>625 -        usch *osp;
626641         usch *fn;
 627642         int c;
 628643 
 629644         if (flslvl)
 630645                 return;
<>631 -        osp = stringbuf;
 632 -        while ((c = sloscan()) == WSPACE)
  646+
  647+        while ((c = cinput()) == ' ' || c == '\t')
633648                 ;
<>634 -        if (c == IDENT) {
 635 -                /* sloscan() will not expand idents */
  649+
  650+        if (c != -1 && (spechr[c] & C_ID0)) {
  651+                usch *sb;
  652+
  653+                /* use sloscan() to read the identifier, then expand it */
  654+                cunput(c);
  655+                c = sloscan();
636656                 if ((nl = lookup(yytext, FIND)) == NULL)
 637657                         goto bad;
<> 658+
  659+                sb = stringbuf;
638660                 if (kfind(nl))
 639661                         unpstr(stringbuf);
 640662                 else
 641663                         unpstr(nl->namep);
<>642 -                stringbuf = osp;
 643 -                c = yylex();
 644 -        }
 645 -        if (c != STRING && c != '<')
 646 -                goto bad;
  664+                stringbuf = sb;
647665 
<>648 -        fn = stringbuf;
 649 -        if (c == STRING) {
 650 -                savstr(&yytext[1]);
 651 -                stringbuf[-1] = 0;
 652 -        } else { /* < > */
 653 -                while ((c = sloscan()) != '>') {
 654 -                        if (c == '\n')
 655 -                                goto bad;
 656 -                        savstr(yytext);
 657 -                }
 658 -                savch('\0');
  666+                c = cinput();
659667         }
<>660 -        while ((c = sloscan()) == WSPACE)
 661 -                ;
 662 -        if (c != '\n')
  668+
  669+        if (c == '\"') {
  670+                if ((fn = incfn('\"')) == NULL)
  671+                        goto bad;
  672+        } else if (c == '<') {
  673+                if ((fn = incfn('>')) == NULL)
  674+                        goto bad;
  675+        } else
663676                 goto bad;
 664677 
 665678         if (fsrch(fn, ifiles->idx, ifiles->incs) == 0)
 666679                 error("cannot find '%s'", fn);
<> 680+
<_667681         prtline();
 668682         return;
 669683 
FishEye: Open Source License registered to PCC.
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-12-26 12:30 +0100