Fix table underrun when looking up the character class of the EOF character,

-1.
This commit is contained in:
David Given 2018-06-10 17:52:45 +09:00
parent b94199aba7
commit 003799f898
2 changed files with 4 additions and 2 deletions

View file

@ -47,7 +47,7 @@ struct hshtab hshtab[HSHSIZ];
int hshused; int hshused;
int eof; int eof;
int peekc; int peekc;
char ctab[128]; const char* ctab;
struct hshtab *bsym; struct hshtab *bsym;
struct hshtab *paraml, *parame; struct hshtab *paraml, *parame;
int cval; int cval;

View file

@ -1287,7 +1287,8 @@ int opdope[] = {
000000 /* NAME */ 000000 /* NAME */
}; };
char ctab[128] = { const char ctaba[129] = {
EOFC, /* -1 */
EOFC, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, EOFC, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN,
LETTER, SPACE, NEWLN, SPACE, SPACE, UNKN, UNKN, UNKN, LETTER, SPACE, NEWLN, SPACE, SPACE, UNKN, UNKN, UNKN,
UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN,
@ -1305,6 +1306,7 @@ char ctab[128] = {
LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
LETTER, LETTER, LETTER, LBRACE, OR, RBRACE, NOT, UNKN LETTER, LETTER, LETTER, LBRACE, OR, RBRACE, NOT, UNKN
}; };
const char* ctab = &ctaba[1]; /* allows indexing with -1 */
/* debug function */ /* debug function */
void printtoken(int tok, FILE *out) void printtoken(int tok, FILE *out)