Skip to content

Commit

Permalink
Replace CR, FF and VT with whitespace.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bschommer authored and xavierleroy committed Nov 5, 2022
1 parent ccfeebf commit e637a49
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/Printlines.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit e637a49

Please sign in to comment.