| 386 | |
| 387 | |
| 388 | static int luaB_select (lua_State *L) { |
| 389 | int n = lua_gettop(L); |
| 390 | if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { |
| 391 | lua_pushinteger(L, n-1); |
| 392 | return 1; |
| 393 | } |
| 394 | else { |
| 395 | lua_Integer i = luaL_checkinteger(L, 1); |
| 396 | if (i < 0) i = n + i; |
| 397 | else if (i > n) i = n; |
| 398 | luaL_argcheck(L, 1 <= i, 1, "index out of range"); |
| 399 | return n - (int)i; |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | |
| 404 | /* |
nothing calls this directly
no test coverage detected