From 88fca4efa1f9991a17aac22353ed4ac959fb6568 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 2 Mar 2015 16:42:19 +0100 Subject: [PATCH] bugfix in CCFormat.to_file --- src/core/CCFormat.ml | 1 + src/core/CCPrint.ml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/CCFormat.ml b/src/core/CCFormat.ml index 0af423c3..f20ae774 100644 --- a/src/core/CCFormat.ml +++ b/src/core/CCFormat.ml @@ -134,6 +134,7 @@ let _with_file_out filename f = begin try let x = f fmt in Format.pp_print_flush fmt (); + close_out oc; x with e -> Format.pp_print_flush fmt (); diff --git a/src/core/CCPrint.ml b/src/core/CCPrint.ml index 4b936a7e..8f8ba7a5 100644 --- a/src/core/CCPrint.ml +++ b/src/core/CCPrint.ml @@ -141,6 +141,7 @@ let _with_file_out filename f = let oc = open_out filename in begin try let x = f oc in + close_out oc; x with e -> close_out_noerr oc; @@ -148,7 +149,7 @@ let _with_file_out filename f = end let to_file filename format = - _with_file_out filename (fun oc -> kfprintf (fun _ -> close_out oc) oc format) + _with_file_out filename (fun oc -> fprintf oc format) (** {2 Monadic IO} *)