[m-rev.] for review: add character escapes in string_to_doc/1
Julien Fischer
jfischer at opturion.com
Tue Jul 17 12:12:39 AEST 2018
For review by anyone.
---------------------------------
Add character escapes in string_to_doc/1.
library/string.m:
In adddition to surrounding the argument of string_to_doc/1 with double
quotes, also add the usual character escapes.
tests/declarative_debugger/sort.exp:
Conform to the above change.
NEWS:
Announce this change.
Julien.
diff --git a/NEWS b/NEWS
index ec6af97..882c4bd 100644
--- a/NEWS
+++ b/NEWS
@@ -314,6 +314,9 @@ Changes to the Mercury standard library:
* We have reduced the memory allocated by string.to_lower and string.to_upper.
+* string.string_to_doc/1 now inserts any required character escapes in its
+ argument, in addition to surrouding it with double quotes.
+
* The following classification predicates have been added to the float module:
- is_finite/1
diff --git a/library/string.m b/library/string.m
index bb38e3b..f751a43 100644
--- a/library/string.m
+++ b/library/string.m
@@ -1417,6 +1417,7 @@
:- import_module require.
:- import_module string.format.
:- import_module string.to_string.
+:- import_module term_io.
% Many routines in this module are implemented using foreign language code.
@@ -5389,7 +5390,7 @@ max_str_length(Str, PrevMaxLen, MaxLen) :-
% Converting strings to docs.
%
-string_to_doc(S) = docs([str("\""), str(S), str("\"")]).
+string_to_doc(S) = docs([str(term_io.quoted_string(S))]).
%---------------------------------------------------------------------------%
%
diff --git a/tests/declarative_debugger/sort.exp b/tests/declarative_debugger/sort.exp
index b8557d9..c9d47bf 100644
--- a/tests/declarative_debugger/sort.exp
+++ b/tests/declarative_debugger/sort.exp
@@ -43,8 +43,7 @@ output_stream_2(...)
do_write_string(...)
Valid? depth io 10
dd> print io 9
-read_line_as_string_2('<<foreign(stream, 0xNNNN)>>', yes, ok, "rafe
-",
+read_line_as_string_2('<<foreign(stream, 0xNNNN)>>', yes, ok, "rafe\n",
'<<foreign(system_error, (nil))>>')
dd> depth io 1
dd> no
More information about the reviews
mailing list