]> pilppa.com Git - uci.git/commitdiff
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 98f1e15e41e9991858f662b9f0d017e50ad28fbd..d16a0fd818e3e48fa97409d9211977f9e6b10d15 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: