Skip to content

Commit

Permalink
tree data BUGFIX in ly_insert_node()
Browse files Browse the repository at this point in the history
Restored functionality regarding the sorting of opaq nodes and nodes
with the LYD_EXT flag set.
  • Loading branch information
lePici committed Feb 13, 2024
1 parent 5c5043b commit f914223
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/tree_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,14 @@ lyd_insert_node_ordby_schema(struct lyd_node *parent, struct lyd_node **first_si
if ((anchor = lyd_insert_node_find_anchor(*first_sibling, node))) {
lyd_insert_before_node(anchor, node);
*first_sibling = *first_sibling != anchor ? *first_sibling : node;
} else if (*first_sibling && node->schema && !(*first_sibling)->prev->schema) {
/* cannot insert data node after opaque nodes */
anchor = (*first_sibling)->prev;
while ((anchor != *first_sibling) && !anchor->prev->schema) {
anchor = anchor->prev;
}
lyd_insert_before_node(anchor, node);
*first_sibling = *first_sibling != anchor ? *first_sibling : node;
} else {
lyd_insert_node_last(parent, first_sibling, node);
}
Expand All @@ -747,7 +755,7 @@ lyd_insert_node(struct lyd_node *parent, struct lyd_node **first_sibling_p, stru
}
first_sibling = parent ? lyd_child(parent) : *first_sibling_p;

if (opts == LYD_INSERT_NODE_LAST) {
if ((opts == LYD_INSERT_NODE_LAST) || !node->schema || (first_sibling && (first_sibling->flags & LYD_EXT))) {
lyd_insert_node_last(parent, &first_sibling, node);
} else if (opts == LYD_INSERT_NODE_LAST_BY_SCHEMA) {
lyd_insert_node_ordby_schema(parent, &first_sibling, node);
Expand Down

0 comments on commit f914223

Please sign in to comment.