From e13cc14a618a1ba817f8d667ea333133028f7e47 Mon Sep 17 00:00:00 2001 From: ame Date: Tue, 25 Nov 2025 03:44:22 -0600 Subject: more consistent locals, better test printing --- src/lua.h | 2 ++ src/thread.c | 13 ++++++++++--- tests/tests.lua | 4 ++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/lua.h b/src/lua.h index 1ae8820..cfff148 100644 --- a/src/lua.h +++ b/src/lua.h @@ -114,6 +114,8 @@ int writer(lua_State*, const void*, size_t, void*); #define lua_gc(A, B) lua_gc(A, B, 0) #elif LUA_VERSION_NUM == 501 + #define LUA_OK 0 + #define luaL_tolstring lua_tolstring #define lua_dump(A, B, C, D) lua_dump(A, B, C) diff --git a/src/thread.c b/src/thread.c index fbf5f01..f166c3f 100644 --- a/src/thread.c +++ b/src/thread.c @@ -203,11 +203,15 @@ int _thread_await(lua_State* L){ pthread_mutex_lock(&*info->lock); if(info->return_count == 0) return 0; + lua_getglobal(L, "_locals"); + int old_locals = lua_gettop(L); + + lua_getglobal(info->L, "_stored_locals"); lua_getglobal(info->L, "_res_locals"); + luaI_jointable(info->L); luaI_deepcopy(info->L, L, SKIP_LOCALS | STRIP_GC); - env_table(L, 0); + //env_table(L, 0); - luaI_jointable(L); lua_setglobal(L, "_locals"); lua_getglobal(info->L, "_return_table"); @@ -219,7 +223,7 @@ int _thread_await(lua_State* L){ luaI_deepcopy(info->L, L, STRIP_GC); } - lua_pushnil(L); + lua_pushvalue(L, old_locals); lua_setglobal(L, "_locals"); pthread_mutex_unlock(&*info->lock); @@ -300,6 +304,9 @@ int l_async(lua_State* oL){ luaI_copyvars(oL, L); luaL_openlibs(L); + lua_getglobal(L, "_locals"); + lua_setglobal(L, "_stored_locals"); + struct thread_info* args = calloc(1, sizeof * args); args->L = L; args->lock = malloc(sizeof * args->lock); diff --git a/tests/tests.lua b/tests/tests.lua index 39c4d12..c95e072 100644 --- a/tests/tests.lua +++ b/tests/tests.lua @@ -21,8 +21,12 @@ local handle = assert(io.popen("find tests/units/".. search .." -type f")) for file in handle:lines() do total = total + 1 + print(file) local f = loadfile(file)() + --move up one line and clear it + io.write("\27[1A\27[K") + if f == true then yay(file) else -- cgit v1.2.3