Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.1
 
1.2
 
MAIN:ragge:20050319093405
 
token.c
_>2929 #include <stdlib.h>
 3030 #include <string.h>
 3131 #include <ctype.h>
<> 32+#include <unistd.h>
  33+#include <fcntl.h>
3234 
 3335 #include "cpp.h"
 3436 
     
 !
3739         struct includ *next;
 3840         char *fname;
 3941         int lineno;
<> 42+#ifdef NEWBUF
  43+        int infil;
  44+        usch *inpbuf;
  45+        usch *curptr;
  46+        int curlen;
  47+#else
4048         FILE *ifil;
<> 49+#endif
4150 } *ifiles;
 4251 
 4352 usch *yyp, yystr[CPPBUF];
<> 53+#if 0
  54+usch inpbuf[NAMEMAX+CPPBUF], *curimp, *imptop;
  55+#endif
4456 
 4557 int yylex(void);
<>46 -int nyylex(void);
4758 int yywrap(void);
<>48 -#if 0
4959 
<>50 -"\n"                    { return nyylex(); }
 51 -.                       { return nyylex(); }
  60+#ifdef NEWBUF
  61+static int
  62+input(void)
  63+{
  64+        if (ifiles->curptr < ifiles->inpbuf+ifiles->curlen)
  65+                return *ifiles->curptr++;
  66+        if ((ifiles->curlen = read(ifiles->infil, ifiles->inpbuf, CPPBUF)) < 0)
  67+                error("read error on file %s", ifiles->fname);
  68+        ifiles->curptr = ifiles->inpbuf;
  69+        return input();
  70+}
5271 
<>53 -#endif
 54 -
  72+static void
  73+unput(int c)
  74+{
  75+        if (ifiles->curptr > ifiles->inpbuf)
  76+                *--ifiles->curptr = c;
  77+        else
  78+                error("out of pushback space");
  79+}
  80+#else
5581 #define input() fgetc(ifiles->ifil)
 5682 #define unput(c) ungetc(c, ifiles->ifil)
<> 83+#endif
5784 static int
 5885 slofgetc(void)
 5986 {
     
 !
95122         }
 96123 }
 97124 
<>98 -int yylex() { return nyylex(); }
 99 -
100125 int
<>101 -nyylex()
  126+yylex()
102127 {
 103128         static int wasnl = 1;
 104129         int c, oc, rval;
     
 !
110135 #define ONEMORE()       { *yyp++ = c; c = slofgetc(); }
 111136 again:  switch (c) {
 112137         case -1:
<>113 -                rval = yywrap() ? 0 : nyylex();
  138+                rval = yywrap() ? 0 : yylex();
114139                 break;
 115140 
 116141         case '\'': /* charcon */
     
 !
277302                         if (Cflag)
 278303                                 putc(c, obuf);
 279304                         if (tflag) {
<>280 -                                rval = nyylex();
  305+                                rval = yylex();
281306                         } else {
 282307                                 *yyp++ = ' '; *yyp = 0;
 283308                                 rval = WSPACE;
     
 !
326351         ic->fname = strdup(file);
 327352         ic->lineno = 1;
 328353         if (ifiles != NULL) {
<> 354+#ifdef NEWBUF
  355+                if ((ic->infil = open(file, O_RDONLY)) < 0)
  356+                        return -1;
  357+#else
329358                 if ((ic->ifil = fopen(file, "r")) == NULL)
 330359                         return -1;
<> 360+#endif
331361         } else
<> 362+#ifdef NEWBUF
  363+                ic->infil = 0;
  364+#else
332365                 ic->ifil = stdin;
<> 366+#endif
  367+#ifdef NEWBUF
  368+        ic->curptr = ic->inpbuf = malloc(CPPBUF);
  369+#endif
333370         ic->next = ifiles;
 334371         ifiles = ic;
 335372 
     
 !
346383 
 347384         ic = ifiles;
 348385         ifiles = ifiles->next;
<> 386+#ifdef NEWBUF
  387+        close(ic->infil);
  388+#else
349389         fclose(ic->ifil);
<> 390+#endif
<_350391         free(ic->fname);
 351392         free(ic);
 352393         prtline();
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-22 22:24 +0100