rust-bindgen icon indicating copy to clipboard operation
rust-bindgen copied to clipboard

🐛Mixed EOL files created on WinOS

Open rivy opened this issue 1 year ago • 0 comments

I'm running into files created by bindgen for WinOS platforms that have mixed line endings (both CRLF and LF). For example, bindings/i686-pc-windows-msvc.rs is a mixed EOL file with \r\n\n ending the starting comment.

It looks like this code is the cause...

https://github.com/rust-lang/rust-bindgen/blob/d71972abc543219c0619c41634bf68a5623be4be/bindgen/lib.rs#L925-L934

NL is set per-platform, but writeln! always ends with LF, no matter the platform (see https://doc.rust-lang.org/std/macro.write.html).

I think that the code you likely want for the write would be:

write!( 
     writer, 
     "/* automatically generated by rust-bindgen {version} */{NL}{NL}", 
)?; 

rivy avatar Aug 18 '24 16:08 rivy