Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.113
 
1.114
 
MAIN:plunky:20140528202054
 
token.c
_>4848 #include <unistd.h>
 4949 #endif
 5050 #include <fcntl.h>
<>51 -#include <ctype.h>
5251 
 5352 #include "compat.h"
<>54 -#include "unicode.h"
5553 #include "cpp.h"
 5654 #include "cpy.h"
 5755 
 5856 static void cvtdig(int);
<> 57+static int dig2num(int);
5958 static int charcon(usch *);
 6059 static void elsestmt(void);
 6160 static void ifdefstmt(void);
     
 !
9998         0,      C_IX,   C_IX,   C_IX,   C_IX,   C_IXE,  C_IX,   C_I,
 10099         C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,
 101100         C_IP,   C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,
<>102 -        C_I,    C_I,    C_I,    0,      0,      0,      0,      C_I,
  101+        C_I,    C_I,    C_I,    0,      C_SPEC0,      0,      C_I,
103102 
 104103         0,      C_IX,   C_IX,   C_IX,   C_IX,   C_IXE,  C_IX,   C_I,
 105104         C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,    C_I,
     
 !
234233         return 0;
 235234 }
 236235 
<>237 -static int
 238 -chkucn(void)
 239 -{
 240 -        int ch, sz;
 241 -
 242 -        ch = inpch();
 243 -        if(ch != '\\'){
 244 -                unch(ch);
 245 -                return 0;
 246 -        }
 247 -        ch = inpch();
 248 -    if (ch == 'u') {
 249 -        int i, v;
 250 -        sz=4;
 251 -ucnshort:
 252 -        for(i=0,v=0;i<sz;i++){
 253 -            ch=toupper(inpch());
 254 -            if(ch>='0' && ch<='9') v=(v<<4)+ch-'0';
 255 -            else if(ch>='A' && ch<='F') v=(v<<4)+ch-'A'+10;
 256 -            else {
 257 -                if(sz>2) warning(
 258 -                    "unicode escape %d digits too short",sz-i);
 259 -                unch(ch);
 260 -                break;
 261 -            }
 262 -        }
 263 -        char u8str[8],*p=cp2u8(u8str,v);
 264 -        while(--p>u8str) unch(*p);
 265 -        return u8str[0];
 266 -    } else if (ch == 'U') {
 267 -        sz=8;
 268 -        goto ucnshort;
 269 -    }
 270 -    unch(ch);
 271 -        unch('\\');
 272 -        return 0;
 273 -}
 274 -
275236 /*
 276237  * return next char, after converting trigraphs and
 277238  * skipping escaped line endings
     
 !
282243         int ch;
 283244 
 284245         for (;;) {
<>285 -                if((ch = chkucn())) return ch;
286246                 ch = inpch();
 287247                 if (ch == '?' && (ch = chktg()) == 0)
 288248                         return '?';
     
 !
292252         }
 293253 }
 294254 
<> 255+/*
  256+ * check for universal-character-name on input, and
  257+ * unput to the pushback buffer encoded as UTF-8.
  258+ */
295259 static int
<> 260+chkucn(void)
  261+{
  262+        unsigned long cp, m;
  263+        int ch, n;
  264+
  265+        if ((ch = inch()) == -1)
  266+                return 0;
  267+        if (ch == 'u')
  268+                n = 4;
  269+        else if (ch == 'U')
  270+                n = 8;
  271+        else {
  272+                unch(ch);
  273+                return 0;
  274+        }
  275+
  276+        cp = 0;
  277+        while (n-- > 0) {
  278+                if ((ch = inch()) == -1 || (spechr[ch] & C_HEX) == 0) {
  279+                        warning("invalid universal character name");
  280+                        // XXX should actually unput the chars and return 0
  281+                        unch(ch); // XXX eof
  282+                        break;
  283+                }
  284+                cp = cp * 16 + dig2num(ch);
  285+        }
  286+
  287+        if (cp > 0x7fffffff)
  288+                error("universal character name out of range");
  289+
  290+        n = 0;
  291+        m = 0x7f;
  292+        while (cp > m) {
  293+                unch(0x80 | (cp & 0x3f));
  294+                cp >>= 6;
  295+                m >>= (n++ ? 1 : 2);
  296+        }
  297+        unch(((m << 1) ^ 0xfe) | cp);
  298+        return 1;
  299+}
  300+
  301+static int
