tighter size for error buffers
This commit is contained in:
7
llex.c
7
llex.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: llex.c,v 1.71 2000/09/27 17:41:58 roberto Exp roberto $
|
** $Id: llex.c,v 1.72 2000/10/20 16:39:03 roberto Exp roberto $
|
||||||
** Lexical Analyzer
|
** Lexical Analyzer
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -38,6 +38,7 @@ void luaX_init (lua_State *L) {
|
|||||||
int i;
|
int i;
|
||||||
for (i=0; i<NUM_RESERVED; i++) {
|
for (i=0; i<NUM_RESERVED; i++) {
|
||||||
TString *ts = luaS_new(L, token2string[i]);
|
TString *ts = luaS_new(L, token2string[i]);
|
||||||
|
LUA_ASSERT(strlen(token2string[i])+1 <= TOKEN_LEN, "incorrect token_len");
|
||||||
ts->marked = (unsigned char)(RESERVEDMARK+i); /* reserved word */
|
ts->marked = (unsigned char)(RESERVEDMARK+i); /* reserved word */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,8 +49,8 @@ void luaX_init (lua_State *L) {
|
|||||||
|
|
||||||
void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) {
|
void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) {
|
||||||
if (val > limit) {
|
if (val > limit) {
|
||||||
char buff[100];
|
char buff[90];
|
||||||
sprintf(buff, "too many %.50s (limit=%d)", msg, limit);
|
sprintf(buff, "too many %.40s (limit=%d)", msg, limit);
|
||||||
luaX_error(ls, buff, ls->t.token);
|
luaX_error(ls, buff, ls->t.token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
6
llex.h
6
llex.h
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: llex.h,v 1.31 2000/09/27 17:41:58 roberto Exp roberto $
|
** $Id: llex.h,v 1.32 2000/12/04 18:33:40 roberto Exp roberto $
|
||||||
** Lexical Analyzer
|
** Lexical Analyzer
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
#define FIRST_RESERVED 257
|
#define FIRST_RESERVED 257
|
||||||
|
|
||||||
/* maximum length of a reserved word (+1 for final 0) */
|
/* maximum length of a reserved word */
|
||||||
#define TOKEN_LEN 15
|
#define TOKEN_LEN (sizeof("function"))
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
10
lparser.c
10
lparser.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lparser.c,v 1.120 2000/12/26 18:46:09 roberto Exp roberto $
|
** $Id: lparser.c,v 1.121 2000/12/28 12:55:41 roberto Exp roberto $
|
||||||
** LL(1) Parser and code generator for Lua
|
** LL(1) Parser and code generator for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -71,9 +71,9 @@ static void lookahead (LexState *ls) {
|
|||||||
|
|
||||||
|
|
||||||
static void error_expected (LexState *ls, int token) {
|
static void error_expected (LexState *ls, int token) {
|
||||||
char buff[100], t[TOKEN_LEN];
|
char buff[30], t[TOKEN_LEN];
|
||||||
luaX_token2str(token, t);
|
luaX_token2str(token, t);
|
||||||
sprintf(buff, "`%.20s' expected", t);
|
sprintf(buff, "`%.10s' expected", t);
|
||||||
luaK_error(ls, buff);
|
luaK_error(ls, buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,11 +104,11 @@ static void check_match (LexState *ls, int what, int who, int where) {
|
|||||||
if (where == ls->linenumber)
|
if (where == ls->linenumber)
|
||||||
error_expected(ls, what);
|
error_expected(ls, what);
|
||||||
else {
|
else {
|
||||||
char buff[100];
|
char buff[70];
|
||||||
char t_what[TOKEN_LEN], t_who[TOKEN_LEN];
|
char t_what[TOKEN_LEN], t_who[TOKEN_LEN];
|
||||||
luaX_token2str(what, t_what);
|
luaX_token2str(what, t_what);
|
||||||
luaX_token2str(who, t_who);
|
luaX_token2str(who, t_who);
|
||||||
sprintf(buff, "`%.20s' expected (to close `%.20s' at line %d)",
|
sprintf(buff, "`%.10s' expected (to close `%.10s' at line %d)",
|
||||||
t_what, t_who, where);
|
t_what, t_who, where);
|
||||||
luaK_error(ls, buff);
|
luaK_error(ls, buff);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user