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

🐛Mixed EOL files created on WinOS #2902

Closed
rivy opened this issue Aug 18, 2024 · 1 comment · Fixed by #2923
Closed

🐛Mixed EOL files created on WinOS #2902

rivy opened this issue Aug 18, 2024 · 1 comment · Fixed by #2923

Comments

@rivy
Copy link

rivy commented Aug 18, 2024

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...

rust-bindgen/bindgen/lib.rs

Lines 925 to 934 in d71972a

const NL: &str = if cfg!(windows) { "\r\n" } else { "\n" };
if !self.options.disable_header_comment {
let version =
option_env!("CARGO_PKG_VERSION").unwrap_or("(unknown version)");
writeln!(
writer,
"/* automatically generated by rust-bindgen {version} */{NL}",
)?;
}

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}", 
)?; 
@pvdrz pvdrz linked a pull request Sep 4, 2024 that will close this issue
@pvdrz
Copy link
Contributor

pvdrz commented Sep 4, 2024

thanks!

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

Successfully merging a pull request may close this issue.

2 participants