Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure stdout is in binary mode on Windows for --dump-ast #59

Merged
2 commits merged into from
Dec 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/migrate_parsetree_ast_io.ml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ let decompose_ast = function

let to_channel oc (filename : filename) x =
let magic_number, payload = decompose_ast x in
set_binary_mode_out oc true;
output_string oc magic_number;
output_value oc filename;
output_value oc payload
Expand Down
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