From 628212e00cbcf723b798777d44e7ecb84dd8570e Mon Sep 17 00:00:00 2001 From: Jianhui Zhao Date: Wed, 17 Jul 2024 15:11:37 +0800 Subject: [PATCH] libuci-lua-53: fix `each` method Fix the issue iterate the first element twice. Signed-off-by: Jianhui Zhao --- libuci-lua-53/src/uci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) mode change 100644 => 100755 libuci-lua-53/src/uci.c diff --git a/libuci-lua-53/src/uci.c b/libuci-lua-53/src/uci.c old mode 100644 new mode 100755 index 820b23f1..b1b2d808 --- a/libuci-lua-53/src/uci.c +++ b/libuci-lua-53/src/uci.c @@ -374,12 +374,12 @@ uci_lua_each_iter(lua_State *L) if (type && (strcmp(s->type, type) != 0)) goto again; - lua_pushlightuserdata(L, tmp); - lua_replace(L, lua_upvalueindex(4)); - lua_pushlightuserdata(L, e); lua_replace(L, lua_upvalueindex(3)); + lua_pushlightuserdata(L, tmp); + lua_replace(L, lua_upvalueindex(4)); + lua_pushinteger(L, i); lua_replace(L, lua_upvalueindex(5)); @@ -418,8 +418,8 @@ uci_lua_each(lua_State *L) lua_pushnil(L); lua_pushlightuserdata(L, &p->sections); - lua_pushlightuserdata(L, tmp); lua_pushlightuserdata(L, e); + lua_pushlightuserdata(L, tmp); lua_pushinteger(L, i); lua_pushcclosure(L, uci_lua_each_iter, 5);