3 @@ -691,6 +691,7 @@ uci_lua_add_change(lua_State *L, struct
11 @@ -704,12 +705,38 @@ uci_lua_add_change(lua_State *L, struct
12 lua_setfield(L, -3, h->section);
15 - name = (h->e.name ? h->e.name : ".type");
17 - lua_pushstring(L, h->value);
19 - lua_pushstring(L, "");
20 - lua_setfield(L, -2, name);
22 + value = h->value ? h->value : "";
25 + lua_getfield(L, -1, name);
27 + /* there seems to be no value yet */
28 + if (lua_isnil(L, -1)) {
29 + /* this delta is a list add operation, initialize table */
30 + if (h->cmd == UCI_CMD_LIST_ADD) {
32 + lua_pushstring(L, value);
33 + lua_rawseti(L, -2, 1);
34 + lua_setfield(L, -3, name);
36 + lua_pushstring(L, value);
37 + lua_setfield(L, -3, name);
40 + /* a table is on the top of the stack so this is a subsequent,
41 + * list_add, append this value to table */
42 + } else if (lua_istable(L, -1)) {
43 + lua_pushstring(L, value);
44 + lua_rawseti(L, -2, lua_objlen(L, -2) + 1);
49 + lua_pushstring(L, value);
50 + lua_setfield(L, -2, ".type");