MCPcopy Create free account
hub / github.com/DFHack/dfhack / tremove

Function tremove

depends/lua/src/ltablib.c:106–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104
105
106static int tremove (lua_State *L) {
107 lua_Integer size = aux_getn(L, 1, TAB_RW);
108 lua_Integer pos = luaL_optinteger(L, 2, size);
109 if (pos != size) /* validate 'pos' if given */
110 luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, "position out of bounds");
111 lua_geti(L, 1, pos); /* result = t[pos] */
112 for ( ; pos < size; pos++) {
113 lua_geti(L, 1, pos + 1);
114 lua_seti(L, 1, pos); /* t[pos] = t[pos + 1] */
115 }
116 lua_pushnil(L);
117 lua_seti(L, 1, pos); /* t[pos] = nil */
118 return 1;
119}
120
121
122/*

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected