name = next_arg(ctx, str, false, true);
assert_eol(ctx, str);
- if (pctx->merge)
- UCI_INTERNAL(uci_set, ctx, pctx->package, name, NULL, type);
- else
+ if (pctx->merge) {
+ UCI_TRAP_SAVE(ctx, error);
+ uci_set(ctx, pctx->package, name, NULL, type);
+ UCI_TRAP_RESTORE(ctx);
+ return;
+error:
+ UCI_THROW(ctx, ctx->errno);
+ } else
pctx->section = uci_alloc_section(pctx->package, type, name);
}
value = next_arg(ctx, str, true, false);
assert_eol(ctx, str);
- if (pctx->merge)
- UCI_INTERNAL(uci_set, ctx, pctx->package, pctx->section->e.name, name, value);
- else
+ if (pctx->merge) {
+ UCI_TRAP_SAVE(ctx, error);
+ uci_set(ctx, pctx->package, pctx->section->e.name, name, value);
+ UCI_TRAP_RESTORE(ctx);
+ return;
+error:
+ UCI_THROW(ctx, ctx->errno);
+ } else
uci_alloc_option(pctx->section, name, value);
}
uci_fixup_section(ctx, ctx->pctx->section);
if (package)
*package = pctx->package;
+ if (pctx->merge)
+ pctx->package = NULL;
pctx->name = NULL;
uci_switch_config(ctx);
FILE *file = NULL;
UCI_HANDLE_ERR(ctx);
- UCI_ASSERT(ctx, name != NULL);
+ UCI_ASSERT(ctx, uci_validate_name(name));
switch (name[0]) {
case '.':