[m-rev.] diff: remove destructive update modes of string__set_char
Simon Taylor
stayl at cs.mu.OZ.AU
Fri Oct 26 16:34:04 AEST 2001
Estimated hours taken: 0.25
Branches: main, release
NEWS:
library/string.m:
Remove the buggy destructive update modes of string__set_char,
string__set_char_det and string__unsafe_set_char (they cause
crashes when applied to constant strings).
Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.220
diff -u -u -r1.220 NEWS
--- NEWS 12 Oct 2001 05:23:31 -0000 1.220
+++ NEWS 26 Oct 2001 06:07:19 -0000
@@ -54,6 +54,10 @@
* We've removed the buggy reverse modes of the arithmetic functions in
float.m and extras/complex_numbers (because of rounding errors the
functions aren't actually reversible).
+
+* We've removed the buggy destructive update modes of string__set_char,
+ string__set_char_det and string__unsafe_set_char (they cause crashes when
+ applied to constant strings).
* The exception module has a new predicate `try_store', which is
like `try_io', but which works with stores rather than io__states.
Index: library/string.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.162
diff -u -u -r1.162 string.m
--- library/string.m 9 Oct 2001 04:03:14 -0000 1.162
+++ library/string.m 26 Oct 2001 05:58:34 -0000
@@ -252,7 +252,6 @@
:- pred string__set_char(char, int, string, string).
:- mode string__set_char(in, in, in, out) is semidet.
-:- mode string__set_char(in, in, di, uo) is semidet.
% string__set_char(Char, Index, String0, String):
% `String' is `String0' with the (`Index' + 1)-th character
% set to `Char'.
@@ -262,7 +261,6 @@
:- func string__set_char_det(char, int, string) = string.
:- pred string__set_char_det(char, int, string, string).
:- mode string__set_char_det(in, in, in, out) is det.
-:- mode string__set_char_det(in, in, di, uo) is det.
% string__set_char_det(Char, Index, String0, String):
% `String' is `String0' with the (`Index' + 1)-th character
% set to `Char'.
@@ -271,10 +269,8 @@
:- func string__unsafe_set_char(char, int, string) = string.
:- mode string__unsafe_set_char(in, in, in) = out is det.
-:- mode string__unsafe_set_char(in, in, di) = uo is det.
:- pred string__unsafe_set_char(char, int, string, string).
:- mode string__unsafe_set_char(in, in, in, out) is det.
-:- mode string__unsafe_set_char(in, in, di, uo) is det.
% string__unsafe_set_char(Char, Index, String0, String):
% `String' is `String0' with the (`Index' + 1)-th character
% set to `Char'.
@@ -1897,35 +1893,6 @@
}
").
-/*
-:- pred string__set_char(char, int, string, string).
-:- mode string__set_char(in, in, di, uo) is semidet.
-*/
-:- pragma foreign_proc("C",
- string__set_char(Ch::in, Index::in, Str0::di, Str::uo),
- [will_not_call_mercury, thread_safe], "
- if ((MR_Unsigned) Index >= strlen(Str0)) {
- SUCCESS_INDICATOR = FALSE;
- } else {
- SUCCESS_INDICATOR = TRUE;
- Str = Str0;
- MR_set_char(Str, Index, Ch);
- }
-").
-
-:- pragma foreign_proc("MC++",
- string__set_char(Ch::in, Index::in, Str0::di, Str::uo),
- [will_not_call_mercury, thread_safe], "
- if (Index >= Str0->get_Length()) {
- SUCCESS_INDICATOR = FALSE;
- } else {
- Str = System::String::Concat(Str0->Substring(0, Index),
- System::Convert::ToString(Ch),
- Str0->Substring(Index + 1));
- SUCCESS_INDICATOR = TRUE;
- }
-").
-
/*-----------------------------------------------------------------------*/
/*
@@ -1942,24 +1909,6 @@
").
:- pragma foreign_proc("MC++",
string__unsafe_set_char(Ch::in, Index::in, Str0::in, Str::out),
- [will_not_call_mercury, thread_safe], "
- Str = System::String::Concat(Str0->Substring(0, Index),
- System::Convert::ToString(Ch),
- Str0->Substring(Index + 1));
-").
-
-/*
-:- pred string__unsafe_set_char(char, int, string, string).
-:- mode string__unsafe_set_char(in, in, di, uo) is det.
-*/
-:- pragma foreign_proc("C",
- string__unsafe_set_char(Ch::in, Index::in, Str0::di, Str::uo),
- [will_not_call_mercury, 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, thread_safe], "
Str = System::String::Concat(Str0->Substring(0, Index),
System::Convert::ToString(Ch),
--------------------------------------------------------------------------
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