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