diff options
| author | ame <[email protected]> | 2026-06-30 04:30:10 -0500 |
|---|---|---|
| committer | ame <[email protected]> | 2026-06-30 04:30:10 -0500 |
| commit | 7f96376ffdd63397a4265975ec4018c4465094f9 (patch) | |
| tree | 28c1c9fc949f08d6828dc5d86604931bb741a4dc /src/table.c | |
| parent | fb6a20845fed68f1fc3bb5722bb1f5f7f9469d95 (diff) | |
table.contains and some check safteystate-copy-changes
Diffstat (limited to 'src/table.c')
| -rw-r--r-- | src/table.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/table.c b/src/table.c index f5bdd5d..e2130dc 100644 --- a/src/table.c +++ b/src/table.c @@ -3,6 +3,23 @@ #include <string.h> #include <stdint.h> +int l_contains(lua_State* L){ + luaI_assert2(L, lua_gettop(L) >= 2); + luaL_checktype(L, 1, LUA_TTABLE); + + lua_pushnil(L); + for(;lua_next(L, 1);){ + if(lua_rawequal(L, -1, 2)){ + lua_pushvalue(L, -2); + return 1; + } + lua_pop(L, 1); + } + + lua_pushnil(L); + return 1; +} + void value_clone_req(lua_State* L){ int idx = lua_gettop(L); @@ -32,7 +49,7 @@ void value_clone_req(lua_State* L){ } int l_dup(lua_State* L){ - if(lua_gettop(L) != 1) return 0; + luaI_assert2(L, lua_gettop(L) == 1); value_clone_req(L); lua_pushvalue(L, 2); |
