From 7bc2529a2061657fe42b70db0785ec5753ea3171 Mon Sep 17 00:00:00 2001 From: Daniel de Rauglaudre Date: Tue, 27 Nov 2001 18:07:10 +0000 Subject: [PATCH] - git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4058 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- camlp4/CHANGES | 4 ++++ camlp4/lib/token.ml | 8 ++++---- camlp4/ocaml_src/lib/token.ml | 8 ++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/camlp4/CHANGES b/camlp4/CHANGES index cd5d8e40e..afa93a8eb 100644 --- a/camlp4/CHANGES +++ b/camlp4/CHANGES @@ -1,6 +1,10 @@ Camlp4 Version 3.04 ------------------- +- [27 Nov 01] Fixed functions Token.eval_char and Token.eval_string which + returned bad values, resulting lexing of backslash sequences incompatible + with OCaml (e.g. "\1" returned "\001" (one character) but OCaml returns + the string of the two characters \ and 1). - [15 Nov 01] In revised syntax, in let binding in sequences, the "in" can be replaced by a semicolon; the revised syntax printer pr_r.cmo now rather prints a semicolon there. diff --git a/camlp4/lib/token.ml b/camlp4/lib/token.ml index 5cf663b7b..23ef32988 100644 --- a/camlp4/lib/token.ml +++ b/camlp4/lib/token.ml @@ -119,17 +119,17 @@ value rec backslash s i = | '0'..'9' as c -> backslash1 (valch c) s (i + 1) | _ -> raise Not_found ] and backslash1 cod s i = - if i = String.length s then (Char.chr cod, i) + if i = String.length s then ('\\', i - 1) else match s.[i] with [ '0'..'9' as c -> backslash2 (10 * cod + valch c) s (i + 1) - | _ -> (Char.chr cod, i) ] + | _ -> ('\\', i - 1) ] and backslash2 cod s i = - if i = String.length s then (Char.chr cod, i) + if i = String.length s then ('\\', i - 2) else match s.[i] with [ '0'..'9' as c -> (Char.chr (10 * cod + valch c), i + 1) - | _ -> (Char.chr cod, i) ] + | _ -> ('\\', i - 2) ] ; value rec skip_indent s i = diff --git a/camlp4/ocaml_src/lib/token.ml b/camlp4/ocaml_src/lib/token.ml index 8bb79bf89..a8e0e1fc7 100644 --- a/camlp4/ocaml_src/lib/token.ml +++ b/camlp4/ocaml_src/lib/token.ml @@ -114,17 +114,17 @@ let rec backslash s i = | '0'..'9' as c -> backslash1 (valch c) s (i + 1) | _ -> raise Not_found and backslash1 cod s i = - if i = String.length s then Char.chr cod, i + if i = String.length s then '\\', i - 1 else match s.[i] with '0'..'9' as c -> backslash2 (10 * cod + valch c) s (i + 1) - | _ -> Char.chr cod, i + | _ -> '\\', i - 1 and backslash2 cod s i = - if i = String.length s then Char.chr cod, i + if i = String.length s then '\\', i - 2 else match s.[i] with '0'..'9' as c -> Char.chr (10 * cod + valch c), i + 1 - | _ -> Char.chr cod, i + | _ -> '\\', i - 2 ;; let rec skip_indent s i =