summaryrefslogtreecommitdiff
path: root/stdlib/camlinternalFormat.ml
diff options
context:
space:
mode:
authorGabriel Scherer <gabriel.scherer@gmail.com>2014-05-12 15:38:25 +0000
committerGabriel Scherer <gabriel.scherer@gmail.com>2014-05-12 15:38:25 +0000
commitf3a309d5ef72b2105e356bbf6a196124b03abe82 (patch)
tree6beec6ef76106b3e79bd13b77f05c74cc6d39040 /stdlib/camlinternalFormat.ml
parent543e542a27161152f387263599d9e22c41cb958f (diff)
downloadocaml-f3a309d5ef72b2105e356bbf6a196124b03abe82.tar.gz
simplification in bprint_char_set
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14836 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'stdlib/camlinternalFormat.ml')
-rw-r--r--stdlib/camlinternalFormat.ml12
1 files changed, 6 insertions, 6 deletions
diff --git a/stdlib/camlinternalFormat.ml b/stdlib/camlinternalFormat.ml
index cf5398c994..09fa133c49 100644
--- a/stdlib/camlinternalFormat.ml
+++ b/stdlib/camlinternalFormat.ml
@@ -169,13 +169,13 @@ let char_of_counter counter = match counter with
(* Print a char_set in a buffer with the OCaml format lexical convention. *)
let bprint_char_set buf char_set =
let rec print_start set =
- if is_in_char_set set ']' &&
- (not (is_in_char_set set '\\') || not (is_in_char_set set '^'))
- then buffer_add_char buf ']';
+ let is_alone c =
+ let before, after = Char.(chr (code c - 1), chr (code c + 1)) in
+ is_in_char_set set c
+ && not (is_in_char_set set before && is_in_char_set set after) in
+ if is_alone ']' then buffer_add_char buf ']';
print_out set 1;
- if is_in_char_set set '-' &&
- (not (is_in_char_set set ',') || not (is_in_char_set set '.'))
- then buffer_add_char buf '-';
+ if is_alone '-' then buffer_add_char buf '-';
and print_out set i =
if i < 256 then
if is_in_char_set set (char_of_int i) then print_first set i