| 14583 | |
| 14584 | |
| 14585 | static int foreach (lua_State *L) { |
| 14586 | luaL_checktype(L, 1, LUA_TTABLE); |
| 14587 | luaL_checktype(L, 2, LUA_TFUNCTION); |
| 14588 | lua_pushnil(L); /* first key */ |
| 14589 | while (lua_next(L, 1)) { |
| 14590 | lua_pushvalue(L, 2); /* function */ |
| 14591 | lua_pushvalue(L, -3); /* key */ |
| 14592 | lua_pushvalue(L, -3); /* value */ |
| 14593 | lua_call(L, 2, 1); |
| 14594 | if (!lua_isnil(L, -1)) |
| 14595 | return 1; |
| 14596 | lua_pop(L, 2); /* remove value and result */ |
| 14597 | } |
| 14598 | return 0; |
| 14599 | } |
| 14600 | |
| 14601 | |
| 14602 | static int maxn (lua_State *L) { |
nothing calls this directly
no test coverage detected