mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Enable compilation of more on Fuchisa.
This commit is contained in:
parent
fd7be06e5b
commit
ba244794f0
4 changed files with 12 additions and 11 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -574,7 +574,6 @@ name = "more"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"nix 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"uucore 0.0.1",
|
"uucore 0.0.1",
|
||||||
]
|
]
|
||||||
|
|
|
@ -87,6 +87,7 @@ fuchsia = [
|
||||||
"ln",
|
"ln",
|
||||||
"mkdir",
|
"mkdir",
|
||||||
"mktemp",
|
"mktemp",
|
||||||
|
"more",
|
||||||
"mv",
|
"mv",
|
||||||
"nl",
|
"nl",
|
||||||
"nproc",
|
"nproc",
|
||||||
|
|
|
@ -9,10 +9,9 @@ path = "more.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
getopts = "*"
|
getopts = "*"
|
||||||
libc = "*"
|
|
||||||
uucore = { path="../uucore" }
|
uucore = { path="../uucore" }
|
||||||
|
|
||||||
[target."cfg(unix)".dependencies]
|
[target.'cfg(all(unix, not(target_os = "fuchsia")))'.dependencies]
|
||||||
nix = "*"
|
nix = "*"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
|
|
@ -18,9 +18,9 @@ use getopts::Options;
|
||||||
use std::io::{stdout, Write, Read};
|
use std::io::{stdout, Write, Read};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(all(unix, not(target_os = "fuchsia")))]
|
||||||
extern crate nix;
|
extern crate nix;
|
||||||
#[cfg(unix)]
|
#[cfg(all(unix, not(target_os = "fuchsia")))]
|
||||||
use nix::sys::termios;
|
use nix::sys::termios;
|
||||||
|
|
||||||
#[derive(Clone, Eq, PartialEq)]
|
#[derive(Clone, Eq, PartialEq)]
|
||||||
|
@ -76,7 +76,7 @@ fn help(usage: &str) {
|
||||||
println!("{}", msg);
|
println!("{}", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(all(unix, not(target_os = "fuchsia")))]
|
||||||
fn setup_term() -> termios::Termios {
|
fn setup_term() -> termios::Termios {
|
||||||
let mut term = termios::tcgetattr(0).unwrap();
|
let mut term = termios::tcgetattr(0).unwrap();
|
||||||
// Unset canonical mode, so we get characters immediately
|
// Unset canonical mode, so we get characters immediately
|
||||||
|
@ -87,19 +87,21 @@ fn setup_term() -> termios::Termios {
|
||||||
term
|
term
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(any(windows, target_os = "fuchsia"))]
|
||||||
|
#[inline(always)]
|
||||||
fn setup_term() -> usize {
|
fn setup_term() -> usize {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(all(unix, not(target_os = "fuchsia")))]
|
||||||
fn reset_term(term: &mut termios::Termios) {
|
fn reset_term(term: &mut termios::Termios) {
|
||||||
term.c_lflag.insert(termios::ICANON);
|
term.c_lflag.insert(termios::ICANON);
|
||||||
term.c_lflag.insert(termios::ECHO);
|
term.c_lflag.insert(termios::ECHO);
|
||||||
termios::tcsetattr(0, termios::TCSADRAIN, &term).unwrap();
|
termios::tcsetattr(0, termios::TCSADRAIN, &term).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(any(windows, target_os = "fuchsia"))]
|
||||||
|
#[inline(always)]
|
||||||
fn reset_term(_: &mut usize) {
|
fn reset_term(_: &mut usize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +114,7 @@ fn more(matches: getopts::Matches) {
|
||||||
|
|
||||||
let mut end = false;
|
let mut end = false;
|
||||||
while let Ok(sz) = f.read(&mut buffer) {
|
while let Ok(sz) = f.read(&mut buffer) {
|
||||||
if sz == 0 { break; }
|
if sz == 0 { break }
|
||||||
stdout().write(&buffer[0..sz]).unwrap();
|
stdout().write(&buffer[0..sz]).unwrap();
|
||||||
for byte in std::io::stdin().bytes() {
|
for byte in std::io::stdin().bytes() {
|
||||||
match byte.unwrap() {
|
match byte.unwrap() {
|
||||||
|
@ -125,7 +127,7 @@ fn more(matches: getopts::Matches) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if end { break;}
|
if end { break }
|
||||||
}
|
}
|
||||||
|
|
||||||
reset_term(&mut term);
|
reset_term(&mut term);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue