From ba244794f0b9eef4fd3b8a7533bc6994ab7cad8b Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 6 Dec 2016 21:28:17 -0500 Subject: [PATCH] Enable compilation of more on Fuchisa. --- Cargo.lock | 1 - Cargo.toml | 1 + src/more/Cargo.toml | 3 +-- src/more/more.rs | 18 ++++++++++-------- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 585f7fc3b..ca035c89b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -574,7 +574,6 @@ name = "more" version = "0.0.1" dependencies = [ "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "uucore 0.0.1", ] diff --git a/Cargo.toml b/Cargo.toml index 51ad33ff1..4936aff70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,6 +87,7 @@ fuchsia = [ "ln", "mkdir", "mktemp", + "more", "mv", "nl", "nproc", diff --git a/src/more/Cargo.toml b/src/more/Cargo.toml index bac1ac0e0..09e53e429 100644 --- a/src/more/Cargo.toml +++ b/src/more/Cargo.toml @@ -9,10 +9,9 @@ path = "more.rs" [dependencies] getopts = "*" -libc = "*" uucore = { path="../uucore" } -[target."cfg(unix)".dependencies] +[target.'cfg(all(unix, not(target_os = "fuchsia")))'.dependencies] nix = "*" [[bin]] diff --git a/src/more/more.rs b/src/more/more.rs index 292d77def..8967fe9e4 100644 --- a/src/more/more.rs +++ b/src/more/more.rs @@ -18,9 +18,9 @@ use getopts::Options; use std::io::{stdout, Write, Read}; use std::fs::File; -#[cfg(unix)] +#[cfg(all(unix, not(target_os = "fuchsia")))] extern crate nix; -#[cfg(unix)] +#[cfg(all(unix, not(target_os = "fuchsia")))] use nix::sys::termios; #[derive(Clone, Eq, PartialEq)] @@ -76,7 +76,7 @@ fn help(usage: &str) { println!("{}", msg); } -#[cfg(unix)] +#[cfg(all(unix, not(target_os = "fuchsia")))] fn setup_term() -> termios::Termios { let mut term = termios::tcgetattr(0).unwrap(); // Unset canonical mode, so we get characters immediately @@ -87,19 +87,21 @@ fn setup_term() -> termios::Termios { term } -#[cfg(windows)] +#[cfg(any(windows, target_os = "fuchsia"))] +#[inline(always)] fn setup_term() -> usize { 0 } -#[cfg(unix)] +#[cfg(all(unix, not(target_os = "fuchsia")))] fn reset_term(term: &mut termios::Termios) { term.c_lflag.insert(termios::ICANON); term.c_lflag.insert(termios::ECHO); termios::tcsetattr(0, termios::TCSADRAIN, &term).unwrap(); } -#[cfg(windows)] +#[cfg(any(windows, target_os = "fuchsia"))] +#[inline(always)] fn reset_term(_: &mut usize) { } @@ -112,7 +114,7 @@ fn more(matches: getopts::Matches) { let mut end = false; while let Ok(sz) = f.read(&mut buffer) { - if sz == 0 { break; } + if sz == 0 { break } stdout().write(&buffer[0..sz]).unwrap(); for byte in std::io::stdin().bytes() { match byte.unwrap() { @@ -125,7 +127,7 @@ fn more(matches: getopts::Matches) { } } - if end { break;} + if end { break } } reset_term(&mut term);