diff: queue.m bug fix

Andrew Bromage bromage at cs.mu.OZ.AU
Tue Sep 8 11:27:51 AEST 1998


G'day all.

Since nobody had any objections to this part of my previous diff, this
has been committed.

Cheers,
Andrew Bromage

Estimated hours taken: 0.5

library/queue.m:
	Fix a bug in queue__delete where the constraint that the `off'
	list is empty if and only if the queue is empty was not being
	preserved in all cases.

Index: library/queue.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/queue.m,v
retrieving revision 1.19
diff -u -t -u -r1.19 queue.m
--- queue.m	1998/02/24 23:59:52	1.19
+++ queue.m	1998/04/09 02:05:56
@@ -165,7 +165,14 @@
 queue__list_to_queue(List, [] - List).
 
 queue__delete_all(On0 - Off0, Elem, On - Off) :-
-        list__delete_all(On0, Elem, On),
-        list__delete_all(Off0, Elem, Off).
+        list__delete_all(On0, Elem, On1),
+        list__delete_all(Off0, Elem, Off1),
+        ( Off1 = [] ->
+                list__reverse(On1, Off),
+                On = []
+        ;
+                On = On1,
+                Off = Off1
+        ).
 
 %--------------------------------------------------------------------------%



More information about the developers mailing list