diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-06-28 10:01:50 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-06-28 10:01:50 -0300 |
commit | f7720bebe31f3523ef91a68fde5a1e3ff1768be9 (patch) | |
tree | 72f857b5ec3014b142fe99e411c219cf80b7db4a | |
parent | 69cc0a12fe54c1ecf69b2c7db3f5d8ea7d530dca (diff) | |
download | lua-f7720bebe31f3523ef91a68fde5a1e3ff1768be9.tar.gz lua-f7720bebe31f3523ef91a68fde5a1e3ff1768be9.tar.bz2 lua-f7720bebe31f3523ef91a68fde5a1e3ff1768be9.zip |
more precise way to check incomplete lines
-rw-r--r-- | lua.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -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 | ||
150 | static int incomplete (lua_State *L, int status) { | 150 | static 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 | ||