diff options
| author | Eli Zaretskii | 2023-04-14 09:21:05 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2023-04-14 09:21:05 +0300 |
| commit | 14e809ddff1e60fb53d8570d9b5cfa3cb134858f (patch) | |
| tree | 1a7b4a29ad79f6d8ce4665b9eab706dcf159b36b | |
| parent | 759cdf1e510d9e0689aefeced784fbb81644cd5e (diff) | |
| download | emacs-14e809ddff1e60fb53d8570d9b5cfa3cb134858f.tar.gz emacs-14e809ddff1e60fb53d8570d9b5cfa3cb134858f.zip | |
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.
| -rw-r--r-- | src/treesit.c | 16 |
1 files 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, | |||
| 3156 | } | 3156 | } |
| 3157 | } | 3157 | } |
| 3158 | 3158 | ||
| 3159 | /** Cleanup function for cursor. */ | 3159 | /* Cleanup function for cursor. */ |
| 3160 | static void treesit_traverse_cleanup_cursor(void *cursor) | 3160 | static void |
| 3161 | treesit_traverse_cleanup_cursor(void *cursor) | ||
| 3161 | { | 3162 | { |
| 3162 | ts_tree_cursor_delete ((TSTreeCursor *) cursor); | 3163 | ts_tree_cursor_delete ((TSTreeCursor *) cursor); |
| 3163 | } | 3164 | } |
| @@ -3213,10 +3214,7 @@ Return the first matched node, or nil if none matches. */) | |||
| 3213 | return_value = make_treesit_node (parser, node); | 3214 | return_value = make_treesit_node (parser, node); |
| 3214 | } | 3215 | } |
| 3215 | 3216 | ||
| 3216 | unbind_to (count, Qnil); | 3217 | return unbind_to (count, return_value); |
| 3217 | |||
| 3218 | ts_tree_cursor_delete (&cursor); | ||
| 3219 | return return_value; | ||
| 3220 | } | 3218 | } |
| 3221 | 3219 | ||
| 3222 | DEFUN ("treesit-search-forward", | 3220 | DEFUN ("treesit-search-forward", |
| @@ -3276,10 +3274,7 @@ always traverse leaf nodes first, then upwards. */) | |||
| 3276 | return_value = make_treesit_node (parser, node); | 3274 | return_value = make_treesit_node (parser, node); |
| 3277 | } | 3275 | } |
| 3278 | 3276 | ||
| 3279 | unbind_to (count, Qnil); | 3277 | return unbind_to (count, return_value); |
| 3280 | |||
| 3281 | ts_tree_cursor_delete (&cursor); | ||
| 3282 | return return_value; | ||
| 3283 | } | 3278 | } |
| 3284 | 3279 | ||
| 3285 | /* Recursively traverse the tree under CURSOR, and append the result | 3280 | /* Recursively traverse the tree under CURSOR, and append the result |
| @@ -3402,7 +3397,6 @@ a regexp. */) | |||
| 3402 | 3397 | ||
| 3403 | unbind_to (count, Qnil); | 3398 | unbind_to (count, Qnil); |
| 3404 | 3399 | ||
| 3405 | ts_tree_cursor_delete (&cursor); | ||
| 3406 | Fsetcdr (parent, Fnreverse (Fcdr (parent))); | 3400 | Fsetcdr (parent, Fnreverse (Fcdr (parent))); |
| 3407 | if (NILP (Fcdr (parent))) | 3401 | if (NILP (Fcdr (parent))) |
| 3408 | return Qnil; | 3402 | return Qnil; |