lua

A copy of the Lua development repository
Log | Files | Refs | README

commit f7720bebe31f3523ef91a68fde5a1e3ff1768be9
parent 69cc0a12fe54c1ecf69b2c7db3f5d8ea7d530dca
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Tue, 28 Jun 2005 10:01:28 -0300

more precise way to check incomplete lines

Diffstat:
Mlua.c | 17++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/lua.c b/lua.c @@ -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 ** 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) { - if (status == LUA_ERRSYNTAX && - strstr(lua_tostring(L, -1), LUA_QL("<eof>")) != NULL) { - lua_pop(L, 1); - return 1; + if (status == LUA_ERRSYNTAX) { + size_t lmsg; + const char *msg = lua_tolstring(L, -1, &lmsg); + 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; + return 0; /* else... */ }