X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Fecoli_parse.c;h=6396fc1831da38b00f415b006ccfc3d77f0f0590;hb=15718f19cbf3868bf6fba79f4e26b5254c57873e;hp=a6def04f38a6d4c85a032644bc42acadf34a5dea;hpb=2f6e2fbedc023ad3579b62181fa4b5637494aa5b;p=protos%2Flibecoli.git diff --git a/lib/ecoli_parse.c b/lib/ecoli_parse.c index a6def04..6396fc1 100644 --- a/lib/ecoli_parse.c +++ b/lib/ecoli_parse.c @@ -42,38 +42,46 @@ static int __ec_node_parse_child(const struct ec_node *node, struct ec_parse *child = NULL; int ret; - if (ec_node_type(node)->parse == NULL) - return -ENOTSUP; + if (ec_node_type(node)->parse == NULL) { + errno = ENOTSUP; + return -1; + } if (!is_root) { child = ec_parse(node); if (child == NULL) - return -ENOMEM; + return -1; ec_parse_link_child(state, child); } else { child = state; } ret = ec_node_type(node)->parse(node, child, strvec); - if (ret < 0 || ret == EC_PARSE_NOMATCH) - goto free; + if (ret < 0) + goto fail; - match_strvec = ec_strvec_ndup(strvec, 0, ret); - if (match_strvec == NULL) { - ret = -ENOMEM; - goto free; + if (ret == EC_PARSE_NOMATCH) { + if (!is_root) { + ec_parse_unlink_child(state, child); + ec_parse_free(child); + } + return ret; } + match_strvec = ec_strvec_ndup(strvec, 0, ret); + if (match_strvec == NULL) + goto fail; + child->strvec = match_strvec; return ret; -free: +fail: if (!is_root) { ec_parse_unlink_child(state, child); ec_parse_free(child); } - return ret; + return -1; } int ec_node_parse_child(const struct ec_node *node, struct ec_parse *state, @@ -244,7 +252,7 @@ static void __ec_parse_dump(FILE *out, { struct ec_parse *child; const struct ec_strvec *vec; - const char *id, *typename = "none"; + const char *id = "none", *typename = "none"; /* node can be null when parsing is incomplete */ if (parse->node != NULL) {