MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / tremove

Function tremove

third-party/lua-5.5.0/src/ltablib.c:102–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100
101
102static int tremove (lua_State *L) {
103 lua_Integer size = aux_getn(L, 1, TAB_RW);
104 lua_Integer pos = luaL_optinteger(L, 2, size);
105 if (pos != size) /* validate 'pos' if given */
106 /* check whether 'pos' is in [1, size + 1] */
107 luaL_argcheck(L, (lua_Unsigned)pos - 1u <= (lua_Unsigned)size, 2,
108 "position out of bounds");
109 lua_geti(L, 1, pos); /* result = t[pos] */
110 for ( ; pos < size; pos++) {
111 lua_geti(L, 1, pos + 1);
112 lua_seti(L, 1, pos); /* t[pos] = t[pos + 1] */
113 }
114 lua_pushnil(L);
115 lua_seti(L, 1, pos); /* remove entry t[pos] */
116 return 1;
117}
118
119
120/*

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected