| 65 | |
| 66 | |
| 67 | static int tremove (lua_State *L) { |
| 68 | int size = aux_getn(L, 1); |
| 69 | int pos = luaL_optint(L, 2, size); |
| 70 | if (pos != size) /* validate 'pos' if given */ |
| 71 | luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, "position out of bounds"); |
| 72 | lua_rawgeti(L, 1, pos); /* result = t[pos] */ |
| 73 | for ( ; pos < size; pos++) { |
| 74 | lua_rawgeti(L, 1, pos+1); |
| 75 | lua_rawseti(L, 1, pos); /* t[pos] = t[pos+1] */ |
| 76 | } |
| 77 | lua_pushnil(L); |
| 78 | lua_rawseti(L, 1, pos); /* t[pos] = nil */ |
| 79 | return 1; |
| 80 | } |
| 81 | |
| 82 | |
| 83 | static void addfield (lua_State *L, luaL_Buffer *b, int i) { |
nothing calls this directly
no test coverage detected