diff --git a/deps/rust-crypto b/deps/rust-crypto index c85bfa94d..716c4241e 160000 --- a/deps/rust-crypto +++ b/deps/rust-crypto @@ -1 +1 @@ -Subproject commit c85bfa94d5003f839540536a6d42ecea094d8a45 +Subproject commit 716c4241e9a8e1e53dde4380eac2b454682ae81c diff --git a/deps/time b/deps/time index 00121035e..7f105d4dd 160000 --- a/deps/time +++ b/deps/time @@ -1 +1 @@ -Subproject commit 00121035e51e1df14d5cd3a3233905f43e5c93a9 +Subproject commit 7f105d4dd2bde23d4b8516dc02566cfc46b60b22 diff --git a/mkuutils.rs b/mkuutils.rs index c263297de..0cd4ed112 100644 --- a/mkuutils.rs +++ b/mkuutils.rs @@ -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) -> int);\n", prog = prog).as_slice()); + util_map.push_str(format!("map.insert(\"{prog}\", {prog}::uumain as fn(Vec) -> isize);\n", prog = prog).as_slice()); } } } diff --git a/src/basename/basename.rs b/src/basename/basename.rs index 0f9f304cb..71892a516 100644 --- a/src/basename/basename.rs +++ b/src/basename/basename.rs @@ -22,7 +22,7 @@ mod util; static NAME: &'static str = "basename"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = strip_dir(args[0].as_slice()); // diff --git a/src/cat/cat.rs b/src/cat/cat.rs index 7c15a1a2b..33b410cd5 100644 --- a/src/cat/cat.rs +++ b/src/cat/cat.rs @@ -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) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].as_slice(); let opts = [ getopts::optflag("A", "show-all", "equivalent to -vET"), diff --git a/src/cp/cp.rs b/src/cp/cp.rs index 765063d17..a9d8e4f5b 100644 --- a/src/cp/cp.rs +++ b/src/cp/cp.rs @@ -31,7 +31,7 @@ pub enum Mode { impl Copy for Mode {} -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let opts = [ optflag("h", "help", "display this help and exit"), optflag("", "version", "output version information and exit"), diff --git a/src/cut/cut.rs b/src/cut/cut.rs index feaefc4aa..3a934b37a 100644 --- a/src/cut/cut.rs +++ b/src/cut/cut.rs @@ -447,7 +447,7 @@ fn cut_files(mut filenames: Vec, mode: Mode) -> int { exit_code } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let opts = [ optopt("b", "bytes", "select only these bytes", "LIST"), optopt("c", "characters", "select only these characters", "LIST"), diff --git a/src/dirname/dirname.rs b/src/dirname/dirname.rs index 8b25bdb67..6f88a8268 100644 --- a/src/dirname/dirname.rs +++ b/src/dirname/dirname.rs @@ -15,7 +15,7 @@ use std::io::print; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); let opts = [ getopts::optflag("z", "zero", "separate output with NUL rather than newline"), diff --git a/src/du/du.rs b/src/du/du.rs index c56ccde0c..d7619f2cf 100644 --- a/src/du/du.rs +++ b/src/du/du.rs @@ -89,7 +89,7 @@ fn du(path: &Path, mut my_stat: Stat, stats } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].as_slice(); let opts = [ // In task diff --git a/src/echo/echo.rs b/src/echo/echo.rs index 176fbd5e3..017a83b2b 100644 --- a/src/echo/echo.rs +++ b/src/echo/echo.rs @@ -162,7 +162,7 @@ fn print_version() { println!("echo version: {}", VERSION); } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let mut options = EchoOptions { newline: false, escape: false diff --git a/src/env/env.rs b/src/env/env.rs index dec94d810..cc67f1ab4 100644 --- a/src/env/env.rs +++ b/src/env/env.rs @@ -51,7 +51,7 @@ fn print_env(null: bool) { } } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let prog = args[0].as_slice(); // to handle arguments the same way than GNU env, we can't use getopts diff --git a/src/expand/expand.rs b/src/expand/expand.rs index 6ba026e92..b65105d54 100644 --- a/src/expand/expand.rs +++ b/src/expand/expand.rs @@ -72,7 +72,7 @@ impl Options { } } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> 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"), diff --git a/src/factor/factor.rs b/src/factor/factor.rs index 935c1c645..b66bf2055 100644 --- a/src/factor/factor.rs +++ b/src/factor/factor.rs @@ -63,7 +63,7 @@ fn print_factors_str(num_str: &str) { print_factors(num); } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].as_slice(); let opts = [ getopts::optflag("h", "help", "show this help message"), diff --git a/src/false/false.rs b/src/false/false.rs index 5fdc0022e..68c3ed16e 100644 --- a/src/false/false.rs +++ b/src/false/false.rs @@ -9,6 +9,6 @@ * file that was distributed with this source code. */ -pub fn uumain(_: Vec) -> int { +pub fn uumain(_: Vec) -> isize { 1 } diff --git a/src/fmt/fmt.rs b/src/fmt/fmt.rs index db5dd748b..2021ef7a0 100644 --- a/src/fmt/fmt.rs +++ b/src/fmt/fmt.rs @@ -54,7 +54,7 @@ struct FmtOptions { tabwidth : uint, } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> 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."), diff --git a/src/fold/fold.rs b/src/fold/fold.rs index 79bc76f96..c7c6deaeb 100644 --- a/src/fold/fold.rs +++ b/src/fold/fold.rs @@ -23,7 +23,7 @@ mod util; static NAME: &'static str = "fold"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let (args, obs_width) = handle_obsolete(args.as_slice()); let program = args[0].clone(); diff --git a/src/groups/groups.rs b/src/groups/groups.rs index 7db857155..29c3a755b 100644 --- a/src/groups/groups.rs +++ b/src/groups/groups.rs @@ -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) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); let options = [ diff --git a/src/hashsum/hashsum.rs b/src/hashsum/hashsum.rs index f5ed9a056..e055b8f2b 100644 --- a/src/hashsum/hashsum.rs +++ b/src/hashsum/hashsum.rs @@ -63,12 +63,12 @@ fn detect_algo(program: &str, matches: &getopts::Matches) -> (&'static str, Box< let mut alg: Option> = None; let mut name: &'static str = ""; match program { - "md5sum" => ("MD5", box Md5::new() as Box), - "sha1sum" => ("SHA1", box Sha1::new() as Box), - "sha224sum" => ("SHA224", box Sha224::new() as Box), - "sha256sum" => ("SHA256", box Sha256::new() as Box), - "sha384sum" => ("SHA384", box Sha384::new() as Box), - "sha512sum" => ("SHA512", box Sha512::new() as Box), + "md5sum" => ("MD5", Box::new(Md5::new()) as Box), + "sha1sum" => ("SHA1", Box::new(Sha1::new()) as Box), + "sha224sum" => ("SHA224", Box::new(Sha224::new()) as Box), + "sha256sum" => ("SHA256", Box::new(Sha256::new()) as Box), + "sha384sum" => ("SHA384", Box::new(Sha384::new()) as Box), + "sha512sum" => ("SHA512", Box::new(Sha512::new()) as Box), _ => { { 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) -> int { +pub fn uumain(args: Vec) -> 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, files: Vec, 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, files: Vec, 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 { diff --git a/src/head/head.rs b/src/head/head.rs index 7e1bbd2ed..965bd2364 100644 --- a/src/head/head.rs +++ b/src/head/head.rs @@ -26,7 +26,7 @@ mod util; static NAME: &'static str = "head"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let mut line_count = 10u; let mut byte_count = 0u; diff --git a/src/hostid/hostid.rs b/src/hostid/hostid.rs index f4902fa5a..63ac56798 100644 --- a/src/hostid/hostid.rs +++ b/src/hostid/hostid.rs @@ -48,7 +48,7 @@ extern { pub fn gethostid() -> c_long; } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let opts = [ optflag("", "help", "display this help and exit"), diff --git a/src/hostname/hostname.rs b/src/hostname/hostname.rs index 5ad247404..65674873a 100644 --- a/src/hostname/hostname.rs +++ b/src/hostname/hostname.rs @@ -41,7 +41,7 @@ extern { fn sethostname(name: *const libc::c_char, namelen: libc::size_t) -> libc::c_int; } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = &args[0]; let options = [ diff --git a/src/id/id.rs b/src/id/id.rs index 442957779..4b7b97126 100644 --- a/src/id/id.rs +++ b/src/id/id.rs @@ -83,7 +83,7 @@ extern { static NAME: &'static str = "id"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let args_t = args.tail(); let options = [ diff --git a/src/kill/kill.rs b/src/kill/kill.rs index abd556da7..f42176237 100644 --- a/src/kill/kill.rs +++ b/src/kill/kill.rs @@ -52,7 +52,7 @@ pub enum Mode { impl Copy for Mode {} -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let opts = [ optflag("h", "help", "display this help and exit"), optflag("V", "version", "output version information and exit"), diff --git a/src/link/link.rs b/src/link/link.rs index 121aad5b7..4f0da2ede 100644 --- a/src/link/link.rs +++ b/src/link/link.rs @@ -21,7 +21,7 @@ mod util; static NAME : &'static str = "link"; static VERSION : &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let opts = [ getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit"), diff --git a/src/logname/logname.rs b/src/logname/logname.rs index f5a36ca6c..ddd8d332c 100644 --- a/src/logname/logname.rs +++ b/src/logname/logname.rs @@ -45,7 +45,7 @@ fn version() { println!("{} {}", NAME, VERSION); } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); // diff --git a/src/mkdir/mkdir.rs b/src/mkdir/mkdir.rs index e21490292..120c5bd2d 100644 --- a/src/mkdir/mkdir.rs +++ b/src/mkdir/mkdir.rs @@ -26,7 +26,7 @@ static VERSION: &'static str = "1.0.0"; /** * Handles option parsing */ -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let opts = [ // Linux-specific options, not implemented diff --git a/src/mkfifo/mkfifo.rs b/src/mkfifo/mkfifo.rs index 7ef335874..5ef8f254e 100644 --- a/src/mkfifo/mkfifo.rs +++ b/src/mkfifo/mkfifo.rs @@ -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) -> int { +pub fn uumain(args: Vec) -> 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) -> int { let mut exit_status = 0; for f in matches.free.iter() { - f.with_c_str(|name| { - let err = unsafe { mkfifo(name, mode) }; - if err == -1 { - show_error!("creating '{}': {}", f, os::error_string(os::errno())); - exit_status = 1; - } - }); + 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 diff --git a/src/mv/mv.rs b/src/mv/mv.rs index 396d15f8a..e2d68ae0b 100644 --- a/src/mv/mv.rs +++ b/src/mv/mv.rs @@ -61,7 +61,7 @@ pub enum BackupMode { impl Copy for BackupMode {} -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].as_slice(); let opts = [ optflagopt("", "backup", "make a backup of each existing destination file", "CONTROL"), diff --git a/src/nice/nice.rs b/src/nice/nice.rs index 4573e8eb4..126f2b35b 100644 --- a/src/nice/nice.rs +++ b/src/nice/nice.rs @@ -32,7 +32,7 @@ extern { fn setpriority(which: c_int, who: c_int, prio: c_int) -> c_int; } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> 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"), diff --git a/src/nl/nl.rs b/src/nl/nl.rs index 9273e72f6..747ae0bbe 100644 --- a/src/nl/nl.rs +++ b/src/nl/nl.rs @@ -73,7 +73,7 @@ enum NumberFormat { RightZero, } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> 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"), diff --git a/src/nohup/nohup.rs b/src/nohup/nohup.rs index 8792f526f..78d5c51a1 100644 --- a/src/nohup/nohup.rs +++ b/src/nohup/nohup.rs @@ -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) -> int { +pub fn uumain(args: Vec) -> isize { let program = &args[0]; let options = [ diff --git a/src/nproc/nproc.rs b/src/nproc/nproc.rs index 589165288..3f1b26f06 100644 --- a/src/nproc/nproc.rs +++ b/src/nproc/nproc.rs @@ -20,7 +20,7 @@ static VERSION : &'static str = "0.0.0"; #[macro_use] mod util; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let opts = [ getopts::optflag("", "all", "print the number of cores available to the system"), getopts::optopt("", "ignore", "ignore up to N cores", "N"), diff --git a/src/paste/paste.rs b/src/paste/paste.rs index a4ecbe8e6..b2cff4916 100644 --- a/src/paste/paste.rs +++ b/src/paste/paste.rs @@ -22,7 +22,7 @@ mod util; static NAME: &'static str = "paste"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); let opts = [ @@ -60,10 +60,10 @@ fn paste(filenames: Vec, serial: bool, delimiters: &str) { let mut files: Vec>> = filenames.into_iter().map(|name| io::BufferedReader::new( if name.as_slice() == "-" { - box io::stdio::stdin_raw() as Box + Box::new(io::stdio::stdin_raw()) as Box } else { let r = crash_if_err!(1, io::File::open(&Path::new(name))); - box r as Box + Box::new(r) as Box } ) ).collect(); diff --git a/src/printenv/printenv.rs b/src/printenv/printenv.rs index 70b7c028f..054353d91 100644 --- a/src/printenv/printenv.rs +++ b/src/printenv/printenv.rs @@ -23,7 +23,7 @@ mod util; static NAME: &'static str = "printenv"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); let opts = [ getopts::optflag("0", "null", "end each output line with 0 byte rather than newline"), diff --git a/src/pwd/pwd.rs b/src/pwd/pwd.rs index 52af689aa..508112ab2 100644 --- a/src/pwd/pwd.rs +++ b/src/pwd/pwd.rs @@ -21,7 +21,7 @@ mod util; static NAME: &'static str = "pwd"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); let opts = [ getopts::optflag("", "help", "display this help and exit"), diff --git a/src/realpath/realpath.rs b/src/realpath/realpath.rs index a42d03507..80a7c08cf 100644 --- a/src/realpath/realpath.rs +++ b/src/realpath/realpath.rs @@ -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) -> int { +pub fn uumain(args: Vec) -> isize { let program = &args[0]; let options = [ optflag("h", "help", "Show help and exit"), diff --git a/src/relpath/relpath.rs b/src/relpath/relpath.rs index 2d2337a45..8b03c4779 100644 --- a/src/relpath/relpath.rs +++ b/src/relpath/relpath.rs @@ -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) -> int { +pub fn uumain(args: Vec) -> isize { let program = &args[0]; let options = [ optflag("h", "help", "Show help and exit"), diff --git a/src/rm/rm.rs b/src/rm/rm.rs index 1e22b4a91..ec45e221e 100644 --- a/src/rm/rm.rs +++ b/src/rm/rm.rs @@ -30,7 +30,7 @@ impl Copy for InteractiveMode {} static NAME: &'static str = "rm"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); // TODO: make getopts support -R in addition to -r diff --git a/src/rmdir/rmdir.rs b/src/rmdir/rmdir.rs index 06fa2700a..e16501042 100644 --- a/src/rmdir/rmdir.rs +++ b/src/rmdir/rmdir.rs @@ -21,7 +21,7 @@ mod util; static NAME: &'static str = "rmdir"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); let opts = [ diff --git a/src/seq/seq.rs b/src/seq/seq.rs index 1b72f0123..9e4cf2c25 100644 --- a/src/seq/seq.rs +++ b/src/seq/seq.rs @@ -145,7 +145,7 @@ fn print_version() { println!("seq 1.0.0\n"); } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); let mut options = SeqOptions { separator: "\n".to_string(), diff --git a/src/shuf/shuf.rs b/src/shuf/shuf.rs index 946967d27..3d2cd1d4c 100644 --- a/src/shuf/shuf.rs +++ b/src/shuf/shuf.rs @@ -32,7 +32,7 @@ enum Mode { static NAME: &'static str = "shuf"; static VERSION: &'static str = "0.0.1"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> 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, repeat: bool, zero: bool, count: uint, outname: Option, random: Option) -> IoResult<()> { let mut output = match outname { - Some(name) => box io::BufferedWriter::new(try!(io::File::create(&Path::new(name)))) as Box, - None => box io::stdout() as Box + Some(name) => Box::new(io::BufferedWriter::new(try!(io::File::create(&Path::new(name))))) as Box, + None => Box::new(io::stdout()) as Box }; let mut rng = match random { Some(name) => WrappedRng::RngFile(rand::reader::ReaderRng::new(try!(io::File::open(&Path::new(name))))), diff --git a/src/sleep/sleep.rs b/src/sleep/sleep.rs index b6d83db67..21efa36e5 100644 --- a/src/sleep/sleep.rs +++ b/src/sleep/sleep.rs @@ -25,7 +25,7 @@ mod time; static NAME: &'static str = "sleep"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); let opts = [ diff --git a/src/sort/sort.rs b/src/sort/sort.rs index 596a59fe0..68be324c8 100644 --- a/src/sort/sort.rs +++ b/src/sort/sort.rs @@ -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) -> int { +pub fn uumain(args: Vec) -> 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, 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, S: Show>(mut iter: T) { +fn print_sorted>(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, bool)> { if path == "-" { let stdin = stdin_raw(); let interactive = stdin.isatty(); - return Some((box stdin as Box, interactive)); + return Some((Box::new(stdin) as Box, interactive)); } match File::open(&std::path::Path::new(path)) { - Ok(f) => Some((box f as Box, false)), + Ok(f) => Some((Box::new(f) as Box, false)), Err(e) => { show_error!("sort: {0}: {1}", path, e.to_string()); None diff --git a/src/split/split.rs b/src/split/split.rs index f5a26f4dd..c0a154ad7 100644 --- a/src/split/split.rs +++ b/src/split/split.rs @@ -23,7 +23,7 @@ mod util; static NAME: &'static str = "split"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> 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"), diff --git a/src/sum/sum.rs b/src/sum/sum.rs index c92bc8a18..4706498fe 100644 --- a/src/sum/sum.rs +++ b/src/sum/sum.rs @@ -22,7 +22,7 @@ mod util; static VERSION: &'static str = "1.0.0"; static NAME: &'static str = "sum"; -fn bsd_sum(mut reader: Box) -> (uint, u16) { +fn bsd_sum(mut reader: Box) -> (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) -> (uint, u16) { (blocks_read, checksum) } -fn sysv_sum(mut reader: Box) -> (uint, u16) { +fn sysv_sum(mut reader: Box) -> (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) -> (uint, u16) { fn open(name: &str) -> IoResult> { match name { - "-" => Ok(box stdin_raw() as Box), + "-" => Ok(Box::new(stdin_raw()) as Box), _ => { let f = try!(File::open(&Path::new(name))); - Ok(box f as Box) + Ok(Box::new(f) as Box) } } } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].as_slice(); let opts = [ getopts::optflag("r", "", "use the BSD compatible algorithm (default)"), diff --git a/src/sync/sync.rs b/src/sync/sync.rs index 8f007dfce..daad1ba4c 100644 --- a/src/sync/sync.rs +++ b/src/sync/sync.rs @@ -138,7 +138,7 @@ mod platform { } } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = &args[0]; let options = [ diff --git a/src/tac/tac.rs b/src/tac/tac.rs index 7211f3df5..bea2790ac 100644 --- a/src/tac/tac.rs +++ b/src/tac/tac.rs @@ -21,7 +21,7 @@ mod util; static NAME: &'static str = "tac"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); let opts = [ @@ -72,10 +72,10 @@ fn tac(filenames: Vec, 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 + Box::new(io::stdio::stdin_raw()) as Box } else { let r = crash_if_err!(1, io::File::open(&Path::new(filename))); - box r as Box + Box::new(r) as Box } ); let mut data = crash_if_err!(1, file.read_to_string()); diff --git a/src/tail/tail.rs b/src/tail/tail.rs index ae27794be..532f263cc 100644 --- a/src/tail/tail.rs +++ b/src/tail/tail.rs @@ -29,7 +29,7 @@ mod util; static NAME: &'static str = "tail"; static VERSION: &'static str = "0.0.1"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let mut beginning = false; let mut lines = true; let mut byte_count = 0u; diff --git a/src/tee/tee.rs b/src/tee/tee.rs index e2f290caa..bbb1bc865 100644 --- a/src/tee/tee.rs +++ b/src/tee/tee.rs @@ -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) -> int { +pub fn uumain(args: Vec) -> isize { match options(args.as_slice()).and_then(exec) { Ok(_) => 0, Err(_) => 1 diff --git a/src/test/test.rs b/src/test/test.rs index 7bab557ac..72dcc6a6d 100644 --- a/src/test/test.rs +++ b/src/test/test.rs @@ -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) -> int { +pub fn uumain(_: Vec) -> isize { let args = args_as_bytes(); let args: Vec<&[u8]> = args.iter().map(|a| a.as_slice()).collect(); if args.len() == 0 { diff --git a/src/timeout/timeout.rs b/src/timeout/timeout.rs index 2ce570618..3462b8cb3 100644 --- a/src/timeout/timeout.rs +++ b/src/timeout/timeout.rs @@ -34,7 +34,7 @@ static VERSION: &'static str = "1.0.0"; static ERR_EXIT_STATUS: int = 125; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); let opts = [ diff --git a/src/touch/touch.rs b/src/touch/touch.rs index 07a37aad9..f32c1c72f 100644 --- a/src/touch/touch.rs +++ b/src/touch/touch.rs @@ -22,7 +22,7 @@ mod util; static NAME: &'static str = "touch"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let opts = [ getopts::optflag("a", "", "change only the access time"), getopts::optflag("c", "no-create", "do not create any files"), diff --git a/src/tr/tr.rs b/src/tr/tr.rs index e8fb644a5..da862aa6c 100644 --- a/src/tr/tr.rs +++ b/src/tr/tr.rs @@ -158,7 +158,7 @@ fn usage(opts: &[OptGroup]) { print(getopts::usage("Translate or delete characters.", opts).as_slice()); } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let opts = [ getopts::optflag("c", "complement", "use the complement of SET1"), getopts::optflag("C", "", "same as -c"), diff --git a/src/true/true.rs b/src/true/true.rs index df9d7f2b2..f43220f82 100644 --- a/src/true/true.rs +++ b/src/true/true.rs @@ -9,6 +9,6 @@ * file that was distributed with this source code. */ -pub fn uumain(_: Vec) -> int { +pub fn uumain(_: Vec) -> isize { 0 } diff --git a/src/truncate/truncate.rs b/src/truncate/truncate.rs index 7b76fe4fb..76cac158a 100644 --- a/src/truncate/truncate.rs +++ b/src/truncate/truncate.rs @@ -33,7 +33,7 @@ enum TruncateMode { static NAME: &'static str = "truncate"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); let opts = [ diff --git a/src/tsort/tsort.rs b/src/tsort/tsort.rs index 198c19933..340db735f 100644 --- a/src/tsort/tsort.rs +++ b/src/tsort/tsort.rs @@ -23,7 +23,7 @@ mod util; static NAME: &'static str = "tsort"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let opts = [ getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit"), diff --git a/src/tty/tty.rs b/src/tty/tty.rs index d7d0aaf2d..fd366c861 100644 --- a/src/tty/tty.rs +++ b/src/tty/tty.rs @@ -33,7 +33,7 @@ extern { static NAME: &'static str = "tty"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let options = [ optflag("s", "silent", "print nothing, only return an exit status") ]; diff --git a/src/uname/uname.rs b/src/uname/uname.rs index c944891b4..7e4b44e12 100644 --- a/src/uname/uname.rs +++ b/src/uname/uname.rs @@ -55,7 +55,7 @@ unsafe fn getuname() -> utsrust { static NAME: &'static str = "uname"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].as_slice(); let opts = [ getopts::optflag("h", "help", "display this help and exit"), diff --git a/src/unexpand/unexpand.rs b/src/unexpand/unexpand.rs index fb1393760..65fa1927e 100644 --- a/src/unexpand/unexpand.rs +++ b/src/unexpand/unexpand.rs @@ -72,7 +72,7 @@ impl Options { } } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> 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)"), diff --git a/src/uniq/uniq.rs b/src/uniq/uniq.rs index dc6b96953..1246234f0 100644 --- a/src/uniq/uniq.rs +++ b/src/uniq/uniq.rs @@ -117,7 +117,7 @@ fn opt_parsed(opt_name: &str, matches: &getopts::Matches) -> Option< }) } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> 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) -> int { fn open_input_file(in_file_name: String) -> io::BufferedReader> { let in_file = if in_file_name.as_slice() == "-" { - box io::stdio::stdin_raw() as Box + Box::new(io::stdio::stdin_raw()) as Box } 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 + Box::new(r) as Box }; io::BufferedReader::new(in_file) } fn open_output_file(out_file_name: String) -> io::BufferedWriter> { let out_file = if out_file_name.as_slice() == "-" { - box io::stdio::stdout_raw() as Box + Box::new(io::stdio::stdout_raw()) as Box } 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 + Box::new(w) as Box }; io::BufferedWriter::new(out_file) } diff --git a/src/unlink/unlink.rs b/src/unlink/unlink.rs index 1895c9902..100e5c493 100644 --- a/src/unlink/unlink.rs +++ b/src/unlink/unlink.rs @@ -24,7 +24,7 @@ mod util; static NAME: &'static str = "unlink"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); let opts = [ getopts::optflag("h", "help", "display this help and exit"), diff --git a/src/uptime/uptime.rs b/src/uptime/uptime.rs index 2fd2eb2ea..06720acc0 100644 --- a/src/uptime/uptime.rs +++ b/src/uptime/uptime.rs @@ -53,7 +53,7 @@ unsafe extern fn utmpxname(_file: *const c_char) -> c_int { 0 } -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); let opts = [ getopts::optflag("v", "version", "output version information and exit"), diff --git a/src/users/users.rs b/src/users/users.rs index 39bc99220..6fa4adec4 100644 --- a/src/users/users.rs +++ b/src/users/users.rs @@ -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) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].as_slice(); let opts = [ getopts::optflag("h", "help", "display this help and exit"), diff --git a/src/wc/wc.rs b/src/wc/wc.rs index 75f20d347..84498e02a 100644 --- a/src/wc/wc.rs +++ b/src/wc/wc.rs @@ -35,7 +35,7 @@ struct Result { static NAME: &'static str = "wc"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> 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>, int> { if "-" == path { - let reader = box stdin_raw() as Box; + let reader = Box::new(stdin_raw()) as Box; return Ok(BufferedReader::new(reader)); } @@ -240,7 +240,7 @@ fn open(path: &str) -> StdResult>, int> { } match File::open(&fpath) { Ok(fd) => { - let reader = box fd as Box; + let reader = Box::new(fd) as Box; Ok(BufferedReader::new(reader)) } Err(e) => { diff --git a/src/whoami/whoami.rs b/src/whoami/whoami.rs index dbea93b70..bcb81bb7d 100644 --- a/src/whoami/whoami.rs +++ b/src/whoami/whoami.rs @@ -62,7 +62,7 @@ mod platform { static NAME: &'static str = "whoami"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].as_slice(); let opts = [ getopts::optflag("h", "help", "display this help and exit"), diff --git a/src/yes/yes.rs b/src/yes/yes.rs index e7143f42b..07634c229 100644 --- a/src/yes/yes.rs +++ b/src/yes/yes.rs @@ -22,7 +22,7 @@ mod util; static NAME: &'static str = "yes"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); let opts = [ getopts::optflag("h", "help", "display this help and exit"),