From e637a49e7a963683a4337b742c0adc0e1f93f139 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Mon, 31 Oct 2022 11:03:13 +0100 Subject: Replace CR, FF and VT with whitespace. We use Printlines to copy C code fragments to assembly comments. While CR, FF and VT are treated like whitespace by C, they could possibly mess up the assembly comments if copied verbatim. Moreover, this avoids generating CR CR LF end-of-lines under Windows. Bug 34075 --- lib/Printlines.ml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Printlines.ml b/lib/Printlines.ml index b60fdf4a..b270e229 100644 --- a/lib/Printlines.ml +++ b/lib/Printlines.ml @@ -101,11 +101,13 @@ let copy oc pref b first last = try while b.lineno <= last do let c = input_char b.chan in - output_char oc c; - if c = '\n' then begin + match c with + | '\n' -> + output_char oc c; b.lineno <- b.lineno + 1; if b.lineno <= last then output_string oc pref - end + | '\r' | '\011' | '\012' -> output_char oc ' ' + | _ -> output_char oc c done with End_of_file -> output_char oc '\n' -- cgit