Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.2
 
1.3
 
MAIN:ragge:20050320162112
 
token.c
_>4141         int lineno;
 4242 #ifdef NEWBUF
 4343         int infil;
<>44 -        usch *inpbuf;
4544         usch *curptr;
 4645         int curlen;
<> 46+        usch *ostr;
  47+        usch buffer[CPPBUF];
4748 #else
 4849         FILE *ifil;
 4950 #endif
<>50 -} *ifiles;
  51+} *ifiles, *freebufs;
5152 
 5253 usch *yyp, yystr[CPPBUF];
<>53 -#if 0
 54 -usch inpbuf[NAMEMAX+CPPBUF], *curimp, *imptop;
 55 -#endif
5654 
 5755 int yylex(void);
 5856 int yywrap(void);
 5957 
 6058 #ifdef NEWBUF
<> 59+static struct includ *
  60+getbuf(usch *file)
  61+{
  62+        struct includ *ic;
  63+
  64+        if (freebufs) {
  65+                /* Have buffer for use already */
  66+                ic = freebufs;
  67+                freebufs = freebufs->next;
  68+                ic->ostr = NULL;
  69+        } else {
  70+                stringbuf = (usch *)ROUND((int)stringbuf);
  71+                ic = (struct includ *)stringbuf;
  72+                stringbuf += sizeof(struct includ);
  73+                ic->ostr = stringbuf;
  74+        }
  75+        if (file) {
  76+                ic->fname = savstr(file); /* XXX - will loose space */
  77+                savch('\0');
  78+        }
  79+        if (ic->ostr)
  80+                ic->ostr = stringbuf;
  81+        return ic;
  82+}
  83+
  84+static void
  85+putbuf(struct includ *ic)
  86+{
  87+        if (ic->ostr == stringbuf) {
  88+                /* no new macros, free this buffer */
  89+                stringbuf = (usch *)ic;
  90+        } else {
  91+                ic->next = freebufs;
  92+                freebufs = ic;
  93+        }
  94+}
  95+
6196 static int
 6297 input(void)
 6398 {
<>64 -        if (ifiles->curptr < ifiles->inpbuf+ifiles->curlen)
  99+        struct includ *ic;
  100+
  101+        if (ifiles->curptr < ifiles->buffer+ifiles->curlen)
65102                 return *ifiles->curptr++;
<>66 -        if ((ifiles->curlen = read(ifiles->infil, ifiles->inpbuf, CPPBUF)) < 0)
  103+        if (ifiles->infil < 0) {
  104+                ic = ifiles;
  105+                ifiles = ifiles->next;
  106+                putbuf(ic);
  107+                return input();
  108+        }
  109+        if ((ifiles->curlen = read(ifiles->infil, ifiles->buffer, CPPBUF)) < 0)
67110                 error("read error on file %s", ifiles->fname);
<>68 -        ifiles->curptr = ifiles->inpbuf;
  111+        if (ifiles->curlen == 0)
  112+                return -1;
  113+        ifiles->curptr = ifiles->buffer;
69114         return input();
 70115 }
 71116 
 72117 static void
 73118 unput(int c)
 74119 {
<>75 -        if (ifiles->curptr > ifiles->inpbuf)
  120+        struct includ *ic;
  121+
  122+        if (ifiles->curptr > ifiles->buffer) {
76123                 *--ifiles->curptr = c;
<>77 -        else
 78 -                error("out of pushback space");
  124+        } else {
  125+                ic = getbuf(NULL);
  126+                ic->fname = ifiles->fname;
  127+                ic->lineno = ifiles->lineno;
  128+                ic->infil = -1;
  129+                ic->curlen = CPPBUF;
  130+                ic->curptr = ic->buffer+CPPBUF;
  131+                ic->next = ifiles;
  132+                ifiles = ic;
  133+                *--ifiles->curptr = c;
  134+        }
79135 }
 80136 #else
<>81 -#define input() fgetc(ifiles->ifil)
 82 -#define unput(c) ungetc(c, ifiles->ifil)
  137+#define input() fgetc(ifiles->ifil)
  138+#define unput(c) ungetc(c, ifiles->ifil)
83139 #endif
 84140 static int
 85141 slofgetc(void)
     
 !
132188         c = input();
 133189         if (c != ' ' && c != '\t' && c != '#')
 134190                 wasnl = 0;
<>135 -#define ONEMORE()       { *yyp++ = c; c = slofgetc(); }
  191+#define ONEMORE()       { *yyp++ = c; c = slofgetc(); }
136192 again:  switch (c) {
 137193         case -1:
 138194                 rval = yywrap() ? 0 : yylex();
     
 !
347403 {
 348404         struct includ *ic;
 349405 
<> 406+#ifdef NEWBUF
  407+        ic = getbuf(file);
  408+#else
350409         ic = malloc(sizeof(struct includ));
 351410         ic->fname = strdup(file);
<> 411+#endif
352412         ic->lineno = 1;
 353413         if (ifiles != NULL) {
 354414 #ifdef NEWBUF
     
 !
365425                 ic->ifil = stdin;
 366426 #endif
 367427 #ifdef NEWBUF
<>368 -        ic->curptr = ic->inpbuf = malloc(CPPBUF);
  428+        ic->curptr = ic->buffer;
369429 #endif
 370430         ic->next = ifiles;
 371431         ifiles = ic;
     
 !
385445         ifiles = ifiles->next;
 386446 #ifdef NEWBUF
 387447         close(ic->infil);
<> 448+        putbuf(ic);
388449 #else
 389450         fclose(ic->ifil);
<>390 -#endif
391451         free(ic->fname);
 392452         free(ic);
<> 453+#endif
<_393454         prtline();
 394455 }
 395456 
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-10-01 20:24 +0200