| 516 | |
| 517 | |
| 518 | static int luaB_select (lua_State *L) { |
| 519 | int n = lua_gettop(L); |
| 520 | if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { |
| 521 | lua_pushinteger(L, n-1); |
| 522 | return 1; |
| 523 | } |
| 524 | else { |
| 525 | lua_Integer i = luaL_checkinteger(L, 1); |
| 526 | if (i < 0) i = n + i; |
| 527 | else if (i > n) i = n; |
| 528 | luaL_argcheck(L, 1 <= i, 1, "index out of range"); |
| 529 | return n - (int)i; |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | |
| 534 | /* |
nothing calls this directly
no test coverage detected