diff --git a/src/base64/base64.rs b/src/base64/base64.rs index 10a6641db..7d17d6566 100644 --- a/src/base64/base64.rs +++ b/src/base64/base64.rs @@ -44,7 +44,7 @@ pub fn uumain(args: Vec) -> int { optflag("h", "help", "display this help text and exit"), optflag("V", "version", "output version information and exit") ]; - let matches = match getopts(args.tail(), opts) { + let matches = match getopts(args.tail(), &opts) { Ok(m) => m, Err(e) => { error!("error: {}", e); @@ -53,7 +53,7 @@ pub fn uumain(args: Vec) -> int { }; let progname = args[0].clone(); - let usage = usage("Base64 encode or decode FILE, or standard input, to standard output.", opts); + let usage = usage("Base64 encode or decode FILE, or standard input, to standard output.", &opts); let mode = if matches.opt_present("help") { Mode::Help } else if matches.opt_present("version") { diff --git a/src/basename/basename.rs b/src/basename/basename.rs index dcb1f71ef..f437fd81c 100644 --- a/src/basename/basename.rs +++ b/src/basename/basename.rs @@ -32,7 +32,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => crash!(1, "Invalid options\n{}", f) }; @@ -43,7 +43,7 @@ pub fn uumain(args: Vec) -> int { println!("Print NAME with any leading directory components removed."); println!("If specified, also remove a trailing SUFFIX."); - print(getopts::usage("", opts).as_slice()); + print(getopts::usage("", &opts).as_slice()); return 0; } diff --git a/src/cat/cat.rs b/src/cat/cat.rs index 39b338f77..75eb900ea 100644 --- a/src/cat/cat.rs +++ b/src/cat/cat.rs @@ -36,7 +36,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => panic!("Invalid options\n{}", f) }; @@ -47,7 +47,7 @@ pub fn uumain(args: Vec) -> int { println!(" {0:s} [OPTION]... [FILE]...", program); println!(""); print(getopts::usage("Concatenate FILE(s), or standard input, to \ - standard output.", opts).as_slice()); + standard output.", &opts).as_slice()); println!(""); println!("With no FILE, or when FILE is -, read standard input."); return 0; @@ -64,11 +64,11 @@ pub fn uumain(args: Vec) -> int { if matches.opt_present("b") { number_mode = NumberingMode::NumberNonEmpty; } - let show_nonprint = matches.opts_present(["A".to_string(), "e".to_string(), + let show_nonprint = matches.opts_present(&["A".to_string(), "e".to_string(), "t".to_string(), "v".to_string()]); - let show_ends = matches.opts_present(["E".to_string(), "A".to_string(), + let show_ends = matches.opts_present(&["E".to_string(), "A".to_string(), "e".to_string()]); - let show_tabs = matches.opts_present(["A".to_string(), "T".to_string(), + let show_tabs = matches.opts_present(&["A".to_string(), "T".to_string(), "t".to_string()]); let squeeze_blank = matches.opt_present("s"); let mut files = matches.free; @@ -104,7 +104,7 @@ fn write_lines(files: Vec, number: NumberingMode, squeeze_blank: bool, let mut writer = UnsafeWriter::new(out_buf.as_mut_slice(), stdout_raw()); let mut at_line_start = true; loop { - let n = match reader.read(in_buf) { + let n = match reader.read(&mut in_buf) { Ok(n) if n != 0 => n, _ => break, }; @@ -180,7 +180,7 @@ fn write_bytes(files: Vec, number: NumberingMode, squeeze_blank: bool, let mut writer = UnsafeWriter::new(out_buf.as_mut_slice(), stdout_raw()); let mut at_line_start = true; loop { - let n = match reader.read(in_buf) { + let n = match reader.read(&mut in_buf) { Ok(n) if n != 0 => n, _ => break, }; @@ -228,8 +228,8 @@ fn write_bytes(files: Vec, number: NumberingMode, squeeze_blank: bool, _ => byte, }; match byte { - 0 ... 31 => writer.write(['^' as u8, byte + 64]), - 127 => writer.write(['^' as u8, byte - 64]), + 0 ... 31 => writer.write(&['^' as u8, byte + 64]), + 127 => writer.write(&['^' as u8, byte - 64]), _ => writer.write_u8(byte), } } else { @@ -251,7 +251,7 @@ fn write_fast(files: Vec) { }; loop { - match reader.read(in_buf) { + match reader.read(&mut in_buf) { Ok(n) if n != 0 => { // This interface is completely broken. writer.write(in_buf.slice_to(n)).unwrap(); diff --git a/src/chmod/chmod.rs b/src/chmod/chmod.rs index 0b1286613..15b34f299 100644 --- a/src/chmod/chmod.rs +++ b/src/chmod/chmod.rs @@ -47,7 +47,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit") ]; // TODO: sanitize input for - at beginning (e.g. chmod -x testfile). Solution is to add a to -x, making a-x - let mut matches = match getopts::getopts(args.tail(), opts) { + let mut matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => { crash!(1, "{}", f) @@ -66,7 +66,7 @@ Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=]?[0-7]+'.", name = NAME, version = VERSION, program = program, usage = getopts::usage("Change the mode of each FILE to MODE. \ With --reference, change the mode of \ - each FILE to that of RFILE.", opts)); + each FILE to that of RFILE.", &opts)); } else if matches.opt_present("version") { println!("{} v{}", NAME, VERSION); } else if matches.free.is_empty() && matches.opt_present("reference") || matches.free.len() < 2 { diff --git a/src/chroot/chroot.rs b/src/chroot/chroot.rs index 249d3800f..1b7f3e1aa 100644 --- a/src/chroot/chroot.rs +++ b/src/chroot/chroot.rs @@ -51,17 +51,17 @@ pub fn uumain(args: Vec) -> int { optflag("V", "version", "Show program's version") ]; - let opts = match getopts(args.tail(), options) { + let opts = match getopts(args.tail(), &options) { Ok(m) => m, Err(f) => { show_error!("{}", f); - help_menu(program.as_slice(), options); + help_menu(program.as_slice(), &options); return 1 } }; if opts.opt_present("V") { version(); return 0 } - if opts.opt_present("h") { help_menu(program.as_slice(), options); return 0 } + if opts.opt_present("h") { help_menu(program.as_slice(), &options); return 0 } if opts.free.len() == 0 { println!("Missing operand: NEWROOT"); diff --git a/src/cksum/cksum.rs b/src/cksum/cksum.rs index 4afa4db60..0a3b793e7 100644 --- a/src/cksum/cksum.rs +++ b/src/cksum/cksum.rs @@ -61,7 +61,7 @@ fn cksum(fname: &str) -> IoResult<(u32, uint)> { let mut bytes: [u8, ..1024 * 1024] = unsafe { mem::uninitialized() }; loop { - match rd.read(bytes) { + match rd.read(&mut bytes) { Ok(num_bytes) => { for &b in bytes.slice_to(num_bytes).iter() { crc = crc_update(crc, b); @@ -80,7 +80,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(err) => panic!("{}", err), }; diff --git a/src/comm/comm.rs b/src/comm/comm.rs index c802194a2..600922f25 100644 --- a/src/comm/comm.rs +++ b/src/comm/comm.rs @@ -117,7 +117,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(err) => panic!("{}", err), }; diff --git a/src/cp/cp.rs b/src/cp/cp.rs index 821f85501..d056bc236 100644 --- a/src/cp/cp.rs +++ b/src/cp/cp.rs @@ -36,7 +36,7 @@ pub fn uumain(args: Vec) -> int { optflag("h", "help", "display this help and exit"), optflag("", "version", "output version information and exit"), ]; - let matches = match getopts(args.tail(), opts) { + let matches = match getopts(args.tail(), &opts) { Ok(m) => m, Err(e) => { error!("error: {}", e); @@ -45,7 +45,7 @@ pub fn uumain(args: Vec) -> int { }; let progname = &args[0]; - let usage = usage("Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.", opts); + let usage = usage("Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.", &opts); let mode = if matches.opt_present("version") { Mode::Version } else if matches.opt_present("help") { diff --git a/src/cut/cut.rs b/src/cut/cut.rs index 7be575fc0..bf97e1d14 100644 --- a/src/cut/cut.rs +++ b/src/cut/cut.rs @@ -127,7 +127,7 @@ fn cut_bytes(reader: R, } buf_read.consume_line(); - out.write([b'\n']).unwrap(); + out.write(&[b'\n']).unwrap(); } 0 @@ -262,7 +262,7 @@ fn cut_fields_delimiter(reader: R, if ! only_delimited { out.write(line.as_slice()).unwrap(); if line[line.len() - 1] != b'\n' { - out.write([b'\n']).unwrap(); + out.write(&[b'\n']).unwrap(); } } @@ -344,7 +344,7 @@ fn cut_fields(reader: R, if ! opts.only_delimited { out.write(line.as_slice()).unwrap(); if line[line.len() - 1] != b'\n' { - out.write([b'\n']).unwrap(); + out.write(&[b'\n']).unwrap(); } } @@ -460,7 +460,7 @@ pub fn uumain(args: Vec) -> int { optflag("", "version", "output version information and exit"), ]; - let matches = match getopts(args.tail(), opts) { + let matches = match getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => { show_error!("Invalid options\n{}", f) @@ -472,7 +472,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {0} OPTION... [FILE]...", args[0]); println!(""); - print(usage("Print selected parts of lines from each FILE to standard output.", opts).as_slice()); + print(usage("Print selected parts of lines from each FILE to standard output.", &opts).as_slice()); println!(""); println!("Use one, and only one of -b, -c or -f. Each LIST is made up of one"); println!("range, or many ranges separated by commas. Selected input is written"); diff --git a/src/dirname/dirname.rs b/src/dirname/dirname.rs index 75db84529..0ca8286c1 100644 --- a/src/dirname/dirname.rs +++ b/src/dirname/dirname.rs @@ -23,7 +23,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => panic!("Invalid options\n{}", f) }; @@ -36,7 +36,7 @@ pub fn uumain(args: Vec) -> int { println!(""); print(getopts::usage("Output each NAME with its last non-slash component and trailing slashes removed; if NAME contains no /'s, output '.' (meaning the current -directory).", opts).as_slice()); +directory).", &opts).as_slice()); return 0; } diff --git a/src/du/du.rs b/src/du/du.rs index d119a6a9b..bebbfd103 100644 --- a/src/du/du.rs +++ b/src/du/du.rs @@ -157,7 +157,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => { show_error!("Invalid options\n{}", f); @@ -184,7 +184,7 @@ Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (pow‐ ers of 1000).", program = program, version = VERSION, - usage = getopts::usage("Summarize disk usage of each FILE, recursively for directories.", opts)); + usage = getopts::usage("Summarize disk usage of each FILE, recursively for directories.", &opts)); return 0; } else if matches.opt_present("version") { println!("{} version: {}", program, VERSION); diff --git a/src/echo/echo.rs b/src/echo/echo.rs index 545970cbe..773417b30 100644 --- a/src/echo/echo.rs +++ b/src/echo/echo.rs @@ -142,7 +142,7 @@ fn print_help(program: &String) { println!(" {0:s} [SHORT-OPTION]... [STRING]...", *program); println!(" {0:s} LONG-OPTION", *program); println!(""); - println(getopts::usage("Echo the STRING(s) to standard output.", opts).as_slice()); + println(getopts::usage("Echo the STRING(s) to standard output.", &opts).as_slice()); println("If -e is in effect, the following sequences are recognized: \\\\ backslash diff --git a/src/expand/expand.rs b/src/expand/expand.rs index 08f48c1a1..557335cb1 100644 --- a/src/expand/expand.rs +++ b/src/expand/expand.rs @@ -82,7 +82,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => crash!(1, "{}", f) }; @@ -91,7 +91,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage: {:s} [OPTION]... [FILE]...", NAME); io::print(getopts::usage( "Convert tabs in each FILE to spaces, writing to standard output.\n\ - With no FILE, or when FILE is -, read standard input.", opts).as_slice()); + With no FILE, or when FILE is -, read standard input.", &opts).as_slice()); return 0; } diff --git a/src/factor/factor.rs b/src/factor/factor.rs index e5399fdb1..757b01932 100644 --- a/src/factor/factor.rs +++ b/src/factor/factor.rs @@ -69,7 +69,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("v", "version", "print the version and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => crash!(1, "Invalid options\n{}", f) }; @@ -82,7 +82,7 @@ pub fn uumain(args: Vec) -> int { \t{program} [OPTION]\n\ \n\ {usage}", program = program, version = VERSION, usage = getopts::usage("Print the prime factors of the given number(s). \ - If none are specified, read from standard input.", opts)); + If none are specified, read from standard input.", &opts)); return 1; } if matches.opt_present("version") { diff --git a/src/fold/fold.rs b/src/fold/fold.rs index cb9a9fce9..399d034d6 100644 --- a/src/fold/fold.rs +++ b/src/fold/fold.rs @@ -36,7 +36,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit") ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => crash!(1, "{}", f) }; @@ -47,7 +47,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {} [OPTION]... [FILE]...", program); println!(""); - print!("{}", getopts::usage("Writes each file (or standard input if no files are given) to standard output whilst breaking long lines", opts)); + print!("{}", getopts::usage("Writes each file (or standard input if no files are given) to standard output whilst breaking long lines", &opts)); } else if matches.opt_present("V") { println!("{} v{}", NAME, VERSION); } else { diff --git a/src/groups/groups.rs b/src/groups/groups.rs index c29aa077f..b1989e14b 100644 --- a/src/groups/groups.rs +++ b/src/groups/groups.rs @@ -33,7 +33,7 @@ pub fn uumain(args: Vec) -> int { optflag("V", "version", "display version information and exit") ]; - let matches = match getopts(args.tail(), options) { + let matches = match getopts(args.tail(), &options) { Ok(m) => { m }, Err(f) => { show_error!("{}", f); @@ -47,7 +47,7 @@ pub fn uumain(args: Vec) -> int { print!("{} v{}\n\n\ Usage:\n \ {} [OPTION]... [USER]...\n\n\ - {}", NAME, VERSION, program, usage("Prints the groups a user is in to standard output.", options)); + {}", NAME, VERSION, program, usage("Prints the groups a user is in to standard output.", &options)); } else { group(get_pw_from_args(&matches.free), true); } diff --git a/src/hashsum/hashsum.rs b/src/hashsum/hashsum.rs index b8f41987e..7d649d71e 100644 --- a/src/hashsum/hashsum.rs +++ b/src/hashsum/hashsum.rs @@ -273,7 +273,7 @@ fn digest_reader(digest: &mut Box, reader: &mut Reader, binary: bool) -> let mut vec = Vec::with_capacity(524288); let mut looking_for_newline = false; loop { - match reader.read(buffer) { + match reader.read(&mut buffer) { Ok(0) => {}, Ok(nread) => { if windows && !binary { diff --git a/src/head/head.rs b/src/head/head.rs index 4e1d758be..b196942c6 100644 --- a/src/head/head.rs +++ b/src/head/head.rs @@ -46,16 +46,16 @@ pub fn uumain(args: Vec) -> int { optflag("V", "version", "version") ]; - let given_options = match getopts(args.as_slice(), possible_options) { + let given_options = match getopts(args.as_slice(), &possible_options) { Ok (m) => { m } Err(_) => { - println!("{:s}", usage(NAME, possible_options)); + println!("{:s}", usage(NAME, &possible_options)); return 1; } }; if given_options.opt_present("h") { - println!("{:s}", usage(NAME, possible_options)); + println!("{:s}", usage(NAME, &possible_options)); return 0; } if given_options.opt_present("V") { version(); return 0 } diff --git a/src/hostid/hostid.rs b/src/hostid/hostid.rs index 7e181c0b9..eeb899429 100644 --- a/src/hostid/hostid.rs +++ b/src/hostid/hostid.rs @@ -54,10 +54,10 @@ pub fn uumain(args: Vec) -> int { optflag("", "version", "output version information and exit"), ]; - let usage = usage("[options]", opts); + let usage = usage("[options]", &opts); - let matches = match getopts(args.tail(), opts) { + let matches = match getopts(args.tail(), &opts) { Ok(m) => m, Err(e) => { show_error!("{}\n{}", e, get_help_text(NAME, usage.as_slice())); diff --git a/src/hostname/hostname.rs b/src/hostname/hostname.rs index 2d3a57166..8588861d3 100644 --- a/src/hostname/hostname.rs +++ b/src/hostname/hostname.rs @@ -53,13 +53,13 @@ pub fn uumain(args: Vec) -> int { optflag("V", "version", "Show program's version") ]; - let matches = match getopts(args.tail(), options) { + let matches = match getopts(args.tail(), &options) { Ok(m) => { m } - _ => { help_menu(program.as_slice(), options); return 0; } + _ => { help_menu(program.as_slice(), &options); return 0; } }; if matches.opt_present("h") { - help_menu(program.as_slice(), options); + help_menu(program.as_slice(), &options); return 0 } if matches.opt_present("V") { version(); return 0 } @@ -110,7 +110,7 @@ pub fn uumain(args: Vec) -> int { } } 1 => xsethostname(matches.free.last().unwrap().as_slice()), - _ => help_menu(program.as_slice(), options) + _ => help_menu(program.as_slice(), &options) }; 0 diff --git a/src/id/id.rs b/src/id/id.rs index 15ef512dc..ee4ba81ee 100644 --- a/src/id/id.rs +++ b/src/id/id.rs @@ -100,16 +100,16 @@ pub fn uumain(args: Vec) -> int { optflag("u", "", "Display the effective user ID as a number") ]; - let matches = match getopts(args_t, options) { + let matches = match getopts(args_t, &options) { Ok(m) => { m }, Err(_) => { - println!("{:s}", usage(NAME, options)); + println!("{:s}", usage(NAME, &options)); return 1; } }; if matches.opt_present("h") { - println!("{:s}", usage(NAME, options)); + println!("{:s}", usage(NAME, &options)); return 0; } diff --git a/src/kill/kill.rs b/src/kill/kill.rs index 18d07829e..910655729 100644 --- a/src/kill/kill.rs +++ b/src/kill/kill.rs @@ -61,11 +61,11 @@ pub fn uumain(args: Vec) -> int { optflag("L", "table", "list all signal names in a nice table"), ]; - let usage = usage("[options] [...]", opts); + let usage = usage("[options] [...]", &opts); let (args, obs_signal) = handle_obsolete(args); - let matches = match getopts(args.tail(), opts) { + let matches = match getopts(args.tail(), &opts) { Ok(m) => m, Err(e) => { show_error!("{}\n{}", e, get_help_text(NAME, usage.as_slice())); diff --git a/src/link/link.rs b/src/link/link.rs index 81f6360b7..a0ab5c582 100644 --- a/src/link/link.rs +++ b/src/link/link.rs @@ -27,7 +27,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(err) => panic!("{}", err), }; diff --git a/src/logname/logname.rs b/src/logname/logname.rs index 6eb37352d..8462d5330 100644 --- a/src/logname/logname.rs +++ b/src/logname/logname.rs @@ -53,7 +53,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => crash!(1, "Invalid options\n{}", f) }; @@ -64,7 +64,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {:s}", program); println!(""); - print(getopts::usage("print user's login name", opts).as_slice()); + print(getopts::usage("print user's login name", &opts).as_slice()); return 0; } if matches.opt_present("version") { diff --git a/src/mkdir/mkdir.rs b/src/mkdir/mkdir.rs index b9cc0aac0..cd38180d1 100644 --- a/src/mkdir/mkdir.rs +++ b/src/mkdir/mkdir.rs @@ -41,7 +41,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "display this version") ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => { crash!(1, "Invalid options\n{}", f); @@ -49,7 +49,7 @@ pub fn uumain(args: Vec) -> int { }; if args.len() == 1 || matches.opt_present("help") { - print_help(opts); + print_help(&opts); return 0; } if matches.opt_present("version") { diff --git a/src/mkfifo/mkfifo.rs b/src/mkfifo/mkfifo.rs index 9b4f7b549..cd11902f4 100644 --- a/src/mkfifo/mkfifo.rs +++ b/src/mkfifo/mkfifo.rs @@ -30,7 +30,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(err) => panic!("{}", err), }; diff --git a/src/mv/mv.rs b/src/mv/mv.rs index 5c44a2f01..9d4a4ca8b 100644 --- a/src/mv/mv.rs +++ b/src/mv/mv.rs @@ -79,14 +79,14 @@ pub fn uumain(args: Vec) -> int { optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts(args.tail(), opts) { + let matches = match getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => { show_error!("Invalid options\n{}", f); return 1; } }; - let usage = usage("Move SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.", opts); + let usage = usage("Move SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.", &opts); /* This does not exactly match the GNU implementation: * The GNU mv defaults to Force, but if more than one of the diff --git a/src/nl/nl.rs b/src/nl/nl.rs index e254fb805..0e9b8c7ea 100644 --- a/src/nl/nl.rs +++ b/src/nl/nl.rs @@ -106,17 +106,17 @@ pub fn uumain(args: Vec) -> int { number_separator: String::from_str("\t"), }; - let given_options = match getopts(args.tail(), possible_options) { + let given_options = match getopts(args.tail(), &possible_options) { Ok (m) => { m } Err(f) => { show_error!("{}", f); - print_usage(possible_options); + print_usage(&possible_options); return 1 } }; if given_options.opt_present("help") { - print_usage(possible_options); + print_usage(&possible_options); return 0; } if given_options.opt_present("version") { version(); return 0; } diff --git a/src/nohup/nohup.rs b/src/nohup/nohup.rs index c077d3170..16d305fb2 100644 --- a/src/nohup/nohup.rs +++ b/src/nohup/nohup.rs @@ -79,17 +79,17 @@ pub fn uumain(args: Vec) -> int { optflag("V", "version", "Show version and exit"), ]; - let opts = match getopts(args.tail(), options) { + let opts = match getopts(args.tail(), &options) { Ok(m) => m, Err(f) => { show_error!("{}", f); - show_usage(program.as_slice(), options); + show_usage(program.as_slice(), &options); return 1 } }; if opts.opt_present("V") { version(); return 0 } - if opts.opt_present("h") { show_usage(program.as_slice(), options); return 0 } + if opts.opt_present("h") { show_usage(program.as_slice(), &options); return 0 } if opts.free.len() == 0 { show_error!("Missing operand: COMMAND"); diff --git a/src/nproc/nproc.rs b/src/nproc/nproc.rs index 881e48159..8bc88156d 100644 --- a/src/nproc/nproc.rs +++ b/src/nproc/nproc.rs @@ -29,7 +29,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(err) => { show_error!("{}", err); @@ -48,7 +48,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {} [OPTIONS] NAME...", NAME); println!(""); - print!("{}", getopts::usage("Print the number of cores available to the current process.", opts)); + print!("{}", getopts::usage("Print the number of cores available to the current process.", &opts)); return 0; } diff --git a/src/paste/paste.rs b/src/paste/paste.rs index fe17917e5..11a78ad26 100644 --- a/src/paste/paste.rs +++ b/src/paste/paste.rs @@ -31,7 +31,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit") ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => crash!(1, "{}", f) }; @@ -41,7 +41,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {0:s} [OPTION]... [FILE]...", program); println!(""); - print!("{}", getopts::usage("Write lines consisting of the sequentially corresponding lines from each FILE, separated by TABs, to standard output.", opts)); + print!("{}", getopts::usage("Write lines consisting of the sequentially corresponding lines from each FILE, separated by TABs, to standard output.", &opts)); } else if matches.opt_present("version") { println!("{} {}", NAME, VERSION); } else { diff --git a/src/printenv/printenv.rs b/src/printenv/printenv.rs index faa4e37bf..d933cb52f 100644 --- a/src/printenv/printenv.rs +++ b/src/printenv/printenv.rs @@ -31,7 +31,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => { crash!(1, "Invalid options\n{}", f) @@ -43,7 +43,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {0:s} [VARIABLE]... [OPTION]...", program); println!(""); - print(getopts::usage("Prints the given environment VARIABLE(s), otherwise prints them all.", opts).as_slice()); + print(getopts::usage("Prints the given environment VARIABLE(s), otherwise prints them all.", &opts).as_slice()); return 0; } if matches.opt_present("version") { diff --git a/src/pwd/pwd.rs b/src/pwd/pwd.rs index a4140a8e0..09974a836 100644 --- a/src/pwd/pwd.rs +++ b/src/pwd/pwd.rs @@ -29,7 +29,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => { crash!(1, "Invalid options\n{}", f) @@ -42,14 +42,14 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {0:s} [OPTION] NAME...", program); println!(""); - print(getopts::usage("Print the full filename of the current working directory.", opts).as_slice()); + print(getopts::usage("Print the full filename of the current working directory.", &opts).as_slice()); } else if matches.opt_present("version") { println!("pwd version: {}", VERSION); return 0; } else { let cwd = std::os::getcwd(); - println!("{}", cwd.display()); + println!("{}", cwd.unwrap().display()); return 0; } diff --git a/src/realpath/realpath.rs b/src/realpath/realpath.rs index b5b8b1570..e4ab63729 100644 --- a/src/realpath/realpath.rs +++ b/src/realpath/realpath.rs @@ -30,17 +30,17 @@ pub fn uumain(args: Vec) -> int { optflag("q", "quiet", "Do not print warnings for invalid paths"), ]; - let opts = match getopts(args.tail(), options) { + let opts = match getopts(args.tail(), &options) { Ok(m) => m, Err(f) => { show_error!("{}", f); - show_usage(program.as_slice(), options); + show_usage(program.as_slice(), &options); return 1 } }; if opts.opt_present("V") { version(); return 0 } - if opts.opt_present("h") { show_usage(program.as_slice(), options); return 0 } + if opts.opt_present("h") { show_usage(program.as_slice(), &options); return 0 } if opts.free.len() == 0 { show_error!("Missing operand: FILENAME, at least one is required"); diff --git a/src/relpath/relpath.rs b/src/relpath/relpath.rs index 26c0f2ede..9a7e8119a 100644 --- a/src/relpath/relpath.rs +++ b/src/relpath/relpath.rs @@ -28,17 +28,17 @@ pub fn uumain(args: Vec) -> int { optopt("d", "", "If any of FROM and TO is not subpath of DIR, output absolute path instead of relative", "DIR"), ]; - let opts = match getopts(args.tail(), options) { + let opts = match getopts(args.tail(), &options) { Ok(m) => m, Err(f) => { show_error!("{}", f); - show_usage(program.as_slice(), options); + show_usage(program.as_slice(), &options); return 1 } }; if opts.opt_present("V") { version(); return 0 } - if opts.opt_present("h") { show_usage(program.as_slice(), options); return 0 } + if opts.opt_present("h") { show_usage(program.as_slice(), &options); return 0 } if opts.free.len() == 0 { show_error!("Missing operand: TO"); diff --git a/src/rm/rm.rs b/src/rm/rm.rs index d74f2b8f8..791a5c940 100644 --- a/src/rm/rm.rs +++ b/src/rm/rm.rs @@ -47,7 +47,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit") ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => { crash!(1, "{}", f) @@ -59,7 +59,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {0:s} [OPTION]... [FILE]...", program); println!(""); - print(getopts::usage("Remove (unlink) the FILE(s).", opts).as_slice()); + print(getopts::usage("Remove (unlink) the FILE(s).", &opts).as_slice()); println!(""); println!("By default, rm does not remove directories. Use the --recursive (-r)"); println!("option to remove each listed directory, too, along with all of its contents"); diff --git a/src/rmdir/rmdir.rs b/src/rmdir/rmdir.rs index b85298ef1..b2723d2fc 100644 --- a/src/rmdir/rmdir.rs +++ b/src/rmdir/rmdir.rs @@ -32,7 +32,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("h", "help", "print this help and exit"), getopts::optflag("V", "version", "output version information and exit") ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => { show_error!("{}", f); @@ -46,7 +46,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {0:s} [OPTION]... DIRECTORY...", program); println!(""); - print(getopts::usage("Remove the DIRECTORY(ies), if they are empty.", opts).as_slice()); + print(getopts::usage("Remove the DIRECTORY(ies), if they are empty.", &opts).as_slice()); } else if matches.opt_present("version") { println!("rmdir 1.0.0"); } else if matches.free.is_empty() { diff --git a/src/seq/seq.rs b/src/seq/seq.rs index fc2d60cba..741dd2f7a 100644 --- a/src/seq/seq.rs +++ b/src/seq/seq.rs @@ -136,7 +136,7 @@ fn print_help(program: &String) { ]; println!("seq 1.0.0\n"); println!("Usage:\n {} [-w] [-s string] [-t string] [first [step]] last\n", *program); - println!("{:s}", getopts::usage("Print sequences of numbers", opts)); + println!("{:s}", getopts::usage("Print sequences of numbers", &opts)); } fn print_version() { diff --git a/src/shuf/shuf.rs b/src/shuf/shuf.rs index dd00e014f..07d15529f 100644 --- a/src/shuf/shuf.rs +++ b/src/shuf/shuf.rs @@ -48,7 +48,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit") ]; - let mut matches = match getopts::getopts(args.tail(), opts) { + let mut matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => { crash!(1, "{}", f) @@ -64,7 +64,7 @@ Usage: {usage} With no FILE, or when FILE is -, read standard input.", name = NAME, version = VERSION, prog = program, - usage = getopts::usage("Write a random permutation of the input lines to standard output.", opts)); + usage = getopts::usage("Write a random permutation of the input lines to standard output.", &opts)); } else if matches.opt_present("version") { println!("{} v{}", NAME, VERSION); } else { diff --git a/src/sleep/sleep.rs b/src/sleep/sleep.rs index cf18d104a..8ebf037c2 100644 --- a/src/sleep/sleep.rs +++ b/src/sleep/sleep.rs @@ -33,7 +33,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit") ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => { show_error!("{}", f); @@ -53,7 +53,7 @@ pub fn uumain(args: Vec) -> int { 'm' for minutes, 'h' for hours or 'd' for days. Unlike most implementations that require NUMBER be an integer, here NUMBER may be an arbitrary floating point number. Given two or more arguments, pause for the amount of time -specified by the sum of their values.", opts).as_slice()); +specified by the sum of their values.", &opts).as_slice()); } else if matches.opt_present("version") { println!("sleep 1.0.0"); } else if matches.free.is_empty() { diff --git a/src/sort/sort.rs b/src/sort/sort.rs index 0836ce032..490481852 100644 --- a/src/sort/sort.rs +++ b/src/sort/sort.rs @@ -35,7 +35,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => crash!(1, "Invalid options\n{}", f) }; @@ -43,7 +43,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage: {0:s} [OPTION]... [FILE]...", program); println!("Write the sorted concatenation of all FILE(s) to standard output."); println!(""); - print(getopts::usage("Mandatory arguments for long options are mandatory for short options too.", opts).as_slice()); + print(getopts::usage("Mandatory arguments for long options are mandatory for short options too.", &opts).as_slice()); println!(""); println!("With no FILE, or when FILE is -, read standard input."); return 0; diff --git a/src/split/split.rs b/src/split/split.rs index 844ac2ef3..3a11d828c 100644 --- a/src/split/split.rs +++ b/src/split/split.rs @@ -36,7 +36,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => crash!(1, "{}", f) }; @@ -47,7 +47,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {0:s} [OPTION]... [INPUT [PREFIX]]", NAME); println!(""); - io::print(getopts::usage("Output fixed-size pieces of INPUT to PREFIXaa, PREFIX ab, ...; default size is 1000, and default PREFIX is 'x'. With no INPUT, or when INPUT is -, read standard input." , opts).as_slice()); + io::print(getopts::usage("Output fixed-size pieces of INPUT to PREFIXaa, PREFIX ab, ...; default size is 1000, and default PREFIX is 'x'. With no INPUT, or when INPUT is -, read standard input." , &opts).as_slice()); return 0; } diff --git a/src/sum/sum.rs b/src/sum/sum.rs index 49025565a..9a6533fa5 100644 --- a/src/sum/sum.rs +++ b/src/sum/sum.rs @@ -27,7 +27,7 @@ fn bsd_sum(mut reader: Box) -> (uint, u16) { let mut blocks_read = 0; let mut checksum: u16 = 0; loop { - match reader.read(buf) { + match reader.read(&mut buf) { Ok(n) if n != 0 => { blocks_read += 1; for &byte in buf.slice_to(n).iter() { @@ -48,7 +48,7 @@ fn sysv_sum(mut reader: Box) -> (uint, u16) { let mut ret = 0; loop { - match reader.read(buf) { + match reader.read(&mut buf) { Ok(n) if n != 0 => { blocks_read += 1; for &byte in buf.slice_to(n).iter() { @@ -84,7 +84,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("v", "version", "print the version and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => crash!(1, "Invalid options\n{}", f) }; @@ -95,7 +95,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {0:s} [OPTION]... [FILE]...", program); println!(""); - print(getopts::usage("checksum and count the blocks in a file", opts).as_slice()); + print(getopts::usage("checksum and count the blocks in a file", &opts).as_slice()); println!(""); println!("With no FILE, or when FILE is -, read standard input."); return 0; diff --git a/src/sync/sync.rs b/src/sync/sync.rs index e79873f1e..adef9c97a 100644 --- a/src/sync/sync.rs +++ b/src/sync/sync.rs @@ -148,13 +148,13 @@ pub fn uumain(args: Vec) -> int { optflag("V", "version", "output version information and exit") ]; - let matches = match getopts(args.tail(), options) { + let matches = match getopts(args.tail(), &options) { Ok(m) => { m } - _ => { help(program.as_slice(), options); return 1 } + _ => { help(program.as_slice(), &options); return 1 } }; if matches.opt_present("h") { - help(program.as_slice(), options); + help(program.as_slice(), &options); return 0 } diff --git a/src/tac/tac.rs b/src/tac/tac.rs index d2972682a..d2e1a0ad4 100644 --- a/src/tac/tac.rs +++ b/src/tac/tac.rs @@ -32,7 +32,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit") ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => crash!(1, "{}", f) }; @@ -42,7 +42,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {0:s} [OPTION]... [FILE]...", program); println!(""); - print!("{}", getopts::usage("Write each file to standard output, last line first.", opts)); + print!("{}", getopts::usage("Write each file to standard output, last line first.", &opts)); } else if matches.opt_present("version") { println!("tac {}", VERSION); } else { diff --git a/src/tail/tail.rs b/src/tail/tail.rs index 943c1da6a..beabc5cc8 100644 --- a/src/tail/tail.rs +++ b/src/tail/tail.rs @@ -54,16 +54,16 @@ pub fn uumain(args: Vec) -> int { optflag("V", "version", "version"), ]; - let given_options = match getopts(args.as_slice(), possible_options) { + let given_options = match getopts(args.as_slice(), &possible_options) { Ok (m) => { m } Err(_) => { - println!("{:s}", usage(NAME, possible_options)); + println!("{:s}", usage(NAME, &possible_options)); return 1; } }; if given_options.opt_present("h") { - println!("{:s}", usage(NAME, possible_options)); + println!("{:s}", usage(NAME, &possible_options)); return 0; } if given_options.opt_present("V") { version(); return 0 } diff --git a/src/tee/tee.rs b/src/tee/tee.rs index 9aa8873d0..40634d567 100644 --- a/src/tee/tee.rs +++ b/src/tee/tee.rs @@ -50,14 +50,14 @@ fn options(args: &[String]) -> Result { let args: Vec = args.iter().map(|x| x.to_string()).collect(); - getopts(args.tail(), opts).map_err(|e| format!("{}", e)).and_then(|m| { + getopts(args.tail(), &opts).map_err(|e| format!("{}", e)).and_then(|m| { let version = format!("{} {}", NAME, VERSION); 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."; let help = format!("{}\n\nUsage:\n {} {}\n\n{}\n{}", - version, program, arguments, usage(brief, opts), + version, program, arguments, usage(brief, &opts), comment); let mut names = m.free.clone().into_iter().collect::>(); names.push("-".to_string()); diff --git a/src/timeout/timeout.rs b/src/timeout/timeout.rs index eab5a464b..349ba26fa 100644 --- a/src/timeout/timeout.rs +++ b/src/timeout/timeout.rs @@ -46,7 +46,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit") ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => { crash!(ERR_EXIT_STATUS, "{}", f) @@ -58,7 +58,7 @@ pub fn uumain(args: Vec) -> int { Usage: {} [OPTION] DURATION COMMAND [ARG]... -{}", NAME, VERSION, program, getopts::usage("Start COMMAND, and kill it if still running after DURATION.", opts)); +{}", NAME, VERSION, program, getopts::usage("Start COMMAND, and kill it if still running after DURATION.", &opts)); } else if matches.opt_present("version") { println!("{} v{}", NAME, VERSION); } else if matches.free.len() < 2 { diff --git a/src/touch/touch.rs b/src/touch/touch.rs index 9752200e9..4de7bacb2 100644 --- a/src/touch/touch.rs +++ b/src/touch/touch.rs @@ -39,7 +39,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(e) => panic!("Invalid options\n{}", e) }; @@ -55,16 +55,16 @@ pub fn uumain(args: Vec) -> int { println!("Usage: {:s} [OPTION]... FILE...", NAME); println!(""); println!("{:s}", getopts::usage("Update the access and modification times of \ - each FILE to the current time.", opts)); + each FILE to the current time.", &opts)); if matches.free.is_empty() { return 1; } return 0; } - if matches.opt_present("date") && matches.opts_present(["reference".to_string(), "t".to_string()]) || - matches.opt_present("reference") && matches.opts_present(["date".to_string(), "t".to_string()]) || - matches.opt_present("t") && matches.opts_present(["date".to_string(), "reference".to_string()]) { + if matches.opt_present("date") && matches.opts_present(&["reference".to_string(), "t".to_string()]) || + matches.opt_present("reference") && matches.opts_present(&["date".to_string(), "t".to_string()]) || + matches.opt_present("t") && matches.opts_present(&["date".to_string(), "reference".to_string()]) { panic!("Invalid options: cannot specify reference time from more than one source"); } @@ -73,7 +73,7 @@ pub fn uumain(args: Vec) -> int { let path = Path::new(matches.opt_str("reference").unwrap().to_string()); let stat = stat(&path, !matches.opt_present("no-dereference")); (stat.accessed, stat.modified) - } else if matches.opts_present(["date".to_string(), "t".to_string()]) { + } else if matches.opts_present(&["date".to_string(), "t".to_string()]) { let timestamp = if matches.opt_present("date") { parse_date(matches.opt_str("date").unwrap().as_slice()) } else { @@ -91,7 +91,7 @@ pub fn uumain(args: Vec) -> int { if !path.exists() { // no-dereference included here for compatibility - if matches.opts_present(["no-create".to_string(), "no-dereference".to_string()]) { + if matches.opts_present(&["no-create".to_string(), "no-dereference".to_string()]) { continue; } @@ -101,14 +101,14 @@ pub fn uumain(args: Vec) -> int { }; // Minor optimization: if no reference time was specified, we're done. - if !matches.opts_present(["date".to_string(), "reference".to_string(), "t".to_string()]) { + if !matches.opts_present(&["date".to_string(), "reference".to_string(), "t".to_string()]) { continue; } } // If changing "only" atime or mtime, grab the existing value of the other. // Note that "-a" and "-m" may be passed together; this is not an xor. - if matches.opts_present(["a".to_string(), "m".to_string(), "time".to_string()]) { + if matches.opts_present(&["a".to_string(), "m".to_string(), "time".to_string()]) { let stat = stat(&path, !matches.opt_present("no-dereference")); let time = matches.opt_strs("time"); diff --git a/src/tr/tr.rs b/src/tr/tr.rs index 7036b2ca4..e03b5d7e6 100644 --- a/src/tr/tr.rs +++ b/src/tr/tr.rs @@ -154,7 +154,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(err) => { show_error!("{}", err); @@ -163,7 +163,7 @@ pub fn uumain(args: Vec) -> int { }; if matches.opt_present("help") { - usage(opts); + usage(&opts); return 0; } @@ -173,12 +173,12 @@ pub fn uumain(args: Vec) -> int { } if matches.free.len() == 0 { - usage(opts); + usage(&opts); return 1; } let dflag = matches.opt_present("d"); - let cflag = matches.opts_present(["c".to_string(), "C".to_string()]); + let cflag = matches.opts_present(&["c".to_string(), "C".to_string()]); let sets = matches.free; if cflag && !dflag { diff --git a/src/truncate/truncate.rs b/src/truncate/truncate.rs index f0e5ea4bf..e52bd61d5 100644 --- a/src/truncate/truncate.rs +++ b/src/truncate/truncate.rs @@ -44,7 +44,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit") ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => { crash!(1, "{}", f) @@ -57,7 +57,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {0:s} [OPTION]... FILE...", program); println!(""); - print!("{}", getopts::usage("Shrink or extend the size of each file to the specified size.", opts)); + print!("{}", getopts::usage("Shrink or extend the size of each file to the specified size.", &opts)); print!(" SIZE is an integer with an optional prefix and optional unit. The available units (K, M, G, T, P, E, Z, and Y) use the following format: diff --git a/src/tsort/tsort.rs b/src/tsort/tsort.rs index 0f320c259..c4dd9659c 100644 --- a/src/tsort/tsort.rs +++ b/src/tsort/tsort.rs @@ -30,7 +30,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => crash!(1, "{}", f) }; @@ -41,7 +41,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {} [OPTIONS] FILE", NAME); println!(""); - io::print(getopts::usage("Topological sort the strings in FILE. Strings are defined as any sequence of tokens separated by whitespace (tab, space, or newline). If FILE is not passed in, stdin is used instead.", opts).as_slice()); + io::print(getopts::usage("Topological sort the strings in FILE. Strings are defined as any sequence of tokens separated by whitespace (tab, space, or newline). If FILE is not passed in, stdin is used instead.", &opts).as_slice()); return 0; } diff --git a/src/tty/tty.rs b/src/tty/tty.rs index 238ef911d..03103b554 100644 --- a/src/tty/tty.rs +++ b/src/tty/tty.rs @@ -39,7 +39,7 @@ pub fn uumain(args: Vec) -> int { optflag("s", "silent", "print nothing, only return an exit status") ]; - let silent = match getopts(args.tail(), options) { + let silent = match getopts(args.tail(), &options) { Ok(m) => { m.opt_present("s") }, diff --git a/src/uname/uname.rs b/src/uname/uname.rs index aa8c99747..6d765a8c2 100644 --- a/src/uname/uname.rs +++ b/src/uname/uname.rs @@ -64,7 +64,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("s", "sysname", "print the operating system name."), getopts::optflag("v", "version", "print the operating system version."), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => crash!(1, "{}", f), }; @@ -74,13 +74,13 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {:s}", program); println!(""); - print(getopts::usage("The uname utility writes symbols representing one or more system characteristics to the standard output.", opts).as_slice()); + print(getopts::usage("The uname utility writes symbols representing one or more system characteristics to the standard output.", &opts).as_slice()); return 0; } let uname = unsafe { getuname() }; let mut output = String::new(); if matches.opt_present("sysname") || matches.opt_present("all") - || !matches.opts_present(["nodename".to_string(), "release".to_string(), "version".to_string(), "machine".to_string()]) { + || !matches.opts_present(&["nodename".to_string(), "release".to_string(), "version".to_string(), "machine".to_string()]) { output.push_str(uname.sysname.as_slice()); output.push_str(" "); } diff --git a/src/unexpand/unexpand.rs b/src/unexpand/unexpand.rs index f37ccf2b6..12ffd573f 100644 --- a/src/unexpand/unexpand.rs +++ b/src/unexpand/unexpand.rs @@ -84,7 +84,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => crash!(1, "{}", f) }; @@ -93,7 +93,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage: {:s} [OPTION]... [FILE]...", NAME); io::print(getopts::usage( "Convert blanks in each FILE to tabs, writing to standard output.\n\ - With no FILE, or when FILE is -, read standard input.", opts).as_slice()); + With no FILE, or when FILE is -, read standard input.", &opts).as_slice()); return 0; } diff --git a/src/uniq/uniq.rs b/src/uniq/uniq.rs index c029d606b..1a6aa5427 100644 --- a/src/uniq/uniq.rs +++ b/src/uniq/uniq.rs @@ -138,7 +138,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit") ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => crash!(1, "{}", f) }; @@ -150,7 +150,7 @@ pub fn uumain(args: Vec) -> int { println!(" {0:s} [OPTION]... [FILE]...", program); println!(""); print!("{}", getopts::usage("Filter adjacent matching lines from INPUT (or standard input),\n\ - writing to OUTPUT (or standard output).", opts)); + writing to OUTPUT (or standard output).", &opts)); println!(""); println!("Note: '{0}' does not detect repeated lines unless they are adjacent.\n\ You may want to sort the input first, or use 'sort -u' without '{0}'.\n", program); diff --git a/src/unlink/unlink.rs b/src/unlink/unlink.rs index 6b81f4793..773be53a6 100644 --- a/src/unlink/unlink.rs +++ b/src/unlink/unlink.rs @@ -32,7 +32,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => { crash!(1, "invalid options\n{}", f) @@ -45,7 +45,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {0:s} [FILE]... [OPTION]...", program); println!(""); - print(getopts::usage("Unlink the file at [FILE].", opts).as_slice()); + print(getopts::usage("Unlink the file at [FILE].", &opts).as_slice()); return 0; } diff --git a/src/uptime/uptime.rs b/src/uptime/uptime.rs index 593dbad25..be4b1dbe2 100644 --- a/src/uptime/uptime.rs +++ b/src/uptime/uptime.rs @@ -58,7 +58,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("v", "version", "output version information and exit"), getopts::optflag("h", "help", "display this help and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => crash!(1, "Invalid options\n{}", f) }; @@ -72,7 +72,7 @@ pub fn uumain(args: Vec) -> int { println!(""); print(getopts::usage("Print the current time, the length of time the system has been up,\n\ the number of users on the system, and the average number of jobs\n\ - in the run queue over the last 1, 5 and 15 minutes.", opts).as_slice()); + in the run queue over the last 1, 5 and 15 minutes.", &opts).as_slice()); return 0; } diff --git a/src/users/users.rs b/src/users/users.rs index ba9914b14..f97aa9628 100644 --- a/src/users/users.rs +++ b/src/users/users.rs @@ -59,7 +59,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => panic!("{}", f), }; @@ -70,7 +70,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {:s} [OPTION]... [FILE]", program); println!(""); - print(getopts::usage("Output who is currently logged in according to FILE.", opts).as_slice()); + print(getopts::usage("Output who is currently logged in according to FILE.", &opts).as_slice()); return 0; } diff --git a/src/wc/wc.rs b/src/wc/wc.rs index d5f616cff..1b2b59a55 100644 --- a/src/wc/wc.rs +++ b/src/wc/wc.rs @@ -47,7 +47,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => { crash!(1, "Invalid options\n{}", f) @@ -58,7 +58,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {0:s} [OPTION]... [FILE]...", program); println!(""); - print(getopts::usage("Print newline, word and byte counts for each FILE", opts).as_slice()); + print(getopts::usage("Print newline, word and byte counts for each FILE", &opts).as_slice()); println!(""); println!("With no FILE, or when FILE is -, read standard input."); return 0; diff --git a/src/whoami/whoami.rs b/src/whoami/whoami.rs index 9e2a6f36b..e19e585fa 100644 --- a/src/whoami/whoami.rs +++ b/src/whoami/whoami.rs @@ -72,7 +72,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => crash!(1, "{}", f), }; @@ -82,7 +82,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {:s}", program); println!(""); - print(getopts::usage("print effective userid", opts).as_slice()); + print(getopts::usage("print effective userid", &opts).as_slice()); return 0; } if matches.opt_present("version") { diff --git a/src/yes/yes.rs b/src/yes/yes.rs index cd51e745c..275ea7241 100644 --- a/src/yes/yes.rs +++ b/src/yes/yes.rs @@ -29,7 +29,7 @@ pub fn uumain(args: Vec) -> int { getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit"), ]; - let matches = match getopts::getopts(args.tail(), opts) { + let matches = match getopts::getopts(args.tail(), &opts) { Ok(m) => m, Err(f) => { crash!(1, "invalid options\n{}", f) @@ -41,7 +41,7 @@ pub fn uumain(args: Vec) -> int { println!("Usage:"); println!(" {0:s} [STRING]... [OPTION]...", program); println!(""); - print(getopts::usage("Repeatedly output a line with all specified STRING(s), or 'y'.", opts).as_slice()); + print(getopts::usage("Repeatedly output a line with all specified STRING(s), or 'y'.", &opts).as_slice()); return 0; } if matches.opt_present("version") {