diff options
-rw-r--r-- | run.c | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -184,18 +184,17 @@ int convienience_wrapper(lua_State *L) { if (tlen == 0) return luaL_error(L, "run's argument can't have 0 length"); int ty = lua_rawgeti(L, 1, 1); lua_pop(L, 1); - if (ty == LUA_TSTRING) { + if (ty != LUA_TTABLE) { // x1 = {"a","b","c",input="ahaha"} - // x2 := {x1,input="ahaha"} + // x2 := {"a","b","c"} lua_newtable(L); - lua_pushvalue(L, 1); - lua_rawseti(L, 2, 1); - lua_pushliteral(L, "input"); - lua_pushliteral(L, "input"); - lua_rawget(L, 1); - lua_rawset(L, 2); - lua_replace(L, 1); + for (int i = 1; i <= tlen; i++) { + lua_rawgeti(L, 1, i); lua_rawseti(L, 2, i); + lua_pushnil(L); lua_rawseti(L, 1, i); + } + lua_rawseti(L, 1, 1); } + return do_the_thing(L); } |