From 7ca5c675d7dc21fa7767b64a42a1705bb800fc86 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 12 Feb 2008 11:49:56 +0100 Subject: [PATCH] fix uci_set --- file.c | 7 +++---- history.c | 6 +++--- list.c | 8 ++++---- uci.h | 2 +- util.c | 1 - 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/file.c b/file.c index 9f59637..d2fdf58 100644 --- a/file.c +++ b/file.c @@ -293,7 +293,6 @@ int uci_import(struct uci_context *ctx, FILE *stream, const char *name, struct u UCI_HANDLE_ERR(ctx); /* make sure no memory from previous parse attempts is leaked */ - ctx->internal = true; uci_cleanup(ctx); uci_alloc_parse_context(ctx); @@ -375,7 +374,7 @@ void uci_file_commit(struct uci_context *ctx, struct uci_package **package, bool /* flush unsaved changes and reload from history file */ UCI_TRAP_SAVE(ctx, done); - if (p->confdir) { + if (p->has_history) { if (!overwrite) { name = uci_strdup(ctx, p->e.name); path = uci_strdup(ctx, p->path); @@ -392,7 +391,7 @@ 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->confdir = true; + p->has_history = true; *package = p; /* freed together with the uci_package */ @@ -517,7 +516,7 @@ static struct uci_package *uci_file_load(struct uci_context *ctx, const char *na if (package) { package->path = filename; - package->confdir = confdir; + package->has_history = confdir; uci_load_history(ctx, package, false); } diff --git a/history.c b/history.c index 089bcef..c46c408 100644 --- a/history.c +++ b/history.c @@ -217,7 +217,7 @@ static int uci_load_history(struct uci_context *ctx, struct uci_package *p, bool FILE *f = NULL; int changes = 0; - if (!p->confdir) + if (!p->has_history) return 0; uci_foreach_element(&ctx->history_path, e) { @@ -321,7 +321,7 @@ int uci_revert(struct uci_context *ctx, struct uci_package **pkg, char *section, UCI_ASSERT(ctx, pkg != NULL); p = *pkg; UCI_ASSERT(ctx, p != NULL); - UCI_ASSERT(ctx, p->confdir); + UCI_ASSERT(ctx, p->has_history); /* * - flush unwritten changes @@ -365,7 +365,7 @@ int uci_save(struct uci_context *ctx, struct uci_package *p) * directly. * does not modify the uci_package pointer */ - if (!p->confdir) + if (!p->has_history) return uci_commit(ctx, &p, false); if (uci_list_empty(&p->history)) diff --git a/list.c b/list.c index a28c5e1..aabcab0 100644 --- a/list.c +++ b/list.c @@ -291,7 +291,7 @@ int uci_del_element(struct uci_context *ctx, struct uci_element *e) } p = s->package; - if (!internal && p->confdir) + if (!internal && p->has_history) uci_add_history(ctx, &p->history, UCI_CMD_REMOVE, s->e.name, option, NULL); switch(e->type) { @@ -354,7 +354,7 @@ int uci_set_element_value(struct uci_context *ctx, struct uci_element **element, return 0; } p = s->package; - if (!internal && p->confdir) + if (!internal && p->has_history) uci_add_history(ctx, &p->history, UCI_CMD_CHANGE, section, option, value); uci_list_del(&e->list); @@ -388,7 +388,7 @@ int uci_rename(struct uci_context *ctx, struct uci_package *p, char *section, ch /* NB: p, section, option validated by uci_lookup */ UCI_INTERNAL(uci_lookup, ctx, &e, p, section, option); - if (!internal && p->confdir) + if (!internal && p->has_history) uci_add_history(ctx, &p->history, UCI_CMD_RENAME, section, option, name); name = uci_strdup(ctx, name); @@ -493,7 +493,7 @@ notfound: UCI_THROW(ctx, UCI_ERR_NOTFOUND); /* now add the missing entry */ - if (!internal && p->confdir) + if (!internal && p->has_history) uci_add_history(ctx, &p->history, UCI_CMD_CHANGE, section, option, value); if (s) { o = uci_alloc_option(s, option, value); diff --git a/uci.h b/uci.h index 44f947f..5bc2061 100644 --- a/uci.h +++ b/uci.h @@ -341,7 +341,7 @@ struct uci_package struct uci_element e; struct uci_list sections; struct uci_context *ctx; - bool confdir; + bool has_history; char *path; /* private: */ diff --git a/util.c b/util.c index f098c4b..35aa2b6 100644 --- a/util.c +++ b/util.c @@ -371,7 +371,6 @@ int uci_parse_argument(struct uci_context *ctx, FILE *stream, char **str, char * if (ctx->pctx) { if (ctx->pctx->file != stream) { - ctx->internal = true; uci_cleanup(ctx); } } else { -- 2.41.1