diff options
| author | Warner Losh <imp@FreeBSD.org> | 2025-08-23 10:56:08 -0600 |
|---|---|---|
| committer | Warner Losh <imp@FreeBSD.org> | 2025-08-23 10:56:08 -0600 |
| commit | 4d63aec3c3805e2b8d91d2622752c525be755c17 (patch) | |
| tree | 4a692e746d81ca00749975969d477c0a5a1d770c /src/lua.c | |
| parent | 82a9c706179ee449d17fe66787bc27182143ddd5 (diff) | |
lua: Import Lua 5.4.8vendor/lua/5.4.8vendor/lua
Diffstat (limited to 'src/lua.c')
| -rw-r--r-- | src/lua.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/lua.c b/src/lua.c index 6da331f11867..4a90e55dd94b 100644 --- a/src/lua.c +++ b/src/lua.c @@ -490,10 +490,8 @@ static int incomplete (lua_State *L, int status) { if (status == LUA_ERRSYNTAX) { size_t lmsg; const char *msg = lua_tolstring(L, -1, &lmsg); - if (lmsg >= marklen && strcmp(msg + lmsg - marklen, EOFMARK) == 0) { - lua_pop(L, 1); + if (lmsg >= marklen && strcmp(msg + lmsg - marklen, EOFMARK) == 0) return 1; - } } return 0; /* else... */ } @@ -508,9 +506,9 @@ static int pushline (lua_State *L, int firstline) { size_t l; const char *prmt = get_prompt(L, firstline); int readstatus = lua_readline(L, b, prmt); - if (readstatus == 0) - return 0; /* no input (prompt will be popped by caller) */ lua_pop(L, 1); /* remove prompt */ + if (readstatus == 0) + return 0; /* no input */ l = strlen(b); if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ b[--l] = '\0'; /* remove it */ @@ -552,8 +550,9 @@ static int multiline (lua_State *L) { int status = luaL_loadbuffer(L, line, len, "=stdin"); /* try it */ if (!incomplete(L, status) || !pushline(L, 0)) { lua_saveline(L, line); /* keep history */ - return status; /* cannot or should not try to add continuation line */ + return status; /* should not or cannot try to add continuation line */ } + lua_remove(L, -2); /* remove error message (from incomplete line) */ lua_pushliteral(L, "\n"); /* add newline... */ lua_insert(L, -2); /* ...between the two lines */ lua_concat(L, 3); /* join them */ |
