MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / tremove

Function tremove

other_src/lua/src/ltablib.cpp:125–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123
124
125static int tremove (lua_State *L) {
126 int e = aux_getn(L, 1);
127 int pos = luaL_optint(L, 2, e);
128 if (!(1 <= pos && pos <= e)) /* position is outside bounds? */
129 return 0; /* nothing to remove */
130 luaL_setn(L, 1, e - 1); /* t.n = n-1 */
131 lua_rawgeti(L, 1, pos); /* result = t[pos] */
132 for ( ;pos<e; pos++) {
133 lua_rawgeti(L, 1, pos+1);
134 lua_rawseti(L, 1, pos); /* t[pos] = t[pos+1] */
135 }
136 lua_pushnil(L);
137 lua_rawseti(L, 1, e); /* t[e] = nil */
138 return 1;
139}
140
141
142static void addfield (lua_State *L, luaL_Buffer *b, int i) {

Callers

nothing calls this directly

Calls 4

luaL_setnFunction · 0.70
lua_rawgetiFunction · 0.70
lua_rawsetiFunction · 0.70
lua_pushnilFunction · 0.70

Tested by

no test coverage detected