fix that iteration continued with siblings for a subtree-root - fixes #656 default tip

Sun, 27 Apr 2025 12:56:05 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 27 Apr 2025 12:56:05 +0200
changeset 1309
b240b73d2a10
parent 1308
ce01b482daa3

fix that iteration continued with siblings for a subtree-root - fixes #656

CHANGELOG file | annotate | diff | comparison | revisions
docs/Writerside/topics/about.md file | annotate | diff | comparison | revisions
src/tree.c file | annotate | diff | comparison | revisions
--- a/CHANGELOG	Sun Apr 27 12:54:16 2025 +0200
+++ b/CHANGELOG	Sun Apr 27 12:56:05 2025 +0200
@@ -12,6 +12,7 @@
  * changes grow strategy for CxBuffer, which does now take the page size into account
  * changes the implementation of cx_strreplacen() for improved efficiency
  * changes all cxListIterator() without index to also accept NULL as list argument
+ * fixes that starting an iteration in a non-root node incorrectly continues iteration with the siblings of that node
  * fixes unnecessary allocations in cx_strcat() family of functions
  * fixes errno value after failing cxBufferSeek() to be consistently EINVAL
  * fixes implementation of cxBufferTerminate()
--- a/docs/Writerside/topics/about.md	Sun Apr 27 12:54:16 2025 +0200
+++ b/docs/Writerside/topics/about.md	Sun Apr 27 12:56:05 2025 +0200
@@ -39,6 +39,7 @@
 * changes grow strategy for CxBuffer, which does now take the page size into account
 * changes the implementation of cx_strreplacen() for improved efficiency
 * changes all cxListIterator() without index to also accept NULL as list argument
+* fixes that starting an iteration in a non-root node incorrectly continues iteration with the siblings of that node
 * fixes unnecessary allocations in cx_strcat() family of functions
 * fixes errno value after failing cxBufferSeek() to be consistently EINVAL
 * fixes implementation of cxBufferTerminate()
--- a/src/tree.c	Sun Apr 27 12:54:16 2025 +0200
+++ b/src/tree.c	Sun Apr 27 12:56:05 2025 +0200
@@ -307,10 +307,10 @@
         // search for the next node
         void *next;
         cx_tree_iter_search_next:
-        // check if there is a sibling
+        // check if there is a sibling, but only if we are not a (subtree-)root
         if (iter->exiting) {
             next = iter->node_next;
-        } else {
+        } else if (iter->depth > 1) {
             next = tree_next(iter->node);
             iter->node_next = next;
         }

mercurial