From c79720566c13a561015870d358822801f319b732 Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Thu, 7 Mar 2019 19:15:51 +0100 Subject: [PATCH] yaml: parse anchors --- src/ecoli_yaml.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ecoli_yaml.c b/src/ecoli_yaml.c index 8ac47eb..326af56 100644 --- a/src/ecoli_yaml.c +++ b/src/ecoli_yaml.c @@ -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 ? -- 2.39.5