Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.6
 
1.7
 
MAIN:ragge:20050514080349
 
token.c
_>3939         struct includ *next;
 4040         char *fname;
 4141         int lineno;
<>42 -#ifdef NEWBUF
4342         int infil;
 4443         usch *curptr;
 4544         usch *maxread;
 4645         usch *ostr;
 4746         usch *buffer;
 4847         usch bbuf[NAMEMAX+CPPBUF+1];
<>49 -#else
 50 -        FILE *ifil;
 51 -#endif
5248 } *ifiles;
 5349 
<>54 -usch *yyp, yystr[CPPBUF];
  50+usch *yyp, *yystr, yybuf[CPPBUF];
5551 
 5652 int yylex(void);
 5753 int yywrap(void);
 5854 
<>59 -#ifdef NEWBUF
6055 static struct includ *
 6156 getbuf(usch *file)
 6257 {
     
 !
134129         }
 135130 //printf("unput %d\n", c);
 136131 }
<>137 -#else
 138 -#define input() fgetc(ifiles->ifil)
 139 -#define unput(c) ungetc(c, ifiles->ifil)
 140 -#endif
  132+
  133+#define UNPUT(c) *--ifiles->curptr = c
  134+#define ADJUST(x) { \
  135+        if (x > (ifiles->maxread-ifiles->curptr)) { \
  136+                memcpy(
  137+
141138 static int
 142139 slofgetc(void)
 143140 {
     
 !
185182         static int wasnl = 1;
 186183         int c, oc, rval;
 187184 
<> 185+fast:   yystr = yybuf;
188186         yyp = yystr;
 189187         c = input();
 190188         if (c != ' ' && c != '\t' && c != '#')
 191189                 wasnl = 0;
 192190 #define ONEMORE()       { *yyp++ = c; c = slofgetc(); }
 193191 again:  switch (c) {
 194192         case -1:
<>195 -#ifdef NEWBUF
196193                 rval = 0;
<>197 -#else
 198 -                rval = yywrap() ? 0 : yylex();
 199 -#endif
200194                 break;
 201195 
 202196         case '\'': /* charcon */
 203197         case '"': /* string */
 204198 chstr:          oc = c;
<>205 -                do {
 206 -                        *yyp++ = c;
 207 -                        if (c == '\\')
 208 -                                *yyp++ = slofgetc();
 209 -                } while ((c = slofgetc()) != EOF && c != oc);
 210 -                *yyp++ = c; *yyp = 0;
  199+                if (slow == 0) {
  200+                        do {
  201+                                putch(c);
  202+                                if (c == '\\')
  203+                                        putch(slofgetc());
  204+                        } while ((c = slofgetc()) != EOF && c != oc);
  205+                        if (c == oc)
  206+                                putch(c);
  207+                        goto fast;
  208+                } else {
  209+                        do {
  210+                                *yyp++ = c;
  211+                                if (c == '\\')
  212+                                        *yyp++ = slofgetc();
  213+                        } while ((c = slofgetc()) != EOF && c != oc);
  214+                        *yyp++ = c; *yyp = 0;
  215+                }
211216                 rval = oc == '"' ? STRING : CHARCON;
 212217                 break;
 213218 
     
 !
259264                 ONEMORE();
 260265                 if (isdigit(c))
 261266                         goto F;
<> 267+                if (!slow) {
  268+                        UNPUT(c);
  269+                        putch('.');
  270+                        goto fast;
  271+                }
262272                 if (c == '.') {
 263273                         ONEMORE();
 264274                         if (c == '.') {
     
 !
281291                 c = input();
 282292                 if (c == '\n') {
 283293                         ifiles->lineno++;
<>284 -                        putc('\n', obuf);
 285 -                        c = input();
  294+                        putch('\n');
  295+                        goto fast;
  296+                }
  297+                if (!slow) {
  298+                        putch('\\');
286299                         goto again;
<>287 -                } else {
 288 -                        cunput(c);
 289 -                        *yyp++ = '\\'; *yyp = 0;
 290 -                        rval = '\\';
291300                 }
<> 301+                UNPUT(c);
  302+                *yyp++ = '\\'; *yyp = 0;
  303+                rval = '\\';
292304                 break;
 293305                 
 294306         case '\n':
 295307                 wasnl = 1;
 296308                 ifiles->lineno++;
<>297 -                *yyp++ = c; *yyp = 0;
298309                 rval = NL;
<>299 -                break;
  310+                if (slow)
  311+                        break;
  312+                if (flslvl == 0) {
  313+                        if (curline() == 1)
  314+                                prtline();
  315+                        else
  316+                                putch('\n');
  317+                }
  318+                goto fast;
300319 
 301320         case '#':
 302321                 if (wasnl) {
 303322                         wasnl = 0;
 304323                         rval = CONTROL;
 305324                         break;
 306325                 }
<> 326+                if (!slow) {
  327+                        putch('#');
  328+                        goto fast;
  329+                }
307330                 *yyp++ = c;
 308331                 c = input();
 309332                 if (c == '#') {
     
 !
390413         default:
 391414                 if (isalpha(c) || c == '_')
 392415                         goto gotid;
<> 416+                if (!slow && c > 5) {
  417+                        putch(c);
  418+                        goto fast;
  419+                }
393420                 yystr[0] = c; yystr[1] = 0;
 394421                 rval = c;
 395422                 break;
 396423         }
 397424         return rval;
 398425 }
 399426 
<>400 -#ifdef NEWBUF
401427 /*
 402428  * A new file included.
 403429  * If ifiles == NULL, this is the first file and already opened (stdin).
     
 !
413439         ic = &ibuf;
 414440         old = ifiles;
 415441 
<> 442+        slow = 0;
416443         if (file != NULL) {
 417444                 if ((ic->infil = open(file, O_RDONLY)) < 0)
 418445                         return -1;
     
 !
437464         close(ic->infil);
 438465         return 0;
 439466 }
<>440 -#else
441467 
 442468 /*
<>443 - * A new file included.
 444 - * If ifiles == NULL, this is the first file and already opened (stdin).
 445 - * Return 0 on success, -1 on failure to open file.
 446 - */
 447 -int
 448 -pushfile(char *file)
 449 -{
 450 -        struct includ *ic;
 451 -
 452 -        ic = malloc(sizeof(struct includ));
 453 -        ic->fname = strdup(file);
 454 -        if (ifiles != NULL) {
 455 -                if ((ic->ifil = fopen(file, "r")) == NULL)
 456 -                        return -1;
 457 -        } else
 458 -                ic->ifil = stdin;
 459 -        ic->next = ifiles;
 460 -        ifiles = ic;
 461 -        ic->lineno = 0;
 462 -        unput('\n');
 463 -
 464 -        return 0;
 465 -}
 466 -
 467 -/*
 468 - * End of included file (or everything).
 469 - */
 470 -void
 471 -popfile()
 472 -{
 473 -        struct includ *ic;
 474 -
 475 -        ic = ifiles;
 476 -        ifiles = ifiles->next;
 477 -        fclose(ic->ifil);
 478 -        free(ic->fname);
 479 -        free(ic);
 480 -        prtline();
 481 -}
 482 -#endif
 483 -
 484 -/*
485469  * Print current position to output file.
 486470  */
 487471 void
     
 !
498482         unput(c);
 499483 }
 500484 
<>501 -#ifndef NEWBUF
 502 -int
 503 -yywrap()
 504 -{
 505 -        if (ifiles->next == 0)
 506 -                return 1;
 507 -        popfile();
 508 -        return 0;
 509 -}
 510 -#endif
 511 -
<_512485 void
 513486 setline(int line)
 514487 {
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-30 00:10 +0200