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

ocp-indent should not change the kind of newlines used in files #288

Open
nojb opened this issue Jun 17, 2019 · 1 comment
Open

ocp-indent should not change the kind of newlines used in files #288

nojb opened this issue Jun 17, 2019 · 1 comment
Assignees

Comments

@nojb
Copy link
Contributor

nojb commented Jun 17, 2019

Currently, if I reindent a file using LF on Windows the resulting file uses CRLF (and vice-versa). ocp-indent should preserve whatever end-of-line being used in the file.

@nojb
Copy link
Contributor Author

nojb commented Oct 9, 2024

The following patch seems to fix this issue:

diff --git a/src/indentMain.ml b/src/indentMain.ml
index 9a02b8e..162ee3c 100644
--- a/src/indentMain.ml
+++ b/src/indentMain.ml
@@ -19,7 +19,7 @@ module Args = IndentArgs
 let indent_channel ic args config out perm =
   let oc, need_close = match out with
     | None | Some "-" -> stdout, false
-    | Some file -> open_out_gen [Open_wronly; Open_creat; Open_trunc; Open_text] perm file, true
+    | Some file -> open_out_gen [Open_wronly; Open_creat; Open_trunc; Open_binary] perm file, true
   in
   let output = {
     IndentPrinter.
@@ -82,7 +82,7 @@ let indent_file args = function
         else
           args.Args.file_out, 0o644, None
       in
-      let ic = open_in path in
+      let ic = open_in_bin path in
       try
         indent_channel ic args config out perm;
         close_in ic;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants