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