diff options
author | Po Lu <luangruo@yahoo.com> | 2023-04-14 08:01:12 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2023-04-14 08:01:12 +0800 |
commit | 2c3ca78e811b288aa4801f78c11ba9ddf9ffe02c (patch) | |
tree | 95f2e1dca188f1cb395e1046133a445707825b6a /src/treesit.c | |
parent | 361c5fc2d8e52d70aa58956c57eaef9495881197 (diff) | |
download | emacs-2c3ca78e811b288aa4801f78c11ba9ddf9ffe02c.tar.gz |
Fix bugs in treesit.o
* src/treesit.c (treesit_traverse_match_predicate): Remove
redundant cast.
(treesit_search_forward, treesit_traverse_cleanup_cursor)
(Ftreesit_search_subtree, Ftreesit_search_forward)
(Ftreesit_induce_sparse_tree): Fix coding style and specpdl
unwinding.
Diffstat (limited to 'src/treesit.c')
-rw-r--r-- | src/treesit.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/src/treesit.c b/src/treesit.c index 09d998b56c8..45b5ab15390 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -3243,10 +3243,8 @@ treesit_traverse_match_predicate (TSTreeCursor *cursor, Lisp_Object pred, Lisp_Object cdr = XCDR (pred); if (EQ (car, Qnot)) - { - return !treesit_traverse_match_predicate (cursor, XCAR (cdr), - parser, named); - } + return !treesit_traverse_match_predicate (cursor, XCAR (cdr), + parser, named); else if (EQ (car, Qor)) { FOR_EACH_TAIL (cdr) @@ -3287,6 +3285,7 @@ treesit_traverse_match_predicate (TSTreeCursor *cursor, Lisp_Object pred, forward, false backward. If SKIP_ROOT is true, don't match ROOT. This function may signal if the predicate function signals. */ + static bool treesit_search_dfs (TSTreeCursor *cursor, Lisp_Object pred, Lisp_Object parser, @@ -3325,6 +3324,7 @@ treesit_search_dfs (TSTreeCursor *cursor, position is undefined. This function may signal if the predicate function signals. */ + static bool treesit_search_forward (TSTreeCursor *cursor, Lisp_Object pred, Lisp_Object parser, @@ -3334,8 +3334,7 @@ treesit_search_forward (TSTreeCursor *cursor, nodes. This way repeated call of this function traverses each node in the tree once and only once: - (while node (setq node (treesit-search-forward node))) - */ + (while node (setq node (treesit-search-forward node))) */ bool initial = true; while (true) { @@ -3362,10 +3361,12 @@ treesit_search_forward (TSTreeCursor *cursor, } } -/** Cleanup function for cursor. */ -static void treesit_traverse_cleanup_cursor(void *cursor) +/* Clean up the given tree cursor CURSOR. */ + +static void +treesit_traverse_cleanup_cursor (void *cursor) { - ts_tree_cursor_delete ((TSTreeCursor *) cursor); + ts_tree_cursor_delete (cursor); } DEFUN ("treesit-search-subtree", @@ -3421,10 +3422,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", @@ -3486,10 +3484,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 @@ -3616,8 +3611,8 @@ a regexp. */) unbind_to (count, Qnil); - ts_tree_cursor_delete (&cursor); Fsetcdr (parent, Fnreverse (Fcdr (parent))); + if (NILP (Fcdr (parent))) return Qnil; else |