[m-rev.] diff: string__suffix bug fix
David Overton
dmo at cs.mu.OZ.AU
Mon Jul 14 16:13:08 AEST 2003
Estimated hours taken: 0.5
Branches: main, release
library/string.m:
Fix a bug in string__suffix(in, in).
tests/hard_coded/Mmakefile:
tests/hard_coded/string_suffix_bug.m:
tests/hard_coded/string_suffix_bug.exp:
Test case.
Index: library/string.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.203
diff -u -r1.203 string.m
--- library/string.m 5 Jun 2003 05:26:34 -0000 1.203
+++ library/string.m 14 Jul 2003 05:39:08 -0000
@@ -830,16 +830,16 @@
Len = length(String),
PreLen = length(Suffix),
PreLen =< Len,
- suffix_2_iiii(String, Suffix, Len - PreLen, Len).
+ suffix_2_iiii(String, Suffix, 0, Len - PreLen, PreLen).
-:- pred suffix_2_iiii(string, string, int, int).
-:- mode suffix_2_iiii(in, in, in, in) is semidet.
+:- pred suffix_2_iiii(string, string, int, int, int).
+:- mode suffix_2_iiii(in, in, in, in, in) is semidet.
-suffix_2_iiii(String, Suffix, I, Len) :-
+suffix_2_iiii(String, Suffix, I, Offset, Len) :-
( if I < Len then
- (String `unsafe_index` I) =
+ (String `unsafe_index` (I + Offset)) =
(Suffix `unsafe_index` I) `with_type` char,
- suffix_2_iiii(String, Suffix, I + 1, Len)
+ suffix_2_iiii(String, Suffix, I + 1, Offset, Len)
else
true
).
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.199
diff -u -r1.199 Mmakefile
--- tests/hard_coded/Mmakefile 13 Jun 2003 05:39:47 -0000 1.199
+++ tests/hard_coded/Mmakefile 14 Jul 2003 05:57:50 -0000
@@ -142,6 +142,7 @@
string_alignment_bug \
string_loop \
string_strip \
+ string_suffix_bug \
target_mlobjs \
term_io_test \
term_to_univ_test \
Index: tests/hard_coded/string_suffix_bug.exp
===================================================================
RCS file: tests/hard_coded/string_suffix_bug.exp
diff -N tests/hard_coded/string_suffix_bug.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/string_suffix_bug.exp 14 Jul 2003 05:57:18 -0000
@@ -0,0 +1 @@
+yes
Index: tests/hard_coded/string_suffix_bug.m
===================================================================
RCS file: tests/hard_coded/string_suffix_bug.m
diff -N tests/hard_coded/string_suffix_bug.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/string_suffix_bug.m 14 Jul 2003 05:55:08 -0000
@@ -0,0 +1,16 @@
+:- module string_suffix_bug.
+:- interface.
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+:- import_module string.
+
+main -->
+ ( { string__suffix("testing string__suffix", "suffix") } ->
+ io__write_string("yes\n")
+ ;
+ io__write_string("no\n")
+ ).
--
David Overton Uni of Melbourne +61 3 8344 1354
dmo at cs.mu.oz.au Monash Uni (Clayton) +61 3 9905 5779
http://www.cs.mu.oz.au/~dmo Mobile Phone +61 4 0337 4393
--------------------------------------------------------------------------
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