lua: use uci_foreach_element_safe in uci_lua_foreach() - patch by jow
[project/uci.git] / file.c
diff --git a/file.c b/file.c
index 33ba93c..af42a37 100644 (file)
--- a/file.c
+++ b/file.c
@@ -266,7 +266,7 @@ int uci_parse_argument(struct uci_context *ctx, FILE *stream, char **str, char *
 }
 
 static int
-uci_fill_ptr(struct uci_context *ctx, struct uci_ptr *ptr, struct uci_element *e, bool complete)
+uci_fill_ptr(struct uci_context *ctx, struct uci_ptr *ptr, struct uci_element *e)
 {
        UCI_ASSERT(ctx, ptr != NULL);
        UCI_ASSERT(ctx, e != NULL);
@@ -296,8 +296,6 @@ fill_package:
        ptr->package = ptr->p->e.name;
 
        ptr->flags |= UCI_LOOKUP_DONE;
-       if (complete)
-               ptr->flags |= UCI_LOOKUP_COMPLETE;
 
        return 0;
 }
@@ -404,7 +402,7 @@ static void uci_parse_config(struct uci_context *ctx, char **str)
                ctx->internal = !pctx->merge;
                UCI_NESTED(uci_add_section, ctx, pctx->package, type, &pctx->section);
        } else {
-               uci_fill_ptr(ctx, &ptr, &pctx->package->e, false);
+               uci_fill_ptr(ctx, &ptr, &pctx->package->e);
                e = uci_lookup_list(&pctx->package->sections, name);
                if (e)
                        ptr.s = uci_to_section(e);
@@ -438,7 +436,7 @@ static void uci_parse_option(struct uci_context *ctx, char **str, bool list)
        value = next_arg(ctx, str, false, false);
        assert_eol(ctx, str);
 
-       uci_fill_ptr(ctx, &ptr, &pctx->section->e, false);
+       uci_fill_ptr(ctx, &ptr, &pctx->section->e);
        e = uci_lookup_list(&pctx->section->options, name);
        if (e)
                ptr.o = uci_to_option(e);
@@ -694,14 +692,14 @@ void uci_file_commit(struct uci_context *ctx, struct uci_package **package, bool
        /* open the config file for writing now, so that it is locked */
        f = uci_open_stream(ctx, p->path, SEEK_SET, true, true);
 
-       /* flush unsaved changes and reload from history file */
+       /* flush unsaved changes and reload from delta file */
        UCI_TRAP_SAVE(ctx, done);
-       if (p->has_history) {
+       if (p->has_delta) {
                if (!overwrite) {
                        name = uci_strdup(ctx, p->e.name);
                        path = uci_strdup(ctx, p->path);
-                       /* dump our own changes to the history file */
-                       if (!uci_list_empty(&p->history))
+                       /* dump our own changes to the delta file */
+                       if (!uci_list_empty(&p->delta))
                                UCI_INTERNAL(uci_save, ctx, p);
 
                        /* 
@@ -713,15 +711,15 @@ void uci_file_commit(struct uci_context *ctx, struct uci_package **package, bool
                        UCI_INTERNAL(uci_import, ctx, f, name, &p, true);
 
                        p->path = path;
-                       p->has_history = true;
+                       p->has_delta = true;
                        *package = p;
 
                        /* freed together with the uci_package */
                        path = NULL;
                }
 
-               /* flush history */
-               if (!uci_load_history(ctx, p, true))
+               /* flush delta */
+               if (!uci_load_delta(ctx, p, true))
                        goto done;
        }
 
@@ -841,8 +839,8 @@ static struct uci_package *uci_file_load(struct uci_context *ctx, const char *na
 
        if (package) {
                package->path = filename;
-               package->has_history = confdir;
-               uci_load_history(ctx, package, false);
+               package->has_delta = confdir;
+               uci_load_delta(ctx, package, false);
        }
 
 done: