]> pilppa.org Git - uci.git/blobdiff - lua/uci.c
lua: add uci.foreach() error handling patch by xMff
[uci.git] / lua / uci.c
index 98f1e15e41e9991858f662b9f0d017e50ad28fbd..4bc4ba26c959fd776fb952c88324a3d79fef79c2 100644 (file)
--- a/lua/uci.c
+++ b/lua/uci.c
@@ -297,8 +297,16 @@ 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;
+               }
+               else
+               {
+                       lua_error(L);
+                       break;
+               }
        }
 
 done: