Skip to content

Commit

Permalink
Merge pull request #40 from jonahbeckford/remove-carriage-return
Browse files Browse the repository at this point in the history
Strip carriage returns from files before processing
  • Loading branch information
Octachron authored Sep 27, 2024
2 parents 0179b58 + 3ed69fe commit 189a434
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*~
**/_build/**
**/.merlin
**/_opam/**
tests/generated/star/m*.mli
*.cm[ioax]
*.cmxa
Expand Down
2 changes: 1 addition & 1 deletion core/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type task =
let compiler_dir =
lazy (
let ch = Unix.open_process_in "ocamlc -where" in
let s= input_line ch in
let s= Win32_compat.dos2unix (input_line ch) in
close_in ch;
s ^ "/"
)
Expand Down
2 changes: 1 addition & 1 deletion core/findlib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let run cmd =
let cin = Unix.open_process_in cmd in
let rec read l =
try
match input_line cin with
match Win32_compat.dos2unix (input_line cin) with
| "" -> read l
| s -> read (s::l)
with
Expand Down
2 changes: 1 addition & 1 deletion experimental/client/codept_client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ let client socket =
output_value ch query;
flush ch;
let rec read () =
match input_line inchan with
match Win32_compat.dos2unix (input_line inchan) with
| exception End_of_file -> ()
| s -> print_endline s; read () in
read ()
Expand Down
7 changes: 7 additions & 0 deletions lib/win32_compat.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let dos2unix s =
let len = String.length s in
let b = Buffer.create len in
for i = 0 to len - 1 do
match s.[i] with '\r' -> () | c -> Buffer.add_char b c
done;
Buffer.contents b
2 changes: 2 additions & 0 deletions lib/win32_compat.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
val dos2unix : string -> string
(** [dos2unix s] removes carriage returns (ASCII 0x0D) from [s]. *)
2 changes: 1 addition & 1 deletion tests/integrated.ml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ let extract_attribute x =
let f = open_in x in
let rec loop l =
try
let nl = input_line f in
let nl = Win32_compat.dos2unix (input_line f) in
try
let att = Scanf.sscanf nl "[%@%@%@%s@]" (fun x -> x) in
loop (att :: l)
Expand Down
2 changes: 1 addition & 1 deletion tests/run.ml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ module Branch(Param:Stage.param) = struct
let cmd = "ocamlc -where " in
let cin = Unix.open_process_in cmd in
try
[Filename.concat (input_line cin) "compiler-libs" ]
[Filename.concat (Win32_compat.dos2unix (input_line cin)) "compiler-libs" ]
with
End_of_file -> []

Expand Down

0 comments on commit 189a434

Please sign in to comment.