MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / tremove

Function tremove

extlibs/lua/src/ltablib.c:90–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88
89
90static int tremove (lua_State *L) {
91 lua_Integer size = aux_getn(L, 1, TAB_RW);
92 lua_Integer pos = luaL_optinteger(L, 2, size);
93 if (pos != size) /* validate 'pos' if given */
94 /* check whether 'pos' is in [1, size + 1] */
95 luaL_argcheck(L, (lua_Unsigned)pos - 1u <= (lua_Unsigned)size, 1,
96 "position out of bounds");
97 lua_geti(L, 1, pos); /* result = t[pos] */
98 for ( ; pos < size; pos++) {
99 lua_geti(L, 1, pos + 1);
100 lua_seti(L, 1, pos); /* t[pos] = t[pos + 1] */
101 }
102 lua_pushnil(L);
103 lua_seti(L, 1, pos); /* remove entry t[pos] */
104 return 1;
105}
106
107
108/*

Callers

nothing calls this directly

Calls 4

luaL_optintegerFunction · 0.85
lua_pushnilFunction · 0.85
lua_getiFunction · 0.70
lua_setiFunction · 0.70

Tested by

no test coverage detected