diff --git a/base64/base64.rs b/base64/base64.rs index 12a5c21cb..b79fcedd8 100644 --- a/base64/base64.rs +++ b/base64/base64.rs @@ -52,7 +52,7 @@ pub fn uumain(args: Vec) -> int { } }; - let progname = args.get(0).clone(); + let progname = args[0].clone(); let usage = usage("Base64 encode or decode FILE, or standard input, to standard output.", opts); let mode = if matches.opt_present("help") { Help @@ -76,11 +76,11 @@ pub fn uumain(args: Vec) -> int { }; let mut stdin_buf; let mut file_buf; - let input = if matches.free.is_empty() || matches.free.get(0).as_slice() == "-" { + let input = if matches.free.is_empty() || matches.free[0].as_slice() == "-" { stdin_buf = stdin_raw(); &mut stdin_buf as &mut Reader } else { - let path = Path::new(matches.free.get(0).as_slice()); + let path = Path::new(matches.free[0].as_slice()); file_buf = File::open(&path); &mut file_buf as &mut Reader }; diff --git a/basename/basename.rs b/basename/basename.rs index 079fa9acb..d15f9669b 100644 --- a/basename/basename.rs +++ b/basename/basename.rs @@ -23,7 +23,7 @@ static NAME: &'static str = "basename"; static VERSION: &'static str = "1.0.0"; pub fn uumain(args: Vec) -> int { - let program = strip_dir(args.get(0).as_slice()); + let program = strip_dir(args[0].as_slice()); // // Argument parsing @@ -62,7 +62,7 @@ pub fn uumain(args: Vec) -> int { } // too many arguments else if args.len() > 3 { - println!("{}: extra operand '{}'", program, args.get(3)); + println!("{}: extra operand '{}'", program, args[3]); println!("Try '{} --help' for more information.", program); return 1; } @@ -71,12 +71,12 @@ pub fn uumain(args: Vec) -> int { // Main Program Processing // - let fullname = args.get(1); + let fullname = &args[1]; let mut name = strip_dir(fullname.as_slice()); if args.len() > 2 { - let suffix = args.get(2).clone(); + let suffix = args[2].clone(); name = strip_suffix(name.as_slice(), suffix.as_slice()); } diff --git a/cat/cat.rs b/cat/cat.rs index 26a81c6f4..e9ff675c4 100644 --- a/cat/cat.rs +++ b/cat/cat.rs @@ -20,7 +20,7 @@ use std::io::{IoResult}; use std::ptr::{copy_nonoverlapping_memory}; pub fn uumain(args: Vec) -> int { - let program = args.get(0).as_slice(); + let program = args[0].as_slice(); let opts = [ getopts::optflag("A", "show-all", "equivalent to -vET"), getopts::optflag("b", "number-nonblank", diff --git a/chroot/chroot.rs b/chroot/chroot.rs index 09d6a18c5..a324aa43b 100644 --- a/chroot/chroot.rs +++ b/chroot/chroot.rs @@ -37,7 +37,7 @@ static NAME: &'static str = "chroot"; static VERSION: &'static str = "1.0.0"; pub fn uumain(args: Vec) -> int { - let program = args.get(0); + let program = &args[0]; let options = [ optopt("u", "user", "User (ID or name) to switch before running the program", "USER"), @@ -72,7 +72,7 @@ pub fn uumain(args: Vec) -> int { let defaultOption: &'static str = "-i"; let userShell = std::os::getenv("SHELL"); - let newroot = Path::new(opts.free.get(0).as_slice()); + let newroot = Path::new(opts.free[0].as_slice()); if !newroot.is_dir() { crash!(1, "cannot change root directory to `{}`: no such directory", newroot.display()); } @@ -91,7 +91,7 @@ pub fn uumain(args: Vec) -> int { set_context(&newroot, &opts); unsafe { - let executable = command.get(0).as_slice().to_c_str().unwrap(); + let executable = command[0].as_slice().to_c_str().unwrap(); let mut commandParts: Vec<*const i8> = command.iter().map(|x| x.to_c_str().unwrap()).collect(); commandParts.push(std::ptr::null()); execvp(executable as *const libc::c_char, commandParts.as_ptr() as *mut *const libc::c_char) as int @@ -113,8 +113,8 @@ fn set_context(root: &Path, options: &getopts::Matches) { } None => Vec::new() }; - let user = if userspec.is_empty() { userStr.as_slice() } else { userspec.get(0).as_slice() }; - let group = if userspec.is_empty() { groupStr.as_slice() } else { userspec.get(1).as_slice() }; + let user = if userspec.is_empty() { userStr.as_slice() } else { userspec[0].as_slice() }; + let group = if userspec.is_empty() { groupStr.as_slice() } else { userspec[1].as_slice() }; enter_chroot(root); diff --git a/comm/comm.rs b/comm/comm.rs index 7f0017cc6..9e94e0b42 100644 --- a/comm/comm.rs +++ b/comm/comm.rs @@ -62,19 +62,19 @@ fn comm(a: &mut Box, b: &mut Box, opts: &getopts::Matches) { match ord { Less => { if !opts.opt_present("1") { - print!("{}{}", delim.get(1), ra.map(ensure_nl).unwrap()); + print!("{}{}", delim[1], ra.map(ensure_nl).unwrap()); } ra = a.read_line(); } Greater => { if !opts.opt_present("2") { - print!("{}{}", delim.get(2), rb.map(ensure_nl).unwrap()); + print!("{}{}", delim[2], rb.map(ensure_nl).unwrap()); } rb = b.read_line(); } Equal => { if !opts.opt_present("3") { - print!("{}{}", delim.get(3), ra.map(ensure_nl).unwrap()); + print!("{}{}", delim[3], ra.map(ensure_nl).unwrap()); } ra = a.read_line(); rb = b.read_line(); @@ -127,8 +127,8 @@ pub fn uumain(args: Vec) -> int { } - let mut f1 = open_file(matches.free.get(0).as_slice()).unwrap(); - let mut f2 = open_file(matches.free.get(1).as_slice()).unwrap(); + let mut f1 = open_file(matches.free[0].as_slice()).unwrap(); + let mut f2 = open_file(matches.free[1].as_slice()).unwrap(); comm(&mut f1, &mut f2, &matches); diff --git a/common/c_types.rs b/common/c_types.rs index 9a42b8ce5..ecc3bd4a3 100644 --- a/common/c_types.rs +++ b/common/c_types.rs @@ -98,7 +98,7 @@ extern { pub fn get_pw_from_args(free: &Vec) -> Option { if free.len() == 1 { - let username = free.get(0).as_slice(); + let username = free[0].as_slice(); // Passed user as id if username.chars().all(|c| c.is_digit()) { diff --git a/cp/cp.rs b/cp/cp.rs index 43848adc6..386652548 100644 --- a/cp/cp.rs +++ b/cp/cp.rs @@ -44,7 +44,7 @@ pub fn uumain(args: Vec) -> int { }, }; - let progname = args.get(0); + let progname = &args[0]; let usage = usage("Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.", opts); let mode = if matches.opt_present("version") { Version @@ -90,13 +90,13 @@ fn copy(matches: getopts::Matches) { fail!() } else { // Only the last argument: - Path::new(matches.free.get(matches.free.len() - 1).as_slice()) + Path::new(matches.free[matches.free.len() - 1].as_slice()) }; assert!(sources.len() >= 1); if sources.len() == 1 { - let source = sources.get(0); + let source = &sources[0]; let same_file = match paths_refer_to_same_file(source, &dest) { Ok(b) => b, Err(e) => if e.kind == io::FileNotFound { diff --git a/cut/cut.rs b/cut/cut.rs index dce917473..2ea176915 100644 --- a/cut/cut.rs +++ b/cut/cut.rs @@ -259,7 +259,7 @@ fn cut_fields_delimiter(reader: R, if delim_search.peek().is_none() { if ! only_delimited { out.write(line.as_slice()).unwrap(); - if *line.get(line.len() - 1) != b'\n' { + if line[line.len() - 1] != b'\n' { out.write([b'\n']).unwrap(); } } @@ -296,7 +296,7 @@ fn cut_fields_delimiter(reader: R, out.write(segment).unwrap(); - if *line.get(line.len() - 1) == b'\n' { + if line[line.len() - 1] == b'\n' { continue 'newline } break @@ -341,7 +341,7 @@ fn cut_fields(reader: R, if delim_search.peek().is_none() { if ! opts.only_delimited { out.write(line.as_slice()).unwrap(); - if *line.get(line.len() - 1) != b'\n' { + if line[line.len() - 1] != b'\n' { out.write([b'\n']).unwrap(); } } @@ -378,7 +378,7 @@ fn cut_fields(reader: R, out.write(segment).unwrap(); - if *line.get(line.len() - 1) == b'\n' { + if line[line.len() - 1] == b'\n' { continue 'newline } break @@ -468,7 +468,7 @@ pub fn uumain(args: Vec) -> int { if matches.opt_present("help") { println!("Usage:"); - println!(" {0} OPTION... [FILE]...", args.get(0)); + println!(" {0} OPTION... [FILE]...", args[0]); println!(""); print(usage("Print selected parts of lines from each FILE to standard output.", opts).as_slice()); println!(""); @@ -548,7 +548,7 @@ pub fn uumain(args: Vec) -> int { Err(err_msg) => { show_error!("{}\n\ Try '{} --help' for more information", - err_msg, args.get(0)); + err_msg, args[0]); 1 } } diff --git a/cut/ranges.rs b/cut/ranges.rs index 6089bcaac..d02025da7 100644 --- a/cut/ranges.rs +++ b/cut/ranges.rs @@ -66,9 +66,9 @@ impl Range { for i in range(0, ranges.len()) { let j = i + 1; - while j < ranges.len() && ranges.get(j).low <= ranges.get(i).high { + while j < ranges.len() && ranges[j].low <= ranges[i].high { let j_high = ranges.remove(j).unwrap().high; - ranges.get_mut(i).high = max(ranges.get(i).high, j_high); + ranges.get_mut(i).high = max(ranges[i].high, j_high); } } @@ -81,8 +81,8 @@ pub fn complement(ranges: &Vec) -> Vec { let mut complements = Vec::with_capacity(ranges.len() + 1); - if ranges.len() > 0 && ranges.get(0).low > 1 { - complements.push(Range { low: 1, high: ranges.get(0).low - 1 }); + if ranges.len() > 0 && ranges[0].low > 1 { + complements.push(Range { low: 1, high: ranges[0].low - 1 }); } let mut ranges_iter = ranges.iter().peekable(); diff --git a/dirname/dirname.rs b/dirname/dirname.rs index af22bede9..5406b263f 100644 --- a/dirname/dirname.rs +++ b/dirname/dirname.rs @@ -16,7 +16,7 @@ use std::io::print; static VERSION: &'static str = "1.0.0"; pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); let opts = [ getopts::optflag("z", "zero", "separate output with NUL rather than newline"), getopts::optflag("", "help", "display this help and exit"), diff --git a/du/du.rs b/du/du.rs index 67436d3e8..fed078a8c 100644 --- a/du/du.rs +++ b/du/du.rs @@ -89,7 +89,7 @@ fn du(path: &Path, mut my_stat: Stat, } pub fn uumain(args: Vec) -> int { - let program = args.get(0).as_slice(); + let program = args[0].as_slice(); let opts = [ // In task getopts::optflag("a", "all", " write counts for all files, not just directories"), @@ -245,7 +245,7 @@ ers of 1000).", } } let number = std::uint::parse_bytes(numbers.as_slice(), 10).unwrap(); - let multiple = match std::str::from_chars(letters.as_slice()).as_slice() { + let multiple = match String::from_chars(letters.as_slice()).as_slice() { "K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024, "T" => 1024 * 1024 * 1024 * 1024, "P" => 1024 * 1024 * 1024 * 1024 * 1024, "E" => 1024 * 1024 * 1024 * 1024 * 1024 * 1024, diff --git a/echo/echo.rs b/echo/echo.rs index b734919ef..2a09a14a8 100644 --- a/echo/echo.rs +++ b/echo/echo.rs @@ -80,7 +80,7 @@ fn convert_str(string: &[u8], index: uint, base: uint) -> (char, uint) { fn parse_options(args: Vec, options: &mut EchoOptions) -> Option> { let mut echo_args = vec!(); - let program = args.get(0).clone(); + let program = args[0].clone(); 'argloop: for arg in args.move_iter().skip(1) { match arg.as_slice() { "--help" | "-h" => { diff --git a/env/env.rs b/env/env.rs index cb48acf5c..59999f98d 100644 --- a/env/env.rs +++ b/env/env.rs @@ -52,7 +52,7 @@ fn print_env(null: bool) { } pub fn uumain(args: Vec) -> int { - let prog = args.get(0).as_slice(); + let prog = args[0].as_slice(); // to handle arguments the same way than GNU env, we can't use getopts let mut opts = box options { @@ -191,7 +191,7 @@ pub fn uumain(args: Vec) -> int { if opts.program.len() >= 1 { use std::io::process::{Command, InheritFd}; - let prog = opts.program.get(0).clone(); + let prog = opts.program[0].clone(); let args = opts.program.slice_from(1); match Command::new(prog).args(args).stdin(InheritFd(0)).stdout(InheritFd(1)).stderr(InheritFd(2)).status() { Ok(exit) => diff --git a/factor/factor.rs b/factor/factor.rs index c5df8d0c0..02e8190ee 100644 --- a/factor/factor.rs +++ b/factor/factor.rs @@ -64,7 +64,7 @@ fn print_factors_str(num_str: &str) { } pub fn uumain(args: Vec) -> int { - let program = args.get(0).as_slice(); + let program = args[0].as_slice(); let opts = [ getopts::optflag("h", "help", "show this help message"), getopts::optflag("v", "version", "print the version and exit"), diff --git a/fmt/fmt.rs b/fmt/fmt.rs index 8157a5a8d..e16049873 100644 --- a/fmt/fmt.rs +++ b/fmt/fmt.rs @@ -83,11 +83,11 @@ pub fn uumain(args: Vec) -> int { let matches = match getopts::getopts(args.tail(), opts.as_slice()) { Ok(m) => m, - Err(f) => crash!(1, "{}\nTry `{} --help' for more information.", f, args.get(0)) + Err(f) => crash!(1, "{}\nTry `{} --help' for more information.", f, args[0]) }; if matches.opt_present("h") { - print_usage(args.get(0).as_slice(), opts.as_slice(), ""); + print_usage(args[0].as_slice(), opts.as_slice(), ""); } if matches.opt_present("V") || matches.opt_present("h") { diff --git a/fmt/linebreak.rs b/fmt/linebreak.rs index a032792c4..33f5f9f88 100644 --- a/fmt/linebreak.rs +++ b/fmt/linebreak.rs @@ -289,7 +289,7 @@ fn find_kp_breakpoints<'a, T: Iterator<&'a WordInfo<'a>>>(iter: T, args: &BreakA if next_active_breaks.is_empty() { // every potential linebreak is too long! choose the linebreak with the least demerits, ld_idx - let new_break = restart_active_breaks(args, linebreaks.get(ld_idx), ld_idx, w, slen, minlength); + let new_break = restart_active_breaks(args, &linebreaks[ld_idx], ld_idx, w, slen, minlength); next_active_breaks.push(linebreaks.len()); linebreaks.push(new_break); least_demerits = 0; @@ -312,7 +312,7 @@ fn find_kp_breakpoints<'a, T: Iterator<&'a WordInfo<'a>>>(iter: T, args: &BreakA fn build_best_path<'a>(paths: &Vec>, active: &Vec) -> Vec<(&'a WordInfo<'a>, bool)> { let mut breakwords = vec!(); // of the active paths, we select the one with the fewest demerits - let mut best_idx = match active.iter().min_by(|&&a| paths.get(a).demerits) { + let mut best_idx = match active.iter().min_by(|&&a| paths[a].demerits) { None => crash!(1, "Failed to find a k-p linebreak solution. This should never happen."), Some(&s) => s }; @@ -320,7 +320,7 @@ fn build_best_path<'a>(paths: &Vec>, active: &Vec) -> Vec<(& // now, chase the pointers back through the break list, recording // the words at which we should break loop { - let next_best = paths.get(best_idx); + let next_best = paths[best_idx]; match next_best.linebreak { None => return breakwords, Some(prev) => { diff --git a/fmt/parasplit.rs b/fmt/parasplit.rs index 1829cf789..fb3348e17 100644 --- a/fmt/parasplit.rs +++ b/fmt/parasplit.rs @@ -425,10 +425,10 @@ impl<'a> ParaWords<'a> { self.words.extend( if self.opts.crown || self.opts.tagged { // crown and tagged mode has the "init" in the first line, so slice from there - WordSplit::new(self.opts, self.para.lines.get(0).as_slice().slice_from(self.para.init_end)) + WordSplit::new(self.opts, self.para.lines[0].as_slice().slice_from(self.para.init_end)) } else { // otherwise we slice from the indent - WordSplit::new(self.opts, self.para.lines.get(0).as_slice().slice_from(self.para.indent_end)) + WordSplit::new(self.opts, self.para.lines[0].as_slice().slice_from(self.para.indent_end)) }); if self.para.lines.len() > 1 { diff --git a/fold/fold.rs b/fold/fold.rs index fb6ba4881..6b8b872d3 100644 --- a/fold/fold.rs +++ b/fold/fold.rs @@ -28,7 +28,7 @@ static VERSION: &'static str = "1.0.0"; pub fn uumain(args: Vec) -> int { let (args, obs_width) = handle_obsolete(args.as_slice()); - let program = args.get(0).clone(); + let program = args[0].clone(); let opts = [ getopts::optflag("b", "bytes", "count using bytes rather than columns (meaning control characters such as newline are not treated specially)"), @@ -86,7 +86,7 @@ fn handle_obsolete(args: &[String]) -> (Vec, Option) { let mut args = Vec::::from_slice(args); let mut i = 0; while i < args.len() { - if args.get(i).as_slice().char_at(0) == '-' && args.get(i).len() > 1 && args.get(i).as_slice().char_at(1).is_digit() { + if args[i].as_slice().char_at(0) == '-' && args[i].len() > 1 && args[i].as_slice().char_at(1).is_digit() { return (args.clone(), Some(args.remove(i).unwrap().as_slice().slice_from(1).to_string())); } diff --git a/groups/groups.rs b/groups/groups.rs index 833c10bc3..c29aa077f 100644 --- a/groups/groups.rs +++ b/groups/groups.rs @@ -26,7 +26,7 @@ static NAME: &'static str = "groups"; static VERSION: &'static str = "1.0.0"; pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); let options = [ optflag("h", "help", "display this help menu and exit"), diff --git a/hashsum/hashsum.rs b/hashsum/hashsum.rs index 83e60cbe2..18197cc66 100644 --- a/hashsum/hashsum.rs +++ b/hashsum/hashsum.rs @@ -90,7 +90,7 @@ fn detect_algo(program: &str, matches: &getopts::Matches) -> (&str, Box) } pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); let binary = Path::new(program.as_slice()); let binary_name = binary.filename_str().unwrap(); @@ -313,4 +313,3 @@ fn digest_reader(digest: &mut Box, reader: &mut Reader, binary: bool) -> Ok(digest.result_str()) } - diff --git a/head/head.rs b/head/head.rs index 4d25d827b..d3890def1 100644 --- a/head/head.rs +++ b/head/head.rs @@ -104,7 +104,7 @@ fn obsolete (options: &[String]) -> (Vec, Option) { let b = options.len(); while a < b { - let current = options.get(a).clone(); + let current = options[a].clone(); let current = current.as_bytes(); if current.len() > 1 && current[0] == '-' as u8 { diff --git a/hostname/hostname.rs b/hostname/hostname.rs index c2f0540bd..8581b220a 100644 --- a/hostname/hostname.rs +++ b/hostname/hostname.rs @@ -33,7 +33,7 @@ extern { } pub fn uumain(args: Vec) -> int { - let program = args.get(0); + let program = &args[0]; let options = [ optflag("f", "full", "Default option to show full name"), diff --git a/kill/kill.rs b/kill/kill.rs index fd3dd5df4..aad1caeab 100644 --- a/kill/kill.rs +++ b/kill/kill.rs @@ -103,7 +103,7 @@ fn handle_obsolete(mut args: Vec) -> (Vec, Option) { let mut i = 0; while i < args.len() { // this is safe because slice is valid when it is referenced - let slice: &str = unsafe { std::mem::transmute(args.get(i).as_slice()) }; + let slice: &str = unsafe { std::mem::transmute(args[i].as_slice()) }; if slice.char_at(0) == '-' && slice.len() > 1 && slice.char_at(1).is_digit() { let val = slice.slice_from(1); match from_str(val) { diff --git a/link/link.rs b/link/link.rs index 61285c7e2..ed20dd1a4 100644 --- a/link/link.rs +++ b/link/link.rs @@ -50,8 +50,8 @@ pub fn uumain(args: Vec) -> int { return 0; } - let old = Path::new(matches.free.get(0).as_slice()); - let new = Path::new(matches.free.get(1).as_slice()); + let old = Path::new(matches.free[0].as_slice()); + let new = Path::new(matches.free[1].as_slice()); match link(&old, &new) { Ok(_) => 0, diff --git a/logname/logname.rs b/logname/logname.rs index e60b9c609..64c764e7c 100644 --- a/logname/logname.rs +++ b/logname/logname.rs @@ -43,7 +43,7 @@ fn version() { } pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); // // Argument parsing diff --git a/mkmain.rs b/mkmain.rs index 0a4907ea1..b7946ec1c 100644 --- a/mkmain.rs +++ b/mkmain.rs @@ -22,14 +22,14 @@ fn main() { return; } - let crat = match args.get(1).as_slice() { + let crat = match args[1].as_slice() { "test" => "uutest", "true" => "uutrue", "false" => "uufalse", "sync" => "uusync", s => s.clone(), }; - let outfile = args.get(2).as_slice(); + let outfile = args[2].as_slice(); let main = std::str::replace(TEMPLATE, "@UTIL_CRATE@", crat); let mut out = File::open_mode(&Path::new(outfile), Truncate, ReadWrite); diff --git a/mkuutils.rs b/mkuutils.rs index f8eac7fb8..856de53c9 100644 --- a/mkuutils.rs +++ b/mkuutils.rs @@ -44,7 +44,7 @@ fn main() { } } } - let outfile = args.get(1).as_slice(); + let outfile = args[1].as_slice(); // XXX: this all just assumes that the IO works correctly let mut out = File::open_mode(&Path::new(outfile), Truncate, Write).unwrap(); diff --git a/nl/helper.rs b/nl/helper.rs index e3401cb06..c4717e60d 100644 --- a/nl/helper.rs +++ b/nl/helper.rs @@ -1,8 +1,6 @@ extern crate getopts; extern crate regex; -use std::str; - // parse_style parses a style string into a NumberingStyle. fn parse_style(chars: &[char]) -> Result<::NumberingStyle, String> { match chars { @@ -10,7 +8,7 @@ fn parse_style(chars: &[char]) -> Result<::NumberingStyle, String> { ['t'] => { Ok(::NumberForNonEmpty) }, ['n'] => { Ok(::NumberForNone) }, ['p', ..rest] => { - match regex::Regex::new(str::from_chars(rest).as_slice()) { + match regex::Regex::new(String::from_chars(rest).as_slice()) { Ok(re) => Ok(::NumberForRegularExpression(re)), Err(_) => Err(String::from_str("Illegal regular expression")), } diff --git a/nohup/nohup.rs b/nohup/nohup.rs index 854655c8c..06c067f0a 100644 --- a/nohup/nohup.rs +++ b/nohup/nohup.rs @@ -50,7 +50,7 @@ fn _vprocmgr_detach_from_console(_: u32) -> *const libc::c_int { std::ptr::null( fn rewind_stdout(_: &mut T) {} pub fn uumain(args: Vec) -> int { - let program = args.get(0); + let program = &args[0]; let options = [ optflag("h", "help", "Show help and exit"), @@ -82,7 +82,7 @@ pub fn uumain(args: Vec) -> int { unsafe { // we ignore the memory leak here because it doesn't matter anymore - let executable = opts.free.get(0).as_slice().to_c_str().unwrap(); + let executable = opts.free[0].as_slice().to_c_str().unwrap(); let mut args: Vec<*const i8> = opts.free.iter().map(|x| x.to_c_str().unwrap()).collect(); args.push(std::ptr::null()); execvp(executable as *const libc::c_char, args.as_ptr() as *mut *const libc::c_char) as int diff --git a/paste/paste.rs b/paste/paste.rs index 0ee655a6e..69282cf59 100644 --- a/paste/paste.rs +++ b/paste/paste.rs @@ -23,7 +23,7 @@ static NAME: &'static str = "paste"; static VERSION: &'static str = "1.0.0"; pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); let opts = [ getopts::optflag("s", "serial", "paste one file at a time instead of in parallel"), @@ -75,7 +75,7 @@ fn paste(filenames: Vec, serial: bool, delimiters: &str) { match file.read_line() { Ok(line) => { output.push_str(line.as_slice().trim_right()); - output.push_str(delimiters.get(delim_count % delimiters.len()).as_slice()); + output.push_str(delimiters[delim_count % delimiters.len()].as_slice()); } Err(f) => if f.kind == io::EndOfFile { break @@ -93,7 +93,7 @@ fn paste(filenames: Vec, serial: bool, delimiters: &str) { let mut output = "".to_string(); let mut eof_count = 0; for (i, file) in files.mut_iter().enumerate() { - if *eof.get(i) { + if eof[i] { eof_count += 1; } else { match file.read_line() { @@ -106,7 +106,7 @@ fn paste(filenames: Vec, serial: bool, delimiters: &str) { } } } - output.push_str(delimiters.get(delim_count % delimiters.len()).as_slice()); + output.push_str(delimiters[delim_count % delimiters.len()].as_slice()); delim_count += 1; } if files.len() == eof_count { diff --git a/printenv/printenv.rs b/printenv/printenv.rs index 6630e42a4..b305d4746 100644 --- a/printenv/printenv.rs +++ b/printenv/printenv.rs @@ -25,7 +25,7 @@ mod util; static NAME: &'static str = "printenv"; pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); let opts = [ getopts::optflag("0", "null", "end each output line with 0 byte rather than newline"), getopts::optflag("h", "help", "display this help and exit"), diff --git a/pwd/pwd.rs b/pwd/pwd.rs index 8dcb38d13..a4140a8e0 100644 --- a/pwd/pwd.rs +++ b/pwd/pwd.rs @@ -23,7 +23,7 @@ static NAME: &'static str = "pwd"; static VERSION: &'static str = "1.0.0"; pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); let opts = [ getopts::optflag("", "help", "display this help and exit"), getopts::optflag("", "version", "output version information and exit"), diff --git a/realpath/realpath.rs b/realpath/realpath.rs index 9d0e2e3b0..b5b8b1570 100644 --- a/realpath/realpath.rs +++ b/realpath/realpath.rs @@ -21,7 +21,7 @@ static NAME: &'static str = "realpath"; static VERSION: &'static str = "1.0.0"; pub fn uumain(args: Vec) -> int { - let program = args.get(0); + let program = &args[0]; let options = [ optflag("h", "help", "Show help and exit"), optflag("V", "version", "Show version and exit"), diff --git a/relpath/relpath.rs b/relpath/relpath.rs index 234c1c649..f6710eb17 100644 --- a/relpath/relpath.rs +++ b/relpath/relpath.rs @@ -21,7 +21,7 @@ static NAME: &'static str = "relpath"; static VERSION: &'static str = "1.0.0"; pub fn uumain(args: Vec) -> int { - let program = args.get(0); + let program = &args[0]; let options = [ optflag("h", "help", "Show help and exit"), optflag("V", "version", "Show version and exit"), @@ -46,9 +46,9 @@ pub fn uumain(args: Vec) -> int { return 1 } - let to = Path::new(opts.free.get(0).as_slice()); + let to = Path::new(opts.free[0].as_slice()); let from = if opts.free.len() > 1 { - Path::new(opts.free.get(1).as_slice()) + Path::new(opts.free[1].as_slice()) } else { std::os::getcwd() }; diff --git a/rm/rm.rs b/rm/rm.rs index 396bbb18d..8d1bb84a9 100644 --- a/rm/rm.rs +++ b/rm/rm.rs @@ -29,7 +29,7 @@ enum InteractiveMode { static NAME: &'static str = "rm"; pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); // TODO: make getopts support -R in addition to -r let opts = [ @@ -235,4 +235,3 @@ fn read_prompt() -> bool { Err(_) => true } } - diff --git a/rmdir/rmdir.rs b/rmdir/rmdir.rs index 2f48c3472..ea1e0805f 100644 --- a/rmdir/rmdir.rs +++ b/rmdir/rmdir.rs @@ -22,7 +22,7 @@ mod util; static NAME: &'static str = "rmdir"; pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); let opts = [ getopts::optflag("", "ignore-fail-on-non-empty", "ignore each failure that is solely because a directory is non-empty"), @@ -96,7 +96,7 @@ fn remove_dir(path: &Path, dir: &str, ignore: bool, parents: bool, verbose: bool }; let mut r = Ok(()); - + if walk_dir.next() == None { match fs::rmdir(path) { Ok(_) => { @@ -122,4 +122,3 @@ fn remove_dir(path: &Path, dir: &str, ignore: bool, parents: bool, verbose: bool r } - diff --git a/seq/seq.rs b/seq/seq.rs index da33e9c2c..44496f705 100644 --- a/seq/seq.rs +++ b/seq/seq.rs @@ -51,7 +51,7 @@ fn escape_sequences(s: &str) -> String { fn parse_options(args: Vec, options: &mut SeqOptions) -> Result, int> { let mut seq_args = vec!(); - let program = args.get(0).clone(); + let program = args[0].clone(); let mut iter = args.move_iter().skip(1); loop { match iter.next() { @@ -159,7 +159,7 @@ fn print_version() { } pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); let mut options = SeqOptions { separator: "\n".to_string(), terminator: None, @@ -176,7 +176,7 @@ pub fn uumain(args: Vec) -> int { let mut largest_dec = 0; let mut padding = 0; let first = if free.len() > 1 { - let slice = free.get(0).as_slice(); + let slice = free[0].as_slice(); let len = slice.len(); let dec = slice.find('.').unwrap_or(len); largest_dec = len - dec; @@ -189,12 +189,12 @@ pub fn uumain(args: Vec) -> int { 1.0 }; let step = if free.len() > 2 { - let slice = free.get(1).as_slice(); + let slice = free[1].as_slice(); let len = slice.len(); let dec = slice.find('.').unwrap_or(len); largest_dec = cmp::max(largest_dec, len - dec); padding = cmp::max(padding, dec); - match parse_float(free.get(1).as_slice()) { + match parse_float(free[1].as_slice()) { Ok(n) => n, Err(s) => { show_error!("{:s}", s); return 1; } } @@ -202,7 +202,7 @@ pub fn uumain(args: Vec) -> int { 1.0 }; let last = { - let slice = free.get(free.len() - 1).as_slice(); + let slice = free[free.len() - 1].as_slice(); padding = cmp::max(padding, slice.find('.').unwrap_or(slice.len())); match parse_float(slice) { Ok(n) => n, diff --git a/shuf/shuf.rs b/shuf/shuf.rs index 62c31e046..33f478072 100644 --- a/shuf/shuf.rs +++ b/shuf/shuf.rs @@ -35,7 +35,7 @@ static NAME: &'static str = "shuf"; static VERSION: &'static str = "0.0.1"; pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); let opts = [ getopts::optflag("e", "echo", "treat each ARG as an input line"), @@ -164,7 +164,7 @@ fn shuf_lines(mut lines: Vec, repeat: bool, zero: bool, count: uint, out let max = if repeat { count } else { cmp::min(count, len) }; for _ in range(0, max) { let idx = rng.next_u32() as uint % len; - try!(write!(output, "{}{}", lines.get(idx), if zero { '\0' } else { '\n' })); + try!(write!(output, "{}{}", lines[idx], if zero { '\0' } else { '\n' })); if !repeat { lines.remove(idx); len -= 1; @@ -178,15 +178,14 @@ fn parse_range(input_range: String) -> Result, (String, int if split.len() != 2 { Err(("invalid range format".to_string(), 1)) } else { - let begin = match from_str::(*split.get(0)) { + let begin = match from_str::(split[0]) { Some(m) => m, - None => return Err((format!("{} is not a valid number", split.get(0)), 1)) + None => return Err((format!("{} is not a valid number", split[0]), 1)) }; - let end = match from_str::(*split.get(1)) { + let end = match from_str::(split[1]) { Some(m) => m, - None => return Err((format!("{} is not a valid number", split.get(1)), 1)) + None => return Err((format!("{} is not a valid number", split[1]), 1)) }; Ok(range_inclusive(begin, end)) } } - diff --git a/sleep/sleep.rs b/sleep/sleep.rs index 1a325a910..ca3468273 100644 --- a/sleep/sleep.rs +++ b/sleep/sleep.rs @@ -24,7 +24,7 @@ mod util; static NAME: &'static str = "sleep"; pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); let opts = [ getopts::optflag("h", "help", "display this help and exit"), diff --git a/sum/sum.rs b/sum/sum.rs index c235944f5..830e3a7b6 100644 --- a/sum/sum.rs +++ b/sum/sum.rs @@ -76,7 +76,7 @@ fn open(name: &str) -> IoResult> { } pub fn uumain(args: Vec) -> int { - let program = args.get(0).as_slice(); + let program = args[0].as_slice(); let opts = [ getopts::optflag("r", "", "use the BSD compatible algorithm (default)"), getopts::optflag("s", "sysv", "use System V compatible algorithm"), diff --git a/sync/sync.rs b/sync/sync.rs index e08fd2097..c0cdeab53 100644 --- a/sync/sync.rs +++ b/sync/sync.rs @@ -137,7 +137,7 @@ mod platform { } pub fn uumain(args: Vec) -> int { - let program = args.get(0); + let program = &args[0]; let options = [ optflag("h", "help", "display this help and exit"), diff --git a/tac/tac.rs b/tac/tac.rs index 670704e73..847ad1387 100644 --- a/tac/tac.rs +++ b/tac/tac.rs @@ -23,7 +23,7 @@ static NAME: &'static str = "tac"; static VERSION: &'static str = "1.0.0"; pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); let opts = [ getopts::optflag("b", "before", "attach the separator before instead of after"), diff --git a/tail/tail.rs b/tail/tail.rs index b0c5f0044..5b8b3bda8 100644 --- a/tail/tail.rs +++ b/tail/tail.rs @@ -109,7 +109,7 @@ pub fn uumain(args: Vec) -> int { tail(&mut buffer, line_count, follow, sleep_sec); } } - + 0 } @@ -123,7 +123,7 @@ fn obsolete (options: &[String]) -> (Vec, Option) { let b = options.len(); while a < b { - let current = options.get(a).clone(); + let current = options[a].clone(); let current = current.as_bytes(); if current.len() > 1 && current[0] == '-' as u8 { diff --git a/tee/tee.rs b/tee/tee.rs index 77ebbc598..1a6e6905b 100644 --- a/tee/tee.rs +++ b/tee/tee.rs @@ -31,6 +31,7 @@ pub fn uumain(args: Vec) -> int { } } +#[allow(dead_code)] struct Options { program: String, append: bool, @@ -51,7 +52,7 @@ fn options(args: &[String]) -> Result { getopts(args.tail(), opts).map_err(|e| format!("{}", e)).and_then(|m| { let version = format!("{} {}", NAME, VERSION); - let program = args.get(0).as_slice(); + let program = args[0].as_slice(); let arguments = "[OPTION]... [FILE]..."; let brief = "Copy standard input to each FILE, and also to standard output."; let comment = "If a FILE is -, copy again to standard output."; @@ -110,7 +111,7 @@ struct NamedWriter { impl Writer for NamedWriter { fn write(&mut self, buf: &[u8]) -> IoResult<()> { - with_path(self.path.clone(), || { + with_path(&*self.path.clone(), || { let val = self.inner.write(buf); if val.is_err() { self.inner = box NullWriter as Box; @@ -120,7 +121,7 @@ impl Writer for NamedWriter { } fn flush(&mut self) -> IoResult<()> { - with_path(self.path.clone(), || { + with_path(&*self.path.clone(), || { let val = self.inner.flush(); if val.is_err() { self.inner = box NullWriter as Box; diff --git a/tr/tr.rs b/tr/tr.rs index dbe783662..a57824e8b 100644 --- a/tr/tr.rs +++ b/tr/tr.rs @@ -187,11 +187,11 @@ pub fn uumain(args: Vec) -> int { } if dflag { - let set1 = expand_set(sets.get(0).as_slice()); + let set1 = expand_set(sets[0].as_slice()); delete(set1, cflag); } else { - let set1 = expand_set(sets.get(0).as_slice()); - let set2 = expand_set(sets.get(1).as_slice()); + let set1 = expand_set(sets[0].as_slice()); + let set2 = expand_set(sets[1].as_slice()); tr(set1.as_slice(), set2.as_slice()); } diff --git a/truncate/truncate.rs b/truncate/truncate.rs index 141a97cbe..31c59c490 100644 --- a/truncate/truncate.rs +++ b/truncate/truncate.rs @@ -34,7 +34,7 @@ enum TruncateMode { static NAME: &'static str = "truncate"; pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); let opts = [ getopts::optflag("c", "no-create", "do not create files that do not exist"), @@ -220,4 +220,3 @@ fn parse_size(size: &str) -> (u64, TruncateMode) { } (number, mode) } - diff --git a/uname/uname.rs b/uname/uname.rs index 910de9a5d..694cb6d3a 100644 --- a/uname/uname.rs +++ b/uname/uname.rs @@ -30,7 +30,7 @@ struct utsrust { nodename: String, release: String, version: String, - machine: String + machine: String } extern { @@ -51,7 +51,7 @@ unsafe fn getuname() -> utsrust { static NAME: &'static str = "uname"; pub fn uumain(args: Vec) -> int { - let program = args.get(0).as_slice(); + let program = args[0].as_slice(); let opts = [ getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("a", "all", "Behave as though all of the options -mnrsv were specified."), diff --git a/uniq/uniq.rs b/uniq/uniq.rs index e65d90077..db63bcd08 100644 --- a/uniq/uniq.rs +++ b/uniq/uniq.rs @@ -43,7 +43,7 @@ impl Uniq { for io_line in reader.lines() { let line = crash_if_err!(1, io_line); - if !lines.is_empty() && self.cmp_key(lines.get(0)) != self.cmp_key(&line) { + if !lines.is_empty() && self.cmp_key(&lines[0]) != self.cmp_key(&line) { let print_delimiter = delimiters == "prepend" || (delimiters == "separate" && first_line_printed); first_line_printed |= self.print_lines(writer, &lines, print_delimiter); lines.truncate(0); @@ -83,7 +83,7 @@ impl Uniq { let mut count = if self.all_repeated { 1 } else { lines.len() }; if lines.len() == 1 && !self.repeats_only || lines.len() > 1 && !self.uniques_only { - self.print_line(writer, lines.get(0), count, print_delimiter); + self.print_line(writer, &lines[0], count, print_delimiter); first_line_printed = true; count += 1; } @@ -119,7 +119,7 @@ fn opt_parsed(opt_name: &str, matches: &getopts::Matches) -> Option< } pub fn uumain(args: Vec) -> int { - let program_path = Path::new(args.get(0).clone()); + let program_path = Path::new(args[0].clone()); let program = program_path.filename_str().unwrap_or(NAME); let opts = [ @@ -159,10 +159,10 @@ pub fn uumain(args: Vec) -> int { } else { let (in_file_name, out_file_name) = match matches.free.len() { 0 => ("-".into_string(), "-".into_string()), - 1 => (matches.free.get(0).clone(), "-".into_string()), - 2 => (matches.free.get(0).clone(), matches.free.get(1).clone()), + 1 => (matches.free[0].clone(), "-".into_string()), + 2 => (matches.free[0].clone(), matches.free[1].clone()), _ => { - crash!(1, "Extra operand: {}", matches.free.get(2)); + crash!(1, "Extra operand: {}", matches.free[2]); } }; let uniq = Uniq { diff --git a/unlink/unlink.rs b/unlink/unlink.rs index e358bf112..fa6fdbe18 100644 --- a/unlink/unlink.rs +++ b/unlink/unlink.rs @@ -26,7 +26,7 @@ mod util; static NAME: &'static str = "unlink"; pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); let opts = [ getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit"), @@ -57,10 +57,10 @@ pub fn uumain(args: Vec) -> int { if matches.free.len() == 0 { crash!(1, "missing operand\nTry '{0:s} --help' for more information.", program); } else if matches.free.len() > 1 { - crash!(1, "extra operand: '{1}'\nTry '{0:s} --help' for more information.", program, matches.free.get(1)); + crash!(1, "extra operand: '{1}'\nTry '{0:s} --help' for more information.", program, matches.free[1]); } - let path = Path::new(matches.free.get(0).clone()); + let path = Path::new(matches.free[0].clone()); let result = path.lstat().and_then(|info| { match info.kind { diff --git a/uptime/uptime.rs b/uptime/uptime.rs index cdd1b82c2..46ea48cbb 100644 --- a/uptime/uptime.rs +++ b/uptime/uptime.rs @@ -47,7 +47,7 @@ extern { } pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); let opts = [ getopts::optflag("v", "version", "output version information and exit"), getopts::optflag("h", "help", "display this help and exit"), @@ -180,7 +180,7 @@ fn print_uptime(upsecs: i64) { let updays = upsecs / 86400; let uphours = (upsecs - (updays * 86400)) / 3600; let upmins = (upsecs - (updays * 86400) - (uphours * 3600)) / 60; - if updays == 1 { + if updays == 1 { print!("up {:1d} day, {:2d}:{:02d}, ", updays, uphours, upmins); } else if updays > 1 { diff --git a/users/users.rs b/users/users.rs index 1d4ad6ce6..5cba806e9 100644 --- a/users/users.rs +++ b/users/users.rs @@ -47,7 +47,7 @@ extern { static NAME: &'static str = "users"; pub fn uumain(args: Vec) -> int { - let program = args.get(0).as_slice(); + let program = args[0].as_slice(); let opts = [ getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit"), @@ -75,7 +75,7 @@ pub fn uumain(args: Vec) -> int { let mut filename = DEFAULT_FILE; if matches.free.len() > 0 { - filename = matches.free.get(0).as_slice(); + filename = matches.free[0].as_slice(); } exec(filename); diff --git a/uutils/uutils.rs b/uutils/uutils.rs index 52c0b5386..b59957535 100644 --- a/uutils/uutils.rs +++ b/uutils/uutils.rs @@ -43,7 +43,7 @@ fn main() { let mut args = os::args(); // try binary name as util name. - let binary = Path::new(args.get(0).as_slice()); + let binary = Path::new(args[0].as_slice()); let binary_as_util = binary.filename_str().unwrap(); match umap.find_equiv(&binary_as_util) { @@ -68,7 +68,7 @@ fn main() { // try first arg as util name. if args.len() >= 2 { args.shift(); - let util = args.get(0).as_slice(); + let util = args[0].as_slice(); match umap.find_equiv(&util) { Some(&uumain) => { @@ -76,10 +76,10 @@ fn main() { return } None => { - if args.get(0).as_slice() == "--help" { + if args[0].as_slice() == "--help" { // see if they want help on a specific util if args.len() >= 2 { - let util = args.get(1).as_slice(); + let util = args[1].as_slice(); match umap.find_equiv(&util) { Some(&uumain) => { os::set_exit_status(uumain(vec![util.to_string(), "--help".to_string()])); diff --git a/wc/wc.rs b/wc/wc.rs index d3d3cf04d..a949a4d96 100644 --- a/wc/wc.rs +++ b/wc/wc.rs @@ -35,7 +35,7 @@ struct Result { static NAME: &'static str = "wc"; pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); let opts = [ getopts::optflag("c", "bytes", "print the byte counts"), getopts::optflag("m", "chars", "print the character counts"), diff --git a/whoami/whoami.rs b/whoami/whoami.rs index 70104f718..c578b465c 100644 --- a/whoami/whoami.rs +++ b/whoami/whoami.rs @@ -67,7 +67,7 @@ mod platform { static NAME: &'static str = "whoami"; pub fn uumain(args: Vec) -> int { - let program = args.get(0).as_slice(); + let program = args[0].as_slice(); let opts = [ getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit"), diff --git a/yes/yes.rs b/yes/yes.rs index fd1669fe3..73bd2c5df 100644 --- a/yes/yes.rs +++ b/yes/yes.rs @@ -24,7 +24,7 @@ mod util; static NAME: &'static str = "yes"; pub fn uumain(args: Vec) -> int { - let program = args.get(0).clone(); + let program = args[0].clone(); let opts = [ getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit"),