diff options
Diffstat (limited to 'plugins/yaml/tree.c')
-rw-r--r-- | plugins/yaml/tree.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/plugins/yaml/tree.c b/plugins/yaml/tree.c index fd2cd8f..5db82ec 100644 --- a/plugins/yaml/tree.c +++ b/plugins/yaml/tree.c @@ -33,7 +33,7 @@ #include <core/logs.h> -#include "scalar.h" +#include "pair.h" #include "collection.h" @@ -184,10 +184,9 @@ GYamlTree *g_yaml_tree_new(GYamlLine **lines, size_t count) if (count > 0) { - result->root = G_YAML_NODE(g_yaml_scalar_new(NULL)); - collec = g_yaml_collection_new(g_yaml_line_is_list_item(lines[0])); - g_yaml_scalar_set_collection(G_YAML_SCALAR(result->root), collec); + + result->root = G_YAML_NODE(collec); indent = g_yaml_line_count_indent(lines[0]); processed = 0; @@ -234,7 +233,6 @@ static bool g_yaml_tree_build_node(GYamlCollection *collec, GYamlLine **lines, s size_t indent; /* Indentation de ligne */ bool is_item; /* Elément d'une liste ? */ GYamlCollection *sub; /* Nouvelle sous-collection */ - GYamlNode *glue; /* Noeud vide intermédiaire */ result = true; @@ -254,7 +252,7 @@ static bool g_yaml_tree_build_node(GYamlCollection *collec, GYamlLine **lines, s * * L'objectif est de créer une simple association de 'clefs: valeurs'. * - * Si la collection n'est pas adapté, alors le parcours n'est pas encore + * Si la collection n'est pas adaptée, alors le parcours n'est pas encore * arrivé à ce stade de construction. */ if (first && is_item && !g_yaml_collection_is_sequence(collec)) @@ -275,7 +273,7 @@ static bool g_yaml_tree_build_node(GYamlCollection *collec, GYamlLine **lines, s assert(last != NULL); sub = g_yaml_collection_new(is_item); - g_yaml_scalar_set_collection(G_YAML_SCALAR(last), sub); + g_yaml_pair_set_collection(G_YAML_PAIR(last), sub); result = g_yaml_tree_build_node(sub, lines, count, indent, cur); if (!result) goto done; @@ -290,7 +288,7 @@ static bool g_yaml_tree_build_node(GYamlCollection *collec, GYamlLine **lines, s /* Vérification de cohérence */ if (!g_yaml_collection_is_sequence(collec)) { - log_variadic_message(LMT_BAD_BINARY, _("A mapping item was expected at line %zu"), + log_variadic_message(LMT_BAD_BINARY, _("A list item was expected at line %zu"), g_yaml_line_get_number(line)); result = false; @@ -298,11 +296,8 @@ static bool g_yaml_tree_build_node(GYamlCollection *collec, GYamlLine **lines, s } - glue = G_YAML_NODE(g_yaml_scalar_new(NULL)); - g_yaml_collection_add_node(collec, glue); - sub = g_yaml_collection_new(false); - g_yaml_scalar_set_collection(G_YAML_SCALAR(glue), sub); + g_yaml_collection_add_node(collec, G_YAML_NODE(sub)); result = g_yaml_tree_build_node(sub, lines, count, expected + 2 /* 2 == strlen("- ") */, cur); if (!result) goto done; @@ -314,7 +309,7 @@ static bool g_yaml_tree_build_node(GYamlCollection *collec, GYamlLine **lines, s /* Vérification de cohérence */ if (g_yaml_collection_is_sequence(collec)) { - log_variadic_message(LMT_BAD_BINARY, _("A list item was expected at line %zu"), + log_variadic_message(LMT_BAD_BINARY, _("A mapping item was expected at line %zu"), g_yaml_line_get_number(line)); @@ -323,7 +318,7 @@ static bool g_yaml_tree_build_node(GYamlCollection *collec, GYamlLine **lines, s } - last = G_YAML_NODE(g_yaml_scalar_new(line)); + last = G_YAML_NODE(g_yaml_pair_new(line)); g_yaml_collection_add_node(collec, last); (*cur)++; |