summaryrefslogtreecommitdiffstats
path: root/camlp4/Camlp4
diff options
context:
space:
mode:
authorJérémie Dimino <jeremie@dimino.org>2012-06-12 16:18:36 +0000
committerJérémie Dimino <jeremie@dimino.org>2012-06-12 16:18:36 +0000
commit318f731baad83da7238c27dc8da936dfad0b1984 (patch)
treea9c3873d4f44ba5ec9f74132ee07a32e99bb50bd /camlp4/Camlp4
parent788846a845ba64d68bff92c1d0e0c60032ce7b80 (diff)
PR#5646: reapply the fix for PR#5442
It was reverted when the bin-annot branch was merged git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12595 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'camlp4/Camlp4')
-rw-r--r--camlp4/Camlp4/Printers/OCaml.ml8
1 files changed, 4 insertions, 4 deletions
diff --git a/camlp4/Camlp4/Printers/OCaml.ml b/camlp4/Camlp4/Printers/OCaml.ml
index c1b5f1d90..6cd292aba 100644
--- a/camlp4/Camlp4/Printers/OCaml.ml
+++ b/camlp4/Camlp4/Printers/OCaml.ml
@@ -106,8 +106,8 @@ module Make (Syntax : Sig.Camlp4Syntax) = struct
"Cannot print %S this identifier does not respect OCaml lexing rules (%s)"
str (Lexer.Error.to_string exn)) ];
- value ocaml_char x =
- match x with [ "'" -> "\\'" | c -> c ];
+ (* This is to be sure character literals are always escaped. *)
+ value ocaml_char x = Char.escaped (Struct.Token.Eval.char x);
value rec get_expr_args a al =
match a with
@@ -557,7 +557,7 @@ module Make (Syntax : Sig.Camlp4Syntax) = struct
| <:expr< $int64:s$ >> -> o#numeric f s "L"
| <:expr< $int32:s$ >> -> o#numeric f s "l"
| <:expr< $flo:s$ >> -> o#numeric f s ""
- | <:expr< $chr:s$ >> -> pp f "'%s'" s
+ | <:expr< $chr:s$ >> -> pp f "'%s'" (ocaml_char s)
| <:expr< $id:i$ >> -> o#var_ident f i
| <:expr< { $b$ } >> ->
pp f "@[<hv0>@[<hv2>{%a@]@ }@]" o#record_binding b
@@ -667,7 +667,7 @@ module Make (Syntax : Sig.Camlp4Syntax) = struct
| <:patt< $int32:s$ >> -> o#numeric f s "l"
| <:patt< $int:s$ >> -> o#numeric f s ""
| <:patt< $flo:s$ >> -> o#numeric f s ""
- | <:patt< $chr:s$ >> -> pp f "'%s'" s
+ | <:patt< $chr:s$ >> -> pp f "'%s'" (ocaml_char s)
| <:patt< ~ $s$ >> -> pp f "~%s" s
| <:patt< ` $uid:s$ >> -> pp f "`%a" o#var s
| <:patt< # $i$ >> -> pp f "@[<2>#%a@]" o#ident i