Skip to content

Commit 67c6612

Browse files
committed
Add -b output binary option
1 parent 40600e3 commit 67c6612

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Changes.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## v1.7.1 (2024-??-??)
22
- [bug] Fix `cppo -version`, which used to print a blank line (#92).
3+
- [+ui] Added the `-b` output binary option so that Windows does
4+
not add CRLF endings.
35

46
## v1.7.0 (2024-08-22)
57
- [+ui] Multi-line macros, without line terminators `\`,

src/cppo_main.ml

+9-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ let main () =
7878
let preserve_quotations = ref false in
7979
let show_exact_locations = ref false in
8080
let show_no_locations = ref false in
81+
let output_binary = ref false in
8182
let options = [
8283
"-D", Arg.String (fun s -> header := ("#define " ^ s ^ "\n") :: !header),
8384
"DEF
@@ -133,6 +134,10 @@ let main () =
133134
Do not output any line directive other than those found in the
134135
input (overrides -s).";
135136

137+
"-b", Arg.Set output_binary,
138+
"
139+
Write output without CRLF normalization on Windows.";
140+
136141
"-version", Arg.Unit (fun () ->
137142
print_endline Cppo_version.cppo_version;
138143
exit 0),
@@ -215,7 +220,10 @@ Options:" Sys.argv.(0) in
215220
print_string (Buffer.contents buf);
216221
flush stdout
217222
| Some file ->
218-
let oc = open_out file in
223+
let oc =
224+
if !output_binary then open_out_bin file
225+
else open_out file
226+
in
219227
output_string oc (Buffer.contents buf);
220228
close_out oc
221229

0 commit comments

Comments
 (0)