bug-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PATCH: Fix sorting problem


From: Peter Collingbourne
Subject: PATCH: Fix sorting problem
Date: Fri, 28 May 2004 12:14:19 +0100
User-agent: Mutt/1.4.1i

Hello

I've found a problem with the sort/2 (and others) predicate in GProlog.
This problem occurs in 1.2.16, as well as the latest unstable version.
The problem occurs when you try to sort a list containing a negative
number:

| ?- sort([-1,1,2,3],X).

X = [1,2,3,-1]

CLearly the -1 is out of place. I did some investigation and found the
underlying problem was in the Term_Compare function in
BipsPl/term_supp.c. Apparently UnTag_INT is not being called on the
arguments when they are compared. Here is a patch to solve the problem:

--- term_supp.c.old     2004-05-28 11:23:42.000000000 +0100
+++ term_supp.c 2004-05-28 11:51:26.000000000 +0100
@@ -126,7 +126,7 @@
          v_tag == FLT)
        return 1;
 
-      return (v_tag != INT) ? -1 : u_word - v_word;
+      return (v_tag != INT) ? -1 : UnTag_INT(u_word) - UnTag_INT(v_word);
 
     case ATM:
       if (v_tag == REF ||
-- 
Peter




reply via email to

[Prev in Thread] Current Thread [Next in Thread]