| 414 | |
| 415 | |
| 416 | static int luaB_select (lua_State *L) { |
| 417 | int n = lua_gettop(L); |
| 418 | if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { |
| 419 | lua_pushinteger(L, n-1); |
| 420 | return 1; |
| 421 | } |
| 422 | else { |
| 423 | lua_Integer i = luaL_checkinteger(L, 1); |
| 424 | if (i < 0) i = n + i; |
| 425 | else if (i > n) i = n; |
| 426 | luaL_argcheck(L, 1 <= i, 1, "index out of range"); |
| 427 | return n - (int)i; |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | |
| 432 | /* |
nothing calls this directly
no test coverage detected