[m-rev.] diff: fix foreign_proc formatting
Zoltan Somogyi
zs at cs.mu.OZ.AU
Fri May 9 19:10:05 AEST 2003
library/array.m:
library/char.m:
library/float.m:
library/int.m:
library/private_builtin.m:
library/string.m:
Fix inconsistent formatting of foreign_proc definitions.
Zoltan.
cvs diff: Diffing .
Index: array.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/array.m,v
retrieving revision 1.120
diff -u -b -r1.120 array.m
--- array.m 5 Mar 2003 15:55:21 -0000 1.120
+++ array.m 9 May 2003 04:58:09 -0000
@@ -700,8 +700,10 @@
:- pred bounds_checks is semidet.
:- pragma inline(bounds_checks/0).
-:- pragma foreign_proc("C", bounds_checks,
- [will_not_call_mercury, promise_pure, thread_safe], "
+:- pragma foreign_proc("C",
+ bounds_checks,
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
#ifdef ML_OMIT_ARRAY_BOUNDS_CHECKS
SUCCESS_INDICATOR = MR_FALSE;
#else
@@ -709,8 +711,10 @@
#endif
").
-:- pragma foreign_proc("MC++", bounds_checks,
- [will_not_call_mercury, promise_pure, thread_safe], "
+:- pragma foreign_proc("MC++",
+ bounds_checks,
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
#if ML_OMIT_ARRAY_BOUNDS_CHECKS
SUCCESS_INDICATOR = MR_FALSE;
#else
@@ -758,21 +762,24 @@
:- pragma foreign_proc("C",
array__init_2(Size::in, Item::in, Array::array_uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
MR_incr_hp_msg(Array, Size + 1, MR_PROC_LABEL, ""array:array/1"");
ML_init_array((MR_ArrayType *)Array, Size, Item);
").
:- pragma foreign_proc("C",
array__make_empty_array(Array::array_uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
MR_incr_hp_msg(Array, 1, MR_PROC_LABEL, ""array:array/1"");
ML_init_array((MR_ArrayType *)Array, 0, 0);
").
:- pragma foreign_proc("C#",
array__init_2(Size::in, Item::in, Array::array_uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Array = System.Array.CreateInstance(Item.GetType(), Size);
for (int i = 0; i < Size; i++) {
Array.SetValue(Item, i);
@@ -780,7 +787,8 @@
").
:- pragma foreign_proc("C#",
array__make_empty_array(Array::array_uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
// XXX A better solution then using the null pointer to represent
// the empty array would be to create an array of size 0. However
// we need to determine the element type of the array before we can
@@ -795,26 +803,30 @@
:- pragma foreign_proc("C",
array__min(Array::array_ui, Min::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
/* Array not used */
Min = 0;
").
:- pragma foreign_proc("C",
array__min(Array::in, Min::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
/* Array not used */
Min = 0;
").
:- pragma foreign_proc("C#",
array__min(Array::array_ui, Min::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
/* Array not used */
Min = 0;
").
:- pragma foreign_proc("C#",
array__min(Array::in, Min::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
/* Array not used */
Min = 0;
").
@@ -822,17 +834,20 @@
:- pragma promise_pure(array__max/2).
:- pragma foreign_proc("C",
array__max(Array::array_ui, Max::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Max = ((MR_ArrayType *)Array)->size - 1;
").
:- pragma foreign_proc("C",
array__max(Array::in, Max::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Max = ((MR_ArrayType *)Array)->size - 1;
").
:- pragma foreign_proc("C#",
array__max(Array::array_ui, Max::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
if (Array != null) {
Max = Array.Length - 1;
} else {
@@ -841,7 +856,8 @@
").
:- pragma foreign_proc("C#",
array__max(Array::in, Max::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
if (Array != null) {
Max = Array.Length - 1;
} else {
@@ -857,18 +873,21 @@
:- pragma foreign_proc("C",
array__size(Array::array_ui, Max::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Max = ((MR_ArrayType *)Array)->size;
").
:- pragma foreign_proc("C",
array__size(Array::in, Max::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Max = ((MR_ArrayType *)Array)->size;
").
:- pragma foreign_proc("C#",
array__size(Array::array_ui, Max::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
if (Array != null) {
Max = Array.Length;
} else {
@@ -877,7 +896,8 @@
").
:- pragma foreign_proc("C#",
array__size(Array::in, Max::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
if (Array != null) {
Max = Array.Length;
} else {
@@ -922,25 +942,29 @@
:- pragma foreign_proc("C",
array__unsafe_lookup(Array::array_ui, Index::in, Item::out),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
MR_ArrayType *array = (MR_ArrayType *)Array;
Item = array->elements[Index];
}").
:- pragma foreign_proc("C",
array__unsafe_lookup(Array::in, Index::in, Item::out),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
MR_ArrayType *array = (MR_ArrayType *)Array;
Item = array->elements[Index];
}").
:- pragma foreign_proc("C#",
array__unsafe_lookup(Array::array_ui, Index::in, Item::out),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
Item = Array.GetValue(Index);
}").
:- pragma foreign_proc("C#",
array__unsafe_lookup(Array::in, Index::in, Item::out),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
Item = Array.GetValue(Index);
}").
@@ -959,7 +983,8 @@
:- pragma foreign_proc("C",
array__unsafe_set(Array0::array_di, Index::in,
Item::in, Array::array_uo),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
MR_ArrayType *array = (MR_ArrayType *)Array0;
array->elements[Index] = Item; /* destructive update! */
Array = Array0;
@@ -968,7 +993,8 @@
:- pragma foreign_proc("C#",
array__unsafe_set(Array0::array_di, Index::in,
Item::in, Array::array_uo),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
Array0.SetValue(Item, Index); /* destructive update! */
Array = Array0;
}").
@@ -1020,7 +1046,8 @@
:- pragma foreign_proc("C",
array__resize(Array0::array_di, Size::in, Item::in,
Array::array_uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
if (((MR_ArrayType *)Array0)->size == Size) {
Array = Array0;
} else {
@@ -1034,8 +1061,8 @@
:- pragma foreign_proc("C#",
array__resize(Array0::array_di, Size::in, Item::in,
Array::array_uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
-
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
if (Array0 == null) {
Array = System.Array.CreateInstance(Item.GetType(), Size);
for (int i = 0; i < Size; i++) {
@@ -1105,7 +1132,8 @@
:- pragma foreign_proc("C",
array__shrink_2(Array0::array_di, Size::in, Array::array_uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
MR_incr_hp_msg(Array, Size + 1, MR_PROC_LABEL, ""array:array/1"");
ML_shrink_array((MR_ArrayType *)Array, (MR_ArrayType *) Array0,
Size);
@@ -1113,7 +1141,8 @@
:- pragma foreign_proc("C#",
array__shrink_2(Array0::array_di, Size::in, Array::array_uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Array = System.Array.CreateInstance(
Array0.GetType().GetElementType(), Size);
System.Array.Copy(Array0, Array, Size);
@@ -1152,24 +1181,26 @@
:- pragma foreign_proc("C",
array__copy(Array0::array_ui, Array::array_uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
MR_incr_hp_msg(Array, (((const MR_ArrayType *) Array0)->size) + 1,
MR_PROC_LABEL, ""array:array/1"");
- ML_copy_array((MR_ArrayType *)Array, (const MR_ArrayType *) Array0);
+ ML_copy_array((MR_ArrayType *) Array, (const MR_ArrayType *) Array0);
").
:- pragma foreign_proc("C",
array__copy(Array0::in, Array::array_uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
MR_incr_hp_msg(Array, (((const MR_ArrayType *) Array0)->size) + 1,
MR_PROC_LABEL, ""array:array/1"");
- ML_copy_array((MR_ArrayType *)Array, (const MR_ArrayType *) Array0);
+ ML_copy_array((MR_ArrayType *) Array, (const MR_ArrayType *) Array0);
").
:- pragma foreign_proc("C#",
array__copy(Array0::array_ui, Array::array_uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
-
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
// XXX we implement the same as ML_copy_array, which doesn't appear
// to deep copy the array elements
Array = System.Array.CreateInstance(
@@ -1179,8 +1210,8 @@
:- pragma foreign_proc("C#",
array__copy(Array0::in, Array::array_uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
-
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
// XXX we implement the same as ML_copy_array, which doesn't appear
// to deep copy the array elements
Array = System.Array.CreateInstance(
@@ -1379,8 +1410,6 @@
Sz = array__size(A0),
permutation_2(Lo, Lo, Hi, Sz, A0, A, RS0, RS).
-
-
:- pred permutation_2(int, int, int, int, array(T), array(T),
random__supply, random__supply).
:- mode permutation_2(in, in, in, in, array_di, array_uo, mdi, muo) is det.
@@ -1412,8 +1441,6 @@
array__foldl(Fn, A, X) =
foldl_0(Fn, A, X, array__min(A), array__max(A)).
-
-
:- func foldl_0(func(T1, T2) = T2, array(T1), T2, int, int) = T2.
:- mode foldl_0(func(in, in) = out is det, array_ui, in, in, in) = out is det.
:- mode foldl_0(func(in, in) = out is det, in, in, in, in) = out is det.
@@ -1430,8 +1457,6 @@
array__foldr(Fn, A, X) =
foldr_0(Fn, A, X, array__min(A), array__max(A)).
-
-
:- func foldr_0(func(T1, T2) = T2, array(T1), T2, int, int) = T2.
:- mode foldr_0(func(in, in) = out is det, array_ui, in, in, in) = out is det.
:- mode foldr_0(func(in, in) = out is det, in, in, in, in) = out is det.
@@ -1452,6 +1477,7 @@
% monotonic sequences and merging them, thereby taking advantage of
% any existing order in the input sequence.
%
+
:- func samsort_subarray(array(T), int, int) = array(T).
:- mode samsort_subarray(array_di, in, in) = array_uo is det.
@@ -1461,8 +1487,6 @@
samsort_subarray(A0, Lo, Hi) = A :-
samsort_up(0, A0, _, array__copy(A0), A, Lo, Hi, Lo).
-
-
:- pred samsort_up(int, array(T), array(T), array(T), array(T), int, int, int).
:- mode samsort_up(in, array_di, array_uo, array_di, array_uo, in, in, in)
is det.
@@ -1478,37 +1502,23 @@
% B is sorted from Lo .. Hi.
%
samsort_up(N, A0, A, B0, B, Lo, Hi, I) :-
-
( if I > Hi then
-
A = A0,
B = B0
-
else if N > 0 then
-
samsort_down(N - 1, B0, B1, A0, A1, I, Hi, J),
-
% A1 is sorted from I .. J - 1.
% A1 and B1 are identical from J .. Hi.
-
B2 = merge_subarrays(A1, B1, Lo, I - 1, I, J - 1, Lo),
A2 = A1,
-
% B2 is sorted from Lo .. J - 1.
-
samsort_up(N + 1, B2, B, A2, A, Lo, Hi, J)
-
else /* N = 0, I = Lo */
-
copy_run_ascending(A0, B0, B1, Lo, Hi, J),
-
% B1 is sorted from Lo .. J - 1.
-
samsort_up(N + 1, B1, B, A0, A, Lo, Hi, J)
).
-
-
:- pred samsort_down(int,array(T),array(T),array(T),array(T),int,int,int).
:- mode samsort_down(in, array_di, array_uo, array_di, array_uo, in, in, out)
is det.
@@ -1524,31 +1534,21 @@
% A and B are identical from I .. Hi.
%
samsort_down(N, A0, A, B0, B, Lo, Hi, I) :-
-
( if Lo > Hi then
-
A = A0,
B = B0,
I = Lo
-
else if N > 0 then
-
samsort_down(N - 1, B0, B1, A0, A1, Lo, Hi, J),
samsort_down(N - 1, B1, B2, A1, A2, J, Hi, I),
-
% A2 is sorted from Lo .. J - 1.
% A2 is sorted from J .. I - 1.
-
A = A2,
B = merge_subarrays(A2, B2, Lo, J - 1, J, I - 1, Lo)
-
% B is sorted from Lo .. I - 1.
-
else
-
A = A0,
copy_run_ascending(A0, B0, B, Lo, Hi, I)
-
% B is sorted from Lo .. I - 1.
).
@@ -1578,9 +1578,10 @@
:- pragma type_spec(search_until/4, T = string).
search_until(R, A, Lo, Hi) =
- ( if Lo < Hi, not compare(R, A ^ elem(Lo), A ^ elem(Lo + 1))
- then search_until(R, A, Lo + 1, Hi)
- else Lo + 1
+ ( if Lo < Hi, not compare(R, A ^ elem(Lo), A ^ elem(Lo + 1)) then
+ search_until(R, A, Lo + 1, Hi)
+ else
+ Lo + 1
).
%------------------------------------------------------------------------------%
@@ -1592,9 +1593,11 @@
:- pragma type_spec(copy_subarray/5, T = string).
copy_subarray(A, B, Lo, Hi, I) =
- ( if Lo =< Hi
- then copy_subarray(A, B ^ elem(I) := A ^ elem(Lo), Lo + 1, Hi, I + 1)
- else B
+ ( if Lo =< Hi then
+ copy_subarray(A, B ^ elem(I) := A ^ elem(Lo),
+ Lo + 1, Hi, I + 1)
+ else
+ B
).
%------------------------------------------------------------------------------%
@@ -1606,9 +1609,11 @@
:- pragma type_spec(copy_subarray_reverse/5, T = string).
copy_subarray_reverse(A, B, Lo, Hi, I) =
- ( if Lo =< Hi
- then copy_subarray_reverse(A, B ^ elem(I) := A ^ elem(Lo), Lo+1, Hi, I-1)
- else B
+ ( if Lo =< Hi then
+ copy_subarray_reverse(A, B ^ elem(I) := A ^ elem(Lo),
+ Lo + 1, Hi, I - 1)
+ else
+ B
).
%------------------------------------------------------------------------------%
@@ -1624,21 +1629,26 @@
:- pragma type_spec(merge_subarrays/7, T = string).
merge_subarrays(A, B0, Lo1, Hi1, Lo2, Hi2, I) = B :-
- ( if Lo1 > Hi1 then B = copy_subarray(A, B0, Lo2, Hi2, I)
- else if Lo2 > Hi2 then B = copy_subarray(A, B0, Lo1, Hi1, I)
+ ( if Lo1 > Hi1 then
+ B = copy_subarray(A, B0, Lo2, Hi2, I)
+ else if Lo2 > Hi2 then
+ B = copy_subarray(A, B0, Lo1, Hi1, I)
else
X1 = A ^ elem(Lo1),
X2 = A ^ elem(Lo2),
compare(R, X1, X2),
(
R = (<),
- B = merge_subarrays(A, B0^elem(I) := X1, Lo1+1, Hi1, Lo2, Hi2, I+1)
+ B = merge_subarrays(A, B0^elem(I) := X1,
+ Lo1+1, Hi1, Lo2, Hi2, I+1)
;
R = (=),
- B = merge_subarrays(A, B0^elem(I) := X1, Lo1+1, Hi1, Lo2, Hi2, I+1)
+ B = merge_subarrays(A, B0^elem(I) := X1,
+ Lo1+1, Hi1, Lo2, Hi2, I+1)
;
R = (>),
- B = merge_subarrays(A, B0^elem(I) := X2, Lo1, Hi1, Lo2+1, Hi2, I+1)
+ B = merge_subarrays(A, B0^elem(I) := X2,
+ Lo1, Hi1, Lo2+1, Hi2, I+1)
)
).
Index: char.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/char.m,v
retrieving revision 1.41
diff -u -b -r1.41 char.m
--- char.m 22 Feb 2003 11:17:34 -0000 1.41
+++ char.m 9 May 2003 04:20:22 -0000
@@ -429,19 +429,22 @@
:- pragma foreign_proc("C",
char__to_int(Character::in, Int::out),
- [will_not_call_mercury, promise_pure, thread_safe] , "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Int = (MR_UnsignedChar) Character;
").
:- pragma foreign_proc("C",
char__to_int(Character::in, Int::in),
- [will_not_call_mercury, promise_pure, thread_safe] , "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
SUCCESS_INDICATOR = ((MR_UnsignedChar) Character == Int);
").
:- pragma foreign_proc("C",
char__to_int(Character::out, Int::in),
- [will_not_call_mercury, promise_pure, thread_safe] , "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
/*
** If the integer doesn't fit into a char, then
** the assignment `Character = Int' below will truncate it.
@@ -454,19 +457,22 @@
:- pragma foreign_proc("MC++",
char__to_int(Character::in, Int::out),
- [will_not_call_mercury, promise_pure, thread_safe] , "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Int = Character;
").
:- pragma foreign_proc("MC++",
char__to_int(Character::in, Int::in),
- [will_not_call_mercury, promise_pure, thread_safe] , "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
SUCCESS_INDICATOR = (Character == Int);
").
:- pragma foreign_proc("MC++",
char__to_int(Character::out, Int::in),
- [will_not_call_mercury, promise_pure, thread_safe] , "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Character = Int;
SUCCESS_INDICATOR = (Character == Int);
").
@@ -479,12 +485,14 @@
:- pragma foreign_decl("C", "#include <limits.h>").
:- pragma foreign_proc("C",
char__max_char_value(Max::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Max = UCHAR_MAX;
").
:- pragma foreign_proc("C#",
char__max_char_value(Max::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
// .NET uses 16-bit 'Unicode'. This might be either UCS-2,
// where Unicode characters that don't fit in 16 bits are encoded
// in two 16 bit characters, or it might be just the 16-bit subset,
@@ -516,4 +524,3 @@
char__det_int_to_digit(N) = C :-
char__det_int_to_digit(N, C).
-
Index: float.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/float.m,v
retrieving revision 1.51
diff -u -b -r1.51 float.m
--- float.m 22 Feb 2003 11:17:34 -0000 1.51
+++ float.m 9 May 2003 04:20:22 -0000
@@ -240,8 +240,10 @@
:- pred domain_checks is semidet.
:- pragma inline(domain_checks/0).
-:- pragma foreign_proc("C", domain_checks,
- [will_not_call_mercury, promise_pure, thread_safe], "
+:- pragma foreign_proc("C",
+ domain_checks,
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
#ifdef ML_OMIT_MATH_DOMAIN_CHECKS
SUCCESS_INDICATOR = MR_FALSE;
#else
@@ -249,8 +251,10 @@
#endif
").
-:- pragma foreign_proc("MC++", domain_checks,
- [thread_safe, promise_pure], "
+:- pragma foreign_proc("MC++",
+ domain_checks,
+ [thread_safe, promise_pure],
+"
#if ML_OMIT_MATH_DOMAIN_CHECKS
SUCCESS_INDICATOR = MR_FALSE;
#else
@@ -268,12 +272,14 @@
% float__ceiling_to_int(X) returns the
% smallest integer not less than X.
-:- pragma foreign_proc("C", float__ceiling_to_int(X :: in) = (Ceil :: out),
+:- pragma foreign_proc("C",
+ float__ceiling_to_int(X :: in) = (Ceil :: out),
[will_not_call_mercury, promise_pure, thread_safe],
"
Ceil = (MR_Integer) ceil(X);
").
-:- pragma foreign_proc("C#", float__ceiling_to_int(X :: in) = (Ceil :: out),
+:- pragma foreign_proc("C#",
+ float__ceiling_to_int(X :: in) = (Ceil :: out),
[will_not_call_mercury, promise_pure, thread_safe],
"
Ceil = System.Convert.ToInt32(System.Math.Ceiling(X));
@@ -281,12 +287,14 @@
% float__floor_to_int(X) returns the
% largest integer not greater than X.
-:- pragma foreign_proc("C", float__floor_to_int(X :: in) = (Floor :: out),
+:- pragma foreign_proc("C",
+ float__floor_to_int(X :: in) = (Floor :: out),
[will_not_call_mercury, promise_pure, thread_safe],
"
Floor = (MR_Integer) floor(X);
").
-:- pragma foreign_proc("C#", float__floor_to_int(X :: in) = (Floor :: out),
+:- pragma foreign_proc("C#",
+ float__floor_to_int(X :: in) = (Floor :: out),
[will_not_call_mercury, promise_pure, thread_safe],
"
Floor = System.Convert.ToInt32(System.Math.Floor(X));
@@ -294,12 +302,14 @@
% float__round_to_int(X) returns the integer closest to X.
% If X has a fractional value of 0.5, it is rounded up.
-:- pragma foreign_proc("C", float__round_to_int(X :: in) = (Round :: out),
+:- pragma foreign_proc("C",
+ float__round_to_int(X :: in) = (Round :: out),
[will_not_call_mercury, promise_pure, thread_safe],
"
Round = (MR_Integer) floor(X + 0.5);
").
-:- pragma foreign_proc("C#", float__round_to_int(X :: in) = (Round :: out),
+:- pragma foreign_proc("C#",
+ float__round_to_int(X :: in) = (Round :: out),
[will_not_call_mercury, promise_pure, thread_safe],
"
Round = System.Convert.ToInt32(System.Math.Floor(X + 0.5));
@@ -307,12 +317,14 @@
% float__truncate_to_int(X) returns the integer closest
% to X such that |float__truncate_to_int(X)| =< |X|.
-:- pragma foreign_proc("C", float__truncate_to_int(X :: in) = (Trunc :: out),
+:- pragma foreign_proc("C",
+ float__truncate_to_int(X :: in) = (Trunc :: out),
[will_not_call_mercury, promise_pure, thread_safe],
"
Trunc = (MR_Integer) X;
").
-:- pragma foreign_proc("C#", float__truncate_to_int(X :: in) = (Trunc :: out),
+:- pragma foreign_proc("C#",
+ float__truncate_to_int(X :: in) = (Trunc :: out),
[will_not_call_mercury, promise_pure, thread_safe],
"
Trunc = System.Convert.ToInt32(X);
@@ -402,12 +414,14 @@
%---------------------------------------------------------------------------%
-:- pragma foreign_proc("C", float__hash(F::in) = (H::out),
+:- pragma foreign_proc("C",
+ float__hash(F::in) = (H::out),
[will_not_call_mercury, promise_pure, thread_safe],
"
H = MR_hash_float(F);
").
-:- pragma foreign_proc("C#", float__hash(F::in) = (H::out),
+:- pragma foreign_proc("C#",
+ float__hash(F::in) = (H::out),
[will_not_call_mercury, promise_pure, thread_safe],
"
H = F.GetHashCode();
@@ -421,24 +435,32 @@
).
:- pragma promise_pure(is_nan/1).
-:- pragma foreign_proc(c, is_nan(Flt::in),
- [will_not_call_mercury, thread_safe], "
+:- pragma foreign_proc(c,
+ is_nan(Flt::in),
+ [will_not_call_mercury, thread_safe],
+"
SUCCESS_INDICATOR = MR_is_nan(Flt);
").
-:- pragma foreign_proc(il, is_nan(Flt::in),
- [will_not_call_mercury, thread_safe, max_stack_size(1)], "
+:- pragma foreign_proc(il,
+ is_nan(Flt::in),
+ [will_not_call_mercury, thread_safe, max_stack_size(1)],
+"
ldloc 'Flt'
call bool [mscorlib]System.Double::IsNaN(float64)
stloc 'succeeded'
").
:- pragma promise_pure(is_inf/1).
-:- pragma foreign_proc(c, is_inf(Flt::in),
- [will_not_call_mercury, thread_safe], "
+:- pragma foreign_proc(c,
+ is_inf(Flt::in),
+ [will_not_call_mercury, thread_safe],
+"
SUCCESS_INDICATOR = MR_is_inf(Flt);
").
-:- pragma foreign_proc(il, is_inf(Flt::in),
- [will_not_call_mercury, thread_safe, max_stack_size(1)], "
+:- pragma foreign_proc(il,
+ is_inf(Flt::in),
+ [will_not_call_mercury, thread_safe, max_stack_size(1)],
+"
ldloc 'Flt'
call bool [mscorlib]System.Double::IsInfinity(float64)
stloc 'succeeded'
@@ -484,84 +506,126 @@
").
% Maximum floating-point number
-:- pragma foreign_proc("C", float__max = (Max::out),
+:- pragma foreign_proc("C",
+ float__max = (Max::out),
[will_not_call_mercury, promise_pure, thread_safe],
- "Max = ML_FLOAT_MAX;").
-:- pragma foreign_proc("C#", float__max = (Max::out),
+"
+ Max = ML_FLOAT_MAX;
+").
+:- pragma foreign_proc("C#",
+ float__max = (Max::out),
[will_not_call_mercury, promise_pure, thread_safe],
- "Max = System.Double.MaxValue;").
+"
+ Max = System.Double.MaxValue;
+").
% Minimum normalised floating-point number */
-:- pragma foreign_proc("C", float__min = (Min::out),
+:- pragma foreign_proc("C",
+ float__min = (Min::out),
[will_not_call_mercury, promise_pure, thread_safe],
- "Min = ML_FLOAT_MIN;").
-:- pragma foreign_proc("C#", float__min = (Min::out),
+"
+ Min = ML_FLOAT_MIN;
+").
+:- pragma foreign_proc("C#",
+ float__min = (Min::out),
[will_not_call_mercury, promise_pure, thread_safe],
+"
% We can't use System.Double.MinValue, because in v1 of the .NET CLR,
% that means something completely different: the negative number
% with the greatest absolute value.
% Instead, we just hard-code the appropriate value (copied from the
% glibc header files); this is OK, because the ECMA specification
% nails down the representation of double as 64-bit IEEE.
- "Min = 2.2250738585072014e-308;").
+ Min = 2.2250738585072014e-308;
+").
% Smallest x such that x \= 1.0 + x
-:- pragma foreign_proc("C", float__epsilon = (Eps::out),
+:- pragma foreign_proc("C",
+ float__epsilon = (Eps::out),
[will_not_call_mercury, promise_pure, thread_safe],
- "Eps = ML_FLOAT_EPSILON;").
-:- pragma foreign_proc("C#", float__epsilon = (Eps::out),
+"
+ Eps = ML_FLOAT_EPSILON;
+").
+:- pragma foreign_proc("C#",
+ float__epsilon = (Eps::out),
[will_not_call_mercury, promise_pure, thread_safe],
+"
% We can't use System.Double.Epsilon, because in v1 of the .NET CLR,
% that means something completely different: the smallest (denormal)
% positive number. I don't know what the people who designed that
- % were smoking; that semantics for "epsilon" is different from the
- % use of "epsilon" in C, Lisp, Ada, etc., not to mention Mercury.
+ % were smoking; that semantics for 'epsilon' is different from the
+ % use of 'epsilon' in C, Lisp, Ada, etc., not to mention Mercury.
% Instead, we just hard-code the appropriate value (copied from the
% glibc header files); this is OK, because the ECMA specification
% nails down the representation of double as 64-bit IEEE.
- "Eps = 2.2204460492503131e-16;").
+ Eps = 2.2204460492503131e-16;
+").
% Radix of the floating-point representation.
-:- pragma foreign_proc("C", float__radix = (Radix::out),
+:- pragma foreign_proc("C",
+ float__radix = (Radix::out),
[will_not_call_mercury, promise_pure, thread_safe],
- "Radix = ML_FLOAT_RADIX;").
-:- pragma foreign_proc("C#", float__radix = (Radix::out),
+"
+ Radix = ML_FLOAT_RADIX;
+").
+:- pragma foreign_proc("C#",
+ float__radix = (Radix::out),
[will_not_call_mercury, promise_pure, thread_safe],
+"
% The ECMA specification requires that double be 64-bit IEEE.
% I think that implies that it must have Radix = 2.
% This is definitely right for x86, anyway.
- "Radix = 2;").
+ Radix = 2;
+").
% The number of base-radix digits in the mantissa.
-:- pragma foreign_proc("C", float__mantissa_digits = (MantDig::out),
+:- pragma foreign_proc("C",
+ float__mantissa_digits = (MantDig::out),
[will_not_call_mercury, promise_pure, thread_safe],
- "MantDig = ML_FLOAT_MANT_DIG;").
-:- pragma foreign_proc("C#", float__mantissa_digits = (MantDig::out),
+"
+ MantDig = ML_FLOAT_MANT_DIG;
+").
+:- pragma foreign_proc("C#",
+ float__mantissa_digits = (MantDig::out),
[will_not_call_mercury, promise_pure, thread_safe],
+"
% ECMA specifies that System.Double is 64-bit IEEE float
- "MantDig = 53;").
+ MantDig = 53;
+").
% Minimum negative integer such that:
% radix ** (min_exponent - 1)
% is a normalised floating-point number.
-:- pragma foreign_proc("C", float__min_exponent = (MinExp::out),
+:- pragma foreign_proc("C",
+ float__min_exponent = (MinExp::out),
[will_not_call_mercury, promise_pure, thread_safe],
- "MinExp = ML_FLOAT_MIN_EXP;").
-:- pragma foreign_proc("C#", float__min_exponent = (MinExp::out),
+"
+ MinExp = ML_FLOAT_MIN_EXP;
+").
+:- pragma foreign_proc("C#",
+ float__min_exponent = (MinExp::out),
[will_not_call_mercury, promise_pure, thread_safe],
+"
% ECMA specifies that System.Double is 64-bit IEEE float
- "MinExp = -1021;").
+ MinExp = -1021;
+").
% Maximum integer such that:
% radix ** (max_exponent - 1)
% is a normalised floating-point number.
-:- pragma foreign_proc("C", float__max_exponent = (MaxExp::out),
+:- pragma foreign_proc("C",
+ float__max_exponent = (MaxExp::out),
[will_not_call_mercury, promise_pure, thread_safe],
- "MaxExp = ML_FLOAT_MAX_EXP;").
-:- pragma foreign_proc("C#", float__max_exponent = (MaxExp::out),
+"
+ MaxExp = ML_FLOAT_MAX_EXP;
+").
+:- pragma foreign_proc("C#",
+ float__max_exponent = (MaxExp::out),
[will_not_call_mercury, promise_pure, thread_safe],
+"
% ECMA specifies that System.Double is 64-bit IEEE float
- "MaxExp = 1024;").
+ MaxExp = 1024;
+").
%---------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
Index: int.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/int.m,v
retrieving revision 1.90
diff -u -b -r1.90 int.m
--- int.m 7 Apr 2003 10:25:07 -0000 1.90
+++ int.m 9 May 2003 04:20:22 -0000
@@ -503,12 +503,14 @@
:- pred int__to_float(int, float) is det.
:- mode int__to_float(in, out) is det.
*/
-:- pragma foreign_proc("C", int__to_float(IntVal::in, FloatVal::out),
+:- pragma foreign_proc("C",
+ int__to_float(IntVal::in, FloatVal::out),
[will_not_call_mercury, promise_pure],
"
FloatVal = IntVal;
").
-:- pragma foreign_proc("MC++", int__to_float(IntVal::in, FloatVal::out),
+:- pragma foreign_proc("MC++",
+ int__to_float(IntVal::in, FloatVal::out),
[will_not_call_mercury, promise_pure],
"
FloatVal = (MR_Float) IntVal;
@@ -532,8 +534,10 @@
").
-:- pragma foreign_proc("C", int__max_int(Max::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+:- pragma foreign_proc("C",
+ int__max_int(Max::out),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
if (sizeof(MR_Integer) == sizeof(int))
Max = INT_MAX;
else if (sizeof(MR_Integer) == sizeof(long))
@@ -542,8 +546,10 @@
MR_fatal_error(""Unable to figure out max integer size"");
").
-:- pragma foreign_proc("C", int__min_int(Min::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+:- pragma foreign_proc("C",
+ int__min_int(Min::out),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
if (sizeof(MR_Integer) == sizeof(int))
Min = INT_MIN;
else if (sizeof(MR_Integer) == sizeof(long))
@@ -552,38 +558,52 @@
MR_fatal_error(""Unable to figure out min integer size"");
").
-:- pragma foreign_proc("C", int__bits_per_int(Bits::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+:- pragma foreign_proc("C",
+ int__bits_per_int(Bits::out),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Bits = ML_BITS_PER_INT;
").
-:- pragma foreign_proc("C", int__quot_bits_per_int(Int::in) = (Div::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+:- pragma foreign_proc("C",
+ int__quot_bits_per_int(Int::in) = (Div::out),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Div = Int / ML_BITS_PER_INT;
").
-:- pragma foreign_proc("C", int__times_bits_per_int(Int::in) = (Result::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+:- pragma foreign_proc("C",
+ int__times_bits_per_int(Int::in) = (Result::out),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Result = Int * ML_BITS_PER_INT;
").
-:- pragma foreign_proc("C", int__rem_bits_per_int(Int::in) = (Rem::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+:- pragma foreign_proc("C",
+ int__rem_bits_per_int(Int::in) = (Rem::out),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Rem = Int % ML_BITS_PER_INT;
").
-:- pragma foreign_proc("MC++", int__max_int(Max::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+:- pragma foreign_proc("MC++",
+ int__max_int(Max::out),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Max = System::Int32::MaxValue;
").
-:- pragma foreign_proc("MC++", int__min_int(Min::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+:- pragma foreign_proc("MC++",
+ int__min_int(Min::out),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Min = System::Int32::MinValue;
").
-:- pragma foreign_proc("MC++", int__bits_per_int(Bits::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+:- pragma foreign_proc("MC++",
+ int__bits_per_int(Bits::out),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Bits = ML_BITS_PER_INT;
").
@@ -615,4 +635,3 @@
int__bits_per_int = X :-
int__bits_per_int(X).
-
Index: private_builtin.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/private_builtin.m,v
retrieving revision 1.116
diff -u -b -r1.116 private_builtin.m
--- private_builtin.m 3 Mar 2003 14:45:27 -0000 1.116
+++ private_builtin.m 9 May 2003 04:20:22 -0000
@@ -709,7 +709,8 @@
:- implementation.
-:- pragma foreign_proc("C", store_ticket(Ticket::out),
+:- pragma foreign_proc("C",
+ store_ticket(Ticket::out),
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
@@ -719,7 +720,8 @@
#endif
").
-:- pragma foreign_proc("C", reset_ticket_undo(Ticket::in),
+:- pragma foreign_proc("C",
+ reset_ticket_undo(Ticket::in),
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
@@ -727,7 +729,8 @@
#endif
").
-:- pragma foreign_proc("C", reset_ticket_commit(Ticket::in),
+:- pragma foreign_proc("C",
+ reset_ticket_commit(Ticket::in),
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
@@ -735,7 +738,8 @@
#endif
").
-:- pragma foreign_proc("C", reset_ticket_solve(Ticket::in),
+:- pragma foreign_proc("C",
+ reset_ticket_solve(Ticket::in),
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
@@ -743,7 +747,8 @@
#endif
").
-:- pragma foreign_proc("C", discard_ticket,
+:- pragma foreign_proc("C",
+ discard_ticket,
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
@@ -751,7 +756,8 @@
#endif
").
-:- pragma foreign_proc("C", prune_ticket,
+:- pragma foreign_proc("C",
+ prune_ticket,
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
@@ -759,7 +765,8 @@
#endif
").
-:- pragma foreign_proc("C", mark_ticket_stack(TicketCounter::out),
+:- pragma foreign_proc("C",
+ mark_ticket_stack(TicketCounter::out),
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
@@ -769,7 +776,8 @@
#endif
").
-:- pragma foreign_proc("C", prune_tickets_to(TicketCounter::in),
+:- pragma foreign_proc("C",
+ prune_tickets_to(TicketCounter::in),
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
@@ -777,7 +785,8 @@
#endif
").
-:- pragma foreign_proc("MC++", store_ticket(Ticket::out),
+:- pragma foreign_proc("MC++",
+ store_ticket(Ticket::out),
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
@@ -788,7 +797,8 @@
#endif
").
-:- pragma foreign_proc("MC++", reset_ticket_undo(Ticket::in),
+:- pragma foreign_proc("MC++",
+ reset_ticket_undo(Ticket::in),
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
@@ -797,7 +807,8 @@
#endif
").
-:- pragma foreign_proc("MC++", reset_ticket_commit(Ticket::in),
+:- pragma foreign_proc("MC++",
+ reset_ticket_commit(Ticket::in),
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
@@ -806,7 +817,8 @@
#endif
").
-:- pragma foreign_proc("MC++", reset_ticket_solve(Ticket::in),
+:- pragma foreign_proc("MC++",
+ reset_ticket_solve(Ticket::in),
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
@@ -815,7 +827,8 @@
#endif
").
-:- pragma foreign_proc("MC++", discard_ticket,
+:- pragma foreign_proc("MC++",
+ discard_ticket,
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
@@ -824,7 +837,8 @@
#endif
").
-:- pragma foreign_proc("MC++", prune_ticket,
+:- pragma foreign_proc("MC++",
+ prune_ticket,
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
@@ -833,7 +847,8 @@
#endif
").
-:- pragma foreign_proc("MC++", mark_ticket_stack(TicketCounter::out),
+:- pragma foreign_proc("MC++",
+ mark_ticket_stack(TicketCounter::out),
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
@@ -844,7 +859,8 @@
#endif
").
-:- pragma foreign_proc("MC++", prune_tickets_to(TicketCounter::in),
+:- pragma foreign_proc("MC++",
+ prune_tickets_to(TicketCounter::in),
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
@@ -942,7 +958,8 @@
#include ""mercury_heap.h"" /* for MR_free_heap() */
").
-:- pragma foreign_proc("C", gc_trace(Pointer::in),
+:- pragma foreign_proc("C",
+ gc_trace(Pointer::in),
[will_not_call_mercury, thread_safe],
"
#ifdef MR_NATIVE_GC
@@ -957,11 +974,15 @@
#endif
").
-:- pragma foreign_proc("C", free_heap(Val::di),
+:- pragma foreign_proc("C",
+ free_heap(Val::di),
[will_not_call_mercury, promise_pure, thread_safe],
- "MR_free_heap((void *) Val);").
+"
+ MR_free_heap((void *) Val);
+").
-:- pragma foreign_proc("C", mark_hp(SavedHeapPointer::out),
+:- pragma foreign_proc("C",
+ mark_hp(SavedHeapPointer::out),
[will_not_call_mercury, thread_safe],
"
#ifndef MR_CONSERVATIVE_GC
@@ -972,7 +993,8 @@
#endif
").
-:- pragma foreign_proc("C", restore_hp(SavedHeapPointer::in),
+:- pragma foreign_proc("C",
+ restore_hp(SavedHeapPointer::in),
[will_not_call_mercury, thread_safe],
"
#ifndef MR_CONSERVATIVE_GC
@@ -980,14 +1002,16 @@
#endif
").
-:- pragma foreign_proc("MC++", mark_hp(SavedHeapPointer::out),
+:- pragma foreign_proc("MC++",
+ mark_hp(SavedHeapPointer::out),
[will_not_call_mercury, thread_safe],
"
/* We can't do heap reclamation on failure in the .NET back-end. */
SavedHeapPointer = 0;
").
-:- pragma foreign_proc("MC++", restore_hp(_SavedHeapPointer::in),
+:- pragma foreign_proc("MC++",
+ restore_hp(_SavedHeapPointer::in),
[will_not_call_mercury, thread_safe],
"
/* We can't do heap reclamation on failure in the .NET back-end. */
@@ -1185,9 +1209,14 @@
no_clauses(PredName) :-
error("no clauses for " ++ PredName).
-:- pragma foreign_proc(c, imp, [will_not_call_mercury, thread_safe], "").
-:- pragma foreign_proc(il, imp,
- [will_not_call_mercury, thread_safe, max_stack_size(0)], "").
+:- pragma foreign_proc(c,
+ imp,
+ [will_not_call_mercury, thread_safe],
+"").
+:- pragma foreign_proc(il,
+ imp,
+ [will_not_call_mercury, thread_safe, max_stack_size(0)],
+"").
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
Index: string.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.197
diff -u -b -r1.197 string.m
--- string.m 3 Mar 2003 03:29:38 -0000 1.197
+++ string.m 9 May 2003 05:04:24 -0000
@@ -103,8 +103,6 @@
% The precision chosen from this range will be such to allow a
% successful decimal -> binary conversion of the float.
-
-
:- pred string__first_char(string, char, string).
:- mode string__first_char(in, in, in) is semidet. % implied
:- mode string__first_char(in, uo, in) is semidet. % implied
@@ -568,7 +566,6 @@
% The implementation uses the sprintf() function, so the
% actual output will depend on the C standard library.
-
%------------------------------------------------------------------------------%
:- type string__poly_type --->
@@ -670,8 +667,6 @@
string__to_int(String, Int) :-
string__base_string_to_int(10, String, Int).
-
-
string__base_string_to_int(Base, String, Int) :-
string__index(String, 0, Char),
Len = string__length(String),
@@ -928,8 +923,10 @@
*/
:- pragma promise_pure(string__to_char_list/2).
-:- pragma foreign_proc("C", string__to_char_list(Str::in, CharList::out),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+:- pragma foreign_proc("C",
+ string__to_char_list(Str::in, CharList::out),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
MR_ConstString p = Str + strlen(Str);
CharList = MR_list_empty_msg(MR_PROC_LABEL);
while (p > Str) {
@@ -939,8 +936,10 @@
}
}").
-:- pragma foreign_proc("C", string__to_char_list(Str::uo, CharList::in),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+:- pragma foreign_proc("C",
+ string__to_char_list(Str::uo, CharList::in),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
/* mode (uo, in) is det */
MR_Word char_list_ptr;
size_t size;
@@ -975,7 +974,6 @@
Str[size] = '\\0';
}").
-
string__to_char_list(Str::in, CharList::out) :-
string__to_char_list_2(Str, 0, CharList).
string__to_char_list(Str::uo, CharList::in) :-
@@ -995,7 +993,6 @@
CharList = []
).
-
/*-----------------------------------------------------------------------*/
%
@@ -1003,9 +1000,10 @@
% but the optimized implementation in C below is there for efficiency since
% it improves the overall speed of parsing by about 7%.
%
-:- pragma foreign_proc("C", string__from_rev_char_list(Chars::in, Str::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
-{
+:- pragma foreign_proc("C",
+ string__from_rev_char_list(Chars::in, Str::uo),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
MR_Word list_ptr;
MR_Word size, len;
/*
@@ -1042,7 +1040,6 @@
}
}").
-
string__from_rev_char_list(Chars::in, Str::uo) :-
Str = string__from_char_list(list__reverse(Chars)).
@@ -1107,8 +1104,6 @@
S = S0
).
-
-
:- pred string__all_match(pred(char), string).
:- mode string__all_match(pred(in) is semidet, in) is semidet.
@@ -1126,8 +1121,6 @@
true
).
-
-
string__is_alpha(S) :-
string__all_match(char__is_alpha, S).
@@ -1137,8 +1130,6 @@
string__is_alnum_or_underscore(S) :-
string__all_match(char__is_alnum_or_underscore, S).
-
-
string__pad_left(String0, PadChar, Width, String) :-
string__length(String0, Length),
( Length < Width ->
@@ -1168,8 +1159,10 @@
% Implementation of string__append_list that uses C as this
% minimises the amount of garbage created.
-:- pragma foreign_proc("C", string__append_list(Strs::in) = (Str::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+:- pragma foreign_proc("C",
+ string__append_list(Strs::in) = (Str::uo),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
MR_Word list = Strs;
MR_Word tmp;
size_t len;
@@ -1199,8 +1192,10 @@
% Implementation of string__join_list that uses C as this
% minimises the amount of garbage created.
-:- pragma foreign_proc("C", string__join_list(Sep::in, Strs::in) = (Str::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+:- pragma foreign_proc("C",
+ string__join_list(Sep::in, Strs::in) = (Str::uo),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
MR_Word list = Strs;
MR_Word tmp;
size_t len = 0;
@@ -1259,9 +1254,6 @@
string__join_list_2(_, []) = "".
string__join_list_2(Sep, [H|T]) = Sep ++ H ++ string__join_list_2(Sep, T).
-
-
-
%-----------------------------------------------------------------------------%
% Note - string__hash is also defined in code/imp.h
@@ -1598,7 +1590,6 @@
[ Char ],
{ char__is_digit(Char) }.
-
% Zero or more occurences of the string parsed by the ho pred.
:- pred zero_or_more_occurences(pred(list(T), list(T)), list(T), list(T)).
:- mode zero_or_more_occurences(pred(in, out) is semidet, in, out) is det.
@@ -1819,7 +1810,6 @@
from_char_list(Width),
from_char_list(Prec), LengthMod, Spec]).
-
% Construct a format string suitable to passing to .NET's formatting
% functions.
% XXX this code is not yet complete. We need to do a lot more work
@@ -1858,19 +1848,20 @@
:- func int_length_modifer = string.
:- pragma foreign_proc("C",
int_length_modifer = (LengthModifier::out),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
MR_make_aligned_string(LengthModifier,
(MR_String) (MR_Word) MR_INTEGER_LENGTH_MODIFIER);
}").
-
% Create a string from a float using the format string.
% Note it is the responsibility of the caller to ensure that the
% format string is valid.
:- func native_format_float(string, float) = string.
:- pragma foreign_proc("C",
native_format_float(FormatStr::in, Val::in) = (Str::out),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
MR_save_transient_hp();
Str = MR_make_string(MR_PROC_LABEL, FormatStr, (double) Val);
MR_restore_transient_hp();
@@ -1882,7 +1873,8 @@
:- func native_format_int(string, int) = string.
:- pragma foreign_proc("C",
native_format_int(FormatStr::in, Val::in) = (Str::out),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
MR_save_transient_hp();
Str = MR_make_string(MR_PROC_LABEL, FormatStr, Val);
MR_restore_transient_hp();
@@ -1894,7 +1886,8 @@
:- func native_format_string(string, string) = string.
:- pragma foreign_proc("C",
native_format_string(FormatStr::in, Val::in) = (Str::out),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
Str = MR_make_string(MR_PROC_LABEL, FormatStr, Val);
}").
@@ -1904,7 +1897,8 @@
:- func native_format_char(string, char) = string.
:- pragma foreign_proc("C",
native_format_char(FormatStr::in, Val::in) = (Str::out),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
MR_save_transient_hp();
Str = MR_make_string(MR_PROC_LABEL, FormatStr, Val);
MR_restore_transient_hp();
@@ -2328,7 +2322,6 @@
NumStr = ""
).
-
%
% Convert an integer to a hexadecimal string using a-f.
%
@@ -2343,7 +2336,6 @@
NumStr = ""
).
-
%
% Convert an integer to a hexadecimal string using A-F.
%
@@ -2804,7 +2796,8 @@
:- pragma foreign_proc("C",
string__float_to_string(Flt::in, Str::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
/*
** For efficiency reasons we duplicate the C implementation
** of string__lowlevel_float_to_string
@@ -2864,7 +2857,8 @@
:- pragma foreign_proc("C",
string__lowlevel_float_to_string(Flt::in, Str::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
/*
** Note any changes here will require the same changes in
** string__float_to_string.
@@ -2874,7 +2868,8 @@
:- pragma foreign_proc("C#",
string__lowlevel_float_to_string(FloatVal::in, FloatString::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
// The R format string prints the double out such that it
// can be round-tripped.
@@ -2887,7 +2882,8 @@
:- pragma export(string__to_float(in, out), "ML_string_to_float").
:- pragma foreign_proc("C",
string__to_float(FloatString::in, FloatVal::out),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
/*
** The %c checks for any erroneous characters appearing after
** the float; if there are then sscanf() will return 2 rather
@@ -2902,7 +2898,8 @@
:- pragma foreign_proc("MC++",
string__to_float(FloatString::in, FloatVal::out),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
// leading or trailing whitespace is not allowed
if (FloatString->Length == 0 ||
System::Char::IsWhiteSpace(FloatString, 0) ||
@@ -2930,7 +2927,8 @@
*/
:- pragma foreign_proc("C",
string__to_int_list(Str::in, IntList::out),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
MR_ConstString p = Str + strlen(Str);
IntList = MR_list_empty_msg(MR_PROC_LABEL);
while (p > Str) {
@@ -2952,12 +2950,16 @@
% strchr always returns true when searching for '\0',
% but the '\0' is an implementation detail which really
% shouldn't be considered to be part of the string itself.
-:- pragma foreign_proc("C", string__contains_char(Str::in, Ch::in),
- [will_not_call_mercury, promise_pure, thread_safe], "
+:- pragma foreign_proc("C",
+ string__contains_char(Str::in, Ch::in),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
SUCCESS_INDICATOR = (strchr(Str, Ch) != NULL) && Ch != '\\0';
").
-:- pragma foreign_proc("MC++", string__contains_char(Str::in, Ch::in),
- [will_not_call_mercury, promise_pure, thread_safe], "
+:- pragma foreign_proc("MC++",
+ string__contains_char(Str::in, Ch::in),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
SUCCESS_INDICATOR = (Str->IndexOf(Ch) != -1);
").
string__contains_char(String, Char) :-
@@ -2998,7 +3000,8 @@
:- mode string__index_check(in, in) is semidet.
:- pragma promise_pure(string__index_check/2).
/* We should consider making this routine a compiler built-in. */
-:- pragma foreign_proc("C", string__index_check(Index::in, Length::in),
+:- pragma foreign_proc("C",
+ string__index_check(Index::in, Length::in),
[will_not_call_mercury, promise_pure, thread_safe],
"
/*
@@ -3012,8 +3015,10 @@
*/
SUCCESS_INDICATOR = ((MR_Unsigned) Index < (MR_Unsigned) Length);
").
-:- pragma foreign_proc("MC++", string__index_check(Index::in, Length::in),
- [will_not_call_mercury, promise_pure, thread_safe], "
+:- pragma foreign_proc("MC++",
+ string__index_check(Index::in, Length::in),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
SUCCESS_INDICATOR = ((MR_Unsigned) Index < (MR_Unsigned) Length);
").
string__index_check(Index, Length) :-
@@ -3024,12 +3029,14 @@
:- pragma foreign_proc("C",
string__unsafe_index(Str::in, Index::in, Ch::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Ch = Str[Index];
").
:- pragma foreign_proc("MC++",
string__unsafe_index(Str::in, Index::in, Ch::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Ch = Str->get_Chars(Index);
").
string__unsafe_index(Str, Index, Char) :-
@@ -3081,7 +3088,8 @@
*/
:- pragma foreign_proc("C",
string__set_char(Ch::in, Index::in, Str0::in, Str::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
size_t len = strlen(Str0);
if ((MR_Unsigned) Index >= len) {
SUCCESS_INDICATOR = MR_FALSE;
@@ -3094,7 +3102,8 @@
").
:- pragma foreign_proc("MC++",
string__set_char(Ch::in, Index::in, Str0::in, Str::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
if (Index >= Str0->get_Length()) {
SUCCESS_INDICATOR = MR_FALSE;
} else {
@@ -3116,7 +3125,8 @@
/*
:- pragma foreign_proc("C",
string__set_char(Ch::in, Index::in, Str0::di, Str::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
if ((MR_Unsigned) Index >= strlen(Str0)) {
SUCCESS_INDICATOR = MR_FALSE;
} else {
@@ -3128,7 +3138,8 @@
:- pragma foreign_proc("MC++",
string__set_char(Ch::in, Index::in, Str0::di, Str::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
if (Index >= Str0->get_Length()) {
SUCCESS_INDICATOR = MR_FALSE;
} else {
@@ -3148,7 +3159,8 @@
*/
:- pragma foreign_proc("C",
string__unsafe_set_char(Ch::in, Index::in, Str0::in, Str::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
size_t len = strlen(Str0);
MR_allocate_aligned_string_msg(Str, len, MR_PROC_LABEL);
strcpy(Str, Str0);
@@ -3156,7 +3168,8 @@
").
:- pragma foreign_proc("MC++",
string__unsafe_set_char(Ch::in, Index::in, Str0::in, Str::out),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Str = System::String::Concat(Str0->Substring(0, Index),
System::Convert::ToString(Ch),
Str0->Substring(Index + 1));
@@ -3169,13 +3182,15 @@
/*
:- pragma foreign_proc("C",
string__unsafe_set_char(Ch::in, Index::in, Str0::di, Str::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Str = Str0;
MR_set_char(Str, Index, Ch);
").
:- pragma foreign_proc("MC++",
string__unsafe_set_char(Ch::in, Index::in, Str0::di, Str::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Str = System::String::Concat(Str0->Substring(0, Index),
System::Convert::ToString(Ch),
Str0->Substring(Index + 1));
@@ -3190,12 +3205,14 @@
*/
:- pragma foreign_proc("C",
string__length(Str::in, Length::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Length = strlen(Str);
").
:- pragma foreign_proc("MC++",
string__length(Str::in, Length::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Length = Str->get_Length();
").
@@ -3205,12 +3222,14 @@
*/
:- pragma foreign_proc("C",
string__length(Str::ui, Length::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Length = strlen(Str);
").
:- pragma foreign_proc("MC++",
string__length(Str::ui, Length::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
Length = Str->get_Length();
").
@@ -3245,7 +3264,8 @@
:- pragma foreign_proc("C",
string__append_iii(S1::in, S2::in, S3::in),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
size_t len_1 = strlen(S1);
SUCCESS_INDICATOR = (
strncmp(S1, S3, len_1) == 0 &&
@@ -3255,7 +3275,8 @@
:- pragma foreign_proc("MC++",
string__append_iii(S1::in, S2::in, S3::in),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
SUCCESS_INDICATOR = S3->Equals(System::String::Concat(S1, S2));
}").
@@ -3266,7 +3287,8 @@
:- pragma foreign_proc("C",
string__append_ioi(S1::in, S2::uo, S3::in),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
size_t len_1, len_2, len_3;
len_1 = strlen(S1);
@@ -3287,7 +3309,8 @@
:- pragma foreign_proc("MC++",
string__append_ioi(S1::in, S2::uo, S3::in),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
if (S3->StartsWith(S1)) {
S2 = S3->Remove(0, S1->Length);
SUCCESS_INDICATOR = MR_TRUE;
@@ -3303,7 +3326,8 @@
:- pragma foreign_proc("C",
string__append_iio(S1::in, S2::in, S3::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
size_t len_1, len_2;
len_1 = strlen(S1);
len_2 = strlen(S2);
@@ -3314,7 +3338,8 @@
:- pragma foreign_proc("MC++",
string__append_iio(S1::in, S2::in, S3::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
S3 = System::String::Concat(S1, S2);
}").
@@ -3348,7 +3373,8 @@
:- pragma foreign_proc("C",
string__append_ooi_3(S1Len::in, S3Len::in, S1::out, S2::out, S3::in),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
MR_allocate_aligned_string_msg(S1, S1Len, MR_PROC_LABEL);
memcpy(S1, S3, S1Len);
S1[S1Len] = '\\0';
@@ -3357,9 +3383,9 @@
}").
:- pragma foreign_proc("MC++",
- string__append_ooi_3(S1Len::in, _S3Len::in,
- S1::out, S2::out, S3::in),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ string__append_ooi_3(S1Len::in, _S3Len::in, S1::out, S2::out, S3::in),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
S1 = S3->Substring(0, S1Len);
S2 = S3->Substring(S1Len);
").
@@ -3400,8 +3426,7 @@
).
:- pragma foreign_proc("C",
- string__substring(Str::in, Start::in, Count::in,
- SubString::uo),
+ string__substring(Str::in, Start::in, Count::in, SubString::uo),
[will_not_call_mercury, promise_pure, thread_safe],
"{
MR_Integer len;
@@ -3428,8 +3453,7 @@
*/
:- pragma foreign_proc("C",
- string__unsafe_substring(Str::in, Start::in, Count::in,
- SubString::uo),
+ string__unsafe_substring(Str::in, Start::in, Count::in, SubString::uo),
[will_not_call_mercury, promise_pure, thread_safe],
"{
MR_Integer len;
@@ -3438,8 +3462,7 @@
SubString[Count] = '\\0';
}").
:- pragma foreign_proc("MC++",
- string__unsafe_substring(Str::in, Start::in, Count::in,
- SubString::uo),
+ string__unsafe_substring(Str::in, Start::in, Count::in, SubString::uo),
[will_not_call_mercury, promise_pure, thread_safe],
"{
SubString = Str->Substring(Start, Count);
@@ -3457,7 +3480,8 @@
:- pragma foreign_proc("C",
string__split(Str::in, Count::in, Left::uo, Right::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
MR_Integer len;
MR_Word tmp;
if (Count <= 0) {
@@ -3482,7 +3506,8 @@
:- pragma foreign_proc("MC++",
string__split(Str::in, Count::in, Left::uo, Right::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
MR_Integer len;
MR_Word tmp;
if (Count <= 0) {
@@ -3518,7 +3543,6 @@
)
).
-
/*-----------------------------------------------------------------------*/
/*
@@ -3538,7 +3562,8 @@
*/
:- pragma foreign_proc("C",
string__first_char(Str::in, First::in, Rest::in),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
SUCCESS_INDICATOR = (
Str[0] == First &&
First != '\\0' &&
@@ -3547,7 +3572,8 @@
").
:- pragma foreign_proc("MC++",
string__first_char(Str::in, First::in, Rest::in),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
MR_Integer len = Str->get_Length();
SUCCESS_INDICATOR = (
len > 0 &&
@@ -3561,13 +3587,15 @@
*/
:- pragma foreign_proc("C",
string__first_char(Str::in, First::uo, Rest::in),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
First = Str[0];
SUCCESS_INDICATOR = (First != '\\0' && strcmp(Str + 1, Rest) == 0);
").
:- pragma foreign_proc("MC++",
string__first_char(Str::in, First::uo, Rest::in),
- [will_not_call_mercury, promise_pure, thread_safe], "
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
MR_Integer len = Str->get_Length();
if (len > 0) {
SUCCESS_INDICATOR =
@@ -3583,7 +3611,8 @@
*/
:- pragma foreign_proc("C",
string__first_char(Str::in, First::in, Rest::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
if (Str[0] != First || First == '\\0') {
SUCCESS_INDICATOR = MR_FALSE;
} else {
@@ -3600,7 +3629,8 @@
}").
:- pragma foreign_proc("MC++",
string__first_char(Str::in, First::in, Rest::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
MR_Integer len = Str->get_Length();
if (len > 0) {
SUCCESS_INDICATOR = (First == Str->get_Chars(0));
@@ -3615,7 +3645,8 @@
*/
:- pragma foreign_proc("C",
string__first_char(Str::in, First::uo, Rest::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
First = Str[0];
if (First == '\\0') {
SUCCESS_INDICATOR = MR_FALSE;
@@ -3633,7 +3664,8 @@
}").
:- pragma foreign_proc("MC++",
string__first_char(Str::in, First::uo, Rest::uo),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
if (Str->get_Length() == 0) {
SUCCESS_INDICATOR = MR_FALSE;
} else {
@@ -3643,13 +3675,13 @@
}
}").
-
/*
:- mode string__first_char(uo, in, in) is det.
*/
:- pragma foreign_proc("C",
string__first_char(Str::uo, First::in, Rest::in),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
size_t len = strlen(Rest) + 1;
MR_allocate_aligned_string_msg(Str, len, MR_PROC_LABEL);
Str[0] = First;
@@ -3657,13 +3689,13 @@
}").
:- pragma foreign_proc("MC++",
string__first_char(Str::uo, First::in, Rest::in),
- [will_not_call_mercury, promise_pure, thread_safe], "{
+ [will_not_call_mercury, promise_pure, thread_safe],
+"{
MR_String FirstStr;
FirstStr = new System::String(First, 1);
Str = System::String::Concat(FirstStr, Rest);
}").
-
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
% Ralph Becket <rwab1 at cl.cam.ac.uk> 27/04/99
@@ -3856,7 +3888,6 @@
prefix_length(P, S) = prefix_length_2(0, length(S), P, S).
-
:- func prefix_length_2(int, int, pred(char), string) = int.
:- mode prefix_length_2(in, in, pred(in ) is semidet, in) = out is det.
@@ -3872,7 +3903,6 @@
suffix_length(P, S) = suffix_length_2(length(S) - 1, length(S), P, S).
-
:- func suffix_length_2(int, int, pred(char), string) = int.
:- mode suffix_length_2(in, in, pred(in ) is semidet, in) = out is det.
@@ -3883,7 +3913,6 @@
)
else N - (I + 1)
).
-
%------------------------------------------------------------------------------%
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list