From: Eshel Yaron Date: Wed, 4 Jan 2023 08:06:37 +0000 (+0200) Subject: * sweep.pl (list_tail/2): Fix possible non-termination X-Git-Tag: V9.1.2-sweep-0.11.0~2 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=556521bbc3de285e38e598d294b2e7b24a1e6b1d;p=dict.git * sweep.pl (list_tail/2): Fix possible non-termination --- diff --git a/README.org b/README.org index 757f19e..b66ceb3 100644 --- a/README.org +++ b/README.org @@ -1338,7 +1338,7 @@ command ~M-x sweeprolog-term-search~. This command, bound by default to ~C-c C-s~ in ~sweeprolog-mode~ buffers, prompts for a Prolog term to search for and finds terms in the current buffer that the search term subsumes. For example, to find if-then-else constructs in the current -buffer do ~C-c C-s _ ; _ -> _ RET~. +buffer do ~C-c C-s _ -> _ ; _ RET~. #+FINDEX: sweeprolog-term-search-repeat-forward #+FINDEX: sweeprolog-term-search-repeat-backward diff --git a/sweep.pl b/sweep.pl index e7e3c46..c9fdf80 100644 --- a/sweep.pl +++ b/sweep.pl @@ -1028,5 +1028,5 @@ sweep_match_term(parentheses_term_position(_, _, ContentPos), Term0, Term, From, sweep_match_term(quasi_quotation_position(_, _, SyntaxTerm, SyntaxPos, _), _, Term, From, To) :- sweep_match_term(SyntaxPos, SyntaxTerm, Term, From, To). -list_tail([_|T0], T) :- T0 = [_|_], !, list_tail(T0, T). +list_tail([_|T0], T) :- nonvar(T0), T0 = [_|_], !, list_tail(T0, T). list_tail([_|T], T). diff --git a/sweeprolog-tests.el b/sweeprolog-tests.el index f2d4206..5fa1cf8 100644 --- a/sweeprolog-tests.el +++ b/sweeprolog-tests.el @@ -85,6 +85,7 @@ foo(Baz) :- baz. "pl" " bar(bar(bar), bar{bar:bar}, [bar,bar|bar]). +foo([Bar|Baz]). "))) (find-file-literally temp) (sweeprolog-mode)