| 340 | |
| 341 | |
| 342 | static int luaB_unpack (lua_State *L) { |
| 343 | int i, e, n; |
| 344 | luaL_checktype(L, 1, LUA_TTABLE); |
| 345 | i = luaL_optint(L, 2, 1); |
| 346 | e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1)); |
| 347 | if (i > e) return 0; /* empty range */ |
| 348 | n = e - i + 1; /* number of elements */ |
| 349 | if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ |
| 350 | return luaL_error(L, "too many results to unpack"); |
| 351 | lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ |
| 352 | while (i++ < e) /* push arg[i + 1...e] */ |
| 353 | lua_rawgeti(L, 1, i); |
| 354 | return n; |
| 355 | } |
| 356 | |
| 357 | |
| 358 | static int luaB_select (lua_State *L) { |
nothing calls this directly
no test coverage detected