aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-06-28 10:01:50 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-06-28 10:01:50 -0300
commitf7720bebe31f3523ef91a68fde5a1e3ff1768be9 (patch)
tree72f857b5ec3014b142fe99e411c219cf80b7db4a
parent69cc0a12fe54c1ecf69b2c7db3f5d8ea7d530dca (diff)
downloadlua-f7720bebe31f3523ef91a68fde5a1e3ff1768be9.tar.gz
lua-f7720bebe31f3523ef91a68fde5a1e3ff1768be9.tar.bz2
lua-f7720bebe31f3523ef91a68fde5a1e3ff1768be9.zip
more precise way to check incomplete lines
-rw-r--r--lua.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/lua.c b/lua.c
index 8d2671a0..b25e1c1f 100644
--- a/lua.c
+++ b/lua.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.c,v 1.144 2005/05/17 19:49:15 roberto Exp roberto $ 2** $Id: lua.c,v 1.145 2005/06/03 20:16:16 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*/
@@ -148,13 +148,16 @@ static const char *get_prompt (lua_State *L, int firstline) {
148 148
149 149
150static int incomplete (lua_State *L, int status) { 150static int incomplete (lua_State *L, int status) {
151 if (status == LUA_ERRSYNTAX && 151 if (status == LUA_ERRSYNTAX) {
152 strstr(lua_tostring(L, -1), LUA_QL("<eof>")) != NULL) { 152 size_t lmsg;
153 lua_pop(L, 1); 153 const char *msg = lua_tolstring(L, -1, &lmsg);
154 return 1; 154 const char *tp = msg + lmsg - (sizeof(LUA_QL("<eof>")) - 1);
155 if (strstr(msg, LUA_QL("<eof>")) == tp) {
156 lua_pop(L, 1);
157 return 1;
158 }
155 } 159 }
156 else 160 return 0; /* else... */
157 return 0;
158} 161}
159 162
160 163