diff --git a/C/save.c b/C/save.c
index ea8669eb0..cf143008f 100644
--- a/C/save.c
+++ b/C/save.c
@@ -2104,6 +2104,7 @@ RestoreClause(Clause *Cl)
case _p_slr_vv:
case _p_arg_vv:
case _p_func2s_vv:
+ case _p_func2f_xx:
pc->u.xxx.x = XAdjust(pc->u.xxx.x);
pc->u.xxx.x1 = XAdjust(pc->u.xxx.x1);
pc->u.xxx.x2 = XAdjust(pc->u.xxx.x2);
@@ -2140,6 +2141,13 @@ RestoreClause(Clause *Cl)
pc->u.xcx.xi = XAdjust(pc->u.xcx.xi);
pc = NEXTOP(pc,xcx);
break;
+ /* instructions type xyx */
+ case _p_func2f_xy:
+ pc->u.xyx.x = XAdjust(pc->u.xyx.x);
+ pc->u.xyx.x1 = XAdjust(pc->u.xyx.x1);
+ pc->u.xyx.y2 = YAdjust(pc->u.xyx.y2);
+ pc = NEXTOP(pc,xyx);
+ break;
/* instructions type yxx */
case _p_plus_y_vv:
case _p_minus_y_vv:
@@ -2151,11 +2159,19 @@ RestoreClause(Clause *Cl)
case _p_slr_y_vv:
case _p_arg_y_vv:
case _p_func2s_y_vv:
+ case _p_func2f_yx:
pc->u.yxx.y = YAdjust(pc->u.yxx.y);
pc->u.yxx.x1 = XAdjust(pc->u.yxx.x1);
pc->u.yxx.x2 = XAdjust(pc->u.yxx.x2);
pc = NEXTOP(pc,yxx);
break;
+ /* instructions type yyx */
+ case _p_func2f_yy:
+ pc->u.yyx.y1 = YAdjust(pc->u.yyx.y1);
+ pc->u.yyx.y2 = YAdjust(pc->u.yyx.y2);
+ pc->u.yyx.x = XAdjust(pc->u.yyx.x);
+ pc = NEXTOP(pc,yyx);
+ break;
/* instructions type yxc */
case _p_plus_y_vc:
case _p_minus_y_cv:
diff --git a/changes4.3.html b/changes4.3.html
index 3908cd6ef..51cda48b8 100644
--- a/changes4.3.html
+++ b/changes4.3.html
@@ -6,6 +6,8 @@
Yap-4.3.19:
+ - FIXED: ord_union/2 should not use use merge/3 but instead
+ ord_union/3 (report from Nicos Angelopoulos).
- FIXED: statistics/0 should report to user_error (report from Nicos
Angelopoulos).
- FIXED: database could copy compiled floats,longs, and bigs
diff --git a/docs/yap.tex b/docs/yap.tex
index 9b9bd9d6a..4e42c3b44 100644
--- a/docs/yap.tex
+++ b/docs/yap.tex
@@ -6537,15 +6537,19 @@ True when @var{Numbers} is a list of integers, and @var{Total} is their sum.
@cindex ordered set
The following ordered set manipulation routines are available once
-included with the @code{use_module(library(ordsets))} command.
+included with the @code{use_module(library(ordsets))} command. An
+ordered set is represented by a list having unique and ordered
+elements. Output arguments are guaranteed to be ordered sets, if the
+relevant inputs are. This is a slightly patched version of Richard
+O'Keefe's original library.
@table @code
@item list_to_ord_set(+@var{List}, ?@var{Set})
@findex list_to_ord_set/2
@syindex list_to_ord_set/2
@cnindex list_to_ord_set/2
-Holds when @var{Set} is the ordered representation of the set represented
-by the unordered representation @var{List}.
+Holds when @var{Set} is the ordered representation of the set
+represented by the unordered representation @var{List}.
@item merge(+@var{List1}, +@var{List2}, -@var{Merged})
@findex merge/3
@@ -6553,6 +6557,10 @@ by the unordered representation @var{List}.
@cnindex merge/3
Holds when @var{Merged} is the stable merge of the two given lists.
+Notice that @code{merge/3} will not remove duplicates, so merging
+ordered sets will not necessarily result in an ordered set. Use
+@code{ord_union/3} instead.
+
@item ord_add_element(+@var{Set1}, +@var{Element}, ?@var{Set2})
@findex ord_add_element/3
@syindex ord_add_element/3
diff --git a/library/ordsets.yap b/library/ordsets.yap
index 73421b49e..9cdde7fb1 100644
--- a/library/ordsets.yap
+++ b/library/ordsets.yap
@@ -316,16 +316,16 @@ ord_member(>,El,[H|T]) :-
ord_union([], []).
ord_union([Set|Sets], Union) :-
length([Set|Sets], NumberOfSets),
- merge_all(NumberOfSets, [Set|Sets], Union, []).
+ ord_union_all(NumberOfSets, [Set|Sets], Union, []).
-merge_all(N,Sets0,Union,Sets) :-
+ord_union_all(N,Sets0,Union,Sets) :-
( N=:=1 -> Sets0=[Union|Sets]
; N=:=2 -> Sets0=[Set1,Set2|Sets],
- merge(Set1,Set2,Union)
+ ord_union(Set1,Set2,Union)
; A is N>>1,
Z is N-A,
- merge_all(A, Sets0, X, Sets1),
- merge_all(Z, Sets1, Y, Sets),
- merge(X, Y, Union)
+ ord_union_all(A, Sets0, X, Sets1),
+ ord_union_all(Z, Sets1, Y, Sets),
+ ord_union(X, Y, Union)
).