X-Git-Url: http://git.droids-corp.org/?p=protos%2Flibecoli.git;a=blobdiff_plain;f=src%2Fecoli_yaml.c;h=4843ef0fe6bdd5423ea825af3a987b5f5889ae61;hp=8ac47eb84a4a1d83ddbaa1d4ab19816ce02ba7d4;hb=HEAD;hpb=ec731385f1ed38a35e4e0df83e5ae4e8b8151df6 diff --git a/src/ecoli_yaml.c b/src/ecoli_yaml.c index 8ac47eb..4843ef0 100644 --- a/src/ecoli_yaml.c +++ b/src/ecoli_yaml.c @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include #include @@ -361,12 +361,19 @@ parse_ec_node(struct enode_table *table, const char *key_str, *value_str; struct ec_node *enode = NULL; char *value_dup = NULL; + size_t i; if (ynode->type != YAML_MAPPING_NODE) { fprintf(stderr, "Ecoli node should be a yaml mapping node\n"); goto fail; } + /* if it's an anchor, the node may be already parsed, reuse it */ + for (i = 0; i < table->len; i++) { + if (table->pair[i].ynode == ynode) + return ec_node_clone(table->pair[i].enode); + } + for (pair = ynode->data.mapping.pairs.start; pair < ynode->data.mapping.pairs.top; pair++) { key = document->nodes.start + pair->key - 1; // XXX -1 ? @@ -459,7 +466,7 @@ parse_ec_node(struct enode_table *table, config = NULL; /* freed */ if (help != NULL) { - if (ec_keyval_set(ec_node_attrs(enode), "help", help, + if (ec_dict_set(ec_node_attrs(enode), "help", help, ec_free_func) < 0) { fprintf(stderr, "Failed to set help\n"); help = NULL; @@ -479,7 +486,7 @@ parse_ec_node(struct enode_table *table, value_dup = ec_strdup(value_str); if (value_dup == NULL) goto fail; - if (ec_keyval_set(ec_node_attrs(enode), key_str, + if (ec_dict_set(ec_node_attrs(enode), key_str, value_dup, ec_free_func) < 0) { value_dup = NULL; goto fail;