MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / maxn

Function maxn

Source/Misc/lua/src/lua.c:14602–14615  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14600
14601
14602static int maxn (lua_State *L) {
14603lua_Number max = 0;
14604luaL_checktype(L, 1, LUA_TTABLE);
14605lua_pushnil(L); /* first key */
14606while (lua_next(L, 1)) {
14607lua_pop(L, 1); /* remove value */
14608if (lua_type(L, -1) == LUA_TNUMBER) {
14609lua_Number v = lua_tonumber(L, -1);
14610if (v > max) max = v;
14611}
14612}
14613lua_pushnumber(L, max);
14614return 1;
14615}
14616
14617
14618static int getn (lua_State *L) {

Callers

nothing calls this directly

Calls 6

luaL_checktypeFunction · 0.85
lua_pushnilFunction · 0.85
lua_nextFunction · 0.85
lua_typeFunction · 0.85
lua_tonumberFunction · 0.85
lua_pushnumberFunction · 0.85

Tested by

no test coverage detected