fix isidnum_table for CH_EOF (-1)

This commit is contained in:
grischka 2008-05-10 06:07:55 +02:00
parent 1300cec38c
commit 2c6cd08bcc

10
tcc.c
View File

@ -398,7 +398,7 @@ static SValue vstack[VSTACK_SIZE], *vtop;
/* some predefined types */ /* some predefined types */
static CType char_pointer_type, func_old_type, int_type; static CType char_pointer_type, func_old_type, int_type;
/* true if isid(c) || isnum(c) */ /* true if isid(c) || isnum(c) */
static unsigned char isidnum_table[256]; static unsigned char isidnum_table[256-CH_EOF];
/* display some information during compilation */ /* display some information during compilation */
static int verbose = 0; static int verbose = 0;
@ -3772,7 +3772,7 @@ static inline void next_nomacro1(void)
p++; p++;
for(;;) { for(;;) {
c = *p; c = *p;
if (!isidnum_table[c]) if (!isidnum_table[c-CH_EOF])
break; break;
h = TOK_HASH_FUNC(h, c); h = TOK_HASH_FUNC(h, c);
p++; p++;
@ -3807,7 +3807,7 @@ static inline void next_nomacro1(void)
p--; p--;
PEEKC(c, p); PEEKC(c, p);
parse_ident_slow: parse_ident_slow:
while (isidnum_table[c]) { while (isidnum_table[c-CH_EOF]) {
cstr_ccat(&tokcstr, c); cstr_ccat(&tokcstr, c);
PEEKC(c, p); PEEKC(c, p);
} }
@ -10114,8 +10114,8 @@ TCCState *tcc_new(void)
s->output_type = TCC_OUTPUT_MEMORY; s->output_type = TCC_OUTPUT_MEMORY;
/* init isid table */ /* init isid table */
for(i=0;i<256;i++) for(i=CH_EOF;i<256;i++)
isidnum_table[i] = isid(i) || isnum(i); isidnum_table[i-CH_EOF] = isid(i) || isnum(i);
/* add all tokens */ /* add all tokens */
table_ident = NULL; table_ident = NULL;