| 436 | |
| 437 | |
| 438 | static int luaB_select (lua_State *L) { |
| 439 | int n = lua_gettop(L); |
| 440 | if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { |
| 441 | lua_pushinteger(L, n-1); |
| 442 | return 1; |
| 443 | } |
| 444 | else { |
| 445 | lua_Integer i = luaL_checkinteger(L, 1); |
| 446 | if (i < 0) i = n + i; |
| 447 | else if (i > n) i = n; |
| 448 | luaL_argcheck(L, 1 <= i, 1, "index out of range"); |
| 449 | return n - (int)i; |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | |
| 454 | /* |
nothing calls this directly
no test coverage detected