| 23 | |
| 24 | #if defined(LUA_COMPAT_MAXN) |
| 25 | static int maxn (lua_State *L) { |
| 26 | lua_Number max = 0; |
| 27 | luaL_checktype(L, 1, LUA_TTABLE); |
| 28 | lua_pushnil(L); /* first key */ |
| 29 | while (lua_next(L, 1)) { |
| 30 | lua_pop(L, 1); /* remove value */ |
| 31 | if (lua_type(L, -1) == LUA_TNUMBER) { |
| 32 | lua_Number v = lua_tonumber(L, -1); |
| 33 | if (v > max) max = v; |
| 34 | } |
| 35 | } |
| 36 | lua_pushnumber(L, max); |
| 37 | return 1; |
| 38 | } |
| 39 | #endif |
| 40 | |
| 41 |
nothing calls this directly
no test coverage detected