Project

General

Profile

Feature #2415 ยป 0069-Apply-patch-4-for-lua-5.5.1.patch

Marko Lindqvist, 11/08/2026 11:47 AM

View differences:

dependencies/lua-5.5/Version.txt
(http://www.lua.org/ftp/lua-5.5.1.tar.gz)
Upstream bug fixes from https://www.lua.org/bugs.html applied:
1, 2, 3
1, 2, 3, 4
Not entire lua distribution directory hierarchy is included here, and
some files needed for Freeciv usage have been added.
dependencies/lua-5.5/src/lcorolib.c
int stat = lua_status(co);
if (stat != LUA_OK && stat != LUA_YIELD) { /* error in the coroutine? */
stat = lua_closethread(co, L); /* close its tbc variables */
lua_assert(stat != LUA_OK);
if (stat == LUA_OK)
return 0; /* nothing to return */
lua_xmove(co, L, 1); /* move error message to the caller */
}
if (stat != LUA_ERRMEM && /* not a memory error and ... */
dependencies/lua-5.5/src/lstate.c
status = luaD_closeprotected(L, 1, status);
if (status != LUA_OK) /* errors? */
luaD_seterrorobj(L, status, L->stack.p + 1);
else
else /* keep in the stack only the fake function-entry for basic ci */
L->top.p = L->stack.p + 1;
luaD_reallocstack(L, cast_int(L->ci->top.p - L->stack.p), 0);
return status;
}
/*
** Auxiliary function to call luaE_resetthread in protected mode.
** That function closes all tbc variables in protected mode, so the
** only possible "error" is when a tbc variable closes the thread being
** closed and therefore calls 'luaD_throwbaselevel'; in that case,
** control goes directly back to the first call to lua_closethread (not
** to the second), to properly return it.
*/
static void resetthread_aux (lua_State *L, void *ud) {
TStatus status = *cast(TStatus*, ud);
status = luaE_resetthread(L, status);
if (status != LUA_OK)
luaD_throw(L, status);
}
LUA_API int lua_closethread (lua_State *L, lua_State *from) {
TStatus status;
lua_lock(L);
L->nCcalls = (from) ? getCcalls(from) : 0;
status = luaE_resetthread(L, L->status);
status = luaD_rawrunprotected(L, resetthread_aux, &L->status);
/* stack has error message iff there was an error */
lua_assert(L->top.p == L->stack.p + (status == LUA_OK ? 1 : 2));
if (L == from) /* closing itself? */
luaD_throwbaselevel(L, status);
lua_unlock(L);
    (1-1/1)