Skip to content

Commit

Permalink
enable progress bar for FreeBSD
Browse files Browse the repository at this point in the history
As FreeBSD uses a unsigned long for the IOCTL syscall this code would
previously fail to compile. Adding a call to into() fixes this problem.

This code should still work on other platfroms as into() is able to
'convert' an u32 into a u32.

Also change the cfg attributes so that the working code is used.

This may also work on other not yet supported platforms, but it was not
tested.
  • Loading branch information
xanderio committed Aug 7, 2019
1 parent 375de4a commit c26e52c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/cargo/core/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ impl ColorChoice {
}
}

#[cfg(any(target_os = "linux", target_os = "macos"))]
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))]
mod imp {
use std::mem;

Expand All @@ -377,7 +377,7 @@ mod imp {
pub fn stderr_width() -> Option<usize> {
unsafe {
let mut winsize: libc::winsize = mem::zeroed();
if libc::ioctl(libc::STDERR_FILENO, libc::TIOCGWINSZ, &mut winsize) < 0 {
if libc::ioctl(libc::STDERR_FILENO, libc::TIOCGWINSZ.into(), &mut winsize) < 0 {
return None;
}
if winsize.ws_col > 0 {
Expand All @@ -396,7 +396,10 @@ mod imp {
}
}

#[cfg(all(unix, not(any(target_os = "linux", target_os = "macos"))))]
#[cfg(all(
unix,
not(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))
))]
mod imp {
pub(super) use super::default_err_erase_line as err_erase_line;

Expand Down

0 comments on commit c26e52c

Please sign in to comment.