[m-rev.] trivial diff: fix another sequential conj problem

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Feb 18 13:07:42 AEDT 2003


Estimated hours taken: 0.25
Branches: main

library/string.m:
	Fix a bug with the Mercury version of string__contains_char,
	where it was relying on the order of execution of conjunctions.

Workspace: /home/ceres/fjh/ws-ceres2/mercury
Index: library/string.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.190
diff -u -d -r1.190 string.m
--- library/string.m	29 Nov 2002 13:25:56 -0000	1.190
+++ library/string.m	18 Feb 2003 02:04:46 -0000
@@ -2939,12 +2939,15 @@
 		int::in, int::in) is semidet.
 
 string__contains_char(Str, Char, Index, Length) :-
-	Index < Length,
-	string__unsafe_index(Str, Index, IndexChar),
-	( IndexChar = Char ->
-		true
+	( Index < Length ->
+		string__unsafe_index(Str, Index, IndexChar),
+		( IndexChar = Char ->
+			true
+		;
+			string__contains_char(Str, Char, Index + 1, Length)
+		)
 	;
-		string__contains_char(Str, Char, Index + 1, Length)
+		fail
 	).
 
 /*-----------------------------------------------------------------------*/

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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