296302 eatcmnt(void)
 297303 {
 298304         int ch;
     
 !
424430 str:                    PUTCH(ch);
 425431                         while ((ch = inch()) != '\"') {
 426432                                 if (ch == '\\') {
<> 433+                                        if (chkucn())
  434+                                                continue;
427435                                         PUTCH('\\');
 428436                                         ch = inch();
 429437                                 }
     
 !
469477                                 break; /* character constants ignored */
 470478                         while ((ch = inch()) != '\'') {
 471479                                 if (ch == '\\') {
<> 480+                                        if (chkucn())
  481+                                                continue;
472482                                         PUTCH('\\');
 473483                                         ch = inch();
 474484                                 }
     
 !
502512                         if ((spechr[ch] & C_ID) == 0)
 503513                                 error("fastscan");
 504514 #endif
<> 515+                ident:
505516                         i = 0;
<>506 -                        do {
  517+                        yytext[i++] = (usch)ch;
  518+                        for (;;) {
  519+                                if ((ch = inch()) == -1)
  520+                                        break;
  521+                                if (ch == '\\') {
  522+                                        if (chkucn())
  523+                                                continue;
  524+                                        unch(ch);
  525+                                        break;
  526+                                }
  527+                                if ((spechr[ch] & C_ID) == 0) {
  528+                                        unch(ch);
  529+                                        break;
  530+                                }
507531                                 yytext[i++] = (usch)ch;
<>508 -                                ch = inch();
 509 -                        } while (ch != -1 && (spechr[ch] & C_ID));
 510 -
  532+                        }
511533                         yytext[i] = 0;
<>512 -                        unch(ch);
513534 
 514535                         if (flslvl == 0) {
 515536                                 cp = stringbuf;
     
 !
523544                                 goto eof;
 524545 
 525546                         break;
<> 547+
  548+                case '\\':
  549+                        if (chkucn()) {
  550+                                ch = inch();
  551+                                goto ident;
  552+                        }
  553+
  554+                        PUTCH('\\');
  555+                        break;
526556                 }
 527557         }
 528558 
     
 !
582612 chlit:
 583613                 for (;;) {
 584614                         if ((ch = inch()) == '\\') {
<> 615+                                if (chkucn())
  616+                                        continue;
585617                                 yytext[yyp++] = (usch)ch;
 586618                                 ch = inch();
 587619                         } else if (ch == '\'')
     
 !
668700         strng:
 669701                 for (;;) {
 670702                         if ((ch = inch()) == '\\') {
<> 703+                                if (chkucn())
  704+                                        continue;
671705                                 yytext[yyp++] = (usch)ch;
 672706                                 ch = inch();
 673707                         } else if (ch == '\"') {
     
 !
684718                 yytext[yyp] = 0;
 685719                 return STRING;
 686720 
<> 721+        case '\\':
  722+                if (chkucn()) {
  723+                        --yyp;
  724+                        goto ident;
  725+                }
  726+                goto any;
  727+
687728         case 'L':
 688729                 if ((ch = inch()) == '\"' && !tflag) {
 689730                         yytext[yyp++] = (usch)ch;
     
 !
708749         case 'Y': case 'Z':
 709750         case '_': /* {L}({L}|{D})* */
 710751 
<>711 -                /* Special hacks */
 712 -        hacks:
  752+        ident:
713753                 for (;;) { /* get chars */
 714754                         if ((ch = inch()) == -1)
 715755                                 break;
<>716 -                        if ((spechr[ch] & C_ID)) {
 717 -                                yytext[yyp++] = (usch)ch;
 718 -                        } else {
  756+                        if (ch == '\\') {
  757+                                if (chkucn())
  758+                                        continue;
  759+                                unch('\\');
  760+                                break;
  761+                        }
  762+                        if ((spechr[ch] & C_ID) == 0) {
719763                                 unch(ch);
 720764                                 break;
 721765                         }
<> 766+                        yytext[yyp++] = (usch)ch;
722767                 }
 723768                 yytext[yyp] = 0; /* need already string */
<>724 -                /* end special hacks */
725769                 return IDENT;
 726770 
 727771         default:
<>728 -                if ((ch&0x80)) goto hacks;
  772+                if ((ch & 0x80))
  773+                        goto ident;
  774+
<_729775         any:
 730776                 yytext[yyp] = 0;
 731777                 return yytext[0];
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-20 23:19 +0100