diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lua.c | 12 | ||||
| -rw-r--r-- | src/lua.h | 2 | ||||
| -rw-r--r-- | src/net.c | 4 |
3 files changed, 9 insertions, 9 deletions
@@ -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)
@@ -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)\
@@ -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("");
|
