X-Git-Url: http://git.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=file.c;h=c670f0449e3fddd29531730586ea8efe9b2d37bd;hp=d5512084c1445399a26880bab28cbe329b6ab56d;hb=563f8dd6f0eb56780a00f5856bf7fcf40e39d845;hpb=87e893157980abef163575ad7aedbcc96c41b0c6 diff --git a/file.c b/file.c index d551208..c670f04 100644 --- a/file.c +++ b/file.c @@ -167,6 +167,7 @@ error: static void uci_parse_list(struct uci_context *ctx, char **str) { struct uci_parse_context *pctx = ctx->pctx; + struct uci_ptr ptr; char *name = NULL; char *value = NULL; @@ -180,27 +181,14 @@ static void uci_parse_list(struct uci_context *ctx, char **str) value = next_arg(ctx, str, false, false); assert_eol(ctx, str); - if (pctx->merge) { - UCI_TRAP_SAVE(ctx, error); - uci_add_list(ctx, pctx->package, pctx->section->e.name, name, value, NULL); - UCI_TRAP_RESTORE(ctx); - return; -error: - UCI_THROW(ctx, ctx->err); - } else { - struct uci_option *o; - struct uci_element *e; - - e = uci_lookup_list(&pctx->section->options, name); - o = uci_to_option(e); - if (!o) { - o = uci_alloc_list(pctx->section, name); - } else { - if (o->type != UCI_TYPE_LIST) - uci_parse_error(ctx, *str, "conflicting list/option keywords"); - } - UCI_INTERNAL(uci_add_element_list, ctx, o, value); - } + UCI_NESTED(uci_fill_ptr, ctx, &ptr, &pctx->section->e, false); + ptr.option = name; + ptr.value = value; + + UCI_INTERNAL(uci_lookup_ptr, ctx, &ptr, NULL, false); + + ctx->internal = !pctx->merge; + UCI_NESTED(uci_add_list, ctx, &ptr); }