From: Felix Fietkau Date: Tue, 5 Feb 2008 01:09:25 +0000 (+0100) Subject: allow merge-import, even if the config file does not exist yet X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d0cd0868cd5e071df9f560455542f6df041056ad;p=oweals%2Fuci.git allow merge-import, even if the config file does not exist yet --- diff --git a/cli.c b/cli.c index 6be3372..9bdd553 100644 --- a/cli.c +++ b/cli.c @@ -171,6 +171,7 @@ static int uci_do_import(int argc, char **argv) struct uci_package *package = NULL; char *name = NULL; int ret = UCI_OK; + bool merge = false; if (argc > 2) return 255; @@ -184,10 +185,12 @@ static int uci_do_import(int argc, char **argv) if (flags & CLI_FLAG_MERGE) { if (uci_load(ctx, name, &package) != UCI_OK) package = NULL; + else + merge = true; } ret = uci_import(ctx, input, name, &package, (name != NULL)); if (ret == UCI_OK) { - if (flags & CLI_FLAG_MERGE) { + if (merge) { ret = uci_save(ctx, package); } else { struct uci_element *e; diff --git a/err.h b/err.h index 358cadf..686cde3 100644 --- a/err.h +++ b/err.h @@ -43,6 +43,7 @@ #define UCI_HANDLE_ERR(ctx) do { \ DPRINTF("ENTER: %s\n", __func__); \ int __val = 0; \ + ctx->errno = 0; \ if (!ctx) \ return UCI_ERR_INVAL; \ if (!ctx->internal) \