From: Eli Zaretskii Date: Fri, 14 Apr 2023 06:21:05 +0000 (+0300) Subject: Fix style and unwinding code in treesit.c X-Git-Tag: emacs-29.0.91~143 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=14e809ddff1e60fb53d8570d9b5cfa3cb134858f;p=emacs.git 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. --- 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;