From cd9311c8d6b7432f507e9eed12587c971875a9de Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 20 Jan 2009 01:28:02 +0100 Subject: [PATCH] lua: fix rewriting uci lists --- lua/uci.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lua/uci.c b/lua/uci.c index 67e9418..70d0205 100644 --- a/lua/uci.c +++ b/lua/uci.c @@ -527,7 +527,18 @@ uci_lua_set(lua_State *L) } if (istable) { - for (i = 1; i <= lua_objlen(L, nargs); i++) { + if (lua_objlen(L, nargs) == 1) { + i = 1; + if (ptr.o) + err = uci_delete(ctx, &ptr); + } else { + i = 2; + err = uci_set(ctx, &ptr); + if (err) + goto error; + } + + for (; i <= lua_objlen(L, nargs); i++) { lua_rawgeti(L, nargs, i); ptr.value = luaL_checkstring(L, -1); err = uci_add_list(ctx, &ptr); -- 2.11.0