Permalink
Browse files

simplification in bprint_char_set

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14836 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information...
1 parent 543e542 commit f3a309d5ef72b2105e356bbf6a196124b03abe82 @gasche gasche committed May 12, 2014
Showing with 6 additions and 6 deletions.
  1. +6 −6 stdlib/camlinternalFormat.ml
View
12 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

0 comments on commit f3a309d

Please sign in to comment.