| 116 | |
| 117 | |
| 118 | static int tremove (lua_State *L) { |
| 119 | int e = aux_getn(L, 1); |
| 120 | int pos = luaL_optint(L, 2, e); |
| 121 | if (!(1 <= pos && pos <= e)) /* position is outside bounds? */ |
| 122 | return 0; /* nothing to remove */ |
| 123 | luaL_setn(L, 1, e - 1); /* t.n = n-1 */ |
| 124 | lua_rawgeti(L, 1, pos); /* result = t[pos] */ |
| 125 | for ( ;pos<e; pos++) { |
| 126 | lua_rawgeti(L, 1, pos+1); |
| 127 | lua_rawseti(L, 1, pos); /* t[pos] = t[pos+1] */ |
| 128 | } |
| 129 | lua_pushnil(L); |
| 130 | lua_rawseti(L, 1, e); /* t[e] = nil */ |
| 131 | return 1; |
| 132 | } |
| 133 | |
| 134 | |
| 135 | static void addfield (lua_State *L, luaL_Buffer *b, int i) { |
nothing calls this directly
no test coverage detected