diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-05-24 10:54:49 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-05-24 10:54:49 -0300 |
commit | ef62b340e0a6b7b18931000dcbb19c4703bfe0e8 (patch) | |
tree | d9d995116a8a686b798d1b625b06ead26f28ba58 /llex.c | |
parent | 5c2dd7a9e0a5b871a71ba66c4683cd88fe4f5aa4 (diff) | |
download | lua-ef62b340e0a6b7b18931000dcbb19c4703bfe0e8.tar.gz lua-ef62b340e0a6b7b18931000dcbb19c4703bfe0e8.tar.bz2 lua-ef62b340e0a6b7b18931000dcbb19c4703bfe0e8.zip |
code cleaner for 16 bits.
Diffstat (limited to 'llex.c')
-rw-r--r-- | llex.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llex.c,v 1.57 2000/04/12 18:57:19 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 1.58 2000/05/08 19:32:53 roberto Exp roberto $ |
3 | ** Lexical Analyzer | 3 | ** Lexical Analyzer |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -49,6 +49,16 @@ void luaX_init (lua_State *L) { | |||
49 | 49 | ||
50 | #define MAXSRC 80 | 50 | #define MAXSRC 80 |
51 | 51 | ||
52 | |||
53 | void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) { | ||
54 | if (val > limit) { | ||
55 | char buff[100]; | ||
56 | sprintf(buff, "too many %.50s (limit=%d)", msg, limit); | ||
57 | luaX_error(ls, buff, ls->token); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | |||
52 | void luaX_syntaxerror (LexState *ls, const char *s, const char *token) { | 62 | void luaX_syntaxerror (LexState *ls, const char *s, const char *token) { |
53 | char buff[MAXSRC]; | 63 | char buff[MAXSRC]; |
54 | luaL_chunkid(buff, zname(ls->z), sizeof(buff)); | 64 | luaL_chunkid(buff, zname(ls->z), sizeof(buff)); |
@@ -175,6 +185,7 @@ static void inclinenumber (lua_State *L, LexState *LS) { | |||
175 | {"debug", "nodebug", "endinput", "end", "ifnot", "if", "else", NULL}; | 185 | {"debug", "nodebug", "endinput", "end", "ifnot", "if", "else", NULL}; |
176 | next(LS); /* skip '\n' */ | 186 | next(LS); /* skip '\n' */ |
177 | ++LS->linenumber; | 187 | ++LS->linenumber; |
188 | luaX_checklimit(LS, LS->linenumber, MAX_INT, "lines in a chunk"); | ||
178 | if (LS->current == '$') { /* is a pragma? */ | 189 | if (LS->current == '$') { /* is a pragma? */ |
179 | char buff[PRAGMASIZE+1]; | 190 | char buff[PRAGMASIZE+1]; |
180 | int ifnot = 0; | 191 | int ifnot = 0; |