From 104f80c78f24b2418db2c7e1bc51692818ff4fdd Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Tue, 18 Dec 2018 10:44:40 +0100 Subject: [PATCH] Ensure --dump-ast sets stdout to binary on Windows --- src/migrate_parsetree_driver.ml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/migrate_parsetree_driver.ml b/src/migrate_parsetree_driver.ml index 80f147df..a294c02e 100644 --- a/src/migrate_parsetree_driver.ml +++ b/src/migrate_parsetree_driver.ml @@ -371,9 +371,14 @@ let load_file file = | Intf fn -> (fn, Intf (Parse.interface lexbuf))) -let with_output output ~f = +let with_output ?bin output ~f = match output with - | None -> f stdout + | None -> + begin match bin with + | Some bin -> set_binary_mode_out stdout bin + | None -> () + end; + f stdout | Some fn -> with_file_out fn ~f type output_mode = @@ -416,7 +421,7 @@ let process_file ~config ~output ~output_mode ~embed_errors file = in match output_mode with | Dump_ast -> - with_output output ~f:(fun oc -> + with_output ~bin:true output ~f:(fun oc -> let ast = match ast with | Intf (_, sg) -> Ast_io.Intf ((module OCaml_current), sg)