summaryrefslogtreecommitdiff
path: root/run.c
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-11-28 12:07:33 +0000
committerubq323 <ubq323@ubq323.website>2024-11-28 12:07:33 +0000
commite08da97cf2c9e69a3955f0327efeed1f9a237768 (patch)
tree32a3d0c8cd548bd66abf3664a6cd11ddb4da0940 /run.c
parent506598af568b79151c0030849ae0762c5add9273 (diff)
simplify convenience wrapper logicHEADtrunk
Diffstat (limited to 'run.c')
-rw-r--r--run.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/run.c b/run.c
index 85e2793..49b96b6 100644
--- a/run.c
+++ b/run.c
@@ -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);
}