| 11204 | |
| 11205 | |
| 11206 | static int luaB_unpack (lua_State *L) { |
| 11207 | int i, e, n; |
| 11208 | luaL_checktype(L, 1, LUA_TTABLE); |
| 11209 | i = luaL_optint(L, 2, 1); |
| 11210 | e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1)); |
| 11211 | if (i > e) return 0; /* empty range */ |
| 11212 | n = e - i + 1; /* number of elements */ |
| 11213 | if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ |
| 11214 | return luaL_error(L, "too many results to unpack"); |
| 11215 | lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ |
| 11216 | while (i++ < e) /* push arg[i + 1...e] */ |
| 11217 | lua_rawgeti(L, 1, i); |
| 11218 | return n; |
| 11219 | } |
| 11220 | |
| 11221 | |
| 11222 | static int luaB_select (lua_State *L) { |
nothing calls this directly
no test coverage detected