avoid whitespace if none needed

This commit is contained in:
Hannes Mehnert 2024-03-14 21:22:14 +01:00
parent 745e816cc2
commit 056c76536e

11
ohex.ml
View file

@ -102,10 +102,11 @@ let pp ?(row_numbers = true) ?(chars = true) () ppf s =
String.sub s (l - (l mod 16)) (l mod 16), String.sub s (l - (l mod 16)) (l mod 16),
pad pad
in in
let pad_chars = pad * 2 + (pad + 1) / 2 + (if pad > 8 then 1 else 0) + 1 in if pad > 0 then
Format.pp_print_string ppf (String.make pad_chars ' '); let pad_chars = pad * 2 + (pad + 1) / 2 + (if pad > 8 then 1 else 0) + 1 in
String.iter (fun c -> Format.pp_print_string ppf (String.make pad_chars ' ');
Format.pp_print_char ppf (if printable_ascii c then c else '.')) String.iter (fun c ->
last_n); Format.pp_print_char ppf (if printable_ascii c then c else '.'))
last_n);
if String.length s mod 16 <> 0 then if String.length s mod 16 <> 0 then
Format.pp_print_string ppf "\n" Format.pp_print_string ppf "\n"