MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / tremove

Function tremove

Source/Misc/lua/src/lua.c:14664–14678  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14662
14663
14664static int tremove (lua_State *L) {
14665int e = aux_getn(L, 1);
14666int pos = luaL_optint(L, 2, e);
14667if (!(1 <= pos && pos <= e)) /* position is outside bounds? */
14668return 0; /* nothing to remove */
14669luaL_setn(L, 1, e - 1); /* t.n = n-1 */
14670lua_rawgeti(L, 1, pos); /* result = t[pos] */
14671for ( ;pos<e; pos++) {
14672lua_rawgeti(L, 1, pos+1);
14673lua_rawseti(L, 1, pos); /* t[pos] = t[pos+1] */
14674}
14675lua_pushnil(L);
14676lua_rawseti(L, 1, e); /* t[e] = nil */
14677return 1;
14678}
14679
14680
14681static void addfield (lua_State *L, luaL_Buffer *b, int i) {

Callers

nothing calls this directly

Calls 4

luaL_setnFunction · 0.85
lua_rawgetiFunction · 0.85
lua_rawsetiFunction · 0.85
lua_pushnilFunction · 0.85

Tested by

no test coverage detected