mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 13:37:48 +00:00
Merge pull request #494 from ebfe/fix-build-alpha
More rust alpha build fixes
This commit is contained in:
commit
bdc6e0edcf
66 changed files with 118 additions and 118 deletions
2
deps/rust-crypto
vendored
2
deps/rust-crypto
vendored
|
@ -1 +1 @@
|
|||
Subproject commit c85bfa94d5003f839540536a6d42ecea094d8a45
|
||||
Subproject commit 716c4241e9a8e1e53dde4380eac2b454682ae81c
|
2
deps/time
vendored
2
deps/time
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 00121035e51e1df14d5cd3a3233905f43e5c93a9
|
||||
Subproject commit 7f105d4dd2bde23d4b8516dc02566cfc46b60b22
|
|
@ -40,7 +40,7 @@ fn main() {
|
|||
}
|
||||
_ => {
|
||||
crates.push_str(format!("extern crate {};\n", prog).as_slice());
|
||||
util_map.push_str(format!("map.insert(\"{prog}\", {prog}::uumain as fn(Vec<String>) -> int);\n", prog = prog).as_slice());
|
||||
util_map.push_str(format!("map.insert(\"{prog}\", {prog}::uumain as fn(Vec<String>) -> isize);\n", prog = prog).as_slice());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ mod util;
|
|||
static NAME: &'static str = "basename";
|
||||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = strip_dir(args[0].as_slice());
|
||||
|
||||
//
|
||||
|
|
|
@ -19,7 +19,7 @@ use std::io::stdio::{stdout_raw, stdin_raw, stderr};
|
|||
use std::io::{IoResult};
|
||||
use std::ptr::{copy_nonoverlapping_memory};
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].as_slice();
|
||||
let opts = [
|
||||
getopts::optflag("A", "show-all", "equivalent to -vET"),
|
||||
|
|
|
@ -31,7 +31,7 @@ pub enum Mode {
|
|||
|
||||
impl Copy for Mode {}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let opts = [
|
||||
optflag("h", "help", "display this help and exit"),
|
||||
optflag("", "version", "output version information and exit"),
|
||||
|
|
|
@ -447,7 +447,7 @@ fn cut_files(mut filenames: Vec<String>, mode: Mode) -> int {
|
|||
exit_code
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let opts = [
|
||||
optopt("b", "bytes", "select only these bytes", "LIST"),
|
||||
optopt("c", "characters", "select only these characters", "LIST"),
|
||||
|
|
|
@ -15,7 +15,7 @@ use std::io::print;
|
|||
|
||||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
let opts = [
|
||||
getopts::optflag("z", "zero", "separate output with NUL rather than newline"),
|
||||
|
|
|
@ -89,7 +89,7 @@ fn du(path: &Path, mut my_stat: Stat,
|
|||
stats
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].as_slice();
|
||||
let opts = [
|
||||
// In task
|
||||
|
|
|
@ -162,7 +162,7 @@ fn print_version() {
|
|||
println!("echo version: {}", VERSION);
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let mut options = EchoOptions {
|
||||
newline: false,
|
||||
escape: false
|
||||
|
|
2
src/env/env.rs
vendored
2
src/env/env.rs
vendored
|
@ -51,7 +51,7 @@ fn print_env(null: bool) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let prog = args[0].as_slice();
|
||||
|
||||
// to handle arguments the same way than GNU env, we can't use getopts
|
||||
|
|
|
@ -72,7 +72,7 @@ impl Options {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let opts = [
|
||||
getopts::optflag("i", "initial", "do not convert tabs after non blanks"),
|
||||
getopts::optopt("t", "tabs", "have tabs NUMBER characters apart, not 8", "NUMBER"),
|
||||
|
|
|
@ -63,7 +63,7 @@ fn print_factors_str(num_str: &str) {
|
|||
print_factors(num);
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].as_slice();
|
||||
let opts = [
|
||||
getopts::optflag("h", "help", "show this help message"),
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
pub fn uumain(_: Vec<String>) -> int {
|
||||
pub fn uumain(_: Vec<String>) -> isize {
|
||||
1
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ struct FmtOptions {
|
|||
tabwidth : uint,
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
|
||||
let opts = [
|
||||
getopts::optflag("c", "crown-margin", "First and second line of paragraph may have different indentations, in which case the first line's indentation is preserved, and each subsequent line's indentation matches the second line."),
|
||||
|
|
|
@ -23,7 +23,7 @@ mod util;
|
|||
static NAME: &'static str = "fold";
|
||||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let (args, obs_width) = handle_obsolete(args.as_slice());
|
||||
let program = args[0].clone();
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ use c_types::{get_pw_from_args, group};
|
|||
static NAME: &'static str = "groups";
|
||||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
|
||||
let options = [
|
||||
|
|
|
@ -63,12 +63,12 @@ fn detect_algo(program: &str, matches: &getopts::Matches) -> (&'static str, Box<
|
|||
let mut alg: Option<Box<Digest>> = None;
|
||||
let mut name: &'static str = "";
|
||||
match program {
|
||||
"md5sum" => ("MD5", box Md5::new() as Box<Digest>),
|
||||
"sha1sum" => ("SHA1", box Sha1::new() as Box<Digest>),
|
||||
"sha224sum" => ("SHA224", box Sha224::new() as Box<Digest>),
|
||||
"sha256sum" => ("SHA256", box Sha256::new() as Box<Digest>),
|
||||
"sha384sum" => ("SHA384", box Sha384::new() as Box<Digest>),
|
||||
"sha512sum" => ("SHA512", box Sha512::new() as Box<Digest>),
|
||||
"md5sum" => ("MD5", Box::new(Md5::new()) as Box<Digest>),
|
||||
"sha1sum" => ("SHA1", Box::new(Sha1::new()) as Box<Digest>),
|
||||
"sha224sum" => ("SHA224", Box::new(Sha224::new()) as Box<Digest>),
|
||||
"sha256sum" => ("SHA256", Box::new(Sha256::new()) as Box<Digest>),
|
||||
"sha384sum" => ("SHA384", Box::new(Sha384::new()) as Box<Digest>),
|
||||
"sha512sum" => ("SHA512", Box::new(Sha512::new()) as Box<Digest>),
|
||||
_ => {
|
||||
{
|
||||
let mut set_or_crash = |&mut: n, val| -> () {
|
||||
|
@ -76,12 +76,12 @@ fn detect_algo(program: &str, matches: &getopts::Matches) -> (&'static str, Box<
|
|||
name = n;
|
||||
alg = Some(val);
|
||||
};
|
||||
if matches.opt_present("md5") { set_or_crash("MD5", box Md5::new()) };
|
||||
if matches.opt_present("sha1") { set_or_crash("SHA1", box Sha1::new()) };
|
||||
if matches.opt_present("sha224") { set_or_crash("SHA224", box Sha224::new()) };
|
||||
if matches.opt_present("sha256") { set_or_crash("SHA256", box Sha256::new()) };
|
||||
if matches.opt_present("sha384") { set_or_crash("SHA384", box Sha384::new()) };
|
||||
if matches.opt_present("sha512") { set_or_crash("SHA512", box Sha512::new()) };
|
||||
if matches.opt_present("md5") { set_or_crash("MD5", Box::new(Md5::new())) };
|
||||
if matches.opt_present("sha1") { set_or_crash("SHA1", Box::new(Sha1::new())) };
|
||||
if matches.opt_present("sha224") { set_or_crash("SHA224", Box::new(Sha224::new())) };
|
||||
if matches.opt_present("sha256") { set_or_crash("SHA256", Box::new(Sha256::new())) };
|
||||
if matches.opt_present("sha384") { set_or_crash("SHA384", Box::new(Sha384::new())) };
|
||||
if matches.opt_present("sha512") { set_or_crash("SHA512", Box::new(Sha512::new())) };
|
||||
}
|
||||
if alg.is_none() { crash!(1, "You must specify hash algorithm!") };
|
||||
(name, alg.unwrap())
|
||||
|
@ -89,7 +89,7 @@ fn detect_algo(program: &str, matches: &getopts::Matches) -> (&'static str, Box<
|
|||
}
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
let binary = Path::new(program.as_slice());
|
||||
let binary_name = binary.filename_str().unwrap();
|
||||
|
@ -167,9 +167,9 @@ fn usage(program: &str, binary_name: &str, opts: &[getopts::OptGroup]) {
|
|||
pipe_print!("{}", getopts::usage("Compute and check message digests.", opts));
|
||||
}
|
||||
|
||||
fn hashsum(algoname: &str, mut digest: Box<Digest>, files: Vec<String>, binary: bool, check: bool, tag: bool, status: bool, quiet: bool, strict: bool, warn: bool) -> Result<(), int> {
|
||||
let mut bad_format = 0u;
|
||||
let mut failed = 0u;
|
||||
fn hashsum(algoname: &str, mut digest: Box<Digest>, files: Vec<String>, binary: bool, check: bool, tag: bool, status: bool, quiet: bool, strict: bool, warn: bool) -> Result<(), isize> {
|
||||
let mut bad_format = 0;
|
||||
let mut failed = 0;
|
||||
let binary_marker = if binary {
|
||||
"*"
|
||||
} else {
|
||||
|
|
|
@ -26,7 +26,7 @@ mod util;
|
|||
|
||||
static NAME: &'static str = "head";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let mut line_count = 10u;
|
||||
let mut byte_count = 0u;
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ extern {
|
|||
pub fn gethostid() -> c_long;
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
|
||||
let opts = [
|
||||
optflag("", "help", "display this help and exit"),
|
||||
|
|
|
@ -41,7 +41,7 @@ extern {
|
|||
fn sethostname(name: *const libc::c_char, namelen: libc::size_t) -> libc::c_int;
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = &args[0];
|
||||
|
||||
let options = [
|
||||
|
|
|
@ -83,7 +83,7 @@ extern {
|
|||
|
||||
static NAME: &'static str = "id";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let args_t = args.tail();
|
||||
|
||||
let options = [
|
||||
|
|
|
@ -52,7 +52,7 @@ pub enum Mode {
|
|||
|
||||
impl Copy for Mode {}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let opts = [
|
||||
optflag("h", "help", "display this help and exit"),
|
||||
optflag("V", "version", "output version information and exit"),
|
||||
|
|
|
@ -21,7 +21,7 @@ mod util;
|
|||
static NAME : &'static str = "link";
|
||||
static VERSION : &'static str = "1.0.0";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let opts = [
|
||||
getopts::optflag("h", "help", "display this help and exit"),
|
||||
getopts::optflag("V", "version", "output version information and exit"),
|
||||
|
|
|
@ -45,7 +45,7 @@ fn version() {
|
|||
println!("{} {}", NAME, VERSION);
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
|
||||
//
|
||||
|
|
|
@ -26,7 +26,7 @@ static VERSION: &'static str = "1.0.0";
|
|||
/**
|
||||
* Handles option parsing
|
||||
*/
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
|
||||
let opts = [
|
||||
// Linux-specific options, not implemented
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
extern crate getopts;
|
||||
extern crate libc;
|
||||
|
||||
use std::ffi::CString;
|
||||
use std::num::FromStrRadix;
|
||||
use std::os;
|
||||
use libc::funcs::posix88::stat_::mkfifo;
|
||||
|
@ -23,7 +24,7 @@ mod util;
|
|||
static NAME : &'static str = "mkfifo";
|
||||
static VERSION : &'static str = "1.0.0";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let opts = [
|
||||
getopts::optopt("m", "mode", "file permissions for the fifo", "(default 0666)"),
|
||||
getopts::optflag("h", "help", "display this help and exit"),
|
||||
|
@ -66,13 +67,11 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
|
||||
let mut exit_status = 0;
|
||||
for f in matches.free.iter() {
|
||||
f.with_c_str(|name| {
|
||||
let err = unsafe { mkfifo(name, mode) };
|
||||
let err = unsafe { mkfifo(CString::from_slice(f.as_bytes()).as_ptr(), mode) };
|
||||
if err == -1 {
|
||||
show_error!("creating '{}': {}", f, os::error_string(os::errno()));
|
||||
exit_status = 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
exit_status
|
||||
|
|
|
@ -61,7 +61,7 @@ pub enum BackupMode {
|
|||
|
||||
impl Copy for BackupMode {}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].as_slice();
|
||||
let opts = [
|
||||
optflagopt("", "backup", "make a backup of each existing destination file", "CONTROL"),
|
||||
|
|
|
@ -32,7 +32,7 @@ extern {
|
|||
fn setpriority(which: c_int, who: c_int, prio: c_int) -> c_int;
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let opts = [
|
||||
getopts::optopt("n", "adjustment", "add N to the niceness (default is 10)", "N"),
|
||||
getopts::optflag("h", "help", "display this help and exit"),
|
||||
|
|
|
@ -73,7 +73,7 @@ enum NumberFormat {
|
|||
RightZero,
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let possible_options = [
|
||||
optopt("b", "body-numbering", "use STYLE for numbering body lines", "STYLE"),
|
||||
optopt("d", "section-delimiter", "use CC for separating logical pages", "CC"),
|
||||
|
|
|
@ -35,7 +35,7 @@ extern {
|
|||
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
|
||||
unsafe fn _vprocmgr_detach_from_console(_: u32) -> *const libc::c_int { std::ptr::null() }
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = &args[0];
|
||||
|
||||
let options = [
|
||||
|
|
|
@ -20,7 +20,7 @@ static VERSION : &'static str = "0.0.0";
|
|||
#[macro_use]
|
||||
mod util;
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let opts = [
|
||||
getopts::optflag("", "all", "print the number of cores available to the system"),
|
||||
getopts::optopt("", "ignore", "ignore up to N cores", "N"),
|
||||
|
|
|
@ -22,7 +22,7 @@ mod util;
|
|||
static NAME: &'static str = "paste";
|
||||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
|
||||
let opts = [
|
||||
|
@ -60,10 +60,10 @@ fn paste(filenames: Vec<String>, serial: bool, delimiters: &str) {
|
|||
let mut files: Vec<io::BufferedReader<Box<Reader>>> = filenames.into_iter().map(|name|
|
||||
io::BufferedReader::new(
|
||||
if name.as_slice() == "-" {
|
||||
box io::stdio::stdin_raw() as Box<Reader>
|
||||
Box::new(io::stdio::stdin_raw()) as Box<Reader>
|
||||
} else {
|
||||
let r = crash_if_err!(1, io::File::open(&Path::new(name)));
|
||||
box r as Box<Reader>
|
||||
Box::new(r) as Box<Reader>
|
||||
}
|
||||
)
|
||||
).collect();
|
||||
|
|
|
@ -23,7 +23,7 @@ mod util;
|
|||
|
||||
static NAME: &'static str = "printenv";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
let opts = [
|
||||
getopts::optflag("0", "null", "end each output line with 0 byte rather than newline"),
|
||||
|
|
|
@ -21,7 +21,7 @@ mod util;
|
|||
static NAME: &'static str = "pwd";
|
||||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
let opts = [
|
||||
getopts::optflag("", "help", "display this help and exit"),
|
||||
|
|
|
@ -19,7 +19,7 @@ use getopts::{optflag, getopts, usage};
|
|||
static NAME: &'static str = "realpath";
|
||||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = &args[0];
|
||||
let options = [
|
||||
optflag("h", "help", "Show help and exit"),
|
||||
|
|
|
@ -19,7 +19,7 @@ use getopts::{optflag, optopt, getopts, usage};
|
|||
static NAME: &'static str = "relpath";
|
||||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = &args[0];
|
||||
let options = [
|
||||
optflag("h", "help", "Show help and exit"),
|
||||
|
|
|
@ -30,7 +30,7 @@ impl Copy for InteractiveMode {}
|
|||
|
||||
static NAME: &'static str = "rm";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
|
||||
// TODO: make getopts support -R in addition to -r
|
||||
|
|
|
@ -21,7 +21,7 @@ mod util;
|
|||
|
||||
static NAME: &'static str = "rmdir";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
|
||||
let opts = [
|
||||
|
|
|
@ -145,7 +145,7 @@ fn print_version() {
|
|||
println!("seq 1.0.0\n");
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
let mut options = SeqOptions {
|
||||
separator: "\n".to_string(),
|
||||
|
|
|
@ -32,7 +32,7 @@ enum Mode {
|
|||
static NAME: &'static str = "shuf";
|
||||
static VERSION: &'static str = "0.0.1";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
|
||||
let opts = [
|
||||
|
@ -157,16 +157,16 @@ enum WrappedRng {
|
|||
impl WrappedRng {
|
||||
fn next_u32(&mut self) -> u32 {
|
||||
match self {
|
||||
&WrappedRng::RngFile(ref mut r) => r.next_u32(),
|
||||
&WrappedRng::RngDefault(ref mut r) => r.next_u32(),
|
||||
&mut WrappedRng::RngFile(ref mut r) => r.next_u32(),
|
||||
&mut WrappedRng::RngDefault(ref mut r) => r.next_u32(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn shuf_lines(mut lines: Vec<String>, repeat: bool, zero: bool, count: uint, outname: Option<String>, random: Option<String>) -> IoResult<()> {
|
||||
let mut output = match outname {
|
||||
Some(name) => box io::BufferedWriter::new(try!(io::File::create(&Path::new(name)))) as Box<Writer>,
|
||||
None => box io::stdout() as Box<Writer>
|
||||
Some(name) => Box::new(io::BufferedWriter::new(try!(io::File::create(&Path::new(name))))) as Box<Writer>,
|
||||
None => Box::new(io::stdout()) as Box<Writer>
|
||||
};
|
||||
let mut rng = match random {
|
||||
Some(name) => WrappedRng::RngFile(rand::reader::ReaderRng::new(try!(io::File::open(&Path::new(name))))),
|
||||
|
|
|
@ -25,7 +25,7 @@ mod time;
|
|||
|
||||
static NAME: &'static str = "sleep";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
|
||||
let opts = [
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
extern crate getopts;
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt::Show;
|
||||
use std::io::{print, File, BufferedReader};
|
||||
use std::io::stdio::stdin_raw;
|
||||
|
@ -28,7 +29,7 @@ static VERSION: &'static str = "0.0.1";
|
|||
static DECIMAL_PT: char = '.';
|
||||
static THOUSANDS_SEP: char = ',';
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].as_slice();
|
||||
let opts = [
|
||||
getopts::optflag("n", "numeric-sort", "compare according to string numerical value"),
|
||||
|
@ -107,9 +108,9 @@ fn exec(files: Vec<String>, numeric: bool, reverse: bool) {
|
|||
fn skip_zeros(mut char_a: char, char_iter: &mut Chars, ret: Ordering) -> Ordering {
|
||||
char_a = match char_iter.next() { None => 0 as char, Some(t) => t };
|
||||
while char_a == '0' {
|
||||
char_a = match char_iter.next() { None => return Equal, Some(t) => t };
|
||||
char_a = match char_iter.next() { None => return Ordering::Equal, Some(t) => t };
|
||||
}
|
||||
if char_a.is_digit(10) { ret } else { Equal }
|
||||
if char_a.is_digit(10) { ret } else { Ordering::Equal }
|
||||
}
|
||||
|
||||
/// Compares two decimal fractions as strings (n < 1)
|
||||
|
@ -127,25 +128,25 @@ fn frac_compare(a: &String, b: &String) -> Ordering {
|
|||
char_b = match b_chars.next() { None => 0 as char, Some(t) => t };
|
||||
// hit the end at the same time, they are equal
|
||||
if !char_a.is_digit(10) {
|
||||
return Equal;
|
||||
return Ordering::Equal;
|
||||
}
|
||||
}
|
||||
if char_a.is_digit(10) && char_b.is_digit(10) {
|
||||
(char_a as int).cmp(&(char_b as int))
|
||||
} else if char_a.is_digit(10) {
|
||||
skip_zeros(char_a, a_chars, Greater)
|
||||
skip_zeros(char_a, a_chars, Ordering::Greater)
|
||||
} else if char_b.is_digit(10) {
|
||||
skip_zeros(char_b, b_chars, Less)
|
||||
} else { Equal }
|
||||
skip_zeros(char_b, b_chars, Ordering::Less)
|
||||
} else { Ordering::Equal }
|
||||
} else if char_a == DECIMAL_PT {
|
||||
skip_zeros(char_a, a_chars, Greater)
|
||||
skip_zeros(char_a, a_chars, Ordering::Greater)
|
||||
} else if char_b == DECIMAL_PT {
|
||||
skip_zeros(char_b, b_chars, Less)
|
||||
} else { Equal }
|
||||
skip_zeros(char_b, b_chars, Ordering::Less)
|
||||
} else { Ordering::Equal }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn print_sorted<T: Iterator<S>, S: Show>(mut iter: T) {
|
||||
fn print_sorted<S, T: Iterator<Item=S>>(mut iter: T) where S: std::fmt::String {
|
||||
for line in iter {
|
||||
print!("{}", line);
|
||||
}
|
||||
|
@ -156,11 +157,11 @@ fn open<'a>(path: &str) -> Option<(Box<Reader + 'a>, bool)> {
|
|||
if path == "-" {
|
||||
let stdin = stdin_raw();
|
||||
let interactive = stdin.isatty();
|
||||
return Some((box stdin as Box<Reader>, interactive));
|
||||
return Some((Box::new(stdin) as Box<Reader>, interactive));
|
||||
}
|
||||
|
||||
match File::open(&std::path::Path::new(path)) {
|
||||
Ok(f) => Some((box f as Box<Reader>, false)),
|
||||
Ok(f) => Some((Box::new(f) as Box<Reader>, false)),
|
||||
Err(e) => {
|
||||
show_error!("sort: {0}: {1}", path, e.to_string());
|
||||
None
|
||||
|
|
|
@ -23,7 +23,7 @@ mod util;
|
|||
static NAME: &'static str = "split";
|
||||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let opts = [
|
||||
getopts::optopt("a", "suffix-length", "use suffixes of length N (default 2)", "N"),
|
||||
getopts::optopt("b", "bytes", "put SIZE bytes per output file", "SIZE"),
|
||||
|
|
|
@ -22,7 +22,7 @@ mod util;
|
|||
static VERSION: &'static str = "1.0.0";
|
||||
static NAME: &'static str = "sum";
|
||||
|
||||
fn bsd_sum(mut reader: Box<Reader>) -> (uint, u16) {
|
||||
fn bsd_sum(mut reader: Box<Reader>) -> (usize, u16) {
|
||||
let mut buf = [0; 1024];
|
||||
let mut blocks_read = 0;
|
||||
let mut checksum: u16 = 0;
|
||||
|
@ -42,7 +42,7 @@ fn bsd_sum(mut reader: Box<Reader>) -> (uint, u16) {
|
|||
(blocks_read, checksum)
|
||||
}
|
||||
|
||||
fn sysv_sum(mut reader: Box<Reader>) -> (uint, u16) {
|
||||
fn sysv_sum(mut reader: Box<Reader>) -> (usize, u16) {
|
||||
let mut buf = [0; 512];
|
||||
let mut blocks_read = 0;
|
||||
let mut ret = 0;
|
||||
|
@ -67,15 +67,15 @@ fn sysv_sum(mut reader: Box<Reader>) -> (uint, u16) {
|
|||
|
||||
fn open(name: &str) -> IoResult<Box<Reader>> {
|
||||
match name {
|
||||
"-" => Ok(box stdin_raw() as Box<Reader>),
|
||||
"-" => Ok(Box::new(stdin_raw()) as Box<Reader>),
|
||||
_ => {
|
||||
let f = try!(File::open(&Path::new(name)));
|
||||
Ok(box f as Box<Reader>)
|
||||
Ok(Box::new(f) as Box<Reader>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].as_slice();
|
||||
let opts = [
|
||||
getopts::optflag("r", "", "use the BSD compatible algorithm (default)"),
|
||||
|
|
|
@ -138,7 +138,7 @@ mod platform {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = &args[0];
|
||||
|
||||
let options = [
|
||||
|
|
|
@ -21,7 +21,7 @@ mod util;
|
|||
static NAME: &'static str = "tac";
|
||||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
|
||||
let opts = [
|
||||
|
@ -72,10 +72,10 @@ fn tac(filenames: Vec<String>, before: bool, _: bool, separator: &str) {
|
|||
for filename in filenames.into_iter() {
|
||||
let mut file = io::BufferedReader::new(
|
||||
if filename.as_slice() == "-" {
|
||||
box io::stdio::stdin_raw() as Box<Reader>
|
||||
Box::new(io::stdio::stdin_raw()) as Box<Reader>
|
||||
} else {
|
||||
let r = crash_if_err!(1, io::File::open(&Path::new(filename)));
|
||||
box r as Box<Reader>
|
||||
Box::new(r) as Box<Reader>
|
||||
}
|
||||
);
|
||||
let mut data = crash_if_err!(1, file.read_to_string());
|
||||
|
|
|
@ -29,7 +29,7 @@ mod util;
|
|||
static NAME: &'static str = "tail";
|
||||
static VERSION: &'static str = "0.0.1";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let mut beginning = false;
|
||||
let mut lines = true;
|
||||
let mut byte_count = 0u;
|
||||
|
|
|
@ -21,7 +21,7 @@ use getopts::{getopts, optflag, usage};
|
|||
static NAME: &'static str = "tee";
|
||||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
match options(args.as_slice()).and_then(exec) {
|
||||
Ok(_) => 0,
|
||||
Err(_) => 1
|
||||
|
|
|
@ -18,7 +18,7 @@ use std::str::{from_utf8};
|
|||
static NAME: &'static str = "test";
|
||||
|
||||
// TODO: decide how to handle non-UTF8 input for all the utils
|
||||
pub fn uumain(_: Vec<String>) -> int {
|
||||
pub fn uumain(_: Vec<String>) -> isize {
|
||||
let args = args_as_bytes();
|
||||
let args: Vec<&[u8]> = args.iter().map(|a| a.as_slice()).collect();
|
||||
if args.len() == 0 {
|
||||
|
|
|
@ -34,7 +34,7 @@ static VERSION: &'static str = "1.0.0";
|
|||
|
||||
static ERR_EXIT_STATUS: int = 125;
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
|
||||
let opts = [
|
||||
|
|
|
@ -22,7 +22,7 @@ mod util;
|
|||
static NAME: &'static str = "touch";
|
||||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let opts = [
|
||||
getopts::optflag("a", "", "change only the access time"),
|
||||
getopts::optflag("c", "no-create", "do not create any files"),
|
||||
|
|
|
@ -158,7 +158,7 @@ fn usage(opts: &[OptGroup]) {
|
|||
print(getopts::usage("Translate or delete characters.", opts).as_slice());
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let opts = [
|
||||
getopts::optflag("c", "complement", "use the complement of SET1"),
|
||||
getopts::optflag("C", "", "same as -c"),
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
pub fn uumain(_: Vec<String>) -> int {
|
||||
pub fn uumain(_: Vec<String>) -> isize {
|
||||
0
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ enum TruncateMode {
|
|||
|
||||
static NAME: &'static str = "truncate";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
|
||||
let opts = [
|
||||
|
|
|
@ -23,7 +23,7 @@ mod util;
|
|||
static NAME: &'static str = "tsort";
|
||||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let opts = [
|
||||
getopts::optflag("h", "help", "display this help and exit"),
|
||||
getopts::optflag("V", "version", "output version information and exit"),
|
||||
|
|
|
@ -33,7 +33,7 @@ extern {
|
|||
|
||||
static NAME: &'static str = "tty";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let options = [
|
||||
optflag("s", "silent", "print nothing, only return an exit status")
|
||||
];
|
||||
|
|
|
@ -55,7 +55,7 @@ unsafe fn getuname() -> utsrust {
|
|||
|
||||
static NAME: &'static str = "uname";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].as_slice();
|
||||
let opts = [
|
||||
getopts::optflag("h", "help", "display this help and exit"),
|
||||
|
|
|
@ -72,7 +72,7 @@ impl Options {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let opts = [
|
||||
getopts::optflag("a", "all", "convert all blanks, instead of just initial blanks"),
|
||||
getopts::optflag("", "first-only", "convert only leading sequences of blanks (overrides -a)"),
|
||||
|
|
|
@ -117,7 +117,7 @@ fn opt_parsed<T: FromStr>(opt_name: &str, matches: &getopts::Matches) -> Option<
|
|||
})
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program_path = Path::new(args[0].clone());
|
||||
let program = program_path.filename_str().unwrap_or(NAME);
|
||||
|
||||
|
@ -191,24 +191,24 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
|
||||
fn open_input_file(in_file_name: String) -> io::BufferedReader<Box<Reader+'static>> {
|
||||
let in_file = if in_file_name.as_slice() == "-" {
|
||||
box io::stdio::stdin_raw() as Box<Reader>
|
||||
Box::new(io::stdio::stdin_raw()) as Box<Reader>
|
||||
} else {
|
||||
let path = Path::new(in_file_name);
|
||||
let in_file = io::File::open(&path);
|
||||
let r = crash_if_err!(1, in_file);
|
||||
box r as Box<Reader>
|
||||
Box::new(r) as Box<Reader>
|
||||
};
|
||||
io::BufferedReader::new(in_file)
|
||||
}
|
||||
|
||||
fn open_output_file(out_file_name: String) -> io::BufferedWriter<Box<Writer+'static>> {
|
||||
let out_file = if out_file_name.as_slice() == "-" {
|
||||
box io::stdio::stdout_raw() as Box<Writer>
|
||||
Box::new(io::stdio::stdout_raw()) as Box<Writer>
|
||||
} else {
|
||||
let path = Path::new(out_file_name);
|
||||
let in_file = io::File::create(&path);
|
||||
let w = crash_if_err!(1, in_file);
|
||||
box w as Box<Writer>
|
||||
Box::new(w) as Box<Writer>
|
||||
};
|
||||
io::BufferedWriter::new(out_file)
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ mod util;
|
|||
|
||||
static NAME: &'static str = "unlink";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
let opts = [
|
||||
getopts::optflag("h", "help", "display this help and exit"),
|
||||
|
|
|
@ -53,7 +53,7 @@ unsafe extern fn utmpxname(_file: *const c_char) -> c_int {
|
|||
0
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
let opts = [
|
||||
getopts::optflag("v", "version", "output version information and exit"),
|
||||
|
|
|
@ -51,7 +51,7 @@ unsafe extern fn utmpxname(_file: *const libc::c_char) -> libc::c_int {
|
|||
|
||||
static NAME: &'static str = "users";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].as_slice();
|
||||
let opts = [
|
||||
getopts::optflag("h", "help", "display this help and exit"),
|
||||
|
|
|
@ -35,7 +35,7 @@ struct Result {
|
|||
|
||||
static NAME: &'static str = "wc";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
let opts = [
|
||||
getopts::optflag("c", "bytes", "print the byte counts"),
|
||||
|
@ -230,7 +230,7 @@ fn print_stats(filename: &str, line_count: uint, word_count: uint, char_count: u
|
|||
|
||||
fn open(path: &str) -> StdResult<BufferedReader<Box<Reader+'static>>, int> {
|
||||
if "-" == path {
|
||||
let reader = box stdin_raw() as Box<Reader>;
|
||||
let reader = Box::new(stdin_raw()) as Box<Reader>;
|
||||
return Ok(BufferedReader::new(reader));
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ fn open(path: &str) -> StdResult<BufferedReader<Box<Reader+'static>>, int> {
|
|||
}
|
||||
match File::open(&fpath) {
|
||||
Ok(fd) => {
|
||||
let reader = box fd as Box<Reader>;
|
||||
let reader = Box::new(fd) as Box<Reader>;
|
||||
Ok(BufferedReader::new(reader))
|
||||
}
|
||||
Err(e) => {
|
||||
|
|
|
@ -62,7 +62,7 @@ mod platform {
|
|||
|
||||
static NAME: &'static str = "whoami";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].as_slice();
|
||||
let opts = [
|
||||
getopts::optflag("h", "help", "display this help and exit"),
|
||||
|
|
|
@ -22,7 +22,7 @@ mod util;
|
|||
|
||||
static NAME: &'static str = "yes";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
pub fn uumain(args: Vec<String>) -> isize {
|
||||
let program = args[0].clone();
|
||||
let opts = [
|
||||
getopts::optflag("h", "help", "display this help and exit"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue