[m-rev.] for review: escape all control characters in io.write, deconstruct.functor
Peter Wang
novalazy at gmail.com
Tue Jun 19 16:54:02 AEST 2018
On Fri, 15 Jun 2018 18:02:56 +1000 (AEST), Julien Fischer <jfischer at opturion.com> wrote:
>
> For review by anyone.
>
> I'll update the NEWS file seprately.
>
> ----------------------------------------------------
>
> Escape all control characters in io.write, deconstruct.functor etc.
>
> The above predicates currently escape all of the C0 control characters (+
> Delete). This change modifies them to escape all of the characters in the
> Unicode category `Other,control' using backslash escapes when they exist and
> octal escapes otherwise.
Can we switch to hexadecimal escapes (later), seeing as the behaviour
wasn't documented?
> diff --git a/library/term_io.m b/library/term_io.m
> index eeaef88..2f4e627 100644
> --- a/library/term_io.m
> +++ b/library/term_io.m
> @@ -785,7 +785,7 @@ string_is_escaped_char(Char::out, String::in) :-
> is_mercury_source_char(Char) :-
> ( char.is_alnum(Char)
> ; is_mercury_punctuation_char(Char)
> - ; char.to_int(Char) >= 0x80
> + ; char.to_int(Char) >= 0xA0 % 0x7f - 0x9f are control characters.
> ).
Ok.
>
> %---------------------------------------------------------------------------%
> @@ -942,39 +942,43 @@ mercury_escape_char(Char) = EscapeCode :-
> % Note: the code here is similar to code in runtime/mercury_trace_base.c;
> % any changes here may require similar changes there.
>
> +% Codepoints: 0x20 -> 0x2f.
I suggest:
% Codepoints in 0x20..0x2f
...
% Codepoints in 0x30..0x3f
...
Otherwise, it looks fine.
Peter
More information about the reviews
mailing list