| 446 | |
| 447 | |
| 448 | static int luaB_select (lua_State *L) { |
| 449 | int n = lua_gettop(L); |
| 450 | if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { |
| 451 | lua_pushinteger(L, n-1); |
| 452 | return 1; |
| 453 | } |
| 454 | else { |
| 455 | lua_Integer i = luaL_checkinteger(L, 1); |
| 456 | if (i < 0) i = n + i; |
| 457 | else if (i > n) i = n; |
| 458 | luaL_argcheck(L, 1 <= i, 1, "index out of range"); |
| 459 | return n - (int)i; |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | |
| 464 | /* |
nothing calls this directly
no test coverage detected