lua: add a return code for aborting iteration in uci_foreach
authorFelix Fietkau <nbd@openwrt.org>
Mon, 24 Aug 2009 23:42:01 +0000 (01:42 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 24 Aug 2009 23:42:01 +0000 (01:42 +0200)
lua/uci.c

index 98f1e15..d16a0fd 100644 (file)
--- a/lua/uci.c
+++ b/lua/uci.c
@@ -297,8 +297,11 @@ uci_lua_foreach(lua_State *L)
 
                lua_pushvalue(L, 3 + offset); /* iterator function */
                uci_push_section(L, s, i - 1);
-               if (lua_pcall(L, 1, 0, 0) == 0)
+               if (lua_pcall(L, 1, 1, 0) == 0) {
                        ret = true;
+                       if (lua_isboolean(L, -1) && !lua_toboolean(L, -1))
+                               break;
+               }
        }
 
 done: