summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/yaml/node.c61
1 files changed, 32 insertions, 29 deletions
diff --git a/plugins/yaml/node.c b/plugins/yaml/node.c
index 57eb3d2..3dc6ec0 100644
--- a/plugins/yaml/node.c
+++ b/plugins/yaml/node.c
@@ -284,65 +284,64 @@ void _g_yaml_node_find_by_path(GYamlNode *node, const char *path, GYamlNode ***n
{
GYamlLine *line; /* Ligne Yaml liée au noeud */
const char *key; /* Clef associée au noeud */
- bool matched; /* Correspondance établie ? */
char *next; /* Prochaine partie du chemin */
size_t cmplen; /* Etendue de la comparaison */
int ret; /* Bilan d'une comparaison */
GYamlCollection *collec; /* Collection de noeuds */
+ if (path[0] == '\0')
+ goto exit;
+
+ line = g_yaml_node_get_yaml_line(node);
+
if (path[0] == '/')
+ {
path++;
- /* Correspondance au niveau du noeud ? */
+ if (path[0] == '\0')
+ goto matched;
- line = g_yaml_node_get_yaml_line(node);
+ }
+
+ /* Correspondance au niveau du noeud ? */
if (line != NULL)
{
key = g_yaml_line_get_key(line);
- if (path[0] == '\0')
- matched = true;
+ next = strchr(path, '/');
+
+ if (next == NULL)
+ ret = strcmp(path, key);
else
{
- next = strchr(path, '/');
-
- cmplen = (next == NULL ? strlen(path) : next - path);
+ cmplen = next - path;
if (cmplen == 0)
goto cont;
ret = strncmp(path, key, cmplen);
- if (ret != 0)
- goto done;
-
- else
- {
- if (next == NULL)
- matched = true;
-
- else
- {
- path += cmplen;
- goto cont;
- }
+ }
- }
+ if (ret != 0)
+ goto done;
+ else if (next != NULL)
+ {
+ path += cmplen;
+ goto cont;
}
- if (matched)
- {
- *nodes = realloc(*nodes, ++(*count) * sizeof(GYamlNode **));
+ matched:
- g_object_ref(G_OBJECT(node));
- (*nodes)[*count - 1] = node;
+ *nodes = realloc(*nodes, ++(*count) * sizeof(GYamlNode **));
- goto done;
+ g_object_ref(G_OBJECT(node));
+ (*nodes)[*count - 1] = node;
- }
+ goto done;
}
@@ -363,6 +362,10 @@ void _g_yaml_node_find_by_path(GYamlNode *node, const char *path, GYamlNode ***n
if (line != NULL)
g_object_unref(G_OBJECT(line));
+ exit:
+
+ ;
+
}