Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.96
 
1.97
 
MAIN:plunky:20121031115454
 
token.c
_>4141  */
 4242 
 4343 #include "config.h"
 4444 
 4545 #include <stdlib.h>
 4646 #include <string.h>
<>47 -#include <ctype.h>
4847 #ifdef HAVE_UNISTD_H
 4948 #include <unistd.h>
 5049 #endif
 5150 #include <fcntl.h>
 5251 
 5352 #include "compat.h"
     
 !
7978 #define NXTCH() (ifiles->curptr < ifiles->maxread ? *ifiles->curptr++ : inpch())
 8079 
 8180 usch yytext[CPPBUF];
 8281 
 8382 struct includ *ifiles;
 8483 
<>85 -char spechr[256] = {
  84+/* some common special combos for init */
  85+#define C_NL    (C_SPEC|C_WSNL)
  86+#define C_DX    (C_SPEC|C_ID|C_DIGIT|C_HEX)
  87+#define C_I     (C_SPEC|C_ID|C_ID0)
  88+#define C_IP    (C_SPEC|C_ID|C_ID0|C_EP)
  89+#define C_IX    (C_SPEC|C_ID|C_ID0|C_HEX)
  90+#define C_IXE   (C_SPEC|C_ID|C_ID0|C_HEX|C_EP)
  91+
  92+usch spechr[256] = {
8693         0,      0,      0,      0,      C_SPECC_SPEC0,      0,
<>87 -        0,      C_WSNLC_SPEC|C_WSNL,  0,
 88 -        0,      C_WSNL0,      0,
  94+        0,      C_WSNLC_NL,   0,      0,      C_WSNL0,      0,
8995         0,      0,      0,      0,      0,      0,      0,      0,
 9096         0,      0,      0,      0,      0,      0,      0,      0,
 9197 
 9298         C_WSNLC_2,    C_SPEC0,      0,      0,      C_2,    C_SPEC,
 9399         0,      0,      0,      C_2,    0,      C_2,    0,      C_SPEC|C_2,
<>94 -        C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,
 95 -        C_I,    C_I,    0,      0,      C_2,    C_2,    C_2,    C_SPEC,
  100+        C_DX,   C_DX,   C_DX,   C_DX,   C_DX,   C_DX,   C_DX,   C_DX,
  101+        C_DX,   C_DX,   0,      0,      C_2,    C_2,    C_2,    C_SPEC,
96102 
<>97 -        0,      C_I,    C_I,    C_I,    C_I,    C_I|C_EP, C_I,  C_I,
  103+        0,      C_IX,   C_IX,   C_IX,   C_IX,   C_IXE,  C_IX,   C_I,
98104         C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,
<>99 -        C_I|C_EP, C_I,  C_I,    C_I,    C_I,    C_I,    C_I,    C_I,
  105+        C_IP,   C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,
100106         C_I,    C_I,    C_I,    0,      C_SPEC0,      0,      C_I,
 101107 
<>102 -        0,      C_I,    C_I,    C_I,    C_I,    C_I|C_EP, C_I,  C_I,
  108+        0,      C_IX,   C_IX,   C_IX,   C_IX,   C_IXE,  C_IX,   C_I,
103109         C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,
<>104 -        C_I|C_EP, C_I,  C_I,    C_I,    C_I,    C_I,    C_I,    C_I,
  110+        C_IP,   C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,
105111         C_I,    C_I,    C_I,    0,      C_2,    0,      0,      0,
<>106 -
107112 };
 108113 
 109114 static void
 110115 unch(int c)
 111116 {
 112117         if (c == -1)
     
 !
520525                 ch = '/';
 521526                 goto any;
 522527 
 523528         case '.':
 524529                 if ((ch = inch()) == -1)
 525530                         return 0;
<>526 -                if (isdigit(ch)) {
  531+                if ((spechr[ch] & C_DIGIT)) {
527532                         yytext[yyp++] = (usch)ch;
 528533                         goto ppnum;
 529534                 } else {
 530535                         unch(ch);
 531536                         ch = '.';
 532537                 }
     
 !
576581         case '_': /* {L}({L}|{D})* */
 577582 
 578583                 /* Special hacks */
 579584                 for (;;) { /* get chars */
 580585                         if ((ch = inch()) == -1)
 581586                                 break;
<>582 -                        if (isalpha(ch) || isdigit(ch) || ch == '_') {
  587+                        if ((spechr[ch] & C_ID)) {
583588                                 yytext[yyp++] = (usch)ch;
 584589                         } else {
 585590                                 unch(ch);
 586591                                 break;
 587592                         }
 588593                 }
     
 !
605610         static int ifdef, noex;
 606611         struct symtab *nl;
 607612         int ch, c2;
 608613 
 609614         while ((ch = sloscan()) == WSPACE)
 610615                 ;
<>611 -        if (ch < 128 && spechr[ch] & C_2)
  616+        if (ch < 128 && (spechr[ch] & C_2))
612617                 c2 = inpch();
 613618         else
 614619                 c2 = 0;
 615620 
<>616 -#define C2(a,b,c) case a: if (c2 == b) return c; break
617621         switch (ch) {
<>618 -        C2('=', '=', EQ);
 619 -        C2('!', '=', NE);
 620 -        C2('|', '|', OROR);
 621 -        C2('&', '&', ANDAND);
  622+        case '=':
  623+                if (c2 == '=') return EQ;
  624+                break;
  625+        case '!':
  626+                if (c2 == '=') return NE;
  627+                break;
  628+        case '|':
  629+                if (c2 == '|') return OROR;
  630+                break;
  631+        case '&':
  632+                if (c2 == '&') return ANDAND;
  633+                break;
622634         case '<':
 623635                 if (c2 == '<') return LS;
 624636                 if (c2 == '=') return LE;
 625637                 break;
 626638         case '>':
 627639                 if (c2 == '>') return RS;
     
 !
910922         usch *y = yytext;
 911923         int c;
 912924 
 913925         c = *y++;
 914926         if (rad == 16)
 915927                 y++;
<>916 -        while (isxdigit(c)) {
  928+        while ((spechr[c] & C_HEX)) {
917929                 rv = rv * rad + dig2num(c);
 918930                 /* check overflow */
 919931                 if (rv / rad < rv2)
 920932                         error("Constant \"%s\" is out of range", yytext);
 921933                 rv2 = rv;
 922934                 c = *y++;
     
 !
950962                 case 't': val = '\t'; break;
 951963                 case 'v': val = '\v'; break;
 952964                 case '\"': val = '\"'; break;
 953965                 case '\'': val = '\''; break;
 954966                 case '\\': val = '\\'; break;
 955967                 case 'x':
<>956 -                        while (isxdigit(c = *p)) {
  968+                        while ((spechr[c = *p] & C_HEX)) {
957969                                 val = val * 16 + dig2num(c);
 958970                                 p++;
 959971                         }
 960972                         break;
 961973                 case '0': case '1': case '2': case '3': case '4':
 962974                 case '5': case '6': case '7':
 963975                         p--;
<>964 -                        while (isdigit(c = *p)) {
  976+                        while ((spechr[c = *p] & C_DIGIT)) {
<_965977                                 val = val * 8 + (c - '0');
 966978                                 p++;
 967979                         }
 968980                         break;
 969981                 default: val = p[-1];
 970982                 }
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-31 22:35 +0100