From e7b647171fd88babeb80cbb6556c2c1fa92a8ce9 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Fri, 6 Feb 2015 14:48:07 +0100 Subject: [PATCH 01/11] os::set_exit_status(isize) -> env::set_exit_status(i32) --- mkmain.rs | 10 ++++++---- mkuutils.rs | 11 ++++++----- src/base64/base64.rs | 2 +- src/basename/basename.rs | 2 +- src/cat/cat.rs | 2 +- src/chmod/chmod.rs | 6 +++--- src/chroot/chroot.rs | 4 ++-- src/cksum/cksum.rs | 2 +- src/comm/comm.rs | 2 +- src/cp/cp.rs | 2 +- src/cut/cut.rs | 12 ++++++------ src/dirname/dirname.rs | 2 +- src/du/du.rs | 2 +- src/echo/echo.rs | 2 +- src/env/env.rs | 4 ++-- src/expand/expand.rs | 2 +- src/factor/factor.rs | 2 +- src/false/false.rs | 2 +- src/fmt/fmt.rs | 2 +- src/fold/fold.rs | 2 +- src/groups/groups.rs | 2 +- src/hashsum/hashsum.rs | 4 ++-- src/head/head.rs | 2 +- src/hostid/hostid.rs | 4 ++-- src/hostname/hostname.rs | 2 +- src/id/id.rs | 2 +- src/kill/kill.rs | 8 ++++---- src/link/link.rs | 2 +- src/logname/logname.rs | 2 +- src/mkdir/mkdir.rs | 4 ++-- src/mkfifo/mkfifo.rs | 2 +- src/mv/mv.rs | 6 +++--- src/nice/nice.rs | 2 +- src/nl/nl.rs | 2 +- src/nohup/nohup.rs | 4 ++-- src/nproc/nproc.rs | 2 +- src/od/od.rs | 2 +- src/paste/paste.rs | 2 +- src/printenv/printenv.rs | 2 +- src/pwd/pwd.rs | 2 +- src/readlink/readlink.rs | 2 +- src/realpath/realpath.rs | 2 +- src/relpath/relpath.rs | 2 +- src/rm/rm.rs | 8 ++++---- src/rmdir/rmdir.rs | 6 +++--- src/seq/seq.rs | 4 ++-- src/shuf/shuf.rs | 4 ++-- src/sleep/sleep.rs | 2 +- src/sort/sort.rs | 2 +- src/split/split.rs | 4 ++-- src/stdbuf/stdbuf.rs | 4 ++-- src/sum/sum.rs | 2 +- src/sync/sync.rs | 2 +- src/tac/tac.rs | 2 +- src/tail/tail.rs | 2 +- src/tee/tee.rs | 2 +- src/test/test.rs | 4 ++-- src/timeout/timeout.rs | 14 +++++++------- src/touch/touch.rs | 2 +- src/tr/tr.rs | 2 +- src/true/true.rs | 2 +- src/truncate/truncate.rs | 4 ++-- src/tsort/tsort.rs | 2 +- src/tty/tty.rs | 4 ++-- src/uname/uname.rs | 2 +- src/unexpand/unexpand.rs | 2 +- src/uniq/uniq.rs | 2 +- src/unlink/unlink.rs | 2 +- src/uptime/uptime.rs | 2 +- src/users/users.rs | 2 +- src/uutils/uutils.rs | 23 ++++++++++++----------- src/wc/wc.rs | 6 +++--- src/whoami/whoami.rs | 2 +- src/yes/yes.rs | 2 +- 74 files changed, 133 insertions(+), 129 deletions(-) diff --git a/mkmain.rs b/mkmain.rs index a7a16266c..ebb71d26a 100644 --- a/mkmain.rs +++ b/mkmain.rs @@ -1,17 +1,19 @@ -#![feature(core, io, os, path)] +#![feature(core, env, io, os, path)] +use std::env; use std::old_io::{File, Truncate, ReadWrite}; use std::os; use std::old_path::Path; static TEMPLATE: &'static str = "\ -#![feature(os)] +#![feature(env, os)] extern crate \"@UTIL_CRATE@\" as uu@UTIL_CRATE@; +use std::env; use std::os; use uu@UTIL_CRATE@::uumain; fn main() { - os::set_exit_status(uumain(os::args())); + env::set_exit_status(uumain(os::args())); } "; @@ -19,7 +21,7 @@ fn main() { let args = os::args(); if args.len() != 3 { println!("usage: mkbuild "); - os::set_exit_status(1); + env::set_exit_status(1); return; } diff --git a/mkuutils.rs b/mkuutils.rs index 119957507..e9a2c0984 100644 --- a/mkuutils.rs +++ b/mkuutils.rs @@ -1,5 +1,6 @@ -#![feature(core, io, os, path)] +#![feature(core, env, io, os, path)] +use std::env; use std::old_io::{File, Truncate, Write}; use std::os; use std::old_path::Path; @@ -8,7 +9,7 @@ fn main() { let args = os::args(); if args.len() < 3 { println!("usage: mkuutils "); - os::set_exit_status(1); + env::set_exit_status(1); return; } @@ -30,11 +31,11 @@ fn main() { hashsum = true; } } - "true" => util_map.push_str("fn uutrue(_: Vec) -> isize { 0 }\nmap.insert(\"true\", uutrue);\n"), - "false" => util_map.push_str("fn uufalse(_: Vec) -> isize { 1 }\nmap.insert(\"false\", uufalse);\n"), + "true" => util_map.push_str("fn uutrue(_: Vec) -> i32 { 0 }\nmap.insert(\"true\", uutrue);\n"), + "false" => util_map.push_str("fn uufalse(_: Vec) -> i32 { 1 }\nmap.insert(\"false\", uufalse);\n"), _ => { crates.push_str(format!("extern crate \"{0}\" as uu{0};\n", prog).as_slice()); - util_map.push_str(format!("map.insert(\"{prog}\", uu{prog}::uumain as fn(Vec) -> isize);\n", prog = prog).as_slice()); + util_map.push_str(format!("map.insert(\"{prog}\", uu{prog}::uumain as fn(Vec) -> i32);\n", prog = prog).as_slice()); } } } diff --git a/src/base64/base64.rs b/src/base64/base64.rs index 88857d4f6..e3ec11784 100644 --- a/src/base64/base64.rs +++ b/src/base64/base64.rs @@ -35,7 +35,7 @@ mod util; static NAME: &'static str = "base64"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let opts = [ optflag("d", "decode", "decode data"), optflag("i", "ignore-garbage", "when decoding, ignore non-alphabetic characters"), diff --git a/src/basename/basename.rs b/src/basename/basename.rs index e2de196f3..07d3f564a 100644 --- a/src/basename/basename.rs +++ b/src/basename/basename.rs @@ -23,7 +23,7 @@ mod util; static NAME: &'static str = "basename"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = strip_dir(args[0].as_slice()); // diff --git a/src/cat/cat.rs b/src/cat/cat.rs index 9bf701391..1f7ac50e9 100644 --- a/src/cat/cat.rs +++ b/src/cat/cat.rs @@ -21,7 +21,7 @@ use std::old_io::stdio::{stdout_raw, stdin_raw, stderr}; use std::old_io::{IoResult}; use std::ptr::{copy_nonoverlapping_memory}; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = &args[0]; let opts = [ getopts::optflag("A", "show-all", "equivalent to -vET"), diff --git a/src/chmod/chmod.rs b/src/chmod/chmod.rs index a3ee27d44..38ee088d3 100644 --- a/src/chmod/chmod.rs +++ b/src/chmod/chmod.rs @@ -33,7 +33,7 @@ mod util; const NAME: &'static str = "chmod"; const VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].clone(); let opts = [ @@ -146,7 +146,7 @@ fn verify_mode(mode: &str) -> Result<(), String> { Ok(()) } -fn chmod(files: Vec, changes: bool, quiet: bool, verbose: bool, preserve_root: bool, recursive: bool, fmode: Option, cmode: Option<&String>) -> Result<(), isize> { +fn chmod(files: Vec, changes: bool, quiet: bool, verbose: bool, preserve_root: bool, recursive: bool, fmode: Option, cmode: Option<&String>) -> Result<(), i32> { let mut r = Ok(()); for filename in files.iter() { @@ -182,7 +182,7 @@ fn chmod(files: Vec, changes: bool, quiet: bool, verbose: bool, preserve r } -fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool, fmode: Option, cmode: Option<&String>) -> Result<(), isize> { +fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool, fmode: Option, cmode: Option<&String>) -> Result<(), i32> { let path = CString::from_slice(name.as_bytes()); match fmode { Some(mode) => { diff --git a/src/chroot/chroot.rs b/src/chroot/chroot.rs index c0467dd32..2f60cfa67 100644 --- a/src/chroot/chroot.rs +++ b/src/chroot/chroot.rs @@ -40,7 +40,7 @@ extern { static NAME: &'static str = "chroot"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = &args[0]; let options = [ @@ -98,7 +98,7 @@ pub fn uumain(args: Vec) -> isize { let executable = CString::from_slice(command[0].as_bytes()).as_bytes_with_nul().as_ptr(); let mut command_parts: Vec<*const u8> = command.iter().map(|x| CString::from_slice(x.as_bytes()).as_bytes_with_nul().as_ptr()).collect(); command_parts.push(std::ptr::null()); - execvp(executable as *const libc::c_char, command_parts.as_ptr() as *mut *const libc::c_char) as isize + execvp(executable as *const libc::c_char, command_parts.as_ptr() as *mut *const libc::c_char) as i32 } } diff --git a/src/cksum/cksum.rs b/src/cksum/cksum.rs index bfb1c56d1..7f734e470 100644 --- a/src/cksum/cksum.rs +++ b/src/cksum/cksum.rs @@ -75,7 +75,7 @@ fn cksum(fname: &str) -> IoResult<(u32, usize)> { } } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let opts = [ getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit"), diff --git a/src/comm/comm.rs b/src/comm/comm.rs index 30b4e49dc..c4594fb01 100644 --- a/src/comm/comm.rs +++ b/src/comm/comm.rs @@ -108,7 +108,7 @@ fn open_file(name: &str) -> IoResult { } } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let opts = [ getopts::optflag("1", "", "suppress column 1 (lines uniq to FILE1)"), getopts::optflag("2", "", "suppress column 2 (lines uniq to FILE2)"), diff --git a/src/cp/cp.rs b/src/cp/cp.rs index 680d7c488..446f2d3be 100644 --- a/src/cp/cp.rs +++ b/src/cp/cp.rs @@ -32,7 +32,7 @@ pub enum Mode { impl Copy for Mode {} -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 771fce319..ac276fe86 100644 --- a/src/cut/cut.rs +++ b/src/cut/cut.rs @@ -54,7 +54,7 @@ fn list_to_ranges(list: &str, complement: bool) -> Result, String> { fn cut_bytes(reader: R, ranges: &Vec, - opts: &Options) -> isize { + opts: &Options) -> i32 { use buffer::Bytes::Select; use buffer::Bytes::Selected::{NewlineFound, Complete, Partial, EndOfFile}; @@ -135,7 +135,7 @@ fn cut_bytes(reader: R, fn cut_characters(reader: R, ranges: &Vec, - opts: &Options) -> isize { + opts: &Options) -> i32 { let mut buf_in = BufferedReader::new(reader); let mut out = BufferedWriter::new(stdio::stdout_raw()); @@ -242,7 +242,7 @@ fn cut_fields_delimiter(reader: R, ranges: &Vec, delim: &String, only_delimited: bool, - out_delim: &String) -> isize { + out_delim: &String) -> i32 { let mut buf_in = BufferedReader::new(reader); let mut out = BufferedWriter::new(stdio::stdout_raw()); @@ -316,7 +316,7 @@ fn cut_fields_delimiter(reader: R, fn cut_fields(reader: R, ranges: &Vec, - opts: &FieldOptions) -> isize { + opts: &FieldOptions) -> i32 { match opts.out_delimeter { Some(ref delim) => { return cut_fields_delimiter(reader, ranges, &opts.delimiter, @@ -395,7 +395,7 @@ fn cut_fields(reader: R, 0 } -fn cut_files(mut filenames: Vec, mode: Mode) -> isize { +fn cut_files(mut filenames: Vec, mode: Mode) -> i32 { let mut stdin_read = false; let mut exit_code = 0; @@ -447,7 +447,7 @@ fn cut_files(mut filenames: Vec, mode: Mode) -> isize { exit_code } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 89eb47aa2..6efbd4bb4 100644 --- a/src/dirname/dirname.rs +++ b/src/dirname/dirname.rs @@ -16,7 +16,7 @@ use std::old_io::print; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 09b717139..ebed7b20f 100644 --- a/src/du/du.rs +++ b/src/du/du.rs @@ -90,7 +90,7 @@ fn du(path: &Path, mut my_stat: Stat, stats } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].as_slice(); let opts = [ // In task diff --git a/src/echo/echo.rs b/src/echo/echo.rs index df90b432a..3e6aaf188 100644 --- a/src/echo/echo.rs +++ b/src/echo/echo.rs @@ -163,7 +163,7 @@ fn print_version() { println!("echo version: {}", VERSION); } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let mut options = EchoOptions { newline: false, escape: false diff --git a/src/env/env.rs b/src/env/env.rs index 845f740d3..be91133c8 100644 --- a/src/env/env.rs +++ b/src/env/env.rs @@ -53,7 +53,7 @@ fn print_env(null: bool) { } } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let prog = args[0].as_slice(); // to handle arguments the same way than GNU env, we can't use getopts @@ -198,7 +198,7 @@ pub fn uumain(args: Vec) -> isize { match Command::new(prog).args(args).stdin(InheritFd(0)).stdout(InheritFd(1)).stderr(InheritFd(2)).status() { Ok(exit) => return match exit { - std::old_io::process::ExitStatus(s) => s, + std::old_io::process::ExitStatus(s) => s as i32, _ => 1 }, Err(_) => return 1 diff --git a/src/expand/expand.rs b/src/expand/expand.rs index 1401b3432..9ed8663ca 100644 --- a/src/expand/expand.rs +++ b/src/expand/expand.rs @@ -75,7 +75,7 @@ impl Options { } } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 493fc0110..79de45d2a 100644 --- a/src/factor/factor.rs +++ b/src/factor/factor.rs @@ -64,7 +64,7 @@ fn print_factors_str(num_str: &str) { print_factors(num); } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 471c523a7..bd19e7dea 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) -> isize { +pub fn uumain(_: Vec) -> i32 { 1 } diff --git a/src/fmt/fmt.rs b/src/fmt/fmt.rs index ec0c10ba9..283eeeea6 100644 --- a/src/fmt/fmt.rs +++ b/src/fmt/fmt.rs @@ -59,7 +59,7 @@ struct FmtOptions { tabwidth : usize, } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 1cd685760..3a7673d95 100644 --- a/src/fold/fold.rs +++ b/src/fold/fold.rs @@ -24,7 +24,7 @@ mod util; static NAME: &'static str = "fold"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 3526b1e69..8ab0c6748 100644 --- a/src/groups/groups.rs +++ b/src/groups/groups.rs @@ -25,7 +25,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) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].clone(); let options = [ diff --git a/src/hashsum/hashsum.rs b/src/hashsum/hashsum.rs index 2688ccb6c..e3be13afc 100644 --- a/src/hashsum/hashsum.rs +++ b/src/hashsum/hashsum.rs @@ -90,7 +90,7 @@ fn detect_algo(program: &str, matches: &getopts::Matches) -> (&'static str, Box< } } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].clone(); let binary = Path::new(program.as_slice()); let binary_name = binary.filename_str().unwrap(); @@ -168,7 +168,7 @@ 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<(), isize> { +fn hashsum(algoname: &str, mut digest: Box, files: Vec, binary: bool, check: bool, tag: bool, status: bool, quiet: bool, strict: bool, warn: bool) -> Result<(), i32> { let mut bad_format = 0; let mut failed = 0; let binary_marker = if binary { diff --git a/src/head/head.rs b/src/head/head.rs index 4c06541d4..9dae049d5 100644 --- a/src/head/head.rs +++ b/src/head/head.rs @@ -28,7 +28,7 @@ mod util; static NAME: &'static str = "head"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let mut line_count = 10us; let mut byte_count = 0us; diff --git a/src/hostid/hostid.rs b/src/hostid/hostid.rs index 42f7fa6a6..518e1a3b2 100644 --- a/src/hostid/hostid.rs +++ b/src/hostid/hostid.rs @@ -34,7 +34,7 @@ mod util; static NAME: &'static str = "hostid"; static VERSION: &'static str = "0.0.1"; -static EXIT_ERR: isize = 1; +static EXIT_ERR: i32 = 1; pub enum Mode { HostId, @@ -49,7 +49,7 @@ extern { pub fn gethostid() -> c_long; } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let opts = [ optflag("", "help", "display this help and exit"), diff --git a/src/hostname/hostname.rs b/src/hostname/hostname.rs index e5d56e4fd..3c88ac33f 100644 --- a/src/hostname/hostname.rs +++ b/src/hostname/hostname.rs @@ -43,7 +43,7 @@ extern { fn sethostname(name: *const libc::c_char, namelen: libc::size_t) -> libc::c_int; } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = &args[0]; let options = [ diff --git a/src/id/id.rs b/src/id/id.rs index 3232aa631..33fabf83f 100644 --- a/src/id/id.rs +++ b/src/id/id.rs @@ -85,7 +85,7 @@ extern { static NAME: &'static str = "id"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let args_t = args.tail(); let options = [ diff --git a/src/kill/kill.rs b/src/kill/kill.rs index 6efc22afe..fd978f35b 100644 --- a/src/kill/kill.rs +++ b/src/kill/kill.rs @@ -40,8 +40,8 @@ mod signals; static NAME: &'static str = "kill"; static VERSION: &'static str = "0.0.1"; -static EXIT_OK: isize = 0; -static EXIT_ERR: isize = 1; +static EXIT_OK: i32 = 0; +static EXIT_ERR: i32 = 1; pub enum Mode { Kill, @@ -53,7 +53,7 @@ pub enum Mode { impl Copy for Mode {} -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let opts = [ optflag("h", "help", "display this help and exit"), optflag("V", "version", "output version information and exit"), @@ -185,7 +185,7 @@ fn help(progname: &str, usage: &str) { println!("{}", get_help_text(progname, usage)); } -fn kill(signalname: &str, pids: std::vec::Vec) -> isize { +fn kill(signalname: &str, pids: std::vec::Vec) -> i32 { let mut status = 0; let optional_signal_value = signals::signal_by_name_or_value(signalname); let signal_value = match optional_signal_value { diff --git a/src/link/link.rs b/src/link/link.rs index 4dc3c710f..28d3d70f6 100644 --- a/src/link/link.rs +++ b/src/link/link.rs @@ -22,7 +22,7 @@ mod util; static NAME : &'static str = "link"; static VERSION : &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 4a015ae48..69224873c 100644 --- a/src/logname/logname.rs +++ b/src/logname/logname.rs @@ -46,7 +46,7 @@ fn version() { println!("{} {}", NAME, VERSION); } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].clone(); // diff --git a/src/mkdir/mkdir.rs b/src/mkdir/mkdir.rs index 646ccaed7..3b4dc0e30 100644 --- a/src/mkdir/mkdir.rs +++ b/src/mkdir/mkdir.rs @@ -27,7 +27,7 @@ static VERSION: &'static str = "1.0.0"; /** * Handles option parsing */ -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let opts = [ // Linux-specific options, not implemented @@ -94,7 +94,7 @@ fn print_help(opts: &[getopts::OptGroup]) { /** * Create the list of new directories */ -fn exec(dirs: Vec, mk_parents: bool, mode: FilePermission, verbose: bool) -> Result<(), isize> { +fn exec(dirs: Vec, mk_parents: bool, mode: FilePermission, verbose: bool) -> Result<(), i32> { let mut result = Ok(()); let mut parent_dirs = Vec::new(); diff --git a/src/mkfifo/mkfifo.rs b/src/mkfifo/mkfifo.rs index 3a67d08c5..0edec0edd 100644 --- a/src/mkfifo/mkfifo.rs +++ b/src/mkfifo/mkfifo.rs @@ -25,7 +25,7 @@ mod util; static NAME : &'static str = "mkfifo"; static VERSION : &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let opts = [ getopts::optopt("m", "mode", "file permissions for the fifo", "(default 0666)"), getopts::optflag("h", "help", "display this help and exit"), diff --git a/src/mv/mv.rs b/src/mv/mv.rs index be6692f9b..50c705435 100644 --- a/src/mv/mv.rs +++ b/src/mv/mv.rs @@ -62,7 +62,7 @@ pub enum BackupMode { impl Copy for BackupMode {} -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].as_slice(); let opts = [ optflagopt("", "backup", "make a backup of each existing destination file", "CONTROL"), @@ -187,7 +187,7 @@ fn help(progname: &str, usage: &str) { println!("{}", msg); } -fn exec(files: &[Path], b: Behaviour) -> isize { +fn exec(files: &[Path], b: Behaviour) -> i32 { match b.target_dir { Some(ref name) => return move_files_into_dir(files, &Path::new(name.as_slice()), &b), None => {} @@ -245,7 +245,7 @@ fn exec(files: &[Path], b: Behaviour) -> isize { 0 } -fn move_files_into_dir(files: &[Path], target_dir: &Path, b: &Behaviour) -> isize { +fn move_files_into_dir(files: &[Path], target_dir: &Path, b: &Behaviour) -> i32 { if !target_dir.is_dir() { show_error!("target ‘{}’ is not a directory", target_dir.display()); return 1; diff --git a/src/nice/nice.rs b/src/nice/nice.rs index 85fb72150..a1648071b 100644 --- a/src/nice/nice.rs +++ b/src/nice/nice.rs @@ -33,7 +33,7 @@ extern { fn setpriority(which: c_int, who: c_int, prio: c_int) -> c_int; } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 46cc8cfc6..f178a1ad4 100644 --- a/src/nl/nl.rs +++ b/src/nl/nl.rs @@ -77,7 +77,7 @@ enum NumberFormat { RightZero, } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 d4566f267..0713b4551 100644 --- a/src/nohup/nohup.rs +++ b/src/nohup/nohup.rs @@ -38,7 +38,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) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = &args[0]; let options = [ @@ -72,7 +72,7 @@ pub fn uumain(args: Vec) -> isize { let cstrs : Vec = opts.free.iter().map(|x| CString::from_slice(x.as_bytes())).collect(); let mut args : Vec<*const c_char> = cstrs.iter().map(|s| s.as_ptr()).collect(); args.push(std::ptr::null()); - unsafe { execvp(args[0], args.as_mut_ptr()) as isize } + unsafe { execvp(args[0], args.as_mut_ptr())} } fn replace_fds() { diff --git a/src/nproc/nproc.rs b/src/nproc/nproc.rs index 94807d114..2d5cd57ac 100644 --- a/src/nproc/nproc.rs +++ b/src/nproc/nproc.rs @@ -21,7 +21,7 @@ static VERSION : &'static str = "0.0.0"; #[macro_use] mod util; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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/od/od.rs b/src/od/od.rs index 0a841c181..7455be927 100644 --- a/src/od/od.rs +++ b/src/od/od.rs @@ -19,7 +19,7 @@ use std::old_io::File; #[derive(Debug)] enum Radix { Decimal, Hexadecimal, Octal, Binary } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let opts = [ getopts::optopt("A", "address-radix", "Select the base in which file offsets are printed.", "RADIX"), diff --git a/src/paste/paste.rs b/src/paste/paste.rs index aed77fa2b..3eab0631f 100644 --- a/src/paste/paste.rs +++ b/src/paste/paste.rs @@ -23,7 +23,7 @@ mod util; static NAME: &'static str = "paste"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].clone(); let opts = [ diff --git a/src/printenv/printenv.rs b/src/printenv/printenv.rs index b818eb5fa..3d14893a4 100644 --- a/src/printenv/printenv.rs +++ b/src/printenv/printenv.rs @@ -24,7 +24,7 @@ mod util; static NAME: &'static str = "printenv"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 e2c2d6337..ec5178f27 100644 --- a/src/pwd/pwd.rs +++ b/src/pwd/pwd.rs @@ -22,7 +22,7 @@ mod util; static NAME: &'static str = "pwd"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].clone(); let opts = [ getopts::optflag("", "help", "display this help and exit"), diff --git a/src/readlink/readlink.rs b/src/readlink/readlink.rs index 9134bd648..771609ccb 100644 --- a/src/readlink/readlink.rs +++ b/src/readlink/readlink.rs @@ -110,7 +110,7 @@ fn canonicalize(original: &Path, can_mode: &CanonicalizeMode) -> io::IoResult) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].as_slice(); let opts = [ optflag("f", "canonicalize", diff --git a/src/realpath/realpath.rs b/src/realpath/realpath.rs index 4bf93c26f..2de84d0b5 100644 --- a/src/realpath/realpath.rs +++ b/src/realpath/realpath.rs @@ -20,7 +20,7 @@ use getopts::{optflag, getopts, usage}; static NAME: &'static str = "realpath"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 5240bba7f..70e95fa2e 100644 --- a/src/relpath/relpath.rs +++ b/src/relpath/relpath.rs @@ -20,7 +20,7 @@ use getopts::{optflag, optopt, getopts, usage}; static NAME: &'static str = "relpath"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 b448c9a5c..a87be39b8 100644 --- a/src/rm/rm.rs +++ b/src/rm/rm.rs @@ -31,7 +31,7 @@ impl Copy for InteractiveMode {} static NAME: &'static str = "rm"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].clone(); // TODO: make getopts support -R in addition to -r @@ -126,7 +126,7 @@ pub fn uumain(args: Vec) -> isize { } // TODO: implement one-file-system -fn remove(files: Vec, force: bool, interactive: InteractiveMode, one_fs: bool, preserve_root: bool, recursive: bool, dir: bool, verbose: bool) -> Result<(), isize> { +fn remove(files: Vec, force: bool, interactive: InteractiveMode, one_fs: bool, preserve_root: bool, recursive: bool, dir: bool, verbose: bool) -> Result<(), i32> { let mut r = Ok(()); for filename in files.iter() { @@ -168,7 +168,7 @@ fn remove(files: Vec, force: bool, interactive: InteractiveMode, one_fs: r } -fn remove_dir(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), isize> { +fn remove_dir(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), i32> { let response = if interactive == InteractiveMode::InteractiveAlways { prompt_file(path, name) @@ -188,7 +188,7 @@ fn remove_dir(path: &Path, name: &str, interactive: InteractiveMode, verbose: bo Ok(()) } -fn remove_file(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), isize> { +fn remove_file(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), i32> { let response = if interactive == InteractiveMode::InteractiveAlways { prompt_file(path, name) diff --git a/src/rmdir/rmdir.rs b/src/rmdir/rmdir.rs index 2412cb5dd..9e21433e7 100644 --- a/src/rmdir/rmdir.rs +++ b/src/rmdir/rmdir.rs @@ -22,7 +22,7 @@ mod util; static NAME: &'static str = "rmdir"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].clone(); let opts = [ @@ -66,7 +66,7 @@ pub fn uumain(args: Vec) -> isize { 0 } -fn remove(dirs: Vec, ignore: bool, parents: bool, verbose: bool) -> Result<(), isize>{ +fn remove(dirs: Vec, ignore: bool, parents: bool, verbose: bool) -> Result<(), i32>{ let mut r = Ok(()); for dir in dirs.iter() { @@ -87,7 +87,7 @@ fn remove(dirs: Vec, ignore: bool, parents: bool, verbose: bool) -> Resu r } -fn remove_dir(path: &Path, dir: &str, ignore: bool, parents: bool, verbose: bool) -> Result<(), isize> { +fn remove_dir(path: &Path, dir: &str, ignore: bool, parents: bool, verbose: bool) -> Result<(), i32> { let mut walk_dir = match fs::walk_dir(path) { Ok(m) => m, Err(f) => { diff --git a/src/seq/seq.rs b/src/seq/seq.rs index 9d8ef4239..7f2702324 100644 --- a/src/seq/seq.rs +++ b/src/seq/seq.rs @@ -37,7 +37,7 @@ fn escape_sequences(s: &str) -> String { replace("\\t", "\t") } -fn parse_options(args: Vec, options: &mut SeqOptions) -> Result, isize> { +fn parse_options(args: Vec, options: &mut SeqOptions) -> Result, i32> { let mut seq_args = vec!(); let program = args[0].clone(); let mut iter = args.into_iter().skip(1); @@ -146,7 +146,7 @@ fn print_version() { println!("seq 1.0.0\n"); } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 48fb4844a..3548969ae 100644 --- a/src/shuf/shuf.rs +++ b/src/shuf/shuf.rs @@ -33,7 +33,7 @@ enum Mode { static NAME: &'static str = "shuf"; static VERSION: &'static str = "0.0.1"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].clone(); let opts = [ @@ -186,7 +186,7 @@ fn shuf_lines(mut lines: Vec, repeat: bool, zero: bool, count: usize, ou Ok(()) } -fn parse_range(input_range: String) -> Result, (String, isize)> { +fn parse_range(input_range: String) -> Result, (String, i32)> { let split: Vec<&str> = input_range.as_slice().split('-').collect(); if split.len() != 2 { Err(("invalid range format".to_string(), 1)) diff --git a/src/sleep/sleep.rs b/src/sleep/sleep.rs index c917021e5..60ebc9d5b 100644 --- a/src/sleep/sleep.rs +++ b/src/sleep/sleep.rs @@ -26,7 +26,7 @@ mod time; static NAME: &'static str = "sleep"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].clone(); let opts = [ diff --git a/src/sort/sort.rs b/src/sort/sort.rs index 0d3b12093..e5ba04cef 100644 --- a/src/sort/sort.rs +++ b/src/sort/sort.rs @@ -29,7 +29,7 @@ static VERSION: &'static str = "0.0.1"; static DECIMAL_PT: char = '.'; static THOUSANDS_SEP: char = ','; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].as_slice(); let opts = [ getopts::optflag("n", "numeric-sort", "compare according to string numerical value"), diff --git a/src/split/split.rs b/src/split/split.rs index c92170e2a..7f92b8498 100644 --- a/src/split/split.rs +++ b/src/split/split.rs @@ -24,7 +24,7 @@ mod util; static NAME: &'static str = "split"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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"), @@ -248,7 +248,7 @@ fn num_prefix(i: usize, width: usize) -> String { c } -fn split(settings: &Settings) -> isize { +fn split(settings: &Settings) -> i32 { let mut reader = io::BufferedReader::new( if settings.input.as_slice() == "-" { Box::new(io::stdio::stdin_raw()) as Box diff --git a/src/stdbuf/stdbuf.rs b/src/stdbuf/stdbuf.rs index da8e4bc58..555385d71 100644 --- a/src/stdbuf/stdbuf.rs +++ b/src/stdbuf/stdbuf.rs @@ -205,7 +205,7 @@ fn get_preload_env() -> (String, String) { } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let optgrps = [ optopt("i", "input", "adjust standard input stream buffering", "MODE"), optopt("o", "output", "adjust standard output stream buffering", "MODE"), @@ -251,7 +251,7 @@ pub fn uumain(args: Vec) -> isize { match process.wait() { Ok(status) => { match status { - ProcessExit::ExitStatus(i) => return i, + ProcessExit::ExitStatus(i) => return i as i32, ProcessExit::ExitSignal(i) => crash!(1, "process killed by signal {}", i), } }, diff --git a/src/sum/sum.rs b/src/sum/sum.rs index 291ad8737..d843e6216 100644 --- a/src/sum/sum.rs +++ b/src/sum/sum.rs @@ -76,7 +76,7 @@ fn open(name: &str) -> IoResult> { } } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 36188768f..f827f7bae 100644 --- a/src/sync/sync.rs +++ b/src/sync/sync.rs @@ -140,7 +140,7 @@ mod platform { } } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = &args[0][]; let options = [ diff --git a/src/tac/tac.rs b/src/tac/tac.rs index 07b49bbd8..a35b5952a 100644 --- a/src/tac/tac.rs +++ b/src/tac/tac.rs @@ -22,7 +22,7 @@ mod util; static NAME: &'static str = "tac"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].clone(); let opts = [ diff --git a/src/tail/tail.rs b/src/tail/tail.rs index 1e27f521d..c102992bd 100644 --- a/src/tail/tail.rs +++ b/src/tail/tail.rs @@ -31,7 +31,7 @@ mod util; static NAME: &'static str = "tail"; static VERSION: &'static str = "0.0.1"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let mut beginning = false; let mut lines = true; let mut byte_count = 0us; diff --git a/src/tee/tee.rs b/src/tee/tee.rs index 204f27536..754857eb1 100644 --- a/src/tee/tee.rs +++ b/src/tee/tee.rs @@ -22,7 +22,7 @@ use getopts::{getopts, optflag, usage}; static NAME: &'static str = "tee"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 88c8d42c6..f5baf4111 100644 --- a/src/test/test.rs +++ b/src/test/test.rs @@ -20,7 +20,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) -> isize { +pub fn uumain(_: Vec) -> i32 { let args = args_as_bytes(); let args: Vec<&[u8]> = args.iter().map(|a| a.as_slice()).collect(); if args.len() == 0 { @@ -40,7 +40,7 @@ pub fn uumain(_: Vec) -> isize { _ => &args[1..args.len()], }; let mut error = false; - let retval = 1 - parse_expr(args, &mut error) as isize; + let retval = 1 - parse_expr(args, &mut error) as i32; if error { 2 } else { diff --git a/src/timeout/timeout.rs b/src/timeout/timeout.rs index 6845db853..31145f6db 100644 --- a/src/timeout/timeout.rs +++ b/src/timeout/timeout.rs @@ -33,9 +33,9 @@ extern { static NAME: &'static str = "timeout"; static VERSION: &'static str = "1.0.0"; -static ERR_EXIT_STATUS: isize = 125; +static ERR_EXIT_STATUS: i32 = 125; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].clone(); let opts = [ @@ -101,7 +101,7 @@ Usage: 0 } -fn timeout(cmdname: &str, args: &[String], duration: f64, signal: usize, kill_after: f64, foreground: bool, preserve_status: bool) -> isize { +fn timeout(cmdname: &str, args: &[String], duration: f64, signal: usize, kill_after: f64, foreground: bool, preserve_status: bool) -> i32 { if !foreground { unsafe { setpgid(0, 0) }; } @@ -125,8 +125,8 @@ fn timeout(cmdname: &str, args: &[String], duration: f64, signal: usize, kill_af process.set_timeout(Some((duration * 1000f64) as u64)); // FIXME: this ignores the f64... match process.wait() { Ok(status) => match status { - ExitStatus(stat) => stat, - ExitSignal(stat) => stat + ExitStatus(stat) => stat as i32, + ExitSignal(stat) => stat as i32 }, Err(_) => { return_if_err!(ERR_EXIT_STATUS, process.signal(signal as isize)); @@ -135,8 +135,8 @@ fn timeout(cmdname: &str, args: &[String], duration: f64, signal: usize, kill_af Ok(status) => { if preserve_status { match status { - ExitStatus(stat) => stat, - ExitSignal(stat) => stat + ExitStatus(stat) => stat as i32, + ExitSignal(stat) => stat as i32 } } else { 124 diff --git a/src/touch/touch.rs b/src/touch/touch.rs index ea2aa8cfa..9048c1066 100644 --- a/src/touch/touch.rs +++ b/src/touch/touch.rs @@ -23,7 +23,7 @@ mod util; static NAME: &'static str = "touch"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 69a34ea18..7f41bc05d 100644 --- a/src/tr/tr.rs +++ b/src/tr/tr.rs @@ -161,7 +161,7 @@ fn usage(opts: &[OptGroup]) { print(getopts::usage("Translate or delete characters.", opts).as_slice()); } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 9909466d6..772870f54 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) -> isize { +pub fn uumain(_: Vec) -> i32 { 0 } diff --git a/src/truncate/truncate.rs b/src/truncate/truncate.rs index a7346d9c9..39686dd3d 100644 --- a/src/truncate/truncate.rs +++ b/src/truncate/truncate.rs @@ -34,7 +34,7 @@ enum TruncateMode { static NAME: &'static str = "truncate"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].clone(); let opts = [ @@ -100,7 +100,7 @@ file based on its current size: 0 } -fn truncate(no_create: bool, _: bool, reference: Option, size: Option, filenames: Vec) -> Result<(), isize> { +fn truncate(no_create: bool, _: bool, reference: Option, size: Option, filenames: Vec) -> Result<(), i32> { let (refsize, mode) = match reference { Some(rfilename) => { let rfile = match File::open(&Path::new(rfilename.clone())) { diff --git a/src/tsort/tsort.rs b/src/tsort/tsort.rs index 33a82357e..efb7df8cb 100644 --- a/src/tsort/tsort.rs +++ b/src/tsort/tsort.rs @@ -24,7 +24,7 @@ mod util; static NAME: &'static str = "tsort"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 97488db82..9e7a6658b 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) -> isize { +pub fn uumain(args: Vec) -> i32 { let options = [ optflag("s", "silent", "print nothing, only return an exit status") ]; @@ -74,7 +74,7 @@ pub fn uumain(args: Vec) -> isize { } }; - exit_code as isize + exit_code } fn usage () { diff --git a/src/uname/uname.rs b/src/uname/uname.rs index ee61ec12c..4008c4bda 100644 --- a/src/uname/uname.rs +++ b/src/uname/uname.rs @@ -56,7 +56,7 @@ unsafe fn getuname() -> utsrust { static NAME: &'static str = "uname"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 dfa0ee196..cb74b3fb6 100644 --- a/src/unexpand/unexpand.rs +++ b/src/unexpand/unexpand.rs @@ -73,7 +73,7 @@ impl Options { } } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 1125943d2..2e0f01bb7 100644 --- a/src/uniq/uniq.rs +++ b/src/uniq/uniq.rs @@ -119,7 +119,7 @@ fn opt_parsed(opt_name: &str, matches: &getopts::Matches) -> Option< }) } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program_path = Path::new(args[0].clone()); let program = program_path.filename_str().unwrap_or(NAME); diff --git a/src/unlink/unlink.rs b/src/unlink/unlink.rs index 941313637..bf6f3dcee 100644 --- a/src/unlink/unlink.rs +++ b/src/unlink/unlink.rs @@ -25,7 +25,7 @@ mod util; static NAME: &'static str = "unlink"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 14a949205..8d330e779 100644 --- a/src/uptime/uptime.rs +++ b/src/uptime/uptime.rs @@ -55,7 +55,7 @@ unsafe extern fn utmpxname(_file: *const c_char) -> c_int { 0 } -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 7579105ad..65b36d65f 100644 --- a/src/users/users.rs +++ b/src/users/users.rs @@ -52,7 +52,7 @@ unsafe extern fn utmpxname(_file: *const libc::c_char) -> libc::c_int { static NAME: &'static str = "users"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = args[0].as_slice(); let opts = [ getopts::optflag("h", "help", "display this help and exit"), diff --git a/src/uutils/uutils.rs b/src/uutils/uutils.rs index 0e2dd4560..b839c8a3f 100644 --- a/src/uutils/uutils.rs +++ b/src/uutils/uutils.rs @@ -1,5 +1,5 @@ #![crate_name = "uutils"] -#![feature(core, os, path, rustc_private)] +#![feature(core, env, os, path, rustc_private)] /* * This file is part of the uutils coreutils package. @@ -14,19 +14,20 @@ extern crate getopts; @CRATES@ +use std::env; use std::os; use std::collections::hash_map::HashMap; static NAME: &'static str = "uutils"; static VERSION: &'static str = "1.0.0"; -fn util_map() -> HashMap<&'static str, fn(Vec) -> isize> { +fn util_map() -> HashMap<&'static str, fn(Vec) -> i32> { let mut map = HashMap::new(); @UTIL_MAP@ map } -fn usage(cmap: &HashMap<&'static str, fn(Vec) -> isize>) { +fn usage(cmap: &HashMap<&'static str, fn(Vec) -> i32>) { println!("{} {}", NAME, VERSION); println!(""); println!("Usage:"); @@ -49,7 +50,7 @@ fn main() { match umap.get(binary_as_util) { Some(&uumain) => { - os::set_exit_status(uumain(args)); + env::set_exit_status(uumain(args)); return } None => (), @@ -62,7 +63,7 @@ fn main() { // what busybox uses the -suffix pattern for. } else { println!("{}: applet not found", binary_as_util); - os::set_exit_status(1); + env::set_exit_status(1); return } @@ -73,7 +74,7 @@ fn main() { match umap.get(util) { Some(&uumain) => { - os::set_exit_status(uumain(args.clone())); + env::set_exit_status(uumain(args.clone())); return } None => { @@ -83,22 +84,22 @@ fn main() { let util = args[1].as_slice(); match umap.get(util) { Some(&uumain) => { - os::set_exit_status(uumain(vec![util.to_string(), "--help".to_string()])); + env::set_exit_status(uumain(vec![util.to_string(), "--help".to_string()])); return } None => { println!("{}: applet not found", util); - os::set_exit_status(1); + env::set_exit_status(1); return } } } usage(&umap); - os::set_exit_status(0); + env::set_exit_status(0); return } else { println!("{}: applet not found", util); - os::set_exit_status(1); + env::set_exit_status(1); return } } @@ -106,7 +107,7 @@ fn main() { } else { // no arguments provided usage(&umap); - os::set_exit_status(0); + env::set_exit_status(0); return } } diff --git a/src/wc/wc.rs b/src/wc/wc.rs index 177d432aa..18078ba0f 100644 --- a/src/wc/wc.rs +++ b/src/wc/wc.rs @@ -37,7 +37,7 @@ struct Result { static NAME: &'static str = "wc"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = &args[0][]; let opts = [ getopts::optflag("c", "bytes", "print the byte counts"), @@ -97,7 +97,7 @@ fn is_word_seperator(byte: u8) -> bool { byte == SPACE || byte == TAB || byte == CR || byte == SYN || byte == FF } -pub fn wc(files: &[String], matches: &Matches) -> StdResult<(), isize> { +pub fn wc(files: &[String], matches: &Matches) -> StdResult<(), i32> { let mut total_line_count: usize = 0; let mut total_word_count: usize = 0; let mut total_char_count: usize = 0; @@ -217,7 +217,7 @@ fn print_stats(filename: &str, line_count: usize, word_count: usize, char_count: } } -fn open(path: &str) -> StdResult>, isize> { +fn open(path: &str) -> StdResult>, i32> { if "-" == path { let reader = Box::new(stdin_raw()) as Box; return Ok(BufferedReader::new(reader)); diff --git a/src/whoami/whoami.rs b/src/whoami/whoami.rs index d8eb3bc61..9972b8060 100644 --- a/src/whoami/whoami.rs +++ b/src/whoami/whoami.rs @@ -61,7 +61,7 @@ mod platform { static NAME: &'static str = "whoami"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { 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 f5ee681a4..70755bd55 100644 --- a/src/yes/yes.rs +++ b/src/yes/yes.rs @@ -24,7 +24,7 @@ mod util; static NAME: &'static str = "yes"; -pub fn uumain(args: Vec) -> isize { +pub fn uumain(args: Vec) -> i32 { let program = &args[0]; let opts = [ getopts::optflag("h", "help", "display this help and exit"), From 910fd61070b700a839ab81e0a89712317b45a8b2 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Fri, 6 Feb 2015 15:04:02 +0100 Subject: [PATCH 02/11] os::args -> env::args --- mkmain.rs | 10 ++++++---- mkuutils.rs | 2 +- src/tee/tee.rs | 2 +- src/uutils/uutils.rs | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/mkmain.rs b/mkmain.rs index ebb71d26a..7dd36fc0b 100644 --- a/mkmain.rs +++ b/mkmain.rs @@ -1,7 +1,6 @@ #![feature(core, env, io, os, path)] use std::env; use std::old_io::{File, Truncate, ReadWrite}; -use std::os; use std::old_path::Path; static TEMPLATE: &'static str = "\ @@ -9,16 +8,19 @@ static TEMPLATE: &'static str = "\ extern crate \"@UTIL_CRATE@\" as uu@UTIL_CRATE@; use std::env; -use std::os; use uu@UTIL_CRATE@::uumain; +fn args() -> Vec { + env::args().map(|a| a.into_string().unwrap()).collect() +} + fn main() { - env::set_exit_status(uumain(os::args())); + env::set_exit_status(uumain(args())); } "; fn main() { - let args = os::args(); + let args : Vec = env::args().map(|a| a.into_string().unwrap()).collect(); if args.len() != 3 { println!("usage: mkbuild "); env::set_exit_status(1); diff --git a/mkuutils.rs b/mkuutils.rs index e9a2c0984..d30d6bb21 100644 --- a/mkuutils.rs +++ b/mkuutils.rs @@ -6,7 +6,7 @@ use std::os; use std::old_path::Path; fn main() { - let args = os::args(); + let args : Vec = env::args().map(|a| a.into_string().unwrap()).collect(); if args.len() < 3 { println!("usage: mkuutils "); env::set_exit_status(1); diff --git a/src/tee/tee.rs b/src/tee/tee.rs index 754857eb1..199105be6 100644 --- a/src/tee/tee.rs +++ b/src/tee/tee.rs @@ -150,5 +150,5 @@ fn with_path(path: &Path, mut cb: F) -> IoResult where F: FnMut() -> Io } fn warn(message: &str) { - error!("{}: {}", os::args()[0], message); + error!("tee: {}", message); } diff --git a/src/uutils/uutils.rs b/src/uutils/uutils.rs index b839c8a3f..aaf92bc74 100644 --- a/src/uutils/uutils.rs +++ b/src/uutils/uutils.rs @@ -42,7 +42,7 @@ fn usage(cmap: &HashMap<&'static str, fn(Vec) -> i32>) { fn main() { let umap = util_map(); - let mut args = os::args(); + let mut args : Vec = env::args().map(|a| a.into_string().unwrap()).collect(); // try binary name as util name. let binary = Path::new(args[0].as_slice()); From ec9c8659ea16bcf2797eeb398f88c6b027e17413 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sun, 8 Feb 2015 20:59:30 +0100 Subject: [PATCH 03/11] Drop unused imports --- mkuutils.rs | 1 - src/uutils/uutils.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/mkuutils.rs b/mkuutils.rs index d30d6bb21..a62a1a808 100644 --- a/mkuutils.rs +++ b/mkuutils.rs @@ -2,7 +2,6 @@ use std::env; use std::old_io::{File, Truncate, Write}; -use std::os; use std::old_path::Path; fn main() { diff --git a/src/uutils/uutils.rs b/src/uutils/uutils.rs index aaf92bc74..e52a62b9d 100644 --- a/src/uutils/uutils.rs +++ b/src/uutils/uutils.rs @@ -15,7 +15,6 @@ extern crate getopts; @CRATES@ use std::env; -use std::os; use std::collections::hash_map::HashMap; static NAME: &'static str = "uutils"; From 50301e63ee1322ea61b0c4223590b019f4089806 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Fri, 13 Feb 2015 20:57:47 +0100 Subject: [PATCH 04/11] env::args return Strings now --- mkmain.rs | 8 ++------ mkuutils.rs | 2 +- src/uutils/uutils.rs | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/mkmain.rs b/mkmain.rs index 7dd36fc0b..c4ad449a9 100644 --- a/mkmain.rs +++ b/mkmain.rs @@ -10,17 +10,13 @@ extern crate \"@UTIL_CRATE@\" as uu@UTIL_CRATE@; use std::env; use uu@UTIL_CRATE@::uumain; -fn args() -> Vec { - env::args().map(|a| a.into_string().unwrap()).collect() -} - fn main() { - env::set_exit_status(uumain(args())); + env::set_exit_status(uumain(env::args().collect())); } "; fn main() { - let args : Vec = env::args().map(|a| a.into_string().unwrap()).collect(); + let args : Vec = env::args().collect(); if args.len() != 3 { println!("usage: mkbuild "); env::set_exit_status(1); diff --git a/mkuutils.rs b/mkuutils.rs index a62a1a808..ad6d91493 100644 --- a/mkuutils.rs +++ b/mkuutils.rs @@ -5,7 +5,7 @@ use std::old_io::{File, Truncate, Write}; use std::old_path::Path; fn main() { - let args : Vec = env::args().map(|a| a.into_string().unwrap()).collect(); + let args : Vec = env::args().collect(); if args.len() < 3 { println!("usage: mkuutils "); env::set_exit_status(1); diff --git a/src/uutils/uutils.rs b/src/uutils/uutils.rs index e52a62b9d..eb328d4db 100644 --- a/src/uutils/uutils.rs +++ b/src/uutils/uutils.rs @@ -41,7 +41,7 @@ fn usage(cmap: &HashMap<&'static str, fn(Vec) -> i32>) { fn main() { let umap = util_map(); - let mut args : Vec = env::args().map(|a| a.into_string().unwrap()).collect(); + let mut args : Vec = env::args().collect(); // try binary name as util name. let binary = Path::new(args[0].as_slice()); From 4e79a82f46d0f8e2c6dd739108fa5ecc3f6e3d1c Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Fri, 13 Feb 2015 21:12:44 +0100 Subject: [PATCH 05/11] fix feature warnings --- mkmain.rs | 4 ++-- mkuutils.rs | 2 +- src/mkfifo/mkfifo.rs | 2 +- src/nice/nice.rs | 2 +- src/stdbuf/libstdbuf.rs | 2 +- src/tee/tee.rs | 1 - src/uutils/uutils.rs | 2 +- 7 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mkmain.rs b/mkmain.rs index c4ad449a9..64c193688 100644 --- a/mkmain.rs +++ b/mkmain.rs @@ -1,10 +1,10 @@ -#![feature(core, env, io, os, path)] +#![feature(core, env, io, path)] use std::env; use std::old_io::{File, Truncate, ReadWrite}; use std::old_path::Path; static TEMPLATE: &'static str = "\ -#![feature(env, os)] +#![feature(env)] extern crate \"@UTIL_CRATE@\" as uu@UTIL_CRATE@; use std::env; diff --git a/mkuutils.rs b/mkuutils.rs index ad6d91493..7f7b1d4c5 100644 --- a/mkuutils.rs +++ b/mkuutils.rs @@ -1,4 +1,4 @@ -#![feature(core, env, io, os, path)] +#![feature(core, env, io, path)] use std::env; use std::old_io::{File, Truncate, Write}; diff --git a/src/mkfifo/mkfifo.rs b/src/mkfifo/mkfifo.rs index 0edec0edd..7695fb520 100644 --- a/src/mkfifo/mkfifo.rs +++ b/src/mkfifo/mkfifo.rs @@ -1,5 +1,5 @@ #![crate_name = "mkfifo"] -#![feature(collections, core, rustc_private, std_misc)] +#![feature(collections, core, os, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/nice/nice.rs b/src/nice/nice.rs index a1648071b..5c87694ba 100644 --- a/src/nice/nice.rs +++ b/src/nice/nice.rs @@ -1,5 +1,5 @@ #![crate_name = "nice"] -#![feature(collections, core, os, rustc_private, std_misc)] +#![feature(collections, core, io, os, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/stdbuf/libstdbuf.rs b/src/stdbuf/libstdbuf.rs index e55402b6b..d530b09ce 100644 --- a/src/stdbuf/libstdbuf.rs +++ b/src/stdbuf/libstdbuf.rs @@ -1,6 +1,6 @@ #![crate_name = "libstdbuf"] #![crate_type = "staticlib"] -#![feature(core, os)] +#![feature(core, libc, os)] extern crate libc; use libc::{c_int, size_t, c_char, FILE, _IOFBF, _IONBF, _IOLBF, setvbuf}; diff --git a/src/tee/tee.rs b/src/tee/tee.rs index 199105be6..78a7a1604 100644 --- a/src/tee/tee.rs +++ b/src/tee/tee.rs @@ -16,7 +16,6 @@ extern crate getopts; use std::old_io::{println, stdin, stdout, Append, File, Truncate, Write}; use std::old_io::{IoResult}; use std::old_io::util::{copy, NullWriter, MultiWriter}; -use std::os; use getopts::{getopts, optflag, usage}; static NAME: &'static str = "tee"; diff --git a/src/uutils/uutils.rs b/src/uutils/uutils.rs index eb328d4db..fcfc380b6 100644 --- a/src/uutils/uutils.rs +++ b/src/uutils/uutils.rs @@ -1,5 +1,5 @@ #![crate_name = "uutils"] -#![feature(core, env, os, path, rustc_private)] +#![feature(core, env, path, rustc_private)] /* * This file is part of the uutils coreutils package. From 9ae9a48387fad389b1b93ba680207f94277b5b6f Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sun, 22 Feb 2015 12:21:06 +0100 Subject: [PATCH 06/11] feature io -> old_io, path -> old_path --- mkmain.rs | 2 +- mkuutils.rs | 2 +- src/base64/base64.rs | 2 +- src/basename/basename.rs | 2 +- src/cat/cat.rs | 2 +- src/chmod/chmod.rs | 2 +- src/chroot/chroot.rs | 2 +- src/cksum/cksum.rs | 2 +- src/comm/comm.rs | 2 +- src/cp/cp.rs | 2 +- src/cut/cut.rs | 2 +- src/dirname/dirname.rs | 2 +- src/du/du.rs | 2 +- src/echo/echo.rs | 2 +- src/env/env.rs | 2 +- src/expand/expand.rs | 2 +- src/factor/factor.rs | 2 +- src/fold/fold.rs | 2 +- src/hashsum/hashsum.rs | 2 +- src/head/head.rs | 2 +- src/hostname/hostname.rs | 2 +- src/kill/kill.rs | 2 +- src/link/link.rs | 2 +- src/logname/logname.rs | 2 +- src/mkdir/mkdir.rs | 2 +- src/mv/mv.rs | 2 +- src/nice/nice.rs | 2 +- src/nl/nl.rs | 2 +- src/nohup/nohup.rs | 2 +- src/od/od.rs | 2 +- src/paste/paste.rs | 2 +- src/printenv/printenv.rs | 2 +- src/pwd/pwd.rs | 2 +- src/readlink/readlink.rs | 2 +- src/realpath/realpath.rs | 2 +- src/relpath/relpath.rs | 2 +- src/rm/rm.rs | 2 +- src/rmdir/rmdir.rs | 2 +- src/shuf/shuf.rs | 2 +- src/sleep/sleep.rs | 2 +- src/sort/sort.rs | 2 +- src/split/split.rs | 2 +- src/stdbuf/stdbuf.rs | 2 +- src/sum/sum.rs | 2 +- src/tac/tac.rs | 2 +- src/tail/tail.rs | 2 +- src/tee/tee.rs | 2 +- src/timeout/timeout.rs | 2 +- src/touch/touch.rs | 2 +- src/tr/tr.rs | 2 +- src/truncate/truncate.rs | 2 +- src/tsort/tsort.rs | 2 +- src/tty/tty.rs | 2 +- src/uname/uname.rs | 2 +- src/unexpand/unexpand.rs | 2 +- src/uniq/uniq.rs | 2 +- src/unlink/unlink.rs | 2 +- src/uptime/uptime.rs | 2 +- src/users/users.rs | 2 +- src/uutils/uutils.rs | 2 +- src/wc/wc.rs | 2 +- src/whoami/whoami.rs | 2 +- src/yes/yes.rs | 2 +- 63 files changed, 63 insertions(+), 63 deletions(-) diff --git a/mkmain.rs b/mkmain.rs index 64c193688..b33c735aa 100644 --- a/mkmain.rs +++ b/mkmain.rs @@ -1,4 +1,4 @@ -#![feature(core, env, io, path)] +#![feature(core, env, old_io, old_path)] use std::env; use std::old_io::{File, Truncate, ReadWrite}; use std::old_path::Path; diff --git a/mkuutils.rs b/mkuutils.rs index 7f7b1d4c5..48445cdc2 100644 --- a/mkuutils.rs +++ b/mkuutils.rs @@ -1,4 +1,4 @@ -#![feature(core, env, io, path)] +#![feature(core, env, old_io, old_path)] use std::env; use std::old_io::{File, Truncate, Write}; diff --git a/src/base64/base64.rs b/src/base64/base64.rs index e3ec11784..79980491a 100644 --- a/src/base64/base64.rs +++ b/src/base64/base64.rs @@ -1,5 +1,5 @@ #![crate_name = "base64"] -#![feature(collections, core, io, path, rustc_private, std_misc)] +#![feature(collections, core, old_io, old_path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/basename/basename.rs b/src/basename/basename.rs index 07d3f564a..7bc4ae57f 100644 --- a/src/basename/basename.rs +++ b/src/basename/basename.rs @@ -1,5 +1,5 @@ #![crate_name = "basename"] -#![feature(collections, core, io, rustc_private)] +#![feature(collections, core, old_io, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/cat/cat.rs b/src/cat/cat.rs index 1f7ac50e9..bbb6832c5 100644 --- a/src/cat/cat.rs +++ b/src/cat/cat.rs @@ -1,5 +1,5 @@ #![crate_name = "cat"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] #![feature(box_syntax, unsafe_destructor)] diff --git a/src/chmod/chmod.rs b/src/chmod/chmod.rs index 38ee088d3..8680eb635 100644 --- a/src/chmod/chmod.rs +++ b/src/chmod/chmod.rs @@ -1,5 +1,5 @@ #![crate_name = "chmod"] -#![feature(collections, core, io, path, rustc_private, std_misc)] +#![feature(collections, core, old_io, old_path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/chroot/chroot.rs b/src/chroot/chroot.rs index 2f60cfa67..de5b5d083 100644 --- a/src/chroot/chroot.rs +++ b/src/chroot/chroot.rs @@ -1,5 +1,5 @@ #![crate_name = "chroot"] -#![feature(collections, core, io, os, path, rustc_private, std_misc)] +#![feature(collections, core, old_io, os, old_path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/cksum/cksum.rs b/src/cksum/cksum.rs index 7f734e470..da30deeec 100644 --- a/src/cksum/cksum.rs +++ b/src/cksum/cksum.rs @@ -1,5 +1,5 @@ #![crate_name = "cksum"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/comm/comm.rs b/src/comm/comm.rs index c4594fb01..8d37027ca 100644 --- a/src/comm/comm.rs +++ b/src/comm/comm.rs @@ -1,5 +1,5 @@ #![crate_name = "comm"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/cp/cp.rs b/src/cp/cp.rs index 446f2d3be..a222ae2b5 100644 --- a/src/cp/cp.rs +++ b/src/cp/cp.rs @@ -1,5 +1,5 @@ #![crate_name = "cp"] -#![feature(collections, core, io, os, path, rustc_private)] +#![feature(collections, core, old_io, os, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/cut/cut.rs b/src/cut/cut.rs index ac276fe86..69f532ba8 100644 --- a/src/cut/cut.rs +++ b/src/cut/cut.rs @@ -1,5 +1,5 @@ #![crate_name = "cut"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/dirname/dirname.rs b/src/dirname/dirname.rs index 6efbd4bb4..839fff7cb 100644 --- a/src/dirname/dirname.rs +++ b/src/dirname/dirname.rs @@ -1,5 +1,5 @@ #![crate_name = "dirname"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/du/du.rs b/src/du/du.rs index ebed7b20f..96cab13cc 100644 --- a/src/du/du.rs +++ b/src/du/du.rs @@ -1,5 +1,5 @@ #![crate_name = "du"] -#![feature(collections, core, io, path, rustc_private, std_misc, unicode)] +#![feature(collections, core, old_io, old_path, rustc_private, std_misc, unicode)] /* * This file is part of the uutils coreutils package. diff --git a/src/echo/echo.rs b/src/echo/echo.rs index 3e6aaf188..19967b398 100644 --- a/src/echo/echo.rs +++ b/src/echo/echo.rs @@ -1,5 +1,5 @@ #![crate_name = "echo"] -#![feature(collections, core, io, rustc_private)] +#![feature(collections, core, old_io, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/env/env.rs b/src/env/env.rs index be91133c8..65a1799e6 100644 --- a/src/env/env.rs +++ b/src/env/env.rs @@ -1,5 +1,5 @@ #![crate_name = "env"] -#![feature(core, io, os)] +#![feature(core, old_io, os)] /* * This file is part of the uutils coreutils package. diff --git a/src/expand/expand.rs b/src/expand/expand.rs index 9ed8663ca..4ee390efc 100644 --- a/src/expand/expand.rs +++ b/src/expand/expand.rs @@ -1,5 +1,5 @@ #![crate_name = "expand"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/factor/factor.rs b/src/factor/factor.rs index 79de45d2a..e3822bf4e 100644 --- a/src/factor/factor.rs +++ b/src/factor/factor.rs @@ -1,5 +1,5 @@ #![crate_name = "factor"] -#![feature(collections, core, io, rustc_private)] +#![feature(collections, core, old_io, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/fold/fold.rs b/src/fold/fold.rs index 3a7673d95..126f1ee23 100644 --- a/src/fold/fold.rs +++ b/src/fold/fold.rs @@ -1,5 +1,5 @@ #![crate_name = "fold"] -#![feature(collections, core, io, path, rustc_private, unicode)] +#![feature(collections, core, old_io, old_path, rustc_private, unicode)] /* * This file is part of the uutils coreutils package. diff --git a/src/hashsum/hashsum.rs b/src/hashsum/hashsum.rs index e3be13afc..7bea447fb 100644 --- a/src/hashsum/hashsum.rs +++ b/src/hashsum/hashsum.rs @@ -1,5 +1,5 @@ #![crate_name = "hashsum"] -#![feature(collections, core, io, path, rustc_private, std_misc)] +#![feature(collections, core, old_io, old_path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/head/head.rs b/src/head/head.rs index 9dae049d5..77aa372d9 100644 --- a/src/head/head.rs +++ b/src/head/head.rs @@ -1,5 +1,5 @@ #![crate_name = "head"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/hostname/hostname.rs b/src/hostname/hostname.rs index 3c88ac33f..cc384be06 100644 --- a/src/hostname/hostname.rs +++ b/src/hostname/hostname.rs @@ -1,5 +1,5 @@ #![crate_name = "hostname"] -#![feature(collections, core, io, rustc_private)] +#![feature(collections, core, old_io, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/kill/kill.rs b/src/kill/kill.rs index fd978f35b..1790820a5 100644 --- a/src/kill/kill.rs +++ b/src/kill/kill.rs @@ -1,5 +1,5 @@ #![crate_name = "kill"] -#![feature(collections, core, io, rustc_private, unicode)] +#![feature(collections, core, old_io, rustc_private, unicode)] /* * This file is part of the uutils coreutils package. diff --git a/src/link/link.rs b/src/link/link.rs index 28d3d70f6..4454a9fe4 100644 --- a/src/link/link.rs +++ b/src/link/link.rs @@ -1,5 +1,5 @@ #![crate_name = "link"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/logname/logname.rs b/src/logname/logname.rs index 69224873c..5f0eea34b 100644 --- a/src/logname/logname.rs +++ b/src/logname/logname.rs @@ -1,5 +1,5 @@ #![crate_name = "logname"] -#![feature(collections, core, io, rustc_private, std_misc)] +#![feature(collections, core, old_io, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/mkdir/mkdir.rs b/src/mkdir/mkdir.rs index 3b4dc0e30..0659bc53a 100644 --- a/src/mkdir/mkdir.rs +++ b/src/mkdir/mkdir.rs @@ -1,5 +1,5 @@ #![crate_name = "mkdir"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/mv/mv.rs b/src/mv/mv.rs index 50c705435..890f6b13d 100644 --- a/src/mv/mv.rs +++ b/src/mv/mv.rs @@ -1,5 +1,5 @@ #![crate_name = "mv"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/nice/nice.rs b/src/nice/nice.rs index 5c87694ba..1f3dd17b6 100644 --- a/src/nice/nice.rs +++ b/src/nice/nice.rs @@ -1,5 +1,5 @@ #![crate_name = "nice"] -#![feature(collections, core, io, os, rustc_private, std_misc)] +#![feature(collections, core, old_io, os, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/nl/nl.rs b/src/nl/nl.rs index f178a1ad4..7e1e0b9cb 100644 --- a/src/nl/nl.rs +++ b/src/nl/nl.rs @@ -1,5 +1,5 @@ #![crate_name = "nl"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] #![plugin(regex_macros)] /* diff --git a/src/nohup/nohup.rs b/src/nohup/nohup.rs index 0713b4551..06ced318a 100644 --- a/src/nohup/nohup.rs +++ b/src/nohup/nohup.rs @@ -1,5 +1,5 @@ #![crate_name = "nohup"] -#![feature(collections, core, io, os, path, rustc_private, std_misc)] +#![feature(collections, core, old_io, os, old_path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/od/od.rs b/src/od/od.rs index 7455be927..32519b3ce 100644 --- a/src/od/od.rs +++ b/src/od/od.rs @@ -1,5 +1,5 @@ #![crate_name = "od"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/paste/paste.rs b/src/paste/paste.rs index 3eab0631f..c33663117 100644 --- a/src/paste/paste.rs +++ b/src/paste/paste.rs @@ -1,5 +1,5 @@ #![crate_name = "paste"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/printenv/printenv.rs b/src/printenv/printenv.rs index 3d14893a4..893833954 100644 --- a/src/printenv/printenv.rs +++ b/src/printenv/printenv.rs @@ -1,5 +1,5 @@ #![crate_name = "printenv"] -#![feature(collections, core, io, os, rustc_private)] +#![feature(collections, core, old_io, os, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/pwd/pwd.rs b/src/pwd/pwd.rs index ec5178f27..c52180db8 100644 --- a/src/pwd/pwd.rs +++ b/src/pwd/pwd.rs @@ -1,5 +1,5 @@ #![crate_name = "pwd"] -#![feature(collections, core, io, os, rustc_private)] +#![feature(collections, core, old_io, os, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/readlink/readlink.rs b/src/readlink/readlink.rs index 771609ccb..34f2a43d6 100644 --- a/src/readlink/readlink.rs +++ b/src/readlink/readlink.rs @@ -1,5 +1,5 @@ #![crate_name = "readlink"] -#![feature(collections, core, io, os, path, rustc_private)] +#![feature(collections, core, old_io, os, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/realpath/realpath.rs b/src/realpath/realpath.rs index 2de84d0b5..508a7ffd0 100644 --- a/src/realpath/realpath.rs +++ b/src/realpath/realpath.rs @@ -1,5 +1,5 @@ #![crate_name= "realpath"] -#![feature(collections, core, io, os, path, rustc_private)] +#![feature(collections, core, old_io, os, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/relpath/relpath.rs b/src/relpath/relpath.rs index 70e95fa2e..d146a36bb 100644 --- a/src/relpath/relpath.rs +++ b/src/relpath/relpath.rs @@ -1,5 +1,5 @@ #![crate_name = "relpath"] -#![feature(collections, core, os, path, rustc_private)] +#![feature(collections, core, os, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/rm/rm.rs b/src/rm/rm.rs index a87be39b8..37aa75682 100644 --- a/src/rm/rm.rs +++ b/src/rm/rm.rs @@ -1,5 +1,5 @@ #![crate_name = "rm"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/rmdir/rmdir.rs b/src/rmdir/rmdir.rs index 9e21433e7..ae8490dd6 100644 --- a/src/rmdir/rmdir.rs +++ b/src/rmdir/rmdir.rs @@ -1,5 +1,5 @@ #![crate_name = "rmdir"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/shuf/shuf.rs b/src/shuf/shuf.rs index 3548969ae..c2265f97a 100644 --- a/src/shuf/shuf.rs +++ b/src/shuf/shuf.rs @@ -1,5 +1,5 @@ #![crate_name = "shuf"] -#![feature(collections, core, io, path, rand, rustc_private)] +#![feature(collections, core, old_io, old_path, rand, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/sleep/sleep.rs b/src/sleep/sleep.rs index 60ebc9d5b..886981bfe 100644 --- a/src/sleep/sleep.rs +++ b/src/sleep/sleep.rs @@ -1,5 +1,5 @@ #![crate_name = "sleep"] -#![feature(collections, core, io, rustc_private, std_misc)] +#![feature(collections, core, old_io, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/sort/sort.rs b/src/sort/sort.rs index e5ba04cef..04d22f8e8 100644 --- a/src/sort/sort.rs +++ b/src/sort/sort.rs @@ -1,5 +1,5 @@ #![crate_name = "sort"] -#![feature(collections, core, io, path, rustc_private, unicode)] +#![feature(collections, core, old_io, old_path, rustc_private, unicode)] /* * This file is part of the uutils coreutils package. diff --git a/src/split/split.rs b/src/split/split.rs index 7f92b8498..d5bcd1ac9 100644 --- a/src/split/split.rs +++ b/src/split/split.rs @@ -1,5 +1,5 @@ #![crate_name = "split"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/stdbuf/stdbuf.rs b/src/stdbuf/stdbuf.rs index 555385d71..ec4aa1b70 100644 --- a/src/stdbuf/stdbuf.rs +++ b/src/stdbuf/stdbuf.rs @@ -1,5 +1,5 @@ #![crate_name = "stdbuf"] -#![feature(core, io, os, path, rustc_private, unicode)] +#![feature(core, old_io, os, old_path, rustc_private, unicode)] /* * This file is part of the uutils coreutils package. diff --git a/src/sum/sum.rs b/src/sum/sum.rs index d843e6216..b0b898431 100644 --- a/src/sum/sum.rs +++ b/src/sum/sum.rs @@ -1,5 +1,5 @@ #![crate_name = "sum"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/tac/tac.rs b/src/tac/tac.rs index a35b5952a..cefb42c9a 100644 --- a/src/tac/tac.rs +++ b/src/tac/tac.rs @@ -1,5 +1,5 @@ #![crate_name = "tac"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/tail/tail.rs b/src/tail/tail.rs index c102992bd..8a848d06e 100644 --- a/src/tail/tail.rs +++ b/src/tail/tail.rs @@ -1,5 +1,5 @@ #![crate_name = "tail"] -#![feature(collections, core, io, path, rustc_private, std_misc)] +#![feature(collections, core, old_io, old_path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/tee/tee.rs b/src/tee/tee.rs index 78a7a1604..32f17a64d 100644 --- a/src/tee/tee.rs +++ b/src/tee/tee.rs @@ -1,5 +1,5 @@ #![crate_name = "tee"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/timeout/timeout.rs b/src/timeout/timeout.rs index 31145f6db..959daa662 100644 --- a/src/timeout/timeout.rs +++ b/src/timeout/timeout.rs @@ -1,5 +1,5 @@ #![crate_name = "timeout"] -#![feature(collections, core, io, rustc_private)] +#![feature(collections, core, old_io, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/touch/touch.rs b/src/touch/touch.rs index 9048c1066..8119f6114 100644 --- a/src/touch/touch.rs +++ b/src/touch/touch.rs @@ -1,5 +1,5 @@ #![crate_name = "touch"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/tr/tr.rs b/src/tr/tr.rs index 7f41bc05d..a35f9c48a 100644 --- a/src/tr/tr.rs +++ b/src/tr/tr.rs @@ -1,5 +1,5 @@ #![crate_name = "tr"] -#![feature(collections, core, io, rustc_private)] +#![feature(collections, core, old_io, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/truncate/truncate.rs b/src/truncate/truncate.rs index 39686dd3d..233a77883 100644 --- a/src/truncate/truncate.rs +++ b/src/truncate/truncate.rs @@ -1,5 +1,5 @@ #![crate_name = "truncate"] -#![feature(collections, core, io, path, rustc_private, std_misc)] +#![feature(collections, core, old_io, old_path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/tsort/tsort.rs b/src/tsort/tsort.rs index efb7df8cb..267134f9d 100644 --- a/src/tsort/tsort.rs +++ b/src/tsort/tsort.rs @@ -1,5 +1,5 @@ #![crate_name = "tsort"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/tty/tty.rs b/src/tty/tty.rs index 9e7a6658b..7c714a004 100644 --- a/src/tty/tty.rs +++ b/src/tty/tty.rs @@ -1,5 +1,5 @@ #![crate_name = "tty"] -#![feature(collections, core, io, rustc_private, std_misc)] +#![feature(collections, core, old_io, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/uname/uname.rs b/src/uname/uname.rs index 4008c4bda..983b69742 100644 --- a/src/uname/uname.rs +++ b/src/uname/uname.rs @@ -1,5 +1,5 @@ #![crate_name = "uname"] -#![feature(collections, core, io, rustc_private, std_misc)] +#![feature(collections, core, old_io, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/unexpand/unexpand.rs b/src/unexpand/unexpand.rs index cb74b3fb6..4f05dc04b 100644 --- a/src/unexpand/unexpand.rs +++ b/src/unexpand/unexpand.rs @@ -1,5 +1,5 @@ #![crate_name = "unexpand"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/uniq/uniq.rs b/src/uniq/uniq.rs index 2e0f01bb7..f400f5867 100644 --- a/src/uniq/uniq.rs +++ b/src/uniq/uniq.rs @@ -1,5 +1,5 @@ #![crate_name = "uniq"] -#![feature(collections, core, io, path, rustc_private, std_misc)] +#![feature(collections, core, old_io, old_path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/unlink/unlink.rs b/src/unlink/unlink.rs index bf6f3dcee..0151110cf 100644 --- a/src/unlink/unlink.rs +++ b/src/unlink/unlink.rs @@ -1,5 +1,5 @@ #![crate_name = "unlink"] -#![feature(collections, core, io, path, rustc_private)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/uptime/uptime.rs b/src/uptime/uptime.rs index 8d330e779..03284b355 100644 --- a/src/uptime/uptime.rs +++ b/src/uptime/uptime.rs @@ -1,5 +1,5 @@ #![crate_name = "uptime"] -#![feature(collections, core, io, path, rustc_private, std_misc)] +#![feature(collections, core, old_io, old_path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/users/users.rs b/src/users/users.rs index 65b36d65f..92d1e6de9 100644 --- a/src/users/users.rs +++ b/src/users/users.rs @@ -1,5 +1,5 @@ #![crate_name = "users"] -#![feature(collections, core, io, rustc_private, std_misc)] +#![feature(collections, core, old_io, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/uutils/uutils.rs b/src/uutils/uutils.rs index fcfc380b6..778dc7f33 100644 --- a/src/uutils/uutils.rs +++ b/src/uutils/uutils.rs @@ -1,5 +1,5 @@ #![crate_name = "uutils"] -#![feature(core, env, path, rustc_private)] +#![feature(core, env, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/wc/wc.rs b/src/wc/wc.rs index 18078ba0f..ebd8d266c 100644 --- a/src/wc/wc.rs +++ b/src/wc/wc.rs @@ -1,5 +1,5 @@ #![crate_name = "wc"] -#![feature(collections, core, io, path, rustc_private, std_misc)] +#![feature(collections, core, old_io, old_path, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/whoami/whoami.rs b/src/whoami/whoami.rs index 9972b8060..79f7022d0 100644 --- a/src/whoami/whoami.rs +++ b/src/whoami/whoami.rs @@ -1,5 +1,5 @@ #![crate_name = "whoami"] -#![feature(collections, core, io, rustc_private, std_misc)] +#![feature(collections, core, old_io, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. diff --git a/src/yes/yes.rs b/src/yes/yes.rs index 70755bd55..630334342 100644 --- a/src/yes/yes.rs +++ b/src/yes/yes.rs @@ -1,5 +1,5 @@ #![crate_name = "yes"] -#![feature(collections, core, io, rustc_private)] +#![feature(collections, core, old_io, rustc_private)] /* * This file is part of the uutils coreutils package. From 8098d172d7eb0a1eb7ac8044d50d17cf27378a5a Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sun, 22 Feb 2015 12:55:30 +0100 Subject: [PATCH 07/11] Update slicing syntax ([] -> [..]) --- src/cat/cat.rs | 8 ++++---- src/sync/sync.rs | 2 +- src/wc/wc.rs | 14 +++++++------- src/yes/yes.rs | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/cat/cat.rs b/src/cat/cat.rs index bbb6832c5..0cdb19dd9 100644 --- a/src/cat/cat.rs +++ b/src/cat/cat.rs @@ -49,7 +49,7 @@ pub fn uumain(args: Vec) -> i32 { println!(" {0} [OPTION]... [FILE]...", program); println!(""); print(&getopts::usage("Concatenate FILE(s), or standard input, to \ - standard output.", &opts)[]); + standard output.", &opts)[..]); println!(""); println!("With no FILE, or when FILE is -, read standard input."); return 0; @@ -95,7 +95,7 @@ fn write_lines(files: Vec, number: NumberingMode, squeeze_blank: bool, let mut line_counter: usize = 1; - for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[])) { + for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[..])) { let mut in_buf = [0; 1024 * 31]; let mut out_buf = [0; 1024 * 64]; @@ -162,7 +162,7 @@ fn write_bytes(files: Vec, number: NumberingMode, squeeze_blank: bool, let mut line_counter: usize = 1; - for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[])) { + for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[..])) { // Flush all 1024 iterations. let mut flush_counter = range(0us, 1024); @@ -234,7 +234,7 @@ fn write_fast(files: Vec) { let mut writer = stdout_raw(); let mut in_buf = [0; 1024 * 64]; - for (mut reader, _) in files.iter().filter_map(|p| open(&p[])) { + for (mut reader, _) in files.iter().filter_map(|p| open(&p[..])) { while let Ok(n) = reader.read(&mut in_buf) { if n == 0 { break } // This interface is completely broken. diff --git a/src/sync/sync.rs b/src/sync/sync.rs index f827f7bae..8b76b30ec 100644 --- a/src/sync/sync.rs +++ b/src/sync/sync.rs @@ -141,7 +141,7 @@ mod platform { } pub fn uumain(args: Vec) -> i32 { - let program = &args[0][]; + let program = &args[0][..]; let options = [ optflag("h", "help", "display this help and exit"), diff --git a/src/wc/wc.rs b/src/wc/wc.rs index ebd8d266c..9132e15da 100644 --- a/src/wc/wc.rs +++ b/src/wc/wc.rs @@ -38,7 +38,7 @@ struct Result { static NAME: &'static str = "wc"; pub fn uumain(args: Vec) -> i32 { - let program = &args[0][]; + let program = &args[0][..]; let opts = [ getopts::optflag("c", "bytes", "print the byte counts"), getopts::optflag("m", "chars", "print the character counts"), @@ -60,7 +60,7 @@ pub fn uumain(args: Vec) -> i32 { println!("Usage:"); println!(" {0} [OPTION]... [FILE]...", program); println!(""); - print(&getopts::usage("Print newline, word and byte counts for each FILE", &opts)[]); + print(&getopts::usage("Print newline, word and byte counts for each FILE", &opts)[..]); println!(""); println!("With no FILE, or when FILE is -, read standard input."); return 0; @@ -74,10 +74,10 @@ pub fn uumain(args: Vec) -> i32 { let files = if matches.free.is_empty() { vec!["-".to_string()].into_cow() } else { - matches.free[].into_cow() + matches.free[..].into_cow() }; - match wc(&files[], &matches) { + match wc(&files[..], &matches) { Ok(()) => ( /* pass */ ), Err(e) => return e } @@ -108,7 +108,7 @@ pub fn wc(files: &[String], matches: &Matches) -> StdResult<(), i32> { let mut max_str_len: usize = 0; for path in files.iter() { - let mut reader = try!(open(&path[])); + let mut reader = try!(open(&path[..])); let mut line_count: usize = 0; let mut word_count: usize = 0; @@ -128,7 +128,7 @@ pub fn wc(files: &[String], matches: &Matches) -> StdResult<(), i32> { // try and convert the bytes to UTF-8 first let current_char_count; - match from_utf8(&raw_line[]) { + match from_utf8(&raw_line[..]) { Ok(line) => { word_count += line.words().count(); current_char_count = line.chars().count(); @@ -170,7 +170,7 @@ pub fn wc(files: &[String], matches: &Matches) -> StdResult<(), i32> { } for result in results.iter() { - print_stats(&result.filename[], result.lines, result.words, result.chars, result.bytes, result.max_line_length, matches, max_str_len); + print_stats(&result.filename[..], result.lines, result.words, result.chars, result.bytes, result.max_line_length, matches, max_str_len); } if files.len() > 1 { diff --git a/src/yes/yes.rs b/src/yes/yes.rs index 630334342..4f6bf17d4 100644 --- a/src/yes/yes.rs +++ b/src/yes/yes.rs @@ -42,7 +42,7 @@ pub fn uumain(args: Vec) -> i32 { println!("Usage:"); println!(" {0} [STRING]... [OPTION]...", program); println!(""); - print(&getopts::usage("Repeatedly output a line with all specified STRING(s), or 'y'.", &opts)[]); + print(&getopts::usage("Repeatedly output a line with all specified STRING(s), or 'y'.", &opts)[..]); return 0; } if matches.opt_present("version") { @@ -55,7 +55,7 @@ pub fn uumain(args: Vec) -> i32 { matches.free.connect(" ").into_cow() }; - exec(&string[]); + exec(&string[..]); 0 } From 26568d2021c191e6583ba4d1297cab4f8ed18ab7 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sun, 22 Feb 2015 13:01:40 +0100 Subject: [PATCH 08/11] Update to the new integer suffixes --- src/cat/cat.rs | 4 ++-- src/cksum/cksum.rs | 2 +- src/common/time.rs | 8 ++++---- src/echo/echo.rs | 2 +- src/fold/fold.rs | 2 +- src/head/head.rs | 4 ++-- src/hostname/hostname.rs | 2 +- src/realpath/realpath.rs | 2 +- src/seq/seq.rs | 2 +- src/split/split.rs | 8 ++++---- src/tail/tail.rs | 38 +++++++++++++++++++------------------- 11 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/cat/cat.rs b/src/cat/cat.rs index 0cdb19dd9..b4378e3e2 100644 --- a/src/cat/cat.rs +++ b/src/cat/cat.rs @@ -165,7 +165,7 @@ fn write_bytes(files: Vec, number: NumberingMode, squeeze_blank: bool, for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[..])) { // Flush all 1024 iterations. - let mut flush_counter = range(0us, 1024); + let mut flush_counter = range(0usize, 1024); let mut in_buf = [0; 1024 * 32]; let mut out_buf = [0; 1024 * 64]; @@ -177,7 +177,7 @@ fn write_bytes(files: Vec, number: NumberingMode, squeeze_blank: bool, for &byte in in_buf[..n].iter() { if flush_counter.next().is_none() { writer.possibly_flush(); - flush_counter = range(0us, 1024); + flush_counter = range(0usize, 1024); } if byte == '\n' as u8 { if !at_line_start || !squeeze_blank { diff --git a/src/cksum/cksum.rs b/src/cksum/cksum.rs index da30deeec..e288287f7 100644 --- a/src/cksum/cksum.rs +++ b/src/cksum/cksum.rs @@ -45,7 +45,7 @@ fn crc_final(mut crc: u32, mut length: usize) -> u32 { #[inline] fn cksum(fname: &str) -> IoResult<(u32, usize)> { let mut crc = 0u32; - let mut size = 0us; + let mut size = 0usize; let mut stdin_buf; let mut file_buf; diff --git a/src/common/time.rs b/src/common/time.rs index 6a30c6e05..73a7da0f7 100644 --- a/src/common/time.rs +++ b/src/common/time.rs @@ -14,10 +14,10 @@ pub fn from_str(string: &str) -> Result { } let slice = &string[..len - 1]; let (numstr, times) = match string.char_at(len - 1) { - 's' | 'S' => (slice, 1us), - 'm' | 'M' => (slice, 60us), - 'h' | 'H' => (slice, 60us * 60), - 'd' | 'D' => (slice, 60us * 60 * 24), + 's' | 'S' => (slice, 1usize), + 'm' | 'M' => (slice, 60usize), + 'h' | 'H' => (slice, 60usize * 60), + 'd' | 'D' => (slice, 60usize * 60 * 24), val => { if !val.is_alphabetic() { (string, 1) diff --git a/src/echo/echo.rs b/src/echo/echo.rs index 19967b398..d66abc859 100644 --- a/src/echo/echo.rs +++ b/src/echo/echo.rs @@ -60,7 +60,7 @@ fn convert_str(string: &[u8], index: usize, base: u32) -> (char, usize) { }; let mut bytes = vec!(); - for offset in range(0us, max_digits) { + for offset in range(0usize, max_digits) { if string.len() <= index + offset as usize { break; } diff --git a/src/fold/fold.rs b/src/fold/fold.rs index 126f1ee23..9e8de9fe6 100644 --- a/src/fold/fold.rs +++ b/src/fold/fold.rs @@ -157,7 +157,7 @@ fn fold_file(file: BufferedReader, bytes: bool, spaces: bool, match rfind_whitespace(slice) { Some(m) => { let routput = slice.slice_chars(m + 1, slice.chars().count()); - let ncount = routput.chars().fold(0us, |out, ch: char| { + let ncount = routput.chars().fold(0usize, |out, ch: char| { out + match ch { '\t' => 8, '\x08' => if out > 0 { -1 } else { 0 }, diff --git a/src/head/head.rs b/src/head/head.rs index 77aa372d9..bce8de96d 100644 --- a/src/head/head.rs +++ b/src/head/head.rs @@ -29,8 +29,8 @@ mod util; static NAME: &'static str = "head"; pub fn uumain(args: Vec) -> i32 { - let mut line_count = 10us; - let mut byte_count = 0us; + let mut line_count = 10usize; + let mut byte_count = 0usize; // handle obsolete -number syntax let options = match obsolete(args.tail()) { diff --git a/src/hostname/hostname.rs b/src/hostname/hostname.rs index cc384be06..89b42538e 100644 --- a/src/hostname/hostname.rs +++ b/src/hostname/hostname.rs @@ -132,7 +132,7 @@ fn help_menu(program: &str, options: &[getopts::OptGroup]) { } fn xgethostname() -> String { - let namelen = 256us; + let namelen = 256usize; let mut name : Vec = repeat(0).take(namelen).collect(); let err = unsafe { gethostname (name.as_mut_ptr() as *mut libc::c_char, diff --git a/src/realpath/realpath.rs b/src/realpath/realpath.rs index 508a7ffd0..daf749f24 100644 --- a/src/realpath/realpath.rs +++ b/src/realpath/realpath.rs @@ -78,7 +78,7 @@ fn resolve_path(path: &str, strip: bool, zero: bool, quiet: bool) -> bool { Some(x) => x, }; - let mut links_left = 256is; + let mut links_left = 256isize; for part in abs.components() { result.push(part); diff --git a/src/seq/seq.rs b/src/seq/seq.rs index 7f2702324..94d1e3acf 100644 --- a/src/seq/seq.rs +++ b/src/seq/seq.rs @@ -217,7 +217,7 @@ fn done_printing(next: f64, step: f64, last: f64) -> bool { } fn print_seq(first: f64, step: f64, last: f64, largest_dec: usize, separator: String, terminator: String, pad: bool, padding: usize) { - let mut i = 0is; + let mut i = 0isize; let mut value = first + i as f64 * step; while !done_printing(value, step, last) { let istr = value.to_string(); diff --git a/src/split/split.rs b/src/split/split.rs index d5bcd1ac9..1a35421e1 100644 --- a/src/split/split.rs +++ b/src/split/split.rs @@ -170,10 +170,10 @@ impl ByteSplitter { let mut strategy_param : Vec = settings.strategy_param.chars().collect(); let suffix = strategy_param.pop().unwrap(); let multiplier = match suffix { - '0'...'9' => 1us, - 'b' => 512us, - 'k' => 1024us, - 'm' => 1024us * 1024us, + '0'...'9' => 1usize, + 'b' => 512usize, + 'k' => 1024usize, + 'm' => 1024usize * 1024usize, _ => crash!(1, "invalid number of bytes") }; let n = if suffix.is_alphabetic() { diff --git a/src/tail/tail.rs b/src/tail/tail.rs index 8a848d06e..d0ab204c4 100644 --- a/src/tail/tail.rs +++ b/src/tail/tail.rs @@ -34,8 +34,8 @@ static VERSION: &'static str = "0.0.1"; pub fn uumain(args: Vec) -> i32 { let mut beginning = false; let mut lines = true; - let mut byte_count = 0us; - let mut line_count = 10us; + let mut byte_count = 0usize; + let mut line_count = 10usize; let mut sleep_msec = 1000u64; // handle obsolete -number syntax @@ -153,29 +153,29 @@ fn parse_size(mut size_slice: &str) -> Option { let mut base = if size_slice.len() > 0 && size_slice.char_at(size_slice.len() - 1) == 'B' { size_slice = &size_slice[..size_slice.len() - 1]; - 1000us + 1000usize } else { - 1024us + 1024usize }; let exponent = if size_slice.len() > 0 { let mut has_suffix = true; let exp = match size_slice.char_at(size_slice.len() - 1) { - 'K' => 1us, - 'M' => 2us, - 'G' => 3us, - 'T' => 4us, - 'P' => 5us, - 'E' => 6us, - 'Z' => 7us, - 'Y' => 8us, + 'K' => 1usize, + 'M' => 2usize, + 'G' => 3usize, + 'T' => 4usize, + 'P' => 5usize, + 'E' => 6usize, + 'Z' => 7usize, + 'Y' => 8usize, 'b' => { - base = 512us; - 1us + base = 512usize; + 1usize } _ => { has_suffix = false; - 0us + 0usize } }; if has_suffix { @@ -183,14 +183,14 @@ fn parse_size(mut size_slice: &str) -> Option { } exp } else { - 0us + 0usize }; - let mut multiplier = 1us; - for _ in range(0us, exponent) { + let mut multiplier = 1usize; + for _ in range(0usize, exponent) { multiplier *= base; } - if base == 1000us && exponent == 0us { + if base == 1000usize && exponent == 0usize { // sole B is not a valid suffix None } else { From 3993a2bf90f07b65f5273313f203ae8d545e4a02 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sun, 22 Feb 2015 13:30:28 +0100 Subject: [PATCH 09/11] Update feature flags --- src/base64/base64.rs | 2 +- src/hashsum/hashsum.rs | 2 +- src/timeout/timeout.rs | 2 +- src/truncate/truncate.rs | 2 +- src/uptime/uptime.rs | 2 +- src/wc/wc.rs | 2 +- src/yes/yes.rs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/base64/base64.rs b/src/base64/base64.rs index 79980491a..16bd62da1 100644 --- a/src/base64/base64.rs +++ b/src/base64/base64.rs @@ -1,5 +1,5 @@ #![crate_name = "base64"] -#![feature(collections, core, old_io, old_path, rustc_private, std_misc)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/hashsum/hashsum.rs b/src/hashsum/hashsum.rs index 7bea447fb..0fcf2ded4 100644 --- a/src/hashsum/hashsum.rs +++ b/src/hashsum/hashsum.rs @@ -1,5 +1,5 @@ #![crate_name = "hashsum"] -#![feature(collections, core, old_io, old_path, rustc_private, std_misc)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/timeout/timeout.rs b/src/timeout/timeout.rs index 959daa662..a66487090 100644 --- a/src/timeout/timeout.rs +++ b/src/timeout/timeout.rs @@ -1,5 +1,5 @@ #![crate_name = "timeout"] -#![feature(collections, core, old_io, rustc_private)] +#![feature(collections, core, io, old_io, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/truncate/truncate.rs b/src/truncate/truncate.rs index 233a77883..cf0628b9f 100644 --- a/src/truncate/truncate.rs +++ b/src/truncate/truncate.rs @@ -1,5 +1,5 @@ #![crate_name = "truncate"] -#![feature(collections, core, old_io, old_path, rustc_private, std_misc)] +#![feature(collections, core, old_io, old_path, rustc_private)] /* * This file is part of the uutils coreutils package. diff --git a/src/uptime/uptime.rs b/src/uptime/uptime.rs index 03284b355..694c7ddc0 100644 --- a/src/uptime/uptime.rs +++ b/src/uptime/uptime.rs @@ -1,5 +1,5 @@ #![crate_name = "uptime"] -#![feature(collections, core, old_io, old_path, rustc_private, std_misc)] +#![feature(collections, core, old_io, old_path, rustc_private, std_misc, str_words)] /* * This file is part of the uutils coreutils package. diff --git a/src/wc/wc.rs b/src/wc/wc.rs index 9132e15da..840da2be7 100644 --- a/src/wc/wc.rs +++ b/src/wc/wc.rs @@ -1,5 +1,5 @@ #![crate_name = "wc"] -#![feature(collections, core, old_io, old_path, rustc_private, std_misc)] +#![feature(collections, old_io, old_path, rustc_private, str_words)] /* * This file is part of the uutils coreutils package. diff --git a/src/yes/yes.rs b/src/yes/yes.rs index 4f6bf17d4..3bfe4830d 100644 --- a/src/yes/yes.rs +++ b/src/yes/yes.rs @@ -1,5 +1,5 @@ #![crate_name = "yes"] -#![feature(collections, core, old_io, rustc_private)] +#![feature(collections, old_io, rustc_private)] /* * This file is part of the uutils coreutils package. From eb6594cc9170cfb3f25d5ea37315c04a17cdee29 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sun, 22 Feb 2015 13:22:51 +0100 Subject: [PATCH 10/11] CString::from_slice -> CString::new --- src/chmod/chmod.rs | 2 +- src/chroot/chroot.rs | 6 +++--- src/common/c_types.rs | 4 ++-- src/mkfifo/mkfifo.rs | 2 +- src/nice/nice.rs | 2 +- src/nohup/nohup.rs | 2 +- src/test/test.rs | 2 +- src/uptime/uptime.rs | 2 +- src/users/users.rs | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/chmod/chmod.rs b/src/chmod/chmod.rs index 8680eb635..fb4179282 100644 --- a/src/chmod/chmod.rs +++ b/src/chmod/chmod.rs @@ -183,7 +183,7 @@ fn chmod(files: Vec, changes: bool, quiet: bool, verbose: bool, preserve } fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool, fmode: Option, cmode: Option<&String>) -> Result<(), i32> { - let path = CString::from_slice(name.as_bytes()); + let path = CString::new(name).unwrap(); match fmode { Some(mode) => { if unsafe { libc::chmod(path.as_ptr(), mode) } == 0 { diff --git a/src/chroot/chroot.rs b/src/chroot/chroot.rs index de5b5d083..72e590841 100644 --- a/src/chroot/chroot.rs +++ b/src/chroot/chroot.rs @@ -95,8 +95,8 @@ pub fn uumain(args: Vec) -> i32 { set_context(&newroot, &opts); unsafe { - let executable = CString::from_slice(command[0].as_bytes()).as_bytes_with_nul().as_ptr(); - let mut command_parts: Vec<*const u8> = command.iter().map(|x| CString::from_slice(x.as_bytes()).as_bytes_with_nul().as_ptr()).collect(); + let executable = CString::new(command[0]).unwrap().as_bytes_with_nul().as_ptr(); + let mut command_parts: Vec<*const u8> = command.iter().map(|x| CString::new(x.as_bytes()).unwrap().as_bytes_with_nul().as_ptr()).collect(); command_parts.push(std::ptr::null()); execvp(executable as *const libc::c_char, command_parts.as_ptr() as *mut *const libc::c_char) as i32 } @@ -131,7 +131,7 @@ fn enter_chroot(root: &Path) { let root_str = root.display(); std::os::change_dir(root).unwrap(); let err = unsafe { - chroot(CString::from_slice(b".").as_bytes_with_nul().as_ptr() as *const libc::c_char) + chroot(CString::new(b".").unwrap().as_bytes_with_nul().as_ptr() as *const libc::c_char) }; if err != 0 { crash!(1, "cannot chroot to {}: {}", root_str, strerror(err).as_slice()) diff --git a/src/common/c_types.rs b/src/common/c_types.rs index a84142ff8..32db00093 100644 --- a/src/common/c_types.rs +++ b/src/common/c_types.rs @@ -133,7 +133,7 @@ pub fn get_pw_from_args(free: &Vec) -> Option { // Passed the username as a string } else { let pw_pointer = unsafe { - let cstr = CString::from_slice(username.as_bytes()); + let cstr = CString::new(username).unwrap(); getpwnam(cstr.as_bytes_with_nul().as_ptr() as *const i8) }; if !pw_pointer.is_null() { @@ -152,7 +152,7 @@ pub fn get_group(groupname: &str) -> Option { unsafe { getgrgid(groupname.parse().unwrap()) } } else { unsafe { - let cstr = CString::from_slice(groupname.as_bytes()); + let cstr = CString::new(groupname).unwrap(); getgrnam(cstr.as_bytes_with_nul().as_ptr() as *const c_char) } }; diff --git a/src/mkfifo/mkfifo.rs b/src/mkfifo/mkfifo.rs index 7695fb520..8a2eb0fe2 100644 --- a/src/mkfifo/mkfifo.rs +++ b/src/mkfifo/mkfifo.rs @@ -68,7 +68,7 @@ pub fn uumain(args: Vec) -> i32 { let mut exit_status = 0; for f in matches.free.iter() { - let err = unsafe { mkfifo(CString::from_slice(f.as_bytes()).as_ptr(), mode) }; + let err = unsafe { mkfifo(CString::new(f.as_bytes()).unwrap().as_ptr(), mode) }; if err == -1 { show_error!("creating '{}': {}", f, os::error_string(os::errno())); exit_status = 1; diff --git a/src/nice/nice.rs b/src/nice/nice.rs index 1f3dd17b6..4e67bb320 100644 --- a/src/nice/nice.rs +++ b/src/nice/nice.rs @@ -102,7 +102,7 @@ pub fn uumain(args: Vec) -> i32 { show_warning!("{}", IoError::last_error()); } - let cstrs : Vec = matches.free.iter().map(|x| CString::from_slice(x.as_bytes())).collect(); + let cstrs : Vec = matches.free.iter().map(|x| CString::new(x.as_bytes()).unwrap()).collect(); let mut args : Vec<*const c_char> = cstrs.iter().map(|s| s.as_ptr()).collect(); args.push(0 as *const c_char); unsafe { execvp(args[0], args.as_mut_ptr()); } diff --git a/src/nohup/nohup.rs b/src/nohup/nohup.rs index 06ced318a..be03ce704 100644 --- a/src/nohup/nohup.rs +++ b/src/nohup/nohup.rs @@ -69,7 +69,7 @@ pub fn uumain(args: Vec) -> i32 { if unsafe { _vprocmgr_detach_from_console(0) } != std::ptr::null() { crash!(2, "Cannot detach from console")}; - let cstrs : Vec = opts.free.iter().map(|x| CString::from_slice(x.as_bytes())).collect(); + let cstrs : Vec = opts.free.iter().map(|x| CString::new(x.as_bytes()).unwrap()).collect(); let mut args : Vec<*const c_char> = cstrs.iter().map(|s| s.as_ptr()).collect(); args.push(std::ptr::null()); unsafe { execvp(args[0], args.as_mut_ptr())} diff --git a/src/test/test.rs b/src/test/test.rs index f5baf4111..b484630bb 100644 --- a/src/test/test.rs +++ b/src/test/test.rs @@ -348,7 +348,7 @@ fn path(path: &[u8], cond: PathCondition) -> bool { } }; - let path = CString::from_slice(path); + let path = CString::new(path).unwrap(); let mut stat = unsafe { std::mem::zeroed() }; if cond == PathCondition::SymLink { if unsafe { lstat(path.as_ptr(), &mut stat) } == 0 { diff --git a/src/uptime/uptime.rs b/src/uptime/uptime.rs index 694c7ddc0..aecfb2dc5 100644 --- a/src/uptime/uptime.rs +++ b/src/uptime/uptime.rs @@ -108,7 +108,7 @@ fn print_loadavg() { #[cfg(unix)] fn process_utmpx() -> (Option, usize) { unsafe { - utmpxname(CString::from_slice(DEFAULT_FILE.as_bytes()).as_ptr()); + utmpxname(CString::new(DEFAULT_FILE).unwrap().as_ptr()); } let mut nusers = 0; diff --git a/src/users/users.rs b/src/users/users.rs index 92d1e6de9..0001628d7 100644 --- a/src/users/users.rs +++ b/src/users/users.rs @@ -91,7 +91,7 @@ pub fn uumain(args: Vec) -> i32 { fn exec(filename: &str) { unsafe { - utmpxname(CString::from_slice(filename.as_bytes()).as_ptr()); + utmpxname(CString::new(filename).unwrap().as_ptr()); } let mut users = vec!(); From a5547507af82ec43c53ad17e0a2249ce7e9659a3 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sun, 22 Feb 2015 13:58:57 +0100 Subject: [PATCH 11/11] c_str_to_bytes -> CStr::from_ptr --- src/chroot/chroot.rs | 4 ++-- src/common/c_types.rs | 4 ++-- src/id/id.rs | 50 +++++++++++++++++++++--------------------- src/logname/logname.rs | 4 ++-- src/tty/tty.rs | 4 ++-- src/uname/uname.rs | 4 ++-- src/users/users.rs | 4 ++-- src/whoami/whoami.rs | 4 ++-- 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/chroot/chroot.rs b/src/chroot/chroot.rs index 72e590841..d9d6a53ff 100644 --- a/src/chroot/chroot.rs +++ b/src/chroot/chroot.rs @@ -16,7 +16,7 @@ extern crate libc; use getopts::{optflag, optopt, getopts, usage}; use c_types::{get_pw_from_args, get_group}; use libc::funcs::posix88::unistd::{execvp, setuid, setgid}; -use std::ffi::{c_str_to_bytes, CString}; +use std::ffi::{CStr, CString}; use std::old_io::fs::PathExtensions; use std::iter::FromIterator; @@ -196,7 +196,7 @@ fn set_user(user: &str) { fn strerror(errno: i32) -> String { unsafe { let err = libc::funcs::c95::string::strerror(errno) as *const libc::c_char; - let bytes= c_str_to_bytes(&err); + let bytes= CStr::from_ptr(err).to_bytes(); String::from_utf8_lossy(bytes).to_string() } } diff --git a/src/common/c_types.rs b/src/common/c_types.rs index 32db00093..0e2bcf76c 100644 --- a/src/common/c_types.rs +++ b/src/common/c_types.rs @@ -15,7 +15,7 @@ use self::libc::int32_t; use self::libc::funcs::posix88::unistd::getgroups; -use std::ffi::{c_str_to_bytes, CString}; +use std::ffi::{CStr, CString}; use std::iter::repeat; use std::vec::Vec; @@ -231,7 +231,7 @@ pub fn group(possible_pw: Option, nflag: bool) { if !group.is_null() { let name = unsafe { let gname = read(group).gr_name; - let bytes= c_str_to_bytes(&gname); + let bytes= CStr::from_ptr(gname).to_bytes(); String::from_utf8_lossy(bytes).to_string() }; print!("{} ", name); diff --git a/src/id/id.rs b/src/id/id.rs index 33fabf83f..0918b9471 100644 --- a/src/id/id.rs +++ b/src/id/id.rs @@ -18,7 +18,7 @@ extern crate getopts; extern crate libc; -use std::ffi::c_str_to_bytes; +use std::ffi::CStr; use std::ptr::read; use libc::{ uid_t, @@ -139,7 +139,7 @@ pub fn uumain(args: Vec) -> i32 { let gr = unsafe { getgrgid(id) }; if nflag && !gr.is_null() { - let gr_name = unsafe { String::from_utf8_lossy(c_str_to_bytes(&read(gr).gr_name)).to_string() }; + let gr_name = unsafe { String::from_utf8_lossy(CStr::from_ptr(read(gr).gr_name).to_bytes()).to_string() }; println!("{}", gr_name); } else { println!("{}", id); @@ -159,7 +159,7 @@ pub fn uumain(args: Vec) -> i32 { let pw = unsafe { getpwuid(id) }; if nflag && !pw.is_null() { let pw_name = unsafe { - String::from_utf8_lossy(c_str_to_bytes(&read(pw).pw_name)).to_string() + String::from_utf8_lossy(CStr::from_ptr(read(pw).pw_name).to_bytes()).to_string() }; println!("{}", pw_name); } else { @@ -197,16 +197,16 @@ fn pretty(possible_pw: Option) { if possible_pw.is_some() { let pw = possible_pw.unwrap(); - let pw_name = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_name)).to_string() }; + let pw_name = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_name).to_bytes()).to_string() }; print!("uid\t{}\ngroups\t", pw_name); group(possible_pw, true); } else { - let login = unsafe { String::from_utf8_lossy(c_str_to_bytes(&(getlogin() as *const i8))).to_string() }; + let login = unsafe { String::from_utf8_lossy(CStr::from_ptr((getlogin() as *const i8)).to_bytes()).to_string() }; let rid = unsafe { getuid() }; let pw = unsafe { getpwuid(rid) }; let is_same_user = unsafe { - String::from_utf8_lossy(c_str_to_bytes(&read(pw).pw_name)).to_string() == login + String::from_utf8_lossy(CStr::from_ptr(read(pw).pw_name).to_bytes()).to_string() == login }; if pw.is_null() || is_same_user { @@ -216,7 +216,7 @@ fn pretty(possible_pw: Option) { if !pw.is_null() { println!( "uid\t{}", - unsafe { String::from_utf8_lossy(c_str_to_bytes(&read(pw).pw_name)).to_string() }) + unsafe { String::from_utf8_lossy(CStr::from_ptr(read(pw).pw_name).to_bytes()).to_string() }) } else { println!("uid\t{}\n", rid); } @@ -227,7 +227,7 @@ fn pretty(possible_pw: Option) { if !pw.is_null() { println!( "euid\t{}", - unsafe { String::from_utf8_lossy(c_str_to_bytes(&read(pw).pw_name)).to_string() }); + unsafe { String::from_utf8_lossy(CStr::from_ptr(read(pw).pw_name).to_bytes()).to_string() }); } else { println!("euid\t{}", eid); } @@ -240,7 +240,7 @@ fn pretty(possible_pw: Option) { if !gr.is_null() { println!( "rgid\t{}", - unsafe { String::from_utf8_lossy(c_str_to_bytes(&read(gr).gr_name)).to_string() }); + unsafe { String::from_utf8_lossy(CStr::from_ptr(read(gr).gr_name).to_bytes()).to_string() }); } else { println!("rgid\t{}", rid); } @@ -259,12 +259,12 @@ fn pline(possible_pw: Option) { possible_pw.unwrap() }; - let pw_name = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_name )).to_string()}; - let pw_passwd = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_passwd)).to_string()}; - let pw_class = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_class )).to_string()}; - let pw_gecos = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_gecos )).to_string()}; - let pw_dir = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_dir )).to_string()}; - let pw_shell = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_shell )).to_string()}; + let pw_name = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_name ).to_bytes()).to_string()}; + let pw_passwd = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_passwd).to_bytes()).to_string()}; + let pw_class = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_class ).to_bytes()).to_string()}; + let pw_gecos = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_gecos ).to_bytes()).to_string()}; + let pw_dir = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_dir ).to_bytes()).to_string()}; + let pw_shell = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_shell ).to_bytes()).to_string()}; println!( "{}:{}:{}:{}:{}:{}:{}:{}:{}:{}", @@ -288,11 +288,11 @@ fn pline(possible_pw: Option) { possible_pw.unwrap() }; - let pw_name = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_name )).to_string()}; - let pw_passwd = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_passwd)).to_string()}; - let pw_gecos = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_gecos )).to_string()}; - let pw_dir = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_dir )).to_string()}; - let pw_shell = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_shell )).to_string()}; + let pw_name = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_name ).to_bytes()).to_string()}; + let pw_passwd = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_passwd).to_bytes()).to_string()}; + let pw_gecos = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_gecos ).to_bytes()).to_string()}; + let pw_dir = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_dir ).to_bytes()).to_string()}; + let pw_shell = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_shell ).to_bytes()).to_string()}; println!( "{}:{}:{}:{}:{}:{}:{}", @@ -352,7 +352,7 @@ fn id_print(possible_pw: Option, print!( "uid={}({})", uid, - unsafe { String::from_utf8_lossy(c_str_to_bytes(&possible_pw.unwrap().pw_name)).to_string() }); + unsafe { String::from_utf8_lossy(CStr::from_ptr(possible_pw.unwrap().pw_name).to_bytes()).to_string() }); } else { print!("uid={}", unsafe { getuid() }); } @@ -362,7 +362,7 @@ fn id_print(possible_pw: Option, if !gr.is_null() { print!( "({})", - unsafe { String::from_utf8_lossy(c_str_to_bytes(&read(gr).gr_name)).to_string() }); + unsafe { String::from_utf8_lossy(CStr::from_ptr(read(gr).gr_name).to_bytes()).to_string() }); } let euid = unsafe { geteuid() }; @@ -372,7 +372,7 @@ fn id_print(possible_pw: Option, if !pw.is_null() { print!( "({})", - unsafe { String::from_utf8_lossy(c_str_to_bytes(&read(pw).pw_name)).to_string() }); + unsafe { String::from_utf8_lossy(CStr::from_ptr(read(pw).pw_name).to_bytes()).to_string() }); } } @@ -382,7 +382,7 @@ fn id_print(possible_pw: Option, unsafe { let grp = getgrgid(egid); if !grp.is_null() { - print!("({})", String::from_utf8_lossy(c_str_to_bytes(&read(grp).gr_name)).to_string()); + print!("({})", String::from_utf8_lossy(CStr::from_ptr(read(grp).gr_name).to_bytes()).to_string()); } } } @@ -397,7 +397,7 @@ fn id_print(possible_pw: Option, let group = unsafe { getgrgid(gr) }; if !group.is_null() { let name = unsafe { - String::from_utf8_lossy(c_str_to_bytes(&read(group).gr_name)).to_string() + String::from_utf8_lossy(CStr::from_ptr(read(group).gr_name).to_bytes()).to_string() }; print!("({})", name); } diff --git a/src/logname/logname.rs b/src/logname/logname.rs index 5f0eea34b..85571165b 100644 --- a/src/logname/logname.rs +++ b/src/logname/logname.rs @@ -17,7 +17,7 @@ extern crate getopts; extern crate libc; -use std::ffi::c_str_to_bytes; +use std::ffi::CStr; use std::old_io::print; use libc::c_char; @@ -34,7 +34,7 @@ fn get_userlogin() -> Option { if login.is_null() { None } else { - Some(String::from_utf8_lossy(c_str_to_bytes(&login)).to_string()) + Some(String::from_utf8_lossy(CStr::from_ptr(login).to_bytes()).to_string()) } } } diff --git a/src/tty/tty.rs b/src/tty/tty.rs index 7c714a004..0bbec78a3 100644 --- a/src/tty/tty.rs +++ b/src/tty/tty.rs @@ -17,7 +17,7 @@ extern crate getopts; extern crate libc; -use std::ffi::c_str_to_bytes; +use std::ffi::CStr; use std::old_io::println; use std::old_io::stdio::stderr; use getopts::{optflag,getopts}; @@ -52,7 +52,7 @@ pub fn uumain(args: Vec) -> i32 { let tty = unsafe { let ptr = ttyname(libc::STDIN_FILENO); if !ptr.is_null() { - String::from_utf8_lossy(c_str_to_bytes(&ptr)).to_string() + String::from_utf8_lossy(CStr::from_ptr(ptr).to_bytes()).to_string() } else { "".to_string() } diff --git a/src/uname/uname.rs b/src/uname/uname.rs index 983b69742..33e601d9d 100644 --- a/src/uname/uname.rs +++ b/src/uname/uname.rs @@ -17,7 +17,7 @@ extern crate getopts; extern crate libc; -use std::ffi::c_str_to_bytes; +use std::ffi::CStr; use std::mem::uninitialized; use std::old_io::print; use c_types::utsname; @@ -38,7 +38,7 @@ extern { } unsafe fn string_from_c_str(ptr: *const i8) -> String { - String::from_utf8_lossy(c_str_to_bytes(&ptr)).to_string() + String::from_utf8_lossy(CStr::from_ptr(ptr).to_bytes()).to_string() } unsafe fn getuname() -> utsrust { diff --git a/src/users/users.rs b/src/users/users.rs index 0001628d7..ccc2ad699 100644 --- a/src/users/users.rs +++ b/src/users/users.rs @@ -18,7 +18,7 @@ extern crate getopts; extern crate libc; -use std::ffi::{CString, c_str_to_bytes}; +use std::ffi::{CStr, CString}; use std::old_io::print; use std::mem; use std::ptr; @@ -107,7 +107,7 @@ fn exec(filename: &str) { } if (*line).ut_type == USER_PROCESS { - let user = String::from_utf8_lossy(c_str_to_bytes(mem::transmute(&(*line).ut_user))).to_string(); + let user = String::from_utf8_lossy(CStr::from_ptr(mem::transmute(&(*line).ut_user)).to_bytes()).to_string(); users.push(user); } } diff --git a/src/whoami/whoami.rs b/src/whoami/whoami.rs index 79f7022d0..b29e0a5f8 100644 --- a/src/whoami/whoami.rs +++ b/src/whoami/whoami.rs @@ -36,7 +36,7 @@ mod platform { let passwd: *const c_passwd = getpwuid(geteuid()); let pw_name: *const libc::c_char = (*passwd).pw_name; - String::from_utf8_lossy(::std::ffi::c_str_to_bytes(&pw_name)).to_string() + String::from_utf8_lossy(::std::ffi::CStr::from_ptr(pw_name).to_bytes()).to_string() } } @@ -55,7 +55,7 @@ mod platform { if !GetUserNameA(buffer.as_mut_ptr(), &mut (buffer.len() as libc::uint32_t)) == 0 { crash!(1, "username is too long"); } - String::from_utf8_lossy(::std::ffi::c_str_to_bytes(&buffer.as_ptr())).to_string() + String::from_utf8_lossy(::std::ffi::CStr::from_ptr(buffer.as_ptr()).to_bytes()).to_string() } }