1
Fork 0
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:
Heather 2015-01-10 17:49:18 +03:00
commit bdc6e0edcf
66 changed files with 118 additions and 118 deletions

2
deps/rust-crypto vendored

@ -1 +1 @@
Subproject commit c85bfa94d5003f839540536a6d42ecea094d8a45 Subproject commit 716c4241e9a8e1e53dde4380eac2b454682ae81c

2
deps/time vendored

@ -1 +1 @@
Subproject commit 00121035e51e1df14d5cd3a3233905f43e5c93a9 Subproject commit 7f105d4dd2bde23d4b8516dc02566cfc46b60b22

View file

@ -40,7 +40,7 @@ fn main() {
} }
_ => { _ => {
crates.push_str(format!("extern crate {};\n", prog).as_slice()); 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());
} }
} }
} }

View file

@ -22,7 +22,7 @@ mod util;
static NAME: &'static str = "basename"; static NAME: &'static str = "basename";
static VERSION: &'static str = "1.0.0"; 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()); let program = strip_dir(args[0].as_slice());
// //

View file

@ -19,7 +19,7 @@ use std::io::stdio::{stdout_raw, stdin_raw, stderr};
use std::io::{IoResult}; use std::io::{IoResult};
use std::ptr::{copy_nonoverlapping_memory}; 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 program = args[0].as_slice();
let opts = [ let opts = [
getopts::optflag("A", "show-all", "equivalent to -vET"), getopts::optflag("A", "show-all", "equivalent to -vET"),

View file

@ -31,7 +31,7 @@ pub enum Mode {
impl Copy for Mode {} impl Copy for Mode {}
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let opts = [ let opts = [
optflag("h", "help", "display this help and exit"), optflag("h", "help", "display this help and exit"),
optflag("", "version", "output version information and exit"), optflag("", "version", "output version information and exit"),

View file

@ -447,7 +447,7 @@ fn cut_files(mut filenames: Vec<String>, mode: Mode) -> int {
exit_code exit_code
} }
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let opts = [ let opts = [
optopt("b", "bytes", "select only these bytes", "LIST"), optopt("b", "bytes", "select only these bytes", "LIST"),
optopt("c", "characters", "select only these characters", "LIST"), optopt("c", "characters", "select only these characters", "LIST"),

View file

@ -15,7 +15,7 @@ use std::io::print;
static VERSION: &'static str = "1.0.0"; 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 program = args[0].clone();
let opts = [ let opts = [
getopts::optflag("z", "zero", "separate output with NUL rather than newline"), getopts::optflag("z", "zero", "separate output with NUL rather than newline"),

View file

@ -89,7 +89,7 @@ fn du(path: &Path, mut my_stat: Stat,
stats stats
} }
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let program = args[0].as_slice(); let program = args[0].as_slice();
let opts = [ let opts = [
// In task // In task

View file

@ -162,7 +162,7 @@ fn print_version() {
println!("echo version: {}", VERSION); println!("echo version: {}", VERSION);
} }
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let mut options = EchoOptions { let mut options = EchoOptions {
newline: false, newline: false,
escape: false escape: false

2
src/env/env.rs vendored
View file

@ -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(); let prog = args[0].as_slice();
// to handle arguments the same way than GNU env, we can't use getopts // to handle arguments the same way than GNU env, we can't use getopts

View file

@ -72,7 +72,7 @@ impl Options {
} }
} }
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let opts = [ let opts = [
getopts::optflag("i", "initial", "do not convert tabs after non blanks"), getopts::optflag("i", "initial", "do not convert tabs after non blanks"),
getopts::optopt("t", "tabs", "have tabs NUMBER characters apart, not 8", "NUMBER"), getopts::optopt("t", "tabs", "have tabs NUMBER characters apart, not 8", "NUMBER"),

View file

@ -63,7 +63,7 @@ fn print_factors_str(num_str: &str) {
print_factors(num); print_factors(num);
} }
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let program = args[0].as_slice(); let program = args[0].as_slice();
let opts = [ let opts = [
getopts::optflag("h", "help", "show this help message"), getopts::optflag("h", "help", "show this help message"),

View file

@ -9,6 +9,6 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
pub fn uumain(_: Vec<String>) -> int { pub fn uumain(_: Vec<String>) -> isize {
1 1
} }

View file

@ -54,7 +54,7 @@ struct FmtOptions {
tabwidth : uint, tabwidth : uint,
} }
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let opts = [ 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."), 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."),

View file

@ -23,7 +23,7 @@ mod util;
static NAME: &'static str = "fold"; static NAME: &'static str = "fold";
static VERSION: &'static str = "1.0.0"; 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 (args, obs_width) = handle_obsolete(args.as_slice());
let program = args[0].clone(); let program = args[0].clone();

View file

@ -23,7 +23,7 @@ use c_types::{get_pw_from_args, group};
static NAME: &'static str = "groups"; static NAME: &'static str = "groups";
static VERSION: &'static str = "1.0.0"; 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 program = args[0].clone();
let options = [ let options = [

View file

@ -63,12 +63,12 @@ fn detect_algo(program: &str, matches: &getopts::Matches) -> (&'static str, Box<
let mut alg: Option<Box<Digest>> = None; let mut alg: Option<Box<Digest>> = None;
let mut name: &'static str = ""; let mut name: &'static str = "";
match program { match program {
"md5sum" => ("MD5", box Md5::new() as Box<Digest>), "md5sum" => ("MD5", Box::new(Md5::new()) as Box<Digest>),
"sha1sum" => ("SHA1", box Sha1::new() as Box<Digest>), "sha1sum" => ("SHA1", Box::new(Sha1::new()) as Box<Digest>),
"sha224sum" => ("SHA224", box Sha224::new() as Box<Digest>), "sha224sum" => ("SHA224", Box::new(Sha224::new()) as Box<Digest>),
"sha256sum" => ("SHA256", box Sha256::new() as Box<Digest>), "sha256sum" => ("SHA256", Box::new(Sha256::new()) as Box<Digest>),
"sha384sum" => ("SHA384", box Sha384::new() as Box<Digest>), "sha384sum" => ("SHA384", Box::new(Sha384::new()) as Box<Digest>),
"sha512sum" => ("SHA512", box Sha512::new() as Box<Digest>), "sha512sum" => ("SHA512", Box::new(Sha512::new()) as Box<Digest>),
_ => { _ => {
{ {
let mut set_or_crash = |&mut: n, val| -> () { 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; name = n;
alg = Some(val); alg = Some(val);
}; };
if matches.opt_present("md5") { set_or_crash("MD5", box Md5::new()) }; if matches.opt_present("md5") { set_or_crash("MD5", Box::new(Md5::new())) };
if matches.opt_present("sha1") { set_or_crash("SHA1", box Sha1::new()) }; if matches.opt_present("sha1") { set_or_crash("SHA1", Box::new(Sha1::new())) };
if matches.opt_present("sha224") { set_or_crash("SHA224", box Sha224::new()) }; if matches.opt_present("sha224") { set_or_crash("SHA224", Box::new(Sha224::new())) };
if matches.opt_present("sha256") { set_or_crash("SHA256", box Sha256::new()) }; if matches.opt_present("sha256") { set_or_crash("SHA256", Box::new(Sha256::new())) };
if matches.opt_present("sha384") { set_or_crash("SHA384", box Sha384::new()) }; if matches.opt_present("sha384") { set_or_crash("SHA384", Box::new(Sha384::new())) };
if matches.opt_present("sha512") { set_or_crash("SHA512", box Sha512::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!") }; if alg.is_none() { crash!(1, "You must specify hash algorithm!") };
(name, alg.unwrap()) (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 program = args[0].clone();
let binary = Path::new(program.as_slice()); let binary = Path::new(program.as_slice());
let binary_name = binary.filename_str().unwrap(); 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)); 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> { 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 = 0u; let mut bad_format = 0;
let mut failed = 0u; let mut failed = 0;
let binary_marker = if binary { let binary_marker = if binary {
"*" "*"
} else { } else {

View file

@ -26,7 +26,7 @@ mod util;
static NAME: &'static str = "head"; 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 line_count = 10u;
let mut byte_count = 0u; let mut byte_count = 0u;

View file

@ -48,7 +48,7 @@ extern {
pub fn gethostid() -> c_long; pub fn gethostid() -> c_long;
} }
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let opts = [ let opts = [
optflag("", "help", "display this help and exit"), optflag("", "help", "display this help and exit"),

View file

@ -41,7 +41,7 @@ extern {
fn sethostname(name: *const libc::c_char, namelen: libc::size_t) -> libc::c_int; 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 program = &args[0];
let options = [ let options = [

View file

@ -83,7 +83,7 @@ extern {
static NAME: &'static str = "id"; 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 args_t = args.tail();
let options = [ let options = [

View file

@ -52,7 +52,7 @@ pub enum Mode {
impl Copy for Mode {} impl Copy for Mode {}
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let opts = [ let opts = [
optflag("h", "help", "display this help and exit"), optflag("h", "help", "display this help and exit"),
optflag("V", "version", "output version information and exit"), optflag("V", "version", "output version information and exit"),

View file

@ -21,7 +21,7 @@ mod util;
static NAME : &'static str = "link"; static NAME : &'static str = "link";
static VERSION : &'static str = "1.0.0"; static VERSION : &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let opts = [ let opts = [
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),
getopts::optflag("V", "version", "output version information and exit"), getopts::optflag("V", "version", "output version information and exit"),

View file

@ -45,7 +45,7 @@ fn version() {
println!("{} {}", NAME, VERSION); println!("{} {}", NAME, VERSION);
} }
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let program = args[0].clone(); let program = args[0].clone();
// //

View file

@ -26,7 +26,7 @@ static VERSION: &'static str = "1.0.0";
/** /**
* Handles option parsing * Handles option parsing
*/ */
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let opts = [ let opts = [
// Linux-specific options, not implemented // Linux-specific options, not implemented

View file

@ -12,6 +12,7 @@
extern crate getopts; extern crate getopts;
extern crate libc; extern crate libc;
use std::ffi::CString;
use std::num::FromStrRadix; use std::num::FromStrRadix;
use std::os; use std::os;
use libc::funcs::posix88::stat_::mkfifo; use libc::funcs::posix88::stat_::mkfifo;
@ -23,7 +24,7 @@ mod util;
static NAME : &'static str = "mkfifo"; static NAME : &'static str = "mkfifo";
static VERSION : &'static str = "1.0.0"; static VERSION : &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let opts = [ let opts = [
getopts::optopt("m", "mode", "file permissions for the fifo", "(default 0666)"), getopts::optopt("m", "mode", "file permissions for the fifo", "(default 0666)"),
getopts::optflag("h", "help", "display this help and exit"), 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; let mut exit_status = 0;
for f in matches.free.iter() { for f in matches.free.iter() {
f.with_c_str(|name| { let err = unsafe { mkfifo(CString::from_slice(f.as_bytes()).as_ptr(), mode) };
let err = unsafe { mkfifo(name, mode) }; if err == -1 {
if err == -1 { show_error!("creating '{}': {}", f, os::error_string(os::errno()));
show_error!("creating '{}': {}", f, os::error_string(os::errno())); exit_status = 1;
exit_status = 1; }
}
});
} }
exit_status exit_status

View file

@ -61,7 +61,7 @@ pub enum BackupMode {
impl Copy for 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 program = args[0].as_slice();
let opts = [ let opts = [
optflagopt("", "backup", "make a backup of each existing destination file", "CONTROL"), optflagopt("", "backup", "make a backup of each existing destination file", "CONTROL"),

View file

@ -32,7 +32,7 @@ extern {
fn setpriority(which: c_int, who: c_int, prio: c_int) -> c_int; 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 = [ let opts = [
getopts::optopt("n", "adjustment", "add N to the niceness (default is 10)", "N"), getopts::optopt("n", "adjustment", "add N to the niceness (default is 10)", "N"),
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),

View file

@ -73,7 +73,7 @@ enum NumberFormat {
RightZero, RightZero,
} }
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let possible_options = [ let possible_options = [
optopt("b", "body-numbering", "use STYLE for numbering body lines", "STYLE"), optopt("b", "body-numbering", "use STYLE for numbering body lines", "STYLE"),
optopt("d", "section-delimiter", "use CC for separating logical pages", "CC"), optopt("d", "section-delimiter", "use CC for separating logical pages", "CC"),

View file

@ -35,7 +35,7 @@ extern {
#[cfg(any(target_os = "linux", target_os = "freebsd"))] #[cfg(any(target_os = "linux", target_os = "freebsd"))]
unsafe fn _vprocmgr_detach_from_console(_: u32) -> *const libc::c_int { std::ptr::null() } 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 program = &args[0];
let options = [ let options = [

View file

@ -20,7 +20,7 @@ static VERSION : &'static str = "0.0.0";
#[macro_use] #[macro_use]
mod util; mod util;
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let opts = [ let opts = [
getopts::optflag("", "all", "print the number of cores available to the system"), getopts::optflag("", "all", "print the number of cores available to the system"),
getopts::optopt("", "ignore", "ignore up to N cores", "N"), getopts::optopt("", "ignore", "ignore up to N cores", "N"),

View file

@ -22,7 +22,7 @@ mod util;
static NAME: &'static str = "paste"; static NAME: &'static str = "paste";
static VERSION: &'static str = "1.0.0"; 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 program = args[0].clone();
let opts = [ 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| let mut files: Vec<io::BufferedReader<Box<Reader>>> = filenames.into_iter().map(|name|
io::BufferedReader::new( io::BufferedReader::new(
if name.as_slice() == "-" { if name.as_slice() == "-" {
box io::stdio::stdin_raw() as Box<Reader> Box::new(io::stdio::stdin_raw()) as Box<Reader>
} else { } else {
let r = crash_if_err!(1, io::File::open(&Path::new(name))); let r = crash_if_err!(1, io::File::open(&Path::new(name)));
box r as Box<Reader> Box::new(r) as Box<Reader>
} }
) )
).collect(); ).collect();

View file

@ -23,7 +23,7 @@ mod util;
static NAME: &'static str = "printenv"; 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 program = args[0].clone();
let opts = [ let opts = [
getopts::optflag("0", "null", "end each output line with 0 byte rather than newline"), getopts::optflag("0", "null", "end each output line with 0 byte rather than newline"),

View file

@ -21,7 +21,7 @@ mod util;
static NAME: &'static str = "pwd"; static NAME: &'static str = "pwd";
static VERSION: &'static str = "1.0.0"; 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 program = args[0].clone();
let opts = [ let opts = [
getopts::optflag("", "help", "display this help and exit"), getopts::optflag("", "help", "display this help and exit"),

View file

@ -19,7 +19,7 @@ use getopts::{optflag, getopts, usage};
static NAME: &'static str = "realpath"; static NAME: &'static str = "realpath";
static VERSION: &'static str = "1.0.0"; 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 program = &args[0];
let options = [ let options = [
optflag("h", "help", "Show help and exit"), optflag("h", "help", "Show help and exit"),

View file

@ -19,7 +19,7 @@ use getopts::{optflag, optopt, getopts, usage};
static NAME: &'static str = "relpath"; static NAME: &'static str = "relpath";
static VERSION: &'static str = "1.0.0"; 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 program = &args[0];
let options = [ let options = [
optflag("h", "help", "Show help and exit"), optflag("h", "help", "Show help and exit"),

View file

@ -30,7 +30,7 @@ impl Copy for InteractiveMode {}
static NAME: &'static str = "rm"; static NAME: &'static str = "rm";
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let program = args[0].clone(); let program = args[0].clone();
// TODO: make getopts support -R in addition to -r // TODO: make getopts support -R in addition to -r

View file

@ -21,7 +21,7 @@ mod util;
static NAME: &'static str = "rmdir"; 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 program = args[0].clone();
let opts = [ let opts = [

View file

@ -145,7 +145,7 @@ fn print_version() {
println!("seq 1.0.0\n"); 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 program = args[0].clone();
let mut options = SeqOptions { let mut options = SeqOptions {
separator: "\n".to_string(), separator: "\n".to_string(),

View file

@ -32,7 +32,7 @@ enum Mode {
static NAME: &'static str = "shuf"; static NAME: &'static str = "shuf";
static VERSION: &'static str = "0.0.1"; 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 program = args[0].clone();
let opts = [ let opts = [
@ -157,16 +157,16 @@ enum WrappedRng {
impl WrappedRng { impl WrappedRng {
fn next_u32(&mut self) -> u32 { fn next_u32(&mut self) -> u32 {
match self { match self {
&WrappedRng::RngFile(ref mut r) => r.next_u32(), &mut WrappedRng::RngFile(ref mut r) => r.next_u32(),
&WrappedRng::RngDefault(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<()> { 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 { let mut output = match outname {
Some(name) => box io::BufferedWriter::new(try!(io::File::create(&Path::new(name)))) as Box<Writer>, Some(name) => Box::new(io::BufferedWriter::new(try!(io::File::create(&Path::new(name))))) as Box<Writer>,
None => box io::stdout() as Box<Writer> None => Box::new(io::stdout()) as Box<Writer>
}; };
let mut rng = match random { let mut rng = match random {
Some(name) => WrappedRng::RngFile(rand::reader::ReaderRng::new(try!(io::File::open(&Path::new(name))))), Some(name) => WrappedRng::RngFile(rand::reader::ReaderRng::new(try!(io::File::open(&Path::new(name))))),

View file

@ -25,7 +25,7 @@ mod time;
static NAME: &'static str = "sleep"; 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 program = args[0].clone();
let opts = [ let opts = [

View file

@ -13,6 +13,7 @@
extern crate getopts; extern crate getopts;
use std::cmp::Ordering;
use std::fmt::Show; use std::fmt::Show;
use std::io::{print, File, BufferedReader}; use std::io::{print, File, BufferedReader};
use std::io::stdio::stdin_raw; use std::io::stdio::stdin_raw;
@ -28,7 +29,7 @@ static VERSION: &'static str = "0.0.1";
static DECIMAL_PT: char = '.'; static DECIMAL_PT: char = '.';
static THOUSANDS_SEP: 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 program = args[0].as_slice();
let opts = [ let opts = [
getopts::optflag("n", "numeric-sort", "compare according to string numerical value"), 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 { 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 }; char_a = match char_iter.next() { None => 0 as char, Some(t) => t };
while char_a == '0' { 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) /// 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 }; char_b = match b_chars.next() { None => 0 as char, Some(t) => t };
// hit the end at the same time, they are equal // hit the end at the same time, they are equal
if !char_a.is_digit(10) { if !char_a.is_digit(10) {
return Equal; return Ordering::Equal;
} }
} }
if char_a.is_digit(10) && char_b.is_digit(10) { if char_a.is_digit(10) && char_b.is_digit(10) {
(char_a as int).cmp(&(char_b as int)) (char_a as int).cmp(&(char_b as int))
} else if char_a.is_digit(10) { } 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) { } else if char_b.is_digit(10) {
skip_zeros(char_b, b_chars, Less) skip_zeros(char_b, b_chars, Ordering::Less)
} else { Equal } } else { Ordering::Equal }
} else if char_a == DECIMAL_PT { } 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 { } else if char_b == DECIMAL_PT {
skip_zeros(char_b, b_chars, Less) skip_zeros(char_b, b_chars, Ordering::Less)
} else { Equal } } else { Ordering::Equal }
} }
#[inline(always)] #[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 { for line in iter {
print!("{}", line); print!("{}", line);
} }
@ -156,11 +157,11 @@ fn open<'a>(path: &str) -> Option<(Box<Reader + 'a>, bool)> {
if path == "-" { if path == "-" {
let stdin = stdin_raw(); let stdin = stdin_raw();
let interactive = stdin.isatty(); 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)) { 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) => { Err(e) => {
show_error!("sort: {0}: {1}", path, e.to_string()); show_error!("sort: {0}: {1}", path, e.to_string());
None None

View file

@ -23,7 +23,7 @@ mod util;
static NAME: &'static str = "split"; static NAME: &'static str = "split";
static VERSION: &'static str = "1.0.0"; static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let opts = [ let opts = [
getopts::optopt("a", "suffix-length", "use suffixes of length N (default 2)", "N"), getopts::optopt("a", "suffix-length", "use suffixes of length N (default 2)", "N"),
getopts::optopt("b", "bytes", "put SIZE bytes per output file", "SIZE"), getopts::optopt("b", "bytes", "put SIZE bytes per output file", "SIZE"),

View file

@ -22,7 +22,7 @@ mod util;
static VERSION: &'static str = "1.0.0"; static VERSION: &'static str = "1.0.0";
static NAME: &'static str = "sum"; 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 buf = [0; 1024];
let mut blocks_read = 0; let mut blocks_read = 0;
let mut checksum: u16 = 0; let mut checksum: u16 = 0;
@ -42,7 +42,7 @@ fn bsd_sum(mut reader: Box<Reader>) -> (uint, u16) {
(blocks_read, checksum) (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 buf = [0; 512];
let mut blocks_read = 0; let mut blocks_read = 0;
let mut ret = 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>> { fn open(name: &str) -> IoResult<Box<Reader>> {
match name { 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))); 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 program = args[0].as_slice();
let opts = [ let opts = [
getopts::optflag("r", "", "use the BSD compatible algorithm (default)"), getopts::optflag("r", "", "use the BSD compatible algorithm (default)"),

View file

@ -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 program = &args[0];
let options = [ let options = [

View file

@ -21,7 +21,7 @@ mod util;
static NAME: &'static str = "tac"; static NAME: &'static str = "tac";
static VERSION: &'static str = "1.0.0"; 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 program = args[0].clone();
let opts = [ let opts = [
@ -72,10 +72,10 @@ fn tac(filenames: Vec<String>, before: bool, _: bool, separator: &str) {
for filename in filenames.into_iter() { for filename in filenames.into_iter() {
let mut file = io::BufferedReader::new( let mut file = io::BufferedReader::new(
if filename.as_slice() == "-" { if filename.as_slice() == "-" {
box io::stdio::stdin_raw() as Box<Reader> Box::new(io::stdio::stdin_raw()) as Box<Reader>
} else { } else {
let r = crash_if_err!(1, io::File::open(&Path::new(filename))); 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()); let mut data = crash_if_err!(1, file.read_to_string());

View file

@ -29,7 +29,7 @@ mod util;
static NAME: &'static str = "tail"; static NAME: &'static str = "tail";
static VERSION: &'static str = "0.0.1"; 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 beginning = false;
let mut lines = true; let mut lines = true;
let mut byte_count = 0u; let mut byte_count = 0u;

View file

@ -21,7 +21,7 @@ use getopts::{getopts, optflag, usage};
static NAME: &'static str = "tee"; static NAME: &'static str = "tee";
static VERSION: &'static str = "1.0.0"; 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) { match options(args.as_slice()).and_then(exec) {
Ok(_) => 0, Ok(_) => 0,
Err(_) => 1 Err(_) => 1

View file

@ -18,7 +18,7 @@ use std::str::{from_utf8};
static NAME: &'static str = "test"; static NAME: &'static str = "test";
// TODO: decide how to handle non-UTF8 input for all the utils // 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 = args_as_bytes();
let args: Vec<&[u8]> = args.iter().map(|a| a.as_slice()).collect(); let args: Vec<&[u8]> = args.iter().map(|a| a.as_slice()).collect();
if args.len() == 0 { if args.len() == 0 {

View file

@ -34,7 +34,7 @@ static VERSION: &'static str = "1.0.0";
static ERR_EXIT_STATUS: int = 125; 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 program = args[0].clone();
let opts = [ let opts = [

View file

@ -22,7 +22,7 @@ mod util;
static NAME: &'static str = "touch"; static NAME: &'static str = "touch";
static VERSION: &'static str = "1.0.0"; static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let opts = [ let opts = [
getopts::optflag("a", "", "change only the access time"), getopts::optflag("a", "", "change only the access time"),
getopts::optflag("c", "no-create", "do not create any files"), getopts::optflag("c", "no-create", "do not create any files"),

View file

@ -158,7 +158,7 @@ fn usage(opts: &[OptGroup]) {
print(getopts::usage("Translate or delete characters.", opts).as_slice()); 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 = [ let opts = [
getopts::optflag("c", "complement", "use the complement of SET1"), getopts::optflag("c", "complement", "use the complement of SET1"),
getopts::optflag("C", "", "same as -c"), getopts::optflag("C", "", "same as -c"),

View file

@ -9,6 +9,6 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
pub fn uumain(_: Vec<String>) -> int { pub fn uumain(_: Vec<String>) -> isize {
0 0
} }

View file

@ -33,7 +33,7 @@ enum TruncateMode {
static NAME: &'static str = "truncate"; 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 program = args[0].clone();
let opts = [ let opts = [

View file

@ -23,7 +23,7 @@ mod util;
static NAME: &'static str = "tsort"; static NAME: &'static str = "tsort";
static VERSION: &'static str = "1.0.0"; static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let opts = [ let opts = [
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),
getopts::optflag("V", "version", "output version information and exit"), getopts::optflag("V", "version", "output version information and exit"),

View file

@ -33,7 +33,7 @@ extern {
static NAME: &'static str = "tty"; static NAME: &'static str = "tty";
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let options = [ let options = [
optflag("s", "silent", "print nothing, only return an exit status") optflag("s", "silent", "print nothing, only return an exit status")
]; ];

View file

@ -55,7 +55,7 @@ unsafe fn getuname() -> utsrust {
static NAME: &'static str = "uname"; 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 program = args[0].as_slice();
let opts = [ let opts = [
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),

View file

@ -72,7 +72,7 @@ impl Options {
} }
} }
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let opts = [ let opts = [
getopts::optflag("a", "all", "convert all blanks, instead of just initial blanks"), getopts::optflag("a", "all", "convert all blanks, instead of just initial blanks"),
getopts::optflag("", "first-only", "convert only leading sequences of blanks (overrides -a)"), getopts::optflag("", "first-only", "convert only leading sequences of blanks (overrides -a)"),

View file

@ -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_path = Path::new(args[0].clone());
let program = program_path.filename_str().unwrap_or(NAME); 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>> { fn open_input_file(in_file_name: String) -> io::BufferedReader<Box<Reader+'static>> {
let in_file = if in_file_name.as_slice() == "-" { 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 { } else {
let path = Path::new(in_file_name); let path = Path::new(in_file_name);
let in_file = io::File::open(&path); let in_file = io::File::open(&path);
let r = crash_if_err!(1, in_file); let r = crash_if_err!(1, in_file);
box r as Box<Reader> Box::new(r) as Box<Reader>
}; };
io::BufferedReader::new(in_file) io::BufferedReader::new(in_file)
} }
fn open_output_file(out_file_name: String) -> io::BufferedWriter<Box<Writer+'static>> { fn open_output_file(out_file_name: String) -> io::BufferedWriter<Box<Writer+'static>> {
let out_file = if out_file_name.as_slice() == "-" { 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 { } else {
let path = Path::new(out_file_name); let path = Path::new(out_file_name);
let in_file = io::File::create(&path); let in_file = io::File::create(&path);
let w = crash_if_err!(1, in_file); let w = crash_if_err!(1, in_file);
box w as Box<Writer> Box::new(w) as Box<Writer>
}; };
io::BufferedWriter::new(out_file) io::BufferedWriter::new(out_file)
} }

View file

@ -24,7 +24,7 @@ mod util;
static NAME: &'static str = "unlink"; 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 program = args[0].clone();
let opts = [ let opts = [
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),

View file

@ -53,7 +53,7 @@ unsafe extern fn utmpxname(_file: *const c_char) -> c_int {
0 0
} }
pub fn uumain(args: Vec<String>) -> int { pub fn uumain(args: Vec<String>) -> isize {
let program = args[0].clone(); let program = args[0].clone();
let opts = [ let opts = [
getopts::optflag("v", "version", "output version information and exit"), getopts::optflag("v", "version", "output version information and exit"),

View file

@ -51,7 +51,7 @@ unsafe extern fn utmpxname(_file: *const libc::c_char) -> libc::c_int {
static NAME: &'static str = "users"; 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 program = args[0].as_slice();
let opts = [ let opts = [
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),

View file

@ -35,7 +35,7 @@ struct Result {
static NAME: &'static str = "wc"; 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 program = args[0].clone();
let opts = [ let opts = [
getopts::optflag("c", "bytes", "print the byte counts"), 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> { fn open(path: &str) -> StdResult<BufferedReader<Box<Reader+'static>>, int> {
if "-" == path { if "-" == path {
let reader = box stdin_raw() as Box<Reader>; let reader = Box::new(stdin_raw()) as Box<Reader>;
return Ok(BufferedReader::new(reader)); return Ok(BufferedReader::new(reader));
} }
@ -240,7 +240,7 @@ fn open(path: &str) -> StdResult<BufferedReader<Box<Reader+'static>>, int> {
} }
match File::open(&fpath) { match File::open(&fpath) {
Ok(fd) => { Ok(fd) => {
let reader = box fd as Box<Reader>; let reader = Box::new(fd) as Box<Reader>;
Ok(BufferedReader::new(reader)) Ok(BufferedReader::new(reader))
} }
Err(e) => { Err(e) => {

View file

@ -62,7 +62,7 @@ mod platform {
static NAME: &'static str = "whoami"; 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 program = args[0].as_slice();
let opts = [ let opts = [
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),

View file

@ -22,7 +22,7 @@ mod util;
static NAME: &'static str = "yes"; 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 program = args[0].clone();
let opts = [ let opts = [
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),