From 88a12e1ed5f15cc7039c9ad94cfb78f33d31bee9 Mon Sep 17 00:00:00 2001 From: ame Date: Wed, 3 Sep 2025 18:24:03 -0500 Subject: merge fixes --- src/lua.c | 12 +++++------- src/lua.h | 2 +- src/net.c | 4 +++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lua.c b/src/lua.c index eedda0e..2623e29 100644 --- a/src/lua.c +++ b/src/lua.c @@ -375,21 +375,19 @@ int env_table(lua_State* L, int provide_table){ return 1; } -//main is the default values, merge is the new and overridden ones -void luaI_jointable(lua_State* L, int main, int merge){ - int idx = lua_gettop(L); - - lua_pushvalue(L, merge); +//top table is prioritized +void luaI_jointable(lua_State* L){ + int idx = lua_gettop(L) - 1; lua_pushnil(L); for(;lua_next(L, -2) != 0;){ lua_pushvalue(L, -2); lua_pushvalue(L, -2); - lua_settable(L, main); + lua_settable(L, idx); lua_pop(L, 1); } - lua_settop(L, idx); + lua_pushvalue(L, idx); } //copys all variables from state A to B, including locals (stored in _locals) diff --git a/src/lua.h b/src/lua.h index d31ef58..1d5bea1 100644 --- a/src/lua.h +++ b/src/lua.h @@ -40,7 +40,7 @@ void luaI_newstream(lua_State* L, stream_read_function, stream_free_function, vo int luaI_nothing(lua_State*); int env_table(lua_State* L, int provide_table); -void luaI_jointable(lua_State* L, int main, int merge); +void luaI_jointable(lua_State* L); //generic macro that takes other macros (see below) #define _tset_b(L, Tidx, K, V, F)\ diff --git a/src/net.c b/src/net.c index e829654..53a5ceb 100644 --- a/src/net.c +++ b/src/net.c @@ -539,7 +539,9 @@ int _request(lua_State* L, struct request_state* state){ luaI_tsets(L, header_idx, "User-Agent", "lullaby/"MAJOR_VERSION); if(params >= 3){ - luaI_jointable(L, header_idx, 3); + lua_pushvalue(L, header_idx); + lua_pushvalue(L, 3); + luaI_jointable(L); } str* header = str_init(""); -- cgit v1.2.3