Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ ocaml_src
build.ninja
jscomp/bin/bsb
jscomp/bin/bsc
jscomp/bin/config_whole_compiler.ml
jscomp/bin/config_whole_compiler.ml
lib/bs
lib/js/jscomp/test
12 changes: 6 additions & 6 deletions jscomp/bin/bsb.ml
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ let finally v action f =
| e -> action v ; e

let with_file_as_chan filename f =
finally (open_out filename) close_out f
finally (open_out_bin filename) close_out f

let with_file_as_pp filename f =
finally (open_out filename) close_out
finally (open_out_bin filename) close_out
(fun chan ->
let fmt = Format.formatter_of_out_channel chan in
let v = f fmt in
Expand Down Expand Up @@ -1478,7 +1478,7 @@ let write_build_cache bsbuild (bs_files : module_info String_map.t) =
close_out oc

let read_build_cache bsbuild : module_info String_map.t =
let ic = open_in bsbuild in
let ic = open_in_bin bsbuild in
let buffer = really_input_string ic (String.length module_info_magic_number) in
assert(buffer = module_info_magic_number);
let data : module_info String_map.t = input_value ic in
Expand Down Expand Up @@ -2624,7 +2624,7 @@ let parse_json_from_chan in_chan =
parse_json lexbuf

let parse_json_from_file s =
let in_chan = open_in s in
let in_chan = open_in_bin s in
let lexbuf = Lexing.from_channel in_chan in
match parse_json lexbuf with
| exception e -> close_in in_chan ; raise e
Expand Down Expand Up @@ -3911,7 +3911,7 @@ let write (fname : string) (x : t) =
close_out oc

let read (fname : string) : t =
let ic = open_in fname in
let ic = open_in_bin fname in (* Windows binary mode*)
let buffer = really_input_string ic (String.length magic_number) in
assert (buffer = magic_number);
let res : t = input_value ic in
Expand Down Expand Up @@ -4597,7 +4597,7 @@ let output_ninja
in (* make sure -bs-package-name is before -bs-package-output *)
String.concat " " ( bsc_flags @ init_flags)
in
let oc = open_out (builddir // Literals.build_ninja) in
let oc = open_out_bin (builddir // Literals.build_ninja) in
begin

let () =
Expand Down
9 changes: 5 additions & 4 deletions jscomp/bin/bsdep.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2785,7 +2785,8 @@ let write_ast (type t) ~(fname : string) ~output (kind : t kind) ( pt : t) : uni
match kind with
| Ml -> Config.ast_impl_magic_number
| Mli -> Config.ast_intf_magic_number in
let oc = open_out output in
let oc = open_out_bin output in
(* FIX for windows: output_value: not a binary channel*)
output_string oc magic ;
output_value oc fname;
output_value oc pt;
Expand Down Expand Up @@ -2897,10 +2898,10 @@ let finally v action f =
| e -> action v ; e

let with_file_as_chan filename f =
finally (open_out filename) close_out f
finally (open_out_bin filename) close_out f

let with_file_as_pp filename f =
finally (open_out filename) close_out
finally (open_out_bin filename) close_out
(fun chan ->
let fmt = Format.formatter_of_out_channel chan in
let v = f fmt in
Expand Down Expand Up @@ -4273,7 +4274,7 @@ let write_build_cache bsbuild (bs_files : module_info String_map.t) =
close_out oc

let read_build_cache bsbuild : module_info String_map.t =
let ic = open_in bsbuild in
let ic = open_in_bin bsbuild in
let buffer = really_input_string ic (String.length module_info_magic_number) in
assert(buffer = module_info_magic_number);
let data : module_info String_map.t = input_value ic in
Expand Down
2 changes: 1 addition & 1 deletion jscomp/bin/bspp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4887,7 +4887,7 @@ let buffer_intervals (intervals : (int * int) list) buf ic oc =


let preprocess fn oc =
let ic = open_in fn in
let ic = open_in_bin fn in
let lexbuf = Lexing.from_channel ic in
let buf = Buffer.create 4096 in
Location.init lexbuf fn;
Expand Down
4 changes: 2 additions & 2 deletions jscomp/bin/bsppx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7358,10 +7358,10 @@ let finally v action f =
| e -> action v ; e

let with_file_as_chan filename f =
finally (open_out filename) close_out f
finally (open_out_bin filename) close_out f

let with_file_as_pp filename f =
finally (open_out filename) close_out
finally (open_out_bin filename) close_out
(fun chan ->
let fmt = Format.formatter_of_out_channel chan in
let v = f fmt in
Expand Down
9 changes: 5 additions & 4 deletions jscomp/bin/whole_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20696,10 +20696,10 @@ let finally v action f =
| e -> action v ; e

let with_file_as_chan filename f =
finally (open_out filename) close_out f
finally (open_out_bin filename) close_out f

let with_file_as_pp filename f =
finally (open_out filename) close_out
finally (open_out_bin filename) close_out
(fun chan ->
let fmt = Format.formatter_of_out_channel chan in
let v = f fmt in
Expand Down Expand Up @@ -22170,7 +22170,8 @@ let write_ast (type t) ~(fname : string) ~output (kind : t kind) ( pt : t) : uni
match kind with
| Ml -> Config.ast_impl_magic_number
| Mli -> Config.ast_intf_magic_number in
let oc = open_out output in
let oc = open_out_bin output in
(* FIX for windows: output_value: not a binary channel*)
output_string oc magic ;
output_value oc fname;
output_value oc pt;
Expand Down Expand Up @@ -97686,7 +97687,7 @@ let write_build_cache bsbuild (bs_files : module_info String_map.t) =
close_out oc

let read_build_cache bsbuild : module_info String_map.t =
let ic = open_in bsbuild in
let ic = open_in_bin bsbuild in
let buffer = really_input_string ic (String.length module_info_magic_number) in
assert(buffer = module_info_magic_number);
let data : module_info String_map.t = input_value ic in
Expand Down
2 changes: 1 addition & 1 deletion jscomp/bsb/bs_dep_infos.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let write (fname : string) (x : t) =
close_out oc

let read (fname : string) : t =
let ic = open_in fname in
let ic = open_in_bin fname in (* Windows binary mode*)
let buffer = really_input_string ic (String.length magic_number) in
assert (buffer = magic_number);
let res : t = input_value ic in
Expand Down
2 changes: 1 addition & 1 deletion jscomp/bsb/bs_json.ml
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ let parse_json_from_chan in_chan =
parse_json lexbuf

let parse_json_from_file s =
let in_chan = open_in s in
let in_chan = open_in_bin s in
let lexbuf = Lexing.from_channel in_chan in
match parse_json lexbuf with
| exception e -> close_in in_chan ; raise e
Expand Down
2 changes: 1 addition & 1 deletion jscomp/bsb/bsb_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ let output_ninja
in (* make sure -bs-package-name is before -bs-package-output *)
String.concat " " ( bsc_flags @ init_flags)
in
let oc = open_out (builddir // Literals.build_ninja) in
let oc = open_out_bin (builddir // Literals.build_ninja) in
begin

let () =
Expand Down
3 changes: 2 additions & 1 deletion jscomp/common/binary_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ let write_ast (type t) ~(fname : string) ~output (kind : t kind) ( pt : t) : uni
match kind with
| Ml -> Config.ast_impl_magic_number
| Mli -> Config.ast_intf_magic_number in
let oc = open_out output in
let oc = open_out_bin output in
(* FIX for windows: output_value: not a binary channel*)
output_string oc magic ;
output_value oc fname;
output_value oc pt;
Expand Down
2 changes: 1 addition & 1 deletion jscomp/common/binary_cache.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let write_build_cache bsbuild (bs_files : module_info String_map.t) =
close_out oc

let read_build_cache bsbuild : module_info String_map.t =
let ic = open_in bsbuild in
let ic = open_in_bin bsbuild in
let buffer = really_input_string ic (String.length module_info_magic_number) in
assert(buffer = module_info_magic_number);
let data : module_info String_map.t = input_value ic in
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/bspack_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ let () =
let out_chan =
lazy (match !output_file with
| None -> stdout
| Some file -> open_out file) in
| Some file -> open_out_bin file) in
let emit_header out_chan =
let local_time = Unix.(localtime (gettimeofday ())) in
(if !header_option
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/bspp_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let buffer_intervals (intervals : (int * int) list) buf ic oc =


let preprocess fn oc =
let ic = open_in fn in
let ic = open_in_bin fn in
let lexbuf = Lexing.from_channel ic in
let buf = Buffer.create 4096 in
Location.init lexbuf fn;
Expand Down
6 changes: 3 additions & 3 deletions jscomp/ext/ext_io.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

(** on 32 bit , there are 16M limitation *)
let load_file f =
Ext_pervasives.finally (open_in f) close_in begin fun ic ->
Ext_pervasives.finally (open_in_bin f) close_in begin fun ic ->
let n = in_channel_length ic in
let s = Bytes.create n in
really_input ic s 0 n;
Expand All @@ -34,7 +34,7 @@ let load_file f =


let rev_lines_of_file file =
Ext_pervasives.finally (open_in file) close_in begin fun chan ->
Ext_pervasives.finally (open_in_bin file) close_in begin fun chan ->
let rec loop acc =
match input_line chan with
| line -> loop (line :: acc)
Expand All @@ -43,6 +43,6 @@ let rev_lines_of_file file =
end

let write_file f content =
Ext_pervasives.finally (open_out f) close_out begin fun oc ->
Ext_pervasives.finally (open_out_bin f) close_out begin fun oc ->
output_string oc content
end
4 changes: 2 additions & 2 deletions jscomp/ext/ext_pervasives.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ let finally v action f =
| e -> action v ; e

let with_file_as_chan filename f =
finally (open_out filename) close_out f
finally (open_out_bin filename) close_out f

let with_file_as_pp filename f =
finally (open_out filename) close_out
finally (open_out_bin filename) close_out
(fun chan ->
let fmt = Format.formatter_of_out_channel chan in
let v = f fmt in
Expand Down
4 changes: 2 additions & 2 deletions jscomp/test/ext_pervasives.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ function $$finally(v, action, f) {
}

function with_file_as_chan(filename, f) {
return $$finally(Pervasives.open_out(filename), Pervasives.close_out, f);
return $$finally(Pervasives.open_out_bin(filename), Pervasives.close_out, f);
}

function with_file_as_pp(filename, f) {
return $$finally(Pervasives.open_out(filename), Pervasives.close_out, function (chan) {
return $$finally(Pervasives.open_out_bin(filename), Pervasives.close_out, function (chan) {
var fmt = Format.formatter_of_out_channel(chan);
var v = Curry._1(f, fmt);
Format.pp_print_flush(fmt, /* () */0);
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/qcc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1959,7 +1959,7 @@ function main() {
};
default:
var oc = Pervasives.open_out("a.out");
inch[0] = Pervasives.open_in(f);
inch[0] = Pervasives.open_in_bin(f);
top(/* () */0);
elfgen(oc);
Caml_io.caml_ml_flush(oc);
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/qcc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ let main () =
| "-blk" -> doone (block (ref 0, 0)) []
| f ->
let oc = open_out "a.out" in
inch := open_in f;
inch := open_in_bin f;
top (); elfgen oc;
close_out oc

Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/sexpm.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var Format = require("../../lib/js/format");
var Caml_string = require("../../lib/js/caml_string");

function _with_in(filename, f) {
var ic = Pervasives.open_in(filename);
var ic = Pervasives.open_in_bin(filename);
try {
var x = Curry._1(f, ic);
(function () {
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/sexpm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type t = [
type sexp = t

let _with_in filename f =
let ic = open_in filename in
let ic = open_in_bin filename in
try
let x = f ic in
close_in ic;
Expand Down