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 eof;
int peekc;
char ctab[128];
const char* ctab;
struct hshtab *bsym;
struct hshtab *paraml, *parame;
int cval;

View file

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