summaryrefslogtreecommitdiff
path: root/lua.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2006-06-23 13:09:15 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2006-06-23 13:09:15 -0300
commit74832b2a1005f480963324b5464e20e16fc73ceb (patch)
tree9cca87bc045f28b187ffda19ee1c5610f9e34c02 /lua.c
parentee41bc03ab0af1b1d0c4a90e172b05cda3dac38f (diff)
downloadlua-74832b2a1005f480963324b5464e20e16fc73ceb.tar.gz
lua-74832b2a1005f480963324b5464e20e16fc73ceb.tar.bz2
lua-74832b2a1005f480963324b5464e20e16fc73ceb.zip
detail
Diffstat (limited to 'lua.c')
-rw-r--r--lua.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lua.c b/lua.c
index b8cf32ed..5c0ae9c5 100644
--- a/lua.c
+++ b/lua.c
@@ -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
161static int incomplete (lua_State *L, int status) { 164static 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 }