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

Use \r\n on windows #2698

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions bindgen/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -927,22 +927,24 @@ impl Bindings {

/// Write these bindings as source text to the given `Write`able.
pub fn write<'a>(&self, mut writer: Box<dyn Write + 'a>) -> io::Result<()> {
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)");
let header = format!(
"/* automatically generated by rust-bindgen {version} */\n\n",
);
writer.write_all(header.as_bytes())?;
writeln!(
writer,
"/* automatically generated by rust-bindgen {version} */{NL}",
)?;
}

for line in self.options.raw_lines.iter() {
writer.write_all(line.as_bytes())?;
writer.write_all("\n".as_bytes())?;
writer.write_all(NL.as_bytes())?;
}

if !self.options.raw_lines.is_empty() {
writer.write_all("\n".as_bytes())?;
writer.write_all(NL.as_bytes())?;
}

match self.format_tokens(&self.module) {
Expand Down
Loading