diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2006-06-23 13:09:15 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2006-06-23 13:09:15 -0300 |
commit | 74832b2a1005f480963324b5464e20e16fc73ceb (patch) | |
tree | 9cca87bc045f28b187ffda19ee1c5610f9e34c02 /lua.c | |
parent | ee41bc03ab0af1b1d0c4a90e172b05cda3dac38f (diff) | |
download | lua-74832b2a1005f480963324b5464e20e16fc73ceb.tar.gz lua-74832b2a1005f480963324b5464e20e16fc73ceb.tar.bz2 lua-74832b2a1005f480963324b5464e20e16fc73ceb.zip |
detail
Diffstat (limited to 'lua.c')
-rw-r--r-- | lua.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.159 2006/05/24 14:16:39 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.160 2006/06/02 15:34:00 roberto Exp roberto $ |
3 | ** Lua stand-alone interpreter | 3 | ** Lua stand-alone interpreter |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -157,13 +157,15 @@ static const char *get_prompt (lua_State *L, int firstline) { | |||
157 | return p; | 157 | return p; |
158 | } | 158 | } |
159 | 159 | ||
160 | /* mark in error messages for incomplete statements */ | ||
161 | #define mark LUA_QL("<eof>") | ||
162 | #define marklen (sizeof(mark) - 1) | ||
160 | 163 | ||
161 | static int incomplete (lua_State *L, int status) { | 164 | static int incomplete (lua_State *L, int status) { |
162 | if (status == LUA_ERRSYNTAX) { | 165 | if (status == LUA_ERRSYNTAX) { |
163 | size_t lmsg; | 166 | size_t lmsg; |
164 | const char *msg = lua_tolstring(L, -1, &lmsg); | 167 | const char *msg = lua_tolstring(L, -1, &lmsg); |
165 | const char *tp = msg + lmsg - (sizeof(LUA_QL("<eof>")) - 1); | 168 | if (lmsg >= marklen && strcmp(msg + lmsg - marklen, mark) == 0) { |
166 | if (strstr(msg, LUA_QL("<eof>")) == tp) { | ||
167 | lua_pop(L, 1); | 169 | lua_pop(L, 1); |
168 | return 1; | 170 | return 1; |
169 | } | 171 | } |