[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 14e809ddff1 2/2: Fix style and unwinding code in treesit.c
From: |
Eli Zaretskii |
Subject: |
emacs-29 14e809ddff1 2/2: Fix style and unwinding code in treesit.c |
Date: |
Fri, 14 Apr 2023 02:24:22 -0400 (EDT) |
branch: emacs-29
commit 14e809ddff1e60fb53d8570d9b5cfa3cb134858f
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
Fix style and unwinding code in treesit.c
This was supposed to be a cherry-pick from master, but
isn't, due to the unnecessary rush to fix master without
cleaning up the mess first and without separating changes
that can and cannot be backported.
* src/treesit.c (treesit_traverse_cleanup_cursor): Fix indentation
style.
(Ftreesit_search_subtree, Ftreesit_search_forward)
(Ftreesit_induce_sparse_tree): Fix specpdl unwinding. (Bug#62823)
Do not merge to master.
---
src/treesit.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/src/treesit.c b/src/treesit.c
index 7d5d033c02c..53dbeb68882 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -3156,8 +3156,9 @@ treesit_search_forward (TSTreeCursor *cursor,
}
}
-/** Cleanup function for cursor. */
-static void treesit_traverse_cleanup_cursor(void *cursor)
+/* Cleanup function for cursor. */
+static void
+treesit_traverse_cleanup_cursor(void *cursor)
{
ts_tree_cursor_delete ((TSTreeCursor *) cursor);
}
@@ -3213,10 +3214,7 @@ Return the first matched node, or nil if none matches.
*/)
return_value = make_treesit_node (parser, node);
}
- unbind_to (count, Qnil);
-
- ts_tree_cursor_delete (&cursor);
- return return_value;
+ return unbind_to (count, return_value);
}
DEFUN ("treesit-search-forward",
@@ -3276,10 +3274,7 @@ always traverse leaf nodes first, then upwards. */)
return_value = make_treesit_node (parser, node);
}
- unbind_to (count, Qnil);
-
- ts_tree_cursor_delete (&cursor);
- return return_value;
+ return unbind_to (count, return_value);
}
/* Recursively traverse the tree under CURSOR, and append the result
@@ -3402,7 +3397,6 @@ a regexp. */)
unbind_to (count, Qnil);
- ts_tree_cursor_delete (&cursor);
Fsetcdr (parent, Fnreverse (Fcdr (parent)));
if (NILP (Fcdr (parent)))
return Qnil;