bug/lib.rs Allow musl builds (#58)

This commit is contained in:
David Irvine 2016-10-20 13:28:34 +01:00 committed by ticki
parent 4358ed6c48
commit 5085815f58
1 changed files with 14 additions and 2 deletions

View File

@ -15,17 +15,25 @@ struct TermSize {
// Since attributes on non-item statements is not stable yet, we use a function.
#[cfg(not(target_os = "redox"))]
#[cfg(target_pointer_width = "64")]
#[cfg(not(target_env = "musl"))]
fn tiocgwinsz() -> u64 {
use termios::TIOCGWINSZ;
TIOCGWINSZ as u64
}
#[cfg(not(target_os = "redox"))]
#[cfg(target_pointer_width = "32")]
#[cfg(not(target_env = "musl"))]
fn tiocgwinsz() -> u32 {
use termios::TIOCGWINSZ;
TIOCGWINSZ as u32
}
#[cfg(target_env = "musl")]
fn tiocgwinsz() -> i32 {
use termios::TIOCGWINSZ;
TIOCGWINSZ as i32
}
/// Get the size of the terminal.
#[cfg(not(target_os = "redox"))]
@ -50,8 +58,12 @@ pub fn terminal_size() -> io::Result<(u16, u16)> {
pub fn terminal_size() -> io::Result<(u16, u16)> {
use std::env;
let width = try!(env::var("COLUMNS").map_err(|x| io::Error::new(io::ErrorKind::NotFound, x))).parse().unwrap_or(0);
let height = try!(env::var("LINES").map_err(|x| io::Error::new(io::ErrorKind::NotFound, x))).parse().unwrap_or(0);
let width = try!(env::var("COLUMNS").map_err(|x| io::Error::new(io::ErrorKind::NotFound, x)))
.parse()
.unwrap_or(0);
let height = try!(env::var("LINES").map_err(|x| io::Error::new(io::ErrorKind::NotFound, x)))
.parse()
.unwrap_or(0);
Ok((width, height))
}