[m-rev.] Trivial diff: fix infinite loop in string.string

Ralph Becket rafe at cs.mu.OZ.AU
Tue Oct 5 15:49:31 AEST 2004


Estimated hours taken: 4
Branches: main

Fix an infinite loop bug in string.string.

library/string.m:
	Fixed a bug where string.string would go into an infinite loop when
	trying to format the argument values of terms.

tests/hard_coded/Mmakefile:
tests/hard_coded/string_string.m:
tests/hard_coded/string_string.exp:
	Added a test case.

Index: library/string.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.218
diff -u -r1.218 string.m
--- library/string.m	7 Jul 2004 07:11:06 -0000	1.218
+++ library/string.m	5 Oct 2004 04:32:29 -0000
@@ -593,8 +593,8 @@
 %-----------------------------------------------------------------------------%
 
 :- implementation.
-:- import_module bool, integer, std_util, int, float, array, require.
-:- use_module term_io, type_desc, rtti_implementation.
+:- import_module array, bool, float, int, integer, require, std_util.
+:- use_module rtti_implementation, term_io, type_desc.
 
 string__replace(Str, Pat, Subst, Result) :-
 	sub_string_search(Str, Pat, Index),
@@ -4310,7 +4310,7 @@
 
 
 :- pred term_args_to_revstrings(deconstruct__noncanon_handling,
-	ops__table, list(T), revstrings, revstrings).
+	ops__table, list(univ), revstrings, revstrings).
 :- mode term_args_to_revstrings(in(do_not_allow), in, in, in, out) is det.
 :- mode term_args_to_revstrings(in(canonicalize), in, in, in, out) is det.
 :- mode term_args_to_revstrings(in(include_details_cc), in, in, in, out)
@@ -4327,7 +4327,7 @@
 
 
 :- pred arg_to_revstrings(deconstruct__noncanon_handling,
-	ops__table, T, revstrings, revstrings).
+	ops__table, univ, revstrings, revstrings).
 :- mode arg_to_revstrings(in(do_not_allow), in, in, in, out) is det.
 :- mode arg_to_revstrings(in(canonicalize), in, in, in, out) is det.
 :- mode arg_to_revstrings(in(include_details_cc), in, in, in, out) is cc_multi.
@@ -4335,7 +4335,7 @@
 
 arg_to_revstrings(NonCanon, OpsTable, X, !Rs) :-
 	Priority = comma_priority(OpsTable),
-	value_to_revstrings(NonCanon, OpsTable, Priority, X, !Rs).
+	value_to_revstrings(NonCanon, OpsTable, Priority, univ_value(X), !Rs).
 
 
 
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.236
diff -u -r1.236 Mmakefile
--- tests/hard_coded/Mmakefile	28 Jul 2004 08:08:29 -0000	1.236
+++ tests/hard_coded/Mmakefile	5 Oct 2004 05:47:20 -0000
@@ -153,6 +153,7 @@
 	string_alignment \
 	string_alignment_bug \
 	string_loop \
+	string_string \
 	string_strip \
 	string_suffix_bug \
 	system_sort \
Index: tests/hard_coded/string_string.exp
===================================================================
RCS file: tests/hard_coded/string_string.exp
diff -N tests/hard_coded/string_string.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/string_string.exp	5 Oct 2004 05:47:04 -0000
@@ -0,0 +1,2 @@
+leaf
+branch(leaf, leaf)
Index: tests/hard_coded/string_string.m
===================================================================
RCS file: tests/hard_coded/string_string.m
diff -N tests/hard_coded/string_string.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/string_string.m	5 Oct 2004 05:46:48 -0000
@@ -0,0 +1,35 @@
+%-----------------------------------------------------------------------------%
+% string_string.m
+% Ralph Becket <rafe at cs.mu.oz.au>
+% Tue Oct  5 13:10:27 EST 2004
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%
+%-----------------------------------------------------------------------------%
+
+:- module string_string.
+
+:- interface.
+
+:- import_module io.
+
+
+
+:- pred main(io :: di, io :: uo) is det.
+
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module string.
+
+:- type tree ---> leaf; branch(tree, tree).
+
+%-----------------------------------------------------------------------------%
+
+main(!IO) :-
+    io.write_string(string.string(leaf) ++ "\n", !IO),
+    io.write_string(string.string(branch(leaf, leaf)) ++ "\n", !IO).
+
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
--------------------------------------------------------------------------
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