mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 13:52:28 +00:00
Upgrade Lua to 5.4.3 (#217)
Based on https://github.com/lua/lua/releases/tag/v5.4.3 (commit eadd8c7).
This commit is contained in:
parent
3ac6576fe5
commit
a73e808b25
41 changed files with 464 additions and 264 deletions
15
third_party/lua/lapi.c
vendored
15
third_party/lua/lapi.c
vendored
|
@ -166,7 +166,7 @@ LUA_API int lua_gettop (lua_State *L) {
|
|||
|
||||
LUA_API void lua_settop (lua_State *L, int idx) {
|
||||
CallInfo *ci;
|
||||
StkId func;
|
||||
StkId func, newtop;
|
||||
ptrdiff_t diff; /* difference for new top */
|
||||
lua_lock(L);
|
||||
ci = L->ci;
|
||||
|
@ -181,12 +181,13 @@ LUA_API void lua_settop (lua_State *L, int idx) {
|
|||
api_check(L, -(idx+1) <= (L->top - (func + 1)), "invalid new top");
|
||||
diff = idx + 1; /* will "subtract" index (as it is negative) */
|
||||
}
|
||||
#if defined(LUA_COMPAT_5_4_0)
|
||||
if (diff < 0 && hastocloseCfunc(ci->nresults))
|
||||
luaF_close(L, L->top + diff, CLOSEKTOP, 0);
|
||||
#endif
|
||||
api_check(L, L->tbclist < L->top + diff, "cannot pop an unclosed slot");
|
||||
L->top += diff;
|
||||
api_check(L, L->tbclist < L->top, "previous pop of an unclosed slot");
|
||||
newtop = L->top + diff;
|
||||
if (diff < 0 && L->tbclist >= newtop) {
|
||||
lua_assert(hastocloseCfunc(ci->nresults));
|
||||
luaF_close(L, newtop, CLOSEKTOP, 0);
|
||||
}
|
||||
L->top = newtop; /* correct top only after closing any upvalue */
|
||||
lua_unlock(L);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue