}
if (pctx->bufsz > LINEBUF_MAX/2) {
+ pctx->reason = "line too long";
pctx->byte = LINEBUF_MAX;
UCI_THROW(ctx, UCI_ERR_PARSE);
}
if (!pctx)
return;
+ ctx->pctx = NULL;
if (pctx->cfg) {
uci_list_del(&pctx->cfg->list);
- uci_drop_file(pctx->cfg);
+ uci_drop_config(pctx->cfg);
}
if (pctx->buf)
free(pctx->buf);
break;
}
}
+ ctx->pctx->reason = "unterminated \"";
ctx->pctx->byte = *str - ctx->pctx->buf;
UCI_THROW(ctx, UCI_ERR_PARSE);
}
addc(target, str);
}
}
+ ctx->pctx->reason = "unterminated '";
ctx->pctx->byte = *str - ctx->pctx->buf;
UCI_THROW(ctx, UCI_ERR_PARSE);
}
skip_whitespace(str);
parse_str(ctx, str, &ptr);
if (required && !*val) {
+ ctx->pctx->reason = "insufficient arguments";
ctx->pctx->byte = *str - ctx->pctx->buf;
UCI_THROW(ctx, UCI_ERR_PARSE);
}
tmp = next_arg(ctx, str, false);
if (tmp && *tmp) {
+ ctx->pctx->reason = "too many arguments";
ctx->pctx->byte = tmp - ctx->pctx->buf;
UCI_THROW(ctx, UCI_ERR_PARSE);
}
{
char *type, *name;
+ /* command string null-terminated by strtok */
*str += strlen(*str) + 1;
- if (!*str) {
- ctx->pctx->byte = *str - ctx->pctx->buf;
- UCI_THROW(ctx, UCI_ERR_PARSE);
- }
-
type = next_arg(ctx, str, true);
name = next_arg(ctx, str, false);
assert_eol(ctx, str);
{
char *name, *value;
+ /* command string null-terminated by strtok */
*str += strlen(*str) + 1;
name = next_arg(ctx, str, true);
value = next_arg(ctx, str, true);
assert_eol(ctx, str);
-
- DPRINTF("\tOption: %s=\"%s\"\n", name, value);
}
/*
uci_parse_option(ctx, &word);
break;
default:
+ pctx->reason = "unterminated command";
pctx->byte = word - pctx->buf;
UCI_THROW(ctx, UCI_ERR_PARSE);
break;
UCI_HANDLE_ERR(ctx);
UCI_ASSERT(ctx, name != NULL);
+ UCI_TRAP_SAVE(ctx, ignore);
+ uci_unload(ctx, name);
+ UCI_TRAP_RESTORE(ctx);
+
+ignore:
/* make sure no memory from previous parse attempts is leaked */
uci_parse_cleanup(ctx);
if (!pctx->file)
UCI_THROW(ctx, UCI_ERR_IO);
- pctx->cfg = uci_alloc_file(ctx, name);
+ pctx->cfg = uci_alloc_config(ctx, name);
while (!feof(pctx->file)) {
uci_getln(ctx);