more precise way to check incomplete lines

This commit is contained in:
Roberto Ierusalimschy 2005-06-28 10:01:50 -03:00
parent 69cc0a12fe
commit f7720bebe3
1 changed files with 10 additions and 7 deletions

17
lua.c
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lua.c,v 1.144 2005/05/17 19:49:15 roberto Exp roberto $ ** $Id: lua.c,v 1.145 2005/06/03 20:16:16 roberto Exp roberto $
** Lua stand-alone interpreter ** Lua stand-alone interpreter
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -148,13 +148,16 @@ static const char *get_prompt (lua_State *L, int firstline) {
static int incomplete (lua_State *L, int status) { static int incomplete (lua_State *L, int status) {
if (status == LUA_ERRSYNTAX && if (status == LUA_ERRSYNTAX) {
strstr(lua_tostring(L, -1), LUA_QL("<eof>")) != NULL) { size_t lmsg;
lua_pop(L, 1); const char *msg = lua_tolstring(L, -1, &lmsg);
return 1; const char *tp = msg + lmsg - (sizeof(LUA_QL("<eof>")) - 1);
if (strstr(msg, LUA_QL("<eof>")) == tp) {
lua_pop(L, 1);
return 1;
}
} }
else return 0; /* else... */
return 0;
} }