| 37 | |
| 38 | |
| 39 | static int foreach (lua_State *L) { |
| 40 | luaL_checktype(L, 1, LUA_TTABLE); |
| 41 | luaL_checktype(L, 2, LUA_TFUNCTION); |
| 42 | lua_pushnil(L); /* first key */ |
| 43 | while (lua_next(L, 1)) { |
| 44 | lua_pushvalue(L, 2); /* function */ |
| 45 | lua_pushvalue(L, -3); /* key */ |
| 46 | lua_pushvalue(L, -3); /* value */ |
| 47 | lua_call(L, 2, 1); |
| 48 | if (!lua_isnil(L, -1)) |
| 49 | return 1; |
| 50 | lua_pop(L, 2); /* remove value and result */ |
| 51 | } |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | |
| 56 | static int maxn (lua_State *L) { |
nothing calls this directly
no test coverage detected