]> git.eshelyaron.com Git - dict.git/commitdiff
FIXED: find next predicate definition more reliably
authorEshel Yaron <me@eshelyaron.com>
Sun, 1 Jan 2023 20:17:22 +0000 (22:17 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sun, 1 Jan 2023 20:17:22 +0000 (22:17 +0200)
* sweep.pl (sweeprolog_beginning_of_last_predicate/2)
(sweeprolog_beginning_of_last_predicate/2): explicitly sort results,
don't assume xref_defined/3 yields ordered results.

sweep.pl

index 5b0b13b3b1140cc4daedad8b3ed36feda32a3b17..f859eeac1fb55bc382e3741b4f2f6f5ad7b220ae 100644 (file)
--- a/sweep.pl
+++ b/sweep.pl
@@ -755,13 +755,19 @@ sweep_beginning_of_last_predicate(Start, Next) :-
                 L < Start
             ),
             Ls),
-    reverse(Ls, [Next|_]).
+    sort(Ls, Sorted),
+    reverse(Sorted, [Next|_]).
 
 sweep_beginning_of_next_predicate(Start, Next) :-
     sweep_source_id(Path),
     xref_source(Path, [comments(store)]),
-    xref_defined(Path, _, H), xref_definition_line(H, Next),
-    Start < Next.
+    findall(L,
+            (   xref_defined(Path, _, H),
+                xref_definition_line(H, L),
+                Start < L
+            ),
+            Ls),
+    sort(Ls, [Next|_]).
 
 sweep_source_id(Path) :-
     sweep_main_thread,