[m-rev.] diff: octal escape bug fix

Fergus Henderson fjh at cs.mu.OZ.AU
Thu May 30 14:38:58 AEST 2002


Estimated hours taken: 1
Branches: main

library/term_io.m:
compiler/mercury_to_mercury.m:
	Fix a bug: output octal escapes in ISO-Prolog style rather than
	C-style.  This is needed so that they can be read back in by
	io__read_term.

Workspace: /home/ceres/fjh/mercury
Index: compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.214
diff -u -d -r1.214 mercury_to_mercury.m
--- compiler/mercury_to_mercury.m	8 May 2002 13:56:59 -0000	1.214
+++ compiler/mercury_to_mercury.m	30 May 2002 03:06:05 -0000
@@ -2618,19 +2618,20 @@
 :- mode mercury_escape_char(in, out) is det.
 
 	% Convert a character to the corresponding octal escape code.
-
-	% XXX Note that we use C-style octal escapes rather than ISO-Prolog
-	% octal escapes.  This is for backwards compatibility with
-	% NU-Prolog and (old versions of?) SICStus Prolog.
-	% The Mercury lexer accepts either, so this should work
-	% ok so long as you don't have two escaped characters
-	% in a row :-(
+	%
+	% We use ISO-Prolog style octal escapes, which are of the form
+	% '\nnn\'; note that unlike C octal escapes, they are terminated
+	% with a backslash.
+	%
+	% Note: the code here is similar to code in
+	% compiler/mercury_to_mercury.m; any changes here
+	% may require similar changes there.
 
 mercury_escape_char(Char, EscapeCode) :-
 	char__to_int(Char, Int),
 	string__int_to_base_string(Int, 8, OctalString0),
 	string__pad_left(OctalString0, '0', 3, OctalString),
-	string__first_char(EscapeCode, '\\', OctalString).
+	EscapeCode = "\\" ++ OctalString ++ "\\".
 
 :- pred mercury_is_source_char(char).
 :- mode mercury_is_source_char(in) is semidet.
Index: library/term_io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/term_io.m,v
retrieving revision 1.64
diff -u -d -r1.64 term_io.m
--- library/term_io.m	8 Nov 2001 15:30:38 -0000	1.64
+++ library/term_io.m	30 May 2002 03:05:53 -0000
@@ -631,14 +631,11 @@
 :- mode mercury_escape_char(in, out) is det.
 
 	% Convert a character to the corresponding octal escape code.
-
-	% XXX Note that we use C-style octal escapes rather than ISO-Prolog
-	% octal escapes.  This is for backwards compatibility with
-	% NU-Prolog and (old versions of?) SICStus Prolog.
-	% The Mercury lexer accepts either, so this should work
-	% ok so long as you don't have two escaped characters
-	% in a row :-(
-
+	%
+	% We use ISO-Prolog style octal escapes, which are of the form
+	% '\nnn\'; note that unlike C octal escapes, they are terminated
+	% with a backslash.
+	%
 	% Note: the code here is similar to code in
 	% compiler/mercury_to_mercury.m; any changes here
 	% may require similar changes there.
@@ -647,7 +644,7 @@
 	char__to_int(Char, Int),
 	string__int_to_base_string(Int, 8, OctalString0),
 	string__pad_left(OctalString0, '0', 3, OctalString),
-	string__first_char(EscapeCode, '\\', OctalString).
+	EscapeCode = "\\" ++ OctalString ++ "\\".
 
 :- pred is_mercury_source_char(char).
 :- mode is_mercury_source_char(in) is semidet.

-- 
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