File tree Expand file tree Collapse file tree 2 files changed +19
-17
lines changed Expand file tree Collapse file tree 2 files changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -41,19 +41,21 @@ let stats_to_string
4141 (String. concat " ,"
4242 (Array. to_list (Array. map string_of_int bucket_histogram)))
4343
44- let string_of_int_as_char i =
45- let str = match Char. unsafe_chr i with
46- | '\' ' -> " \\ '"
47- | '\\' -> " \\\\ "
48- | '\n' -> " \\ n"
49- | '\t' -> " \\ t"
50- | '\r' -> " \\ r"
51- | '\b' -> " \\ b"
52- | ' ' .. '~' as c ->
53- let s = (Bytes. create [@ doesNotRaise]) 1 in
54- Bytes. unsafe_set s 0 c;
55- Bytes. unsafe_to_string s
56- | _ -> Ext_utf8. encode_codepoint i
57- in
58- Printf. sprintf " \' %s\' " str
59-
44+ let string_of_int_as_char (i : int ) : string =
45+ if i < = 255 && i > = 0 then Format. asprintf " %C" (Char. unsafe_chr i)
46+ else
47+ let str =
48+ match Char. unsafe_chr i with
49+ | '\' ' -> " \\ '"
50+ | '\\' -> " \\\\ "
51+ | '\n' -> " \\ n"
52+ | '\t' -> " \\ t"
53+ | '\r' -> " \\ r"
54+ | '\b' -> " \\ b"
55+ | ' ' .. '~' as c ->
56+ let s = (Bytes. create [@ doesNotRaise]) 1 in
57+ Bytes. unsafe_set s 0 c;
58+ Bytes. unsafe_to_string s
59+ | _ -> Ext_utf8. encode_codepoint i
60+ in
61+ Printf. sprintf " \' %s\' " str
Original file line number Diff line number Diff line change @@ -192,7 +192,7 @@ let rec longident f = function
192192
193193let longident_loc f x = pp f " %a" longident x.txt
194194
195- let string_of_int_as_char i = Ext_utf8. encode_codepoint i
195+ let string_of_int_as_char i = Ext_util. string_of_int_as_char i
196196
197197let constant f = function
198198 | Pconst_char i -> pp f " %s" (string_of_int_as_char i)
You can’t perform that action at this time.
0 commit comments