| 399 | |
| 400 | |
| 401 | static int luaB_select (lua_State *L) { |
| 402 | int n = lua_gettop(L); |
| 403 | if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { |
| 404 | lua_pushinteger(L, n-1); |
| 405 | return 1; |
| 406 | } |
| 407 | else { |
| 408 | lua_Integer i = luaL_checkinteger(L, 1); |
| 409 | if (i < 0) i = n + i; |
| 410 | else if (i > n) i = n; |
| 411 | luaL_argcheck(L, 1 <= i, 1, "index out of range"); |
| 412 | return n - (int)i; |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | |
| 417 | /* |
nothing calls this directly
no test coverage detected