X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=parse.c;h=9dd7126f3325a01a361174f492590ff07725a0af;hp=b15421050f088a4f75d0727ab704a95c6d795262;hb=5e35ebaeb9da2e5fc7f455b6da9904b5187b0d06;hpb=60c0c8e8fe97a3c2a46093657af7c1d168a53c46 diff --git a/parse.c b/parse.c index b154210..9dd7126 100644 --- a/parse.c +++ b/parse.c @@ -72,6 +72,10 @@ static void uci_parse_cleanup(struct uci_context *ctx) if (!pctx) return; + if (pctx->cfg) { + uci_list_del(&pctx->cfg->list); + uci_drop_file(pctx->cfg); + } if (pctx->buf) free(pctx->buf); if (pctx->file) @@ -159,12 +163,16 @@ static char *next_arg(struct uci_context *ctx, char **str, bool required) switch (**str) { case '"': val = parse_double_quote(str); + break; case '\'': val = parse_single_quote(str); + break; case 0: val = NULL; + break; default: val = parse_unquoted(str); + break; } if (required && !val) { @@ -277,12 +285,18 @@ int uci_parse(struct uci_context *ctx, const char *name) if (!pctx->file) UCI_THROW(ctx, UCI_ERR_NOTFOUND); + pctx->cfg = uci_alloc_file(ctx, name); + while (!feof(pctx->file)) { uci_getln(ctx); if (*(pctx->buf)) uci_parse_line(ctx); } + /* add to main config file list */ + uci_list_add(&ctx->root, &pctx->cfg->list); + pctx->cfg = NULL; + /* if no error happened, we can get rid of the parser context now */ uci_parse_cleanup(ctx);