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.
This commit is contained in:
Eli Zaretskii 2023-04-14 09:21:05 +03:00
parent 759cdf1e51
commit 14e809ddff

View file

@ -3156,8 +3156,9 @@ treesit_search_forward (TSTreeCursor *cursor,
} }
} }
/** Cleanup function for cursor. */ /* Cleanup function for cursor. */
static void treesit_traverse_cleanup_cursor(void *cursor) static void
treesit_traverse_cleanup_cursor(void *cursor)
{ {
ts_tree_cursor_delete ((TSTreeCursor *) 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); return_value = make_treesit_node (parser, node);
} }
unbind_to (count, Qnil); return unbind_to (count, return_value);
ts_tree_cursor_delete (&cursor);
return return_value;
} }
DEFUN ("treesit-search-forward", DEFUN ("treesit-search-forward",
@ -3276,10 +3274,7 @@ always traverse leaf nodes first, then upwards. */)
return_value = make_treesit_node (parser, node); return_value = make_treesit_node (parser, node);
} }
unbind_to (count, Qnil); return unbind_to (count, return_value);
ts_tree_cursor_delete (&cursor);
return return_value;
} }
/* Recursively traverse the tree under CURSOR, and append the result /* Recursively traverse the tree under CURSOR, and append the result
@ -3402,7 +3397,6 @@ a regexp. */)
unbind_to (count, Qnil); unbind_to (count, Qnil);
ts_tree_cursor_delete (&cursor);
Fsetcdr (parent, Fnreverse (Fcdr (parent))); Fsetcdr (parent, Fnreverse (Fcdr (parent)));
if (NILP (Fcdr (parent))) if (NILP (Fcdr (parent)))
return Qnil; return Qnil;