mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 12:37:49 +00:00
Update for lastest Rust
This commit is contained in:
parent
9b3b8622ed
commit
bc6cd77132
55 changed files with 123 additions and 129 deletions
|
@ -52,7 +52,7 @@ pub fn uumain(args: Vec<String>) -> 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 usage = usage("Base64 encode or decode FILE, or standard input, to standard output.", opts);
|
||||||
let mode = if matches.opt_present("help") {
|
let mode = if matches.opt_present("help") {
|
||||||
Help
|
Help
|
||||||
|
@ -76,11 +76,11 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
};
|
};
|
||||||
let mut stdin_buf;
|
let mut stdin_buf;
|
||||||
let mut file_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();
|
stdin_buf = stdin_raw();
|
||||||
&mut stdin_buf as &mut Reader
|
&mut stdin_buf as &mut Reader
|
||||||
} else {
|
} 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);
|
file_buf = File::open(&path);
|
||||||
&mut file_buf as &mut Reader
|
&mut file_buf as &mut Reader
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,7 +23,7 @@ static NAME: &'static str = "basename";
|
||||||
static VERSION: &'static str = "1.0.0";
|
static VERSION: &'static str = "1.0.0";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = strip_dir(args.get(0).as_slice());
|
let program = strip_dir(args[0].as_slice());
|
||||||
|
|
||||||
//
|
//
|
||||||
// Argument parsing
|
// Argument parsing
|
||||||
|
@ -62,7 +62,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
}
|
}
|
||||||
// too many arguments
|
// too many arguments
|
||||||
else if args.len() > 3 {
|
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);
|
println!("Try '{} --help' for more information.", program);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -71,12 +71,12 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
// Main Program Processing
|
// Main Program Processing
|
||||||
//
|
//
|
||||||
|
|
||||||
let fullname = args.get(1);
|
let fullname = &args[1];
|
||||||
|
|
||||||
let mut name = strip_dir(fullname.as_slice());
|
let mut name = strip_dir(fullname.as_slice());
|
||||||
|
|
||||||
if args.len() > 2 {
|
if args.len() > 2 {
|
||||||
let suffix = args.get(2).clone();
|
let suffix = args[2].clone();
|
||||||
name = strip_suffix(name.as_slice(), suffix.as_slice());
|
name = strip_suffix(name.as_slice(), suffix.as_slice());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ use std::io::{IoResult};
|
||||||
use std::ptr::{copy_nonoverlapping_memory};
|
use std::ptr::{copy_nonoverlapping_memory};
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).as_slice();
|
let program = args[0].as_slice();
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("A", "show-all", "equivalent to -vET"),
|
getopts::optflag("A", "show-all", "equivalent to -vET"),
|
||||||
getopts::optflag("b", "number-nonblank",
|
getopts::optflag("b", "number-nonblank",
|
||||||
|
|
|
@ -37,7 +37,7 @@ static NAME: &'static str = "chroot";
|
||||||
static VERSION: &'static str = "1.0.0";
|
static VERSION: &'static str = "1.0.0";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0);
|
let program = &args[0];
|
||||||
|
|
||||||
let options = [
|
let options = [
|
||||||
optopt("u", "user", "User (ID or name) to switch before running the program", "USER"),
|
optopt("u", "user", "User (ID or name) to switch before running the program", "USER"),
|
||||||
|
@ -72,7 +72,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
let defaultOption: &'static str = "-i";
|
let defaultOption: &'static str = "-i";
|
||||||
let userShell = std::os::getenv("SHELL");
|
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() {
|
if !newroot.is_dir() {
|
||||||
crash!(1, "cannot change root directory to `{}`: no such directory", newroot.display());
|
crash!(1, "cannot change root directory to `{}`: no such directory", newroot.display());
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
set_context(&newroot, &opts);
|
set_context(&newroot, &opts);
|
||||||
|
|
||||||
unsafe {
|
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();
|
let mut commandParts: Vec<*const i8> = command.iter().map(|x| x.to_c_str().unwrap()).collect();
|
||||||
commandParts.push(std::ptr::null());
|
commandParts.push(std::ptr::null());
|
||||||
execvp(executable as *const libc::c_char, commandParts.as_ptr() as *mut *const libc::c_char) as int
|
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()
|
None => Vec::new()
|
||||||
};
|
};
|
||||||
let user = if userspec.is_empty() { userStr.as_slice() } else { userspec.get(0).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.get(1).as_slice() };
|
let group = if userspec.is_empty() { groupStr.as_slice() } else { userspec[1].as_slice() };
|
||||||
|
|
||||||
enter_chroot(root);
|
enter_chroot(root);
|
||||||
|
|
||||||
|
|
10
comm/comm.rs
10
comm/comm.rs
|
@ -62,19 +62,19 @@ fn comm(a: &mut Box<Buffer>, b: &mut Box<Buffer>, opts: &getopts::Matches) {
|
||||||
match ord {
|
match ord {
|
||||||
Less => {
|
Less => {
|
||||||
if !opts.opt_present("1") {
|
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();
|
ra = a.read_line();
|
||||||
}
|
}
|
||||||
Greater => {
|
Greater => {
|
||||||
if !opts.opt_present("2") {
|
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();
|
rb = b.read_line();
|
||||||
}
|
}
|
||||||
Equal => {
|
Equal => {
|
||||||
if !opts.opt_present("3") {
|
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();
|
ra = a.read_line();
|
||||||
rb = b.read_line();
|
rb = b.read_line();
|
||||||
|
@ -127,8 +127,8 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let mut f1 = open_file(matches.free.get(0).as_slice()).unwrap();
|
let mut f1 = open_file(matches.free[0].as_slice()).unwrap();
|
||||||
let mut f2 = open_file(matches.free.get(1).as_slice()).unwrap();
|
let mut f2 = open_file(matches.free[1].as_slice()).unwrap();
|
||||||
|
|
||||||
comm(&mut f1, &mut f2, &matches);
|
comm(&mut f1, &mut f2, &matches);
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ extern {
|
||||||
|
|
||||||
pub fn get_pw_from_args(free: &Vec<String>) -> Option<c_passwd> {
|
pub fn get_pw_from_args(free: &Vec<String>) -> Option<c_passwd> {
|
||||||
if free.len() == 1 {
|
if free.len() == 1 {
|
||||||
let username = free.get(0).as_slice();
|
let username = free[0].as_slice();
|
||||||
|
|
||||||
// Passed user as id
|
// Passed user as id
|
||||||
if username.chars().all(|c| c.is_digit()) {
|
if username.chars().all(|c| c.is_digit()) {
|
||||||
|
|
6
cp/cp.rs
6
cp/cp.rs
|
@ -44,7 +44,7 @@ pub fn uumain(args: Vec<String>) -> 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 usage = usage("Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.", opts);
|
||||||
let mode = if matches.opt_present("version") {
|
let mode = if matches.opt_present("version") {
|
||||||
Version
|
Version
|
||||||
|
@ -90,13 +90,13 @@ fn copy(matches: getopts::Matches) {
|
||||||
fail!()
|
fail!()
|
||||||
} else {
|
} else {
|
||||||
// Only the last argument:
|
// 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);
|
assert!(sources.len() >= 1);
|
||||||
|
|
||||||
if 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) {
|
let same_file = match paths_refer_to_same_file(source, &dest) {
|
||||||
Ok(b) => b,
|
Ok(b) => b,
|
||||||
Err(e) => if e.kind == io::FileNotFound {
|
Err(e) => if e.kind == io::FileNotFound {
|
||||||
|
|
12
cut/cut.rs
12
cut/cut.rs
|
@ -259,7 +259,7 @@ fn cut_fields_delimiter<R: Reader>(reader: R,
|
||||||
if delim_search.peek().is_none() {
|
if delim_search.peek().is_none() {
|
||||||
if ! only_delimited {
|
if ! only_delimited {
|
||||||
out.write(line.as_slice()).unwrap();
|
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();
|
out.write([b'\n']).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ fn cut_fields_delimiter<R: Reader>(reader: R,
|
||||||
|
|
||||||
out.write(segment).unwrap();
|
out.write(segment).unwrap();
|
||||||
|
|
||||||
if *line.get(line.len() - 1) == b'\n' {
|
if line[line.len() - 1] == b'\n' {
|
||||||
continue 'newline
|
continue 'newline
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
@ -341,7 +341,7 @@ fn cut_fields<R: Reader>(reader: R,
|
||||||
if delim_search.peek().is_none() {
|
if delim_search.peek().is_none() {
|
||||||
if ! opts.only_delimited {
|
if ! opts.only_delimited {
|
||||||
out.write(line.as_slice()).unwrap();
|
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();
|
out.write([b'\n']).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,7 +378,7 @@ fn cut_fields<R: Reader>(reader: R,
|
||||||
|
|
||||||
out.write(segment).unwrap();
|
out.write(segment).unwrap();
|
||||||
|
|
||||||
if *line.get(line.len() - 1) == b'\n' {
|
if line[line.len() - 1] == b'\n' {
|
||||||
continue 'newline
|
continue 'newline
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
@ -468,7 +468,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
|
|
||||||
if matches.opt_present("help") {
|
if matches.opt_present("help") {
|
||||||
println!("Usage:");
|
println!("Usage:");
|
||||||
println!(" {0} OPTION... [FILE]...", args.get(0));
|
println!(" {0} OPTION... [FILE]...", args[0]);
|
||||||
println!("");
|
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!("");
|
||||||
|
@ -548,7 +548,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
Err(err_msg) => {
|
Err(err_msg) => {
|
||||||
show_error!("{}\n\
|
show_error!("{}\n\
|
||||||
Try '{} --help' for more information",
|
Try '{} --help' for more information",
|
||||||
err_msg, args.get(0));
|
err_msg, args[0]);
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,9 +66,9 @@ impl Range {
|
||||||
for i in range(0, ranges.len()) {
|
for i in range(0, ranges.len()) {
|
||||||
let j = i + 1;
|
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;
|
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<Range>) -> Vec<Range> {
|
||||||
|
|
||||||
let mut complements = Vec::with_capacity(ranges.len() + 1);
|
let mut complements = Vec::with_capacity(ranges.len() + 1);
|
||||||
|
|
||||||
if ranges.len() > 0 && ranges.get(0).low > 1 {
|
if ranges.len() > 0 && ranges[0].low > 1 {
|
||||||
complements.push(Range { low: 1, high: ranges.get(0).low - 1 });
|
complements.push(Range { low: 1, high: ranges[0].low - 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut ranges_iter = ranges.iter().peekable();
|
let mut ranges_iter = ranges.iter().peekable();
|
||||||
|
|
|
@ -16,7 +16,7 @@ use std::io::print;
|
||||||
static VERSION: &'static str = "1.0.0";
|
static VERSION: &'static str = "1.0.0";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("z", "zero", "separate output with NUL rather than newline"),
|
getopts::optflag("z", "zero", "separate output with NUL rather than newline"),
|
||||||
getopts::optflag("", "help", "display this help and exit"),
|
getopts::optflag("", "help", "display this help and exit"),
|
||||||
|
|
4
du/du.rs
4
du/du.rs
|
@ -89,7 +89,7 @@ fn du(path: &Path, mut my_stat: Stat,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).as_slice();
|
let program = args[0].as_slice();
|
||||||
let opts = [
|
let opts = [
|
||||||
// In task
|
// In task
|
||||||
getopts::optflag("a", "all", " write counts for all files, not just directories"),
|
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 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,
|
"K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024,
|
||||||
"T" => 1024 * 1024 * 1024 * 1024, "P" => 1024 * 1024 * 1024 * 1024 * 1024,
|
"T" => 1024 * 1024 * 1024 * 1024, "P" => 1024 * 1024 * 1024 * 1024 * 1024,
|
||||||
"E" => 1024 * 1024 * 1024 * 1024 * 1024 * 1024,
|
"E" => 1024 * 1024 * 1024 * 1024 * 1024 * 1024,
|
||||||
|
|
|
@ -80,7 +80,7 @@ fn convert_str(string: &[u8], index: uint, base: uint) -> (char, uint) {
|
||||||
|
|
||||||
fn parse_options(args: Vec<String>, options: &mut EchoOptions) -> Option<Vec<String>> {
|
fn parse_options(args: Vec<String>, options: &mut EchoOptions) -> Option<Vec<String>> {
|
||||||
let mut echo_args = vec!();
|
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) {
|
'argloop: for arg in args.move_iter().skip(1) {
|
||||||
match arg.as_slice() {
|
match arg.as_slice() {
|
||||||
"--help" | "-h" => {
|
"--help" | "-h" => {
|
||||||
|
|
4
env/env.rs
vendored
4
env/env.rs
vendored
|
@ -52,7 +52,7 @@ fn print_env(null: bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> 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
|
// to handle arguments the same way than GNU env, we can't use getopts
|
||||||
let mut opts = box options {
|
let mut opts = box options {
|
||||||
|
@ -191,7 +191,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
|
|
||||||
if opts.program.len() >= 1 {
|
if opts.program.len() >= 1 {
|
||||||
use std::io::process::{Command, InheritFd};
|
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);
|
let args = opts.program.slice_from(1);
|
||||||
match Command::new(prog).args(args).stdin(InheritFd(0)).stdout(InheritFd(1)).stderr(InheritFd(2)).status() {
|
match Command::new(prog).args(args).stdin(InheritFd(0)).stdout(InheritFd(1)).stderr(InheritFd(2)).status() {
|
||||||
Ok(exit) =>
|
Ok(exit) =>
|
||||||
|
|
|
@ -64,7 +64,7 @@ fn print_factors_str(num_str: &str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).as_slice();
|
let program = args[0].as_slice();
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("h", "help", "show this help message"),
|
getopts::optflag("h", "help", "show this help message"),
|
||||||
getopts::optflag("v", "version", "print the version and exit"),
|
getopts::optflag("v", "version", "print the version and exit"),
|
||||||
|
|
|
@ -83,11 +83,11 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
|
|
||||||
let matches = match getopts::getopts(args.tail(), opts.as_slice()) {
|
let matches = match getopts::getopts(args.tail(), opts.as_slice()) {
|
||||||
Ok(m) => m,
|
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") {
|
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") {
|
if matches.opt_present("V") || matches.opt_present("h") {
|
||||||
|
|
|
@ -289,7 +289,7 @@ fn find_kp_breakpoints<'a, T: Iterator<&'a WordInfo<'a>>>(iter: T, args: &BreakA
|
||||||
|
|
||||||
if next_active_breaks.is_empty() {
|
if next_active_breaks.is_empty() {
|
||||||
// every potential linebreak is too long! choose the linebreak with the least demerits, ld_idx
|
// 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());
|
next_active_breaks.push(linebreaks.len());
|
||||||
linebreaks.push(new_break);
|
linebreaks.push(new_break);
|
||||||
least_demerits = 0;
|
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<LineBreak<'a>>, active: &Vec<uint>) -> Vec<(&'a WordInfo<'a>, bool)> {
|
fn build_best_path<'a>(paths: &Vec<LineBreak<'a>>, active: &Vec<uint>) -> Vec<(&'a WordInfo<'a>, bool)> {
|
||||||
let mut breakwords = vec!();
|
let mut breakwords = vec!();
|
||||||
// of the active paths, we select the one with the fewest demerits
|
// 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."),
|
None => crash!(1, "Failed to find a k-p linebreak solution. This should never happen."),
|
||||||
Some(&s) => s
|
Some(&s) => s
|
||||||
};
|
};
|
||||||
|
@ -320,7 +320,7 @@ fn build_best_path<'a>(paths: &Vec<LineBreak<'a>>, active: &Vec<uint>) -> Vec<(&
|
||||||
// now, chase the pointers back through the break list, recording
|
// now, chase the pointers back through the break list, recording
|
||||||
// the words at which we should break
|
// the words at which we should break
|
||||||
loop {
|
loop {
|
||||||
let next_best = paths.get(best_idx);
|
let next_best = paths[best_idx];
|
||||||
match next_best.linebreak {
|
match next_best.linebreak {
|
||||||
None => return breakwords,
|
None => return breakwords,
|
||||||
Some(prev) => {
|
Some(prev) => {
|
||||||
|
|
|
@ -425,10 +425,10 @@ impl<'a> ParaWords<'a> {
|
||||||
self.words.extend(
|
self.words.extend(
|
||||||
if self.opts.crown || self.opts.tagged {
|
if self.opts.crown || self.opts.tagged {
|
||||||
// crown and tagged mode has the "init" in the first line, so slice from there
|
// 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 {
|
} else {
|
||||||
// otherwise we slice from the indent
|
// 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 {
|
if self.para.lines.len() > 1 {
|
||||||
|
|
|
@ -28,7 +28,7 @@ static VERSION: &'static str = "1.0.0";
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
|
|
||||||
let (args, obs_width) = handle_obsolete(args.as_slice());
|
let (args, obs_width) = handle_obsolete(args.as_slice());
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
|
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("b", "bytes", "count using bytes rather than columns (meaning control characters such as newline are not treated specially)"),
|
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<String>, Option<String>) {
|
||||||
let mut args = Vec::<String>::from_slice(args);
|
let mut args = Vec::<String>::from_slice(args);
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
while i < args.len() {
|
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(),
|
return (args.clone(),
|
||||||
Some(args.remove(i).unwrap().as_slice().slice_from(1).to_string()));
|
Some(args.remove(i).unwrap().as_slice().slice_from(1).to_string()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ static NAME: &'static str = "groups";
|
||||||
static VERSION: &'static str = "1.0.0";
|
static VERSION: &'static str = "1.0.0";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
|
|
||||||
let options = [
|
let options = [
|
||||||
optflag("h", "help", "display this help menu and exit"),
|
optflag("h", "help", "display this help menu and exit"),
|
||||||
|
|
|
@ -90,7 +90,7 @@ fn detect_algo(program: &str, matches: &getopts::Matches) -> (&str, Box<Digest>)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
let binary = Path::new(program.as_slice());
|
let binary = Path::new(program.as_slice());
|
||||||
let binary_name = binary.filename_str().unwrap();
|
let binary_name = binary.filename_str().unwrap();
|
||||||
|
|
||||||
|
@ -313,4 +313,3 @@ fn digest_reader(digest: &mut Box<Digest>, reader: &mut Reader, binary: bool) ->
|
||||||
|
|
||||||
Ok(digest.result_str())
|
Ok(digest.result_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ fn obsolete (options: &[String]) -> (Vec<String>, Option<uint>) {
|
||||||
let b = options.len();
|
let b = options.len();
|
||||||
|
|
||||||
while a < b {
|
while a < b {
|
||||||
let current = options.get(a).clone();
|
let current = options[a].clone();
|
||||||
let current = current.as_bytes();
|
let current = current.as_bytes();
|
||||||
|
|
||||||
if current.len() > 1 && current[0] == '-' as u8 {
|
if current.len() > 1 && current[0] == '-' as u8 {
|
||||||
|
|
|
@ -33,7 +33,7 @@ extern {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0);
|
let program = &args[0];
|
||||||
|
|
||||||
let options = [
|
let options = [
|
||||||
optflag("f", "full", "Default option to show full name"),
|
optflag("f", "full", "Default option to show full name"),
|
||||||
|
|
|
@ -103,7 +103,7 @@ fn handle_obsolete(mut args: Vec<String>) -> (Vec<String>, Option<String>) {
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
while i < args.len() {
|
while i < args.len() {
|
||||||
// this is safe because slice is valid when it is referenced
|
// 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() {
|
if slice.char_at(0) == '-' && slice.len() > 1 && slice.char_at(1).is_digit() {
|
||||||
let val = slice.slice_from(1);
|
let val = slice.slice_from(1);
|
||||||
match from_str(val) {
|
match from_str(val) {
|
||||||
|
|
|
@ -50,8 +50,8 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let old = Path::new(matches.free.get(0).as_slice());
|
let old = Path::new(matches.free[0].as_slice());
|
||||||
let new = Path::new(matches.free.get(1).as_slice());
|
let new = Path::new(matches.free[1].as_slice());
|
||||||
|
|
||||||
match link(&old, &new) {
|
match link(&old, &new) {
|
||||||
Ok(_) => 0,
|
Ok(_) => 0,
|
||||||
|
|
|
@ -43,7 +43,7 @@ fn version() {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Argument parsing
|
// Argument parsing
|
||||||
|
|
|
@ -22,14 +22,14 @@ fn main() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let crat = match args.get(1).as_slice() {
|
let crat = match args[1].as_slice() {
|
||||||
"test" => "uutest",
|
"test" => "uutest",
|
||||||
"true" => "uutrue",
|
"true" => "uutrue",
|
||||||
"false" => "uufalse",
|
"false" => "uufalse",
|
||||||
"sync" => "uusync",
|
"sync" => "uusync",
|
||||||
s => s.clone(),
|
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 main = std::str::replace(TEMPLATE, "@UTIL_CRATE@", crat);
|
||||||
let mut out = File::open_mode(&Path::new(outfile), Truncate, ReadWrite);
|
let mut out = File::open_mode(&Path::new(outfile), Truncate, ReadWrite);
|
||||||
|
|
|
@ -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
|
// XXX: this all just assumes that the IO works correctly
|
||||||
let mut out = File::open_mode(&Path::new(outfile), Truncate, Write).unwrap();
|
let mut out = File::open_mode(&Path::new(outfile), Truncate, Write).unwrap();
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
extern crate regex;
|
extern crate regex;
|
||||||
|
|
||||||
use std::str;
|
|
||||||
|
|
||||||
// parse_style parses a style string into a NumberingStyle.
|
// parse_style parses a style string into a NumberingStyle.
|
||||||
fn parse_style(chars: &[char]) -> Result<::NumberingStyle, String> {
|
fn parse_style(chars: &[char]) -> Result<::NumberingStyle, String> {
|
||||||
match chars {
|
match chars {
|
||||||
|
@ -10,7 +8,7 @@ fn parse_style(chars: &[char]) -> Result<::NumberingStyle, String> {
|
||||||
['t'] => { Ok(::NumberForNonEmpty) },
|
['t'] => { Ok(::NumberForNonEmpty) },
|
||||||
['n'] => { Ok(::NumberForNone) },
|
['n'] => { Ok(::NumberForNone) },
|
||||||
['p', ..rest] => {
|
['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)),
|
Ok(re) => Ok(::NumberForRegularExpression(re)),
|
||||||
Err(_) => Err(String::from_str("Illegal regular expression")),
|
Err(_) => Err(String::from_str("Illegal regular expression")),
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ fn _vprocmgr_detach_from_console(_: u32) -> *const libc::c_int { std::ptr::null(
|
||||||
fn rewind_stdout<T: std::rt::rtio::RtioFileStream>(_: &mut T) {}
|
fn rewind_stdout<T: std::rt::rtio::RtioFileStream>(_: &mut T) {}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0);
|
let program = &args[0];
|
||||||
|
|
||||||
let options = [
|
let options = [
|
||||||
optflag("h", "help", "Show help and exit"),
|
optflag("h", "help", "Show help and exit"),
|
||||||
|
@ -82,7 +82,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
// we ignore the memory leak here because it doesn't matter anymore
|
// 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();
|
let mut args: Vec<*const i8> = opts.free.iter().map(|x| x.to_c_str().unwrap()).collect();
|
||||||
args.push(std::ptr::null());
|
args.push(std::ptr::null());
|
||||||
execvp(executable as *const libc::c_char, args.as_ptr() as *mut *const libc::c_char) as int
|
execvp(executable as *const libc::c_char, args.as_ptr() as *mut *const libc::c_char) as int
|
||||||
|
|
|
@ -23,7 +23,7 @@ static NAME: &'static str = "paste";
|
||||||
static VERSION: &'static str = "1.0.0";
|
static VERSION: &'static str = "1.0.0";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
|
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("s", "serial", "paste one file at a time instead of in parallel"),
|
getopts::optflag("s", "serial", "paste one file at a time instead of in parallel"),
|
||||||
|
@ -75,7 +75,7 @@ fn paste(filenames: Vec<String>, serial: bool, delimiters: &str) {
|
||||||
match file.read_line() {
|
match file.read_line() {
|
||||||
Ok(line) => {
|
Ok(line) => {
|
||||||
output.push_str(line.as_slice().trim_right());
|
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 {
|
Err(f) => if f.kind == io::EndOfFile {
|
||||||
break
|
break
|
||||||
|
@ -93,7 +93,7 @@ fn paste(filenames: Vec<String>, serial: bool, delimiters: &str) {
|
||||||
let mut output = "".to_string();
|
let mut output = "".to_string();
|
||||||
let mut eof_count = 0;
|
let mut eof_count = 0;
|
||||||
for (i, file) in files.mut_iter().enumerate() {
|
for (i, file) in files.mut_iter().enumerate() {
|
||||||
if *eof.get(i) {
|
if eof[i] {
|
||||||
eof_count += 1;
|
eof_count += 1;
|
||||||
} else {
|
} else {
|
||||||
match file.read_line() {
|
match file.read_line() {
|
||||||
|
@ -106,7 +106,7 @@ fn paste(filenames: Vec<String>, 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;
|
delim_count += 1;
|
||||||
}
|
}
|
||||||
if files.len() == eof_count {
|
if files.len() == eof_count {
|
||||||
|
|
|
@ -25,7 +25,7 @@ mod util;
|
||||||
static NAME: &'static str = "printenv";
|
static NAME: &'static str = "printenv";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("0", "null", "end each output line with 0 byte rather than newline"),
|
getopts::optflag("0", "null", "end each output line with 0 byte rather than newline"),
|
||||||
getopts::optflag("h", "help", "display this help and exit"),
|
getopts::optflag("h", "help", "display this help and exit"),
|
||||||
|
|
|
@ -23,7 +23,7 @@ static NAME: &'static str = "pwd";
|
||||||
static VERSION: &'static str = "1.0.0";
|
static VERSION: &'static str = "1.0.0";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("", "help", "display this help and exit"),
|
getopts::optflag("", "help", "display this help and exit"),
|
||||||
getopts::optflag("", "version", "output version information and exit"),
|
getopts::optflag("", "version", "output version information and exit"),
|
||||||
|
|
|
@ -21,7 +21,7 @@ static NAME: &'static str = "realpath";
|
||||||
static VERSION: &'static str = "1.0.0";
|
static VERSION: &'static str = "1.0.0";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0);
|
let program = &args[0];
|
||||||
let options = [
|
let options = [
|
||||||
optflag("h", "help", "Show help and exit"),
|
optflag("h", "help", "Show help and exit"),
|
||||||
optflag("V", "version", "Show version and exit"),
|
optflag("V", "version", "Show version and exit"),
|
||||||
|
|
|
@ -21,7 +21,7 @@ static NAME: &'static str = "relpath";
|
||||||
static VERSION: &'static str = "1.0.0";
|
static VERSION: &'static str = "1.0.0";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0);
|
let program = &args[0];
|
||||||
let options = [
|
let options = [
|
||||||
optflag("h", "help", "Show help and exit"),
|
optflag("h", "help", "Show help and exit"),
|
||||||
optflag("V", "version", "Show version and exit"),
|
optflag("V", "version", "Show version and exit"),
|
||||||
|
@ -46,9 +46,9 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
return 1
|
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 {
|
let from = if opts.free.len() > 1 {
|
||||||
Path::new(opts.free.get(1).as_slice())
|
Path::new(opts.free[1].as_slice())
|
||||||
} else {
|
} else {
|
||||||
std::os::getcwd()
|
std::os::getcwd()
|
||||||
};
|
};
|
||||||
|
|
3
rm/rm.rs
3
rm/rm.rs
|
@ -29,7 +29,7 @@ enum InteractiveMode {
|
||||||
static NAME: &'static str = "rm";
|
static NAME: &'static str = "rm";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
|
|
||||||
// TODO: make getopts support -R in addition to -r
|
// TODO: make getopts support -R in addition to -r
|
||||||
let opts = [
|
let opts = [
|
||||||
|
@ -235,4 +235,3 @@ fn read_prompt() -> bool {
|
||||||
Err(_) => true
|
Err(_) => true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ mod util;
|
||||||
static NAME: &'static str = "rmdir";
|
static NAME: &'static str = "rmdir";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
|
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("", "ignore-fail-on-non-empty", "ignore each failure that is solely because a directory is non-empty"),
|
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(());
|
let mut r = Ok(());
|
||||||
|
|
||||||
if walk_dir.next() == None {
|
if walk_dir.next() == None {
|
||||||
match fs::rmdir(path) {
|
match fs::rmdir(path) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
@ -122,4 +122,3 @@ fn remove_dir(path: &Path, dir: &str, ignore: bool, parents: bool, verbose: bool
|
||||||
|
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
seq/seq.rs
12
seq/seq.rs
|
@ -51,7 +51,7 @@ fn escape_sequences(s: &str) -> String {
|
||||||
|
|
||||||
fn parse_options(args: Vec<String>, options: &mut SeqOptions) -> Result<Vec<String>, int> {
|
fn parse_options(args: Vec<String>, options: &mut SeqOptions) -> Result<Vec<String>, int> {
|
||||||
let mut seq_args = vec!();
|
let mut seq_args = vec!();
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
let mut iter = args.move_iter().skip(1);
|
let mut iter = args.move_iter().skip(1);
|
||||||
loop {
|
loop {
|
||||||
match iter.next() {
|
match iter.next() {
|
||||||
|
@ -159,7 +159,7 @@ fn print_version() {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
let mut options = SeqOptions {
|
let mut options = SeqOptions {
|
||||||
separator: "\n".to_string(),
|
separator: "\n".to_string(),
|
||||||
terminator: None,
|
terminator: None,
|
||||||
|
@ -176,7 +176,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
let mut largest_dec = 0;
|
let mut largest_dec = 0;
|
||||||
let mut padding = 0;
|
let mut padding = 0;
|
||||||
let first = if free.len() > 1 {
|
let first = if free.len() > 1 {
|
||||||
let slice = free.get(0).as_slice();
|
let slice = free[0].as_slice();
|
||||||
let len = slice.len();
|
let len = slice.len();
|
||||||
let dec = slice.find('.').unwrap_or(len);
|
let dec = slice.find('.').unwrap_or(len);
|
||||||
largest_dec = len - dec;
|
largest_dec = len - dec;
|
||||||
|
@ -189,12 +189,12 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
1.0
|
1.0
|
||||||
};
|
};
|
||||||
let step = if free.len() > 2 {
|
let step = if free.len() > 2 {
|
||||||
let slice = free.get(1).as_slice();
|
let slice = free[1].as_slice();
|
||||||
let len = slice.len();
|
let len = slice.len();
|
||||||
let dec = slice.find('.').unwrap_or(len);
|
let dec = slice.find('.').unwrap_or(len);
|
||||||
largest_dec = cmp::max(largest_dec, len - dec);
|
largest_dec = cmp::max(largest_dec, len - dec);
|
||||||
padding = cmp::max(padding, dec);
|
padding = cmp::max(padding, dec);
|
||||||
match parse_float(free.get(1).as_slice()) {
|
match parse_float(free[1].as_slice()) {
|
||||||
Ok(n) => n,
|
Ok(n) => n,
|
||||||
Err(s) => { show_error!("{:s}", s); return 1; }
|
Err(s) => { show_error!("{:s}", s); return 1; }
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
1.0
|
1.0
|
||||||
};
|
};
|
||||||
let last = {
|
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()));
|
padding = cmp::max(padding, slice.find('.').unwrap_or(slice.len()));
|
||||||
match parse_float(slice) {
|
match parse_float(slice) {
|
||||||
Ok(n) => n,
|
Ok(n) => n,
|
||||||
|
|
13
shuf/shuf.rs
13
shuf/shuf.rs
|
@ -35,7 +35,7 @@ static NAME: &'static str = "shuf";
|
||||||
static VERSION: &'static str = "0.0.1";
|
static VERSION: &'static str = "0.0.1";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
|
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("e", "echo", "treat each ARG as an input line"),
|
getopts::optflag("e", "echo", "treat each ARG as an input line"),
|
||||||
|
@ -164,7 +164,7 @@ fn shuf_lines(mut lines: Vec<String>, repeat: bool, zero: bool, count: uint, out
|
||||||
let max = if repeat { count } else { cmp::min(count, len) };
|
let max = if repeat { count } else { cmp::min(count, len) };
|
||||||
for _ in range(0, max) {
|
for _ in range(0, max) {
|
||||||
let idx = rng.next_u32() as uint % len;
|
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 {
|
if !repeat {
|
||||||
lines.remove(idx);
|
lines.remove(idx);
|
||||||
len -= 1;
|
len -= 1;
|
||||||
|
@ -178,15 +178,14 @@ fn parse_range(input_range: String) -> Result<RangeInclusive<uint>, (String, int
|
||||||
if split.len() != 2 {
|
if split.len() != 2 {
|
||||||
Err(("invalid range format".to_string(), 1))
|
Err(("invalid range format".to_string(), 1))
|
||||||
} else {
|
} else {
|
||||||
let begin = match from_str::<uint>(*split.get(0)) {
|
let begin = match from_str::<uint>(split[0]) {
|
||||||
Some(m) => m,
|
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::<uint>(*split.get(1)) {
|
let end = match from_str::<uint>(split[1]) {
|
||||||
Some(m) => m,
|
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))
|
Ok(range_inclusive(begin, end))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ mod util;
|
||||||
static NAME: &'static str = "sleep";
|
static NAME: &'static str = "sleep";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
|
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("h", "help", "display this help and exit"),
|
getopts::optflag("h", "help", "display this help and exit"),
|
||||||
|
|
|
@ -76,7 +76,7 @@ fn open(name: &str) -> IoResult<Box<Reader>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).as_slice();
|
let program = args[0].as_slice();
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("r", "", "use the BSD compatible algorithm (default)"),
|
getopts::optflag("r", "", "use the BSD compatible algorithm (default)"),
|
||||||
getopts::optflag("s", "sysv", "use System V compatible algorithm"),
|
getopts::optflag("s", "sysv", "use System V compatible algorithm"),
|
||||||
|
|
|
@ -137,7 +137,7 @@ mod platform {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0);
|
let program = &args[0];
|
||||||
|
|
||||||
let options = [
|
let options = [
|
||||||
optflag("h", "help", "display this help and exit"),
|
optflag("h", "help", "display this help and exit"),
|
||||||
|
|
|
@ -23,7 +23,7 @@ static NAME: &'static str = "tac";
|
||||||
static VERSION: &'static str = "1.0.0";
|
static VERSION: &'static str = "1.0.0";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
|
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("b", "before", "attach the separator before instead of after"),
|
getopts::optflag("b", "before", "attach the separator before instead of after"),
|
||||||
|
|
|
@ -109,7 +109,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
tail(&mut buffer, line_count, follow, sleep_sec);
|
tail(&mut buffer, line_count, follow, sleep_sec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ fn obsolete (options: &[String]) -> (Vec<String>, Option<uint>) {
|
||||||
let b = options.len();
|
let b = options.len();
|
||||||
|
|
||||||
while a < b {
|
while a < b {
|
||||||
let current = options.get(a).clone();
|
let current = options[a].clone();
|
||||||
let current = current.as_bytes();
|
let current = current.as_bytes();
|
||||||
|
|
||||||
if current.len() > 1 && current[0] == '-' as u8 {
|
if current.len() > 1 && current[0] == '-' as u8 {
|
||||||
|
|
|
@ -31,6 +31,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
struct Options {
|
struct Options {
|
||||||
program: String,
|
program: String,
|
||||||
append: bool,
|
append: bool,
|
||||||
|
@ -51,7 +52,7 @@ fn options(args: &[String]) -> Result<Options, ()> {
|
||||||
|
|
||||||
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 version = format!("{} {}", NAME, VERSION);
|
||||||
let program = args.get(0).as_slice();
|
let program = args[0].as_slice();
|
||||||
let arguments = "[OPTION]... [FILE]...";
|
let arguments = "[OPTION]... [FILE]...";
|
||||||
let brief = "Copy standard input to each FILE, and also to standard output.";
|
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 comment = "If a FILE is -, copy again to standard output.";
|
||||||
|
@ -110,7 +111,7 @@ struct NamedWriter {
|
||||||
|
|
||||||
impl Writer for NamedWriter {
|
impl Writer for NamedWriter {
|
||||||
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
|
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
|
||||||
with_path(self.path.clone(), || {
|
with_path(&*self.path.clone(), || {
|
||||||
let val = self.inner.write(buf);
|
let val = self.inner.write(buf);
|
||||||
if val.is_err() {
|
if val.is_err() {
|
||||||
self.inner = box NullWriter as Box<Writer>;
|
self.inner = box NullWriter as Box<Writer>;
|
||||||
|
@ -120,7 +121,7 @@ impl Writer for NamedWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush(&mut self) -> IoResult<()> {
|
fn flush(&mut self) -> IoResult<()> {
|
||||||
with_path(self.path.clone(), || {
|
with_path(&*self.path.clone(), || {
|
||||||
let val = self.inner.flush();
|
let val = self.inner.flush();
|
||||||
if val.is_err() {
|
if val.is_err() {
|
||||||
self.inner = box NullWriter as Box<Writer>;
|
self.inner = box NullWriter as Box<Writer>;
|
||||||
|
|
6
tr/tr.rs
6
tr/tr.rs
|
@ -187,11 +187,11 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
}
|
}
|
||||||
|
|
||||||
if dflag {
|
if dflag {
|
||||||
let set1 = expand_set(sets.get(0).as_slice());
|
let set1 = expand_set(sets[0].as_slice());
|
||||||
delete(set1, cflag);
|
delete(set1, cflag);
|
||||||
} else {
|
} else {
|
||||||
let set1 = expand_set(sets.get(0).as_slice());
|
let set1 = expand_set(sets[0].as_slice());
|
||||||
let set2 = expand_set(sets.get(1).as_slice());
|
let set2 = expand_set(sets[1].as_slice());
|
||||||
tr(set1.as_slice(), set2.as_slice());
|
tr(set1.as_slice(), set2.as_slice());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ enum TruncateMode {
|
||||||
static NAME: &'static str = "truncate";
|
static NAME: &'static str = "truncate";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
|
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("c", "no-create", "do not create files that do not exist"),
|
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)
|
(number, mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ struct utsrust {
|
||||||
nodename: String,
|
nodename: String,
|
||||||
release: String,
|
release: String,
|
||||||
version: String,
|
version: String,
|
||||||
machine: String
|
machine: String
|
||||||
}
|
}
|
||||||
|
|
||||||
extern {
|
extern {
|
||||||
|
@ -51,7 +51,7 @@ unsafe fn getuname() -> utsrust {
|
||||||
static NAME: &'static str = "uname";
|
static NAME: &'static str = "uname";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).as_slice();
|
let program = args[0].as_slice();
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("h", "help", "display this help and exit"),
|
getopts::optflag("h", "help", "display this help and exit"),
|
||||||
getopts::optflag("a", "all", "Behave as though all of the options -mnrsv were specified."),
|
getopts::optflag("a", "all", "Behave as though all of the options -mnrsv were specified."),
|
||||||
|
|
12
uniq/uniq.rs
12
uniq/uniq.rs
|
@ -43,7 +43,7 @@ impl Uniq {
|
||||||
|
|
||||||
for io_line in reader.lines() {
|
for io_line in reader.lines() {
|
||||||
let line = crash_if_err!(1, io_line);
|
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);
|
let print_delimiter = delimiters == "prepend" || (delimiters == "separate" && first_line_printed);
|
||||||
first_line_printed |= self.print_lines(writer, &lines, print_delimiter);
|
first_line_printed |= self.print_lines(writer, &lines, print_delimiter);
|
||||||
lines.truncate(0);
|
lines.truncate(0);
|
||||||
|
@ -83,7 +83,7 @@ impl Uniq {
|
||||||
let mut count = if self.all_repeated { 1 } else { lines.len() };
|
let mut count = if self.all_repeated { 1 } else { lines.len() };
|
||||||
if lines.len() == 1 && !self.repeats_only
|
if lines.len() == 1 && !self.repeats_only
|
||||||
|| lines.len() > 1 && !self.uniques_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;
|
first_line_printed = true;
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ fn opt_parsed<T: FromStr>(opt_name: &str, matches: &getopts::Matches) -> Option<
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> 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 program = program_path.filename_str().unwrap_or(NAME);
|
||||||
|
|
||||||
let opts = [
|
let opts = [
|
||||||
|
@ -159,10 +159,10 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
} else {
|
} else {
|
||||||
let (in_file_name, out_file_name) = match matches.free.len() {
|
let (in_file_name, out_file_name) = match matches.free.len() {
|
||||||
0 => ("-".into_string(), "-".into_string()),
|
0 => ("-".into_string(), "-".into_string()),
|
||||||
1 => (matches.free.get(0).clone(), "-".into_string()),
|
1 => (matches.free[0].clone(), "-".into_string()),
|
||||||
2 => (matches.free.get(0).clone(), matches.free.get(1).clone()),
|
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 {
|
let uniq = Uniq {
|
||||||
|
|
|
@ -26,7 +26,7 @@ mod util;
|
||||||
static NAME: &'static str = "unlink";
|
static NAME: &'static str = "unlink";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("h", "help", "display this help and exit"),
|
getopts::optflag("h", "help", "display this help and exit"),
|
||||||
getopts::optflag("V", "version", "output version information and exit"),
|
getopts::optflag("V", "version", "output version information and exit"),
|
||||||
|
@ -57,10 +57,10 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
if matches.free.len() == 0 {
|
if matches.free.len() == 0 {
|
||||||
crash!(1, "missing operand\nTry '{0:s} --help' for more information.", program);
|
crash!(1, "missing operand\nTry '{0:s} --help' for more information.", program);
|
||||||
} else if matches.free.len() > 1 {
|
} 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| {
|
let result = path.lstat().and_then(|info| {
|
||||||
match info.kind {
|
match info.kind {
|
||||||
|
|
|
@ -47,7 +47,7 @@ extern {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("v", "version", "output version information and exit"),
|
getopts::optflag("v", "version", "output version information and exit"),
|
||||||
getopts::optflag("h", "help", "display this help 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 updays = upsecs / 86400;
|
||||||
let uphours = (upsecs - (updays * 86400)) / 3600;
|
let uphours = (upsecs - (updays * 86400)) / 3600;
|
||||||
let upmins = (upsecs - (updays * 86400) - (uphours * 3600)) / 60;
|
let upmins = (upsecs - (updays * 86400) - (uphours * 3600)) / 60;
|
||||||
if updays == 1 {
|
if updays == 1 {
|
||||||
print!("up {:1d} day, {:2d}:{:02d}, ", updays, uphours, upmins);
|
print!("up {:1d} day, {:2d}:{:02d}, ", updays, uphours, upmins);
|
||||||
}
|
}
|
||||||
else if updays > 1 {
|
else if updays > 1 {
|
||||||
|
|
|
@ -47,7 +47,7 @@ extern {
|
||||||
static NAME: &'static str = "users";
|
static NAME: &'static str = "users";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).as_slice();
|
let program = args[0].as_slice();
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("h", "help", "display this help and exit"),
|
getopts::optflag("h", "help", "display this help and exit"),
|
||||||
getopts::optflag("V", "version", "output version information and exit"),
|
getopts::optflag("V", "version", "output version information and exit"),
|
||||||
|
@ -75,7 +75,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
|
|
||||||
let mut filename = DEFAULT_FILE;
|
let mut filename = DEFAULT_FILE;
|
||||||
if matches.free.len() > 0 {
|
if matches.free.len() > 0 {
|
||||||
filename = matches.free.get(0).as_slice();
|
filename = matches.free[0].as_slice();
|
||||||
}
|
}
|
||||||
|
|
||||||
exec(filename);
|
exec(filename);
|
||||||
|
|
|
@ -43,7 +43,7 @@ fn main() {
|
||||||
let mut args = os::args();
|
let mut args = os::args();
|
||||||
|
|
||||||
// try binary name as util name.
|
// 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();
|
let binary_as_util = binary.filename_str().unwrap();
|
||||||
|
|
||||||
match umap.find_equiv(&binary_as_util) {
|
match umap.find_equiv(&binary_as_util) {
|
||||||
|
@ -68,7 +68,7 @@ fn main() {
|
||||||
// try first arg as util name.
|
// try first arg as util name.
|
||||||
if args.len() >= 2 {
|
if args.len() >= 2 {
|
||||||
args.shift();
|
args.shift();
|
||||||
let util = args.get(0).as_slice();
|
let util = args[0].as_slice();
|
||||||
|
|
||||||
match umap.find_equiv(&util) {
|
match umap.find_equiv(&util) {
|
||||||
Some(&uumain) => {
|
Some(&uumain) => {
|
||||||
|
@ -76,10 +76,10 @@ fn main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
if args.get(0).as_slice() == "--help" {
|
if args[0].as_slice() == "--help" {
|
||||||
// see if they want help on a specific util
|
// see if they want help on a specific util
|
||||||
if args.len() >= 2 {
|
if args.len() >= 2 {
|
||||||
let util = args.get(1).as_slice();
|
let util = args[1].as_slice();
|
||||||
match umap.find_equiv(&util) {
|
match umap.find_equiv(&util) {
|
||||||
Some(&uumain) => {
|
Some(&uumain) => {
|
||||||
os::set_exit_status(uumain(vec![util.to_string(), "--help".to_string()]));
|
os::set_exit_status(uumain(vec![util.to_string(), "--help".to_string()]));
|
||||||
|
|
2
wc/wc.rs
2
wc/wc.rs
|
@ -35,7 +35,7 @@ struct Result {
|
||||||
static NAME: &'static str = "wc";
|
static NAME: &'static str = "wc";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("c", "bytes", "print the byte counts"),
|
getopts::optflag("c", "bytes", "print the byte counts"),
|
||||||
getopts::optflag("m", "chars", "print the character counts"),
|
getopts::optflag("m", "chars", "print the character counts"),
|
||||||
|
|
|
@ -67,7 +67,7 @@ mod platform {
|
||||||
static NAME: &'static str = "whoami";
|
static NAME: &'static str = "whoami";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).as_slice();
|
let program = args[0].as_slice();
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("h", "help", "display this help and exit"),
|
getopts::optflag("h", "help", "display this help and exit"),
|
||||||
getopts::optflag("V", "version", "output version information and exit"),
|
getopts::optflag("V", "version", "output version information and exit"),
|
||||||
|
|
|
@ -24,7 +24,7 @@ mod util;
|
||||||
static NAME: &'static str = "yes";
|
static NAME: &'static str = "yes";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> int {
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
let program = args.get(0).clone();
|
let program = args[0].clone();
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("h", "help", "display this help and exit"),
|
getopts::optflag("h", "help", "display this help and exit"),
|
||||||
getopts::optflag("V", "version", "output version information and exit"),
|
getopts::optflag("V", "version", "output version information and exit"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue