Skip to content

Commit

Permalink
Ensure --dump-ast sets stdout to binary on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dra27 authored and jeremiedimino committed Dec 19, 2018
1 parent ccd08e2 commit 104f80c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/migrate_parsetree_driver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 104f80c

Please sign in to comment.