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