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