mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-08 12:15:32 -05:00
bugfix in CCFormat.to_file (fd was closed too early)
This commit is contained in:
parent
871fe7cfb7
commit
9d9f709600
1 changed files with 4 additions and 14 deletions
|
|
@ -130,22 +130,12 @@ let fprintf = Format.fprintf
|
||||||
let stdout = Format.std_formatter
|
let stdout = Format.std_formatter
|
||||||
let stderr = Format.err_formatter
|
let stderr = Format.err_formatter
|
||||||
|
|
||||||
let _with_file_out filename f =
|
let to_file filename format =
|
||||||
let oc = open_out filename in
|
let oc = open_out filename in
|
||||||
let fmt = Format.formatter_of_out_channel oc in
|
let fmt = Format.formatter_of_out_channel oc in
|
||||||
begin try
|
Format.kfprintf
|
||||||
let x = f fmt in
|
(fun fmt -> Format.pp_print_flush fmt (); close_out_noerr oc)
|
||||||
Format.pp_print_flush fmt ();
|
fmt format
|
||||||
close_out oc;
|
|
||||||
x
|
|
||||||
with e ->
|
|
||||||
Format.pp_print_flush fmt ();
|
|
||||||
close_out_noerr oc;
|
|
||||||
raise e
|
|
||||||
end
|
|
||||||
|
|
||||||
let to_file filename format =
|
|
||||||
_with_file_out filename (fun fmt -> Format.fprintf fmt format)
|
|
||||||
|
|
||||||
type color =
|
type color =
|
||||||
[ `Black
|
[ `Black
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue