From ef62b340e0a6b7b18931000dcbb19c4703bfe0e8 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 24 May 2000 10:54:49 -0300 Subject: code cleaner for 16 bits. --- llex.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'llex.c') diff --git a/llex.c b/llex.c index ae498715..00a248a9 100644 --- a/llex.c +++ b/llex.c @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 1.57 2000/04/12 18:57:19 roberto Exp roberto $ +** $Id: llex.c,v 1.58 2000/05/08 19:32:53 roberto Exp roberto $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -49,6 +49,16 @@ void luaX_init (lua_State *L) { #define MAXSRC 80 + +void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) { + if (val > limit) { + char buff[100]; + sprintf(buff, "too many %.50s (limit=%d)", msg, limit); + luaX_error(ls, buff, ls->token); + } +} + + void luaX_syntaxerror (LexState *ls, const char *s, const char *token) { char buff[MAXSRC]; luaL_chunkid(buff, zname(ls->z), sizeof(buff)); @@ -175,6 +185,7 @@ static void inclinenumber (lua_State *L, LexState *LS) { {"debug", "nodebug", "endinput", "end", "ifnot", "if", "else", NULL}; next(LS); /* skip '\n' */ ++LS->linenumber; + luaX_checklimit(LS, LS->linenumber, MAX_INT, "lines in a chunk"); if (LS->current == '$') { /* is a pragma? */ char buff[PRAGMASIZE+1]; int ifnot = 0; -- cgit v1.2.3-55-g6feb