1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

Enable compilation of more on Fuchisa.

This commit is contained in:
Lei Zhang 2016-12-06 21:28:17 -05:00
parent fd7be06e5b
commit ba244794f0
4 changed files with 12 additions and 11 deletions

1
Cargo.lock generated
View file

@ -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",
]

View file

@ -87,6 +87,7 @@ fuchsia = [
"ln",
"mkdir",
"mktemp",
"more",
"mv",
"nl",
"nproc",

View file

@ -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]]

View file

@ -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);