mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Update for latest Rust
This commit is contained in:
parent
208e407748
commit
366c388d3f
22 changed files with 63 additions and 63 deletions
|
@ -161,7 +161,7 @@ fn help(progname: &str, usage: &str) {
|
|||
println!("");
|
||||
println(usage);
|
||||
|
||||
let msg = ~"With no FILE, or when FILE is -, read standard input.\n\n\
|
||||
let msg = "With no FILE, or when FILE is -, read standard input.\n\n\
|
||||
The data are encoded as described for the base64 alphabet in RFC \
|
||||
3548. When\ndecoding, the input may contain newlines in addition \
|
||||
to the bytes of the formal\nbase64 alphabet. Use --ignore-garbage \
|
||||
|
|
|
@ -15,7 +15,6 @@ extern crate libc;
|
|||
|
||||
use std::io::{print, println};
|
||||
use std::os;
|
||||
use std::str;
|
||||
use std::str::StrSlice;
|
||||
|
||||
#[path = "../common/util.rs"]
|
||||
|
@ -86,17 +85,17 @@ fn main() {
|
|||
println(name);
|
||||
}
|
||||
|
||||
fn strip_dir(fullname :&~str) -> ~str {
|
||||
let mut name = ~"";
|
||||
fn strip_dir(fullname: &~str) -> ~str {
|
||||
let mut name = StrBuf::new();
|
||||
|
||||
for c in fullname.chars_rev() {
|
||||
for c in fullname.chars().rev() {
|
||||
if c == '/' || c == '\\' {
|
||||
return name;
|
||||
break;
|
||||
}
|
||||
name = str::from_char(c) + name;
|
||||
name.push_char(c);
|
||||
}
|
||||
|
||||
return fullname.clone();
|
||||
return name.as_slice().chars().rev().collect();
|
||||
}
|
||||
|
||||
fn strip_suffix(name: &~str, suffix: &~str) -> ~str {
|
||||
|
|
|
@ -62,13 +62,13 @@ fn main() {
|
|||
if matches.opt_present("number-nonblank") {
|
||||
number_mode = NumberNonEmpty;
|
||||
}
|
||||
let show_nonprint = matches.opts_present([~"show-nonprinting", ~"show-all", ~"t", ~"e"]);
|
||||
let show_ends = matches.opts_present([~"show-ends", ~"show-all", ~"e"]);
|
||||
let show_tabs = matches.opts_present([~"show-tabs", ~"show-all", ~"t"]);
|
||||
let show_nonprint = matches.opts_present(["show-nonprinting".to_owned(), "show-all".to_owned(), "t".to_owned(), "e".to_owned()]);
|
||||
let show_ends = matches.opts_present(["show-ends".to_owned(), "show-all".to_owned(), "e".to_owned()]);
|
||||
let show_tabs = matches.opts_present(["show-tabs".to_owned(), "show-all".to_owned(), "t".to_owned()]);
|
||||
let squeeze_blank = matches.opt_present("squeeze-blank");
|
||||
let mut files = matches.free;
|
||||
if files.is_empty() {
|
||||
files = vec!(~"-");
|
||||
files = vec!("-".to_owned());
|
||||
}
|
||||
|
||||
exec(files, number_mode, show_nonprint, show_ends, show_tabs, squeeze_blank);
|
||||
|
|
16
cat/test.rs
16
cat/test.rs
|
@ -1,32 +1,32 @@
|
|||
use std::io::process::{Process, ProcessConfig};
|
||||
use std::io::process::Process;
|
||||
use std::str;
|
||||
|
||||
#[test]
|
||||
fn test_output_multi_files_print_all_chars() {
|
||||
let prog = Process::output("build/cat",
|
||||
[~"cat/fixtures/alpha.txt", ~"cat/fixtures/256.txt",
|
||||
~"-A", ~"-n"]).unwrap();
|
||||
["cat/fixtures/alpha.txt".to_owned(), "cat/fixtures/256.txt".to_owned(),
|
||||
"-A".to_owned(), "-n".to_owned()]).unwrap();
|
||||
let out = str::from_utf8_owned(prog.output.as_slice().to_owned()).unwrap();
|
||||
assert_eq!(out,
|
||||
~" 1\tabcde$\n 2\tfghij$\n 3\tklmno$\n 4\tpqrst$\n 5\tuvwxyz$\n 6\t^@^A^B^C^D^E^F^G^H^I$\n 7\t^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\\^]^^^_ !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?M-^@M-^AM-^BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^KM-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^VM-^WM-^XM-^YM-^ZM-^[M-^\\M-^]M-^^M-^_M- M-!M-\"M-#M-$M-%M-&M-\'M-(M-)M-*M-+M-,M--M-.M-/M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9M-:M-;M-<M-=M->M-?M-@M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-ZM-[M-\\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?");
|
||||
" 1\tabcde$\n 2\tfghij$\n 3\tklmno$\n 4\tpqrst$\n 5\tuvwxyz$\n 6\t^@^A^B^C^D^E^F^G^H^I$\n 7\t^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\\^]^^^_ !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?M-^@M-^AM-^BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^KM-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^VM-^WM-^XM-^YM-^ZM-^[M-^\\M-^]M-^^M-^_M- M-!M-\"M-#M-$M-%M-&M-\'M-(M-)M-*M-+M-,M--M-.M-/M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9M-:M-;M-<M-=M->M-?M-@M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-ZM-[M-\\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?".to_owned());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_stdin_squeeze() {
|
||||
let mut prog = Process::new("build/cat", [~"-A"]).unwrap();
|
||||
let mut prog = Process::new("build/cat", ["-A".to_owned()]).unwrap();
|
||||
|
||||
prog.stdin.take_unwrap().write(bytes!("\x00\x01\x02"));
|
||||
|
||||
let out = str::from_utf8_owned(prog.wait_with_output().output.as_slice().to_owned()).unwrap();
|
||||
assert_eq!(out, ~"^@^A^B");
|
||||
assert_eq!(out, "^@^A^B".to_owned());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_stdin_number_non_blank() {
|
||||
let mut prog = Process::new("build/cat", [~"-b", ~"-"]).unwrap();
|
||||
let mut prog = Process::new("build/cat", ["-b".to_owned(), "-".to_owned()]).unwrap();
|
||||
|
||||
prog.stdin.take_unwrap().write(bytes!("\na\nb\n\n\nc"));
|
||||
|
||||
let out = str::from_utf8_owned(prog.wait_with_output().output.as_slice().to_owned()).unwrap();
|
||||
assert_eq!(out, ~"\n 1\ta\n 2\tb\n\n\n 3\tc");
|
||||
assert_eq!(out, "\n 1\ta\n 2\tb\n\n\n 3\tc".to_owned());
|
||||
}
|
||||
|
|
2
du/du.rs
2
du/du.rs
|
@ -212,7 +212,7 @@ ers of 1000).",
|
|||
separate_dirs: matches.opt_present("S"),
|
||||
};
|
||||
|
||||
let strs = if matches.free.is_empty() {vec!(~"./")} else {matches.free.clone()};
|
||||
let strs = if matches.free.is_empty() {vec!("./".to_owned())} else {matches.free.clone()};
|
||||
|
||||
let options_arc = Arc::new(options);
|
||||
|
||||
|
|
|
@ -166,10 +166,10 @@ fn fold_file<T: io::Reader>(file: BufferedReader<T>, bytes: bool, spaces: bool,
|
|||
let ncount = routput.chars().fold(0, |out, ch: char| out + if ch == '\t' { 8 } else { 1 });
|
||||
(slice.slice_to(m + 1), routput, ncount)
|
||||
},
|
||||
None => (slice, ~"", 0)
|
||||
None => (slice, "".to_owned(), 0)
|
||||
}
|
||||
} else {
|
||||
(slice, ~"", 0)
|
||||
(slice, "".to_owned(), 0)
|
||||
};
|
||||
println!("{}", out);
|
||||
(val, ncount)
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#![feature(macro_rules)]
|
||||
|
||||
extern crate getopts;
|
||||
//extern crate libc;
|
||||
|
||||
use std::os;
|
||||
use getopts::{
|
||||
|
|
|
@ -89,7 +89,7 @@ fn main() {
|
|||
};
|
||||
|
||||
match mode {
|
||||
Kill => kill(matches.opt_str("signal").unwrap_or(~"9"), matches.free),
|
||||
Kill => kill(matches.opt_str("signal").unwrap_or("9".to_owned()), matches.free),
|
||||
Table => table(),
|
||||
List => list(matches.opt_str("list")),
|
||||
Help => help(NAME, usage),
|
||||
|
@ -166,7 +166,7 @@ fn help(progname: &str, usage: &str) {
|
|||
}
|
||||
|
||||
fn signal_by_name_or_value(signal_name_or_value:~str) -> Option<uint> {
|
||||
if signal_name_or_value == ~"0"{
|
||||
if signal_name_or_value == "0".to_owned() {
|
||||
return Some(0);
|
||||
}
|
||||
for signal in ALL_SIGNALS.iter() {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
extern crate crypto = "rust-crypto";
|
||||
extern crate getopts;
|
||||
extern crate libc;
|
||||
|
||||
use std::io::fs::File;
|
||||
use std::io::BufferedReader;
|
||||
|
@ -134,7 +135,7 @@ fn md5sum(files: Vec<~str>, binary: bool, check: bool, tag: bool, status: bool,
|
|||
fn calc_sum(md5: &mut crypto::md5::Md5, file: &mut File, binary: bool) -> ~str {
|
||||
let data =
|
||||
if binary {
|
||||
safe_unwrap!(file.read_to_end())
|
||||
(safe_unwrap!(file.read_to_end())).as_slice().to_owned()
|
||||
} else {
|
||||
(safe_unwrap!(file.read_to_str())).into_bytes()
|
||||
};
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit fd168c53c00475c4fae3efc329301e80451bd967
|
||||
Subproject commit c5d40913eabdd51c226c06c274e7dd8dcc49d2fe
|
|
@ -16,6 +16,7 @@ extern crate libc;
|
|||
|
||||
use std::os;
|
||||
use std::io::fs;
|
||||
use std::io::FilePermission;
|
||||
use std::num::strconv;
|
||||
|
||||
#[path = "../common/util.rs"]
|
||||
|
@ -62,19 +63,19 @@ fn main() {
|
|||
|
||||
// Translate a ~str in octal form to u32, default to 755
|
||||
// Not tested on Windows
|
||||
let mode_match = matches.opts_str(&[~"mode"]);
|
||||
let mode: u32 = if mode_match.is_some() {
|
||||
let mode_match = matches.opts_str(&["mode".to_owned()]);
|
||||
let mode: FilePermission = if mode_match.is_some() {
|
||||
let m = mode_match.unwrap();
|
||||
let res = strconv::from_str_common(m, 8, false, false, false,
|
||||
strconv::ExpNone,
|
||||
false, false);
|
||||
let res: Option<u32> = strconv::from_str_common(m, 8, false, false, false,
|
||||
strconv::ExpNone,
|
||||
false, false);
|
||||
if res.is_some() {
|
||||
res.unwrap()
|
||||
unsafe { std::cast::transmute(res.unwrap()) }
|
||||
} else {
|
||||
crash!(1, "no mode given");
|
||||
}
|
||||
} else {
|
||||
0o755
|
||||
unsafe { std::cast::transmute(0o755 as u32) }
|
||||
};
|
||||
|
||||
let dirs = matches.free;
|
||||
|
@ -92,7 +93,7 @@ fn print_help(opts: &[getopts::OptGroup]) {
|
|||
/**
|
||||
* Create the list of new directories
|
||||
*/
|
||||
fn exec(dirs: Vec<~str>, mk_parents: bool, mode: u32, verbose: bool) {
|
||||
fn exec(dirs: Vec<~str>, mk_parents: bool, mode: FilePermission, verbose: bool) {
|
||||
let mut parent_dirs = Vec::new();
|
||||
if mk_parents {
|
||||
for dir in dirs.iter() {
|
||||
|
@ -141,7 +142,7 @@ fn exec(dirs: Vec<~str>, mk_parents: bool, mode: u32, verbose: bool) {
|
|||
/**
|
||||
* Wrapper to catch errors, return false if failed
|
||||
*/
|
||||
fn mkdir(path: &Path, mode: u32) {
|
||||
fn mkdir(path: &Path, mode: FilePermission) {
|
||||
match fs::mkdir(path, mode) {
|
||||
Ok(_) => {},
|
||||
Err(e) => {
|
||||
|
|
|
@ -43,7 +43,7 @@ fn test_mkdir_dup_dir() {
|
|||
#[test]
|
||||
fn test_mkdir_mode() {
|
||||
cleanup(test_dir3);
|
||||
let prog = Process::status(exe.into_owned(), [~"-m", ~"755", test_dir3.into_owned()]);
|
||||
let prog = Process::status(exe.into_owned(), ["-m".to_owned(), "755".to_owned(), test_dir3.into_owned()]);
|
||||
let exit_success = prog.unwrap().success();
|
||||
cleanup(test_dir3);
|
||||
assert_eq!(exit_success, true);
|
||||
|
@ -52,7 +52,7 @@ fn test_mkdir_mode() {
|
|||
#[test]
|
||||
fn test_mkdir_parent() {
|
||||
cleanup(test_dir4);
|
||||
let prog = Process::status(exe.into_owned(), [~"-p", test_dir4.into_owned()]);
|
||||
let prog = Process::status(exe.into_owned(), ["-p".to_owned(), test_dir4.into_owned()]);
|
||||
let exit_success = prog.unwrap().success();
|
||||
cleanup(test_dir4);
|
||||
assert_eq!(exit_success, true);
|
||||
|
|
|
@ -50,7 +50,7 @@ fn main() {
|
|||
let serial = matches.opt_present("serial");
|
||||
let delimiters = match matches.opt_str("delimiters") {
|
||||
Some(m) => m,
|
||||
None => ~"\t"
|
||||
None => "\t".to_owned()
|
||||
};
|
||||
paste(matches.free, serial, delimiters);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ fn paste(filenames: Vec<~str>, serial: bool, delimiters: ~str) {
|
|||
let mut delim_count = 0;
|
||||
if serial {
|
||||
for file in files.mut_iter() {
|
||||
let mut output = ~"";
|
||||
let mut output = "".to_owned();
|
||||
loop {
|
||||
output = output + match file.read_line() {
|
||||
Ok(line) => line.trim_right() + delimiters[delim_count % delimiters.len()],
|
||||
|
@ -81,7 +81,7 @@ fn paste(filenames: Vec<~str>, serial: bool, delimiters: ~str) {
|
|||
} else {
|
||||
let mut eof = Vec::from_elem(files.len(), false);
|
||||
loop {
|
||||
let mut output = ~"";
|
||||
let mut output = "".to_owned();
|
||||
let mut eof_count = 0;
|
||||
for (i, file) in files.mut_iter().enumerate() {
|
||||
if *eof.get(i) {
|
||||
|
|
4
rm/rm.rs
4
rm/rm.rs
|
@ -125,7 +125,7 @@ fn remove(files: Vec<~str>, force: bool, interactive: InteractiveMode, one_fs: b
|
|||
let file = Path::new(filename.to_owned());
|
||||
if file.exists() {
|
||||
if file.is_dir() {
|
||||
if recursive && (*filename != ~"/" || !preserve_root) {
|
||||
if recursive && (*filename != "/".to_owned() || !preserve_root) {
|
||||
let walk_dir = match fs::walk_dir(&file) {
|
||||
Ok(m) => m,
|
||||
Err(f) => {
|
||||
|
@ -134,7 +134,7 @@ fn remove(files: Vec<~str>, force: bool, interactive: InteractiveMode, one_fs: b
|
|||
};
|
||||
remove(walk_dir.map(|x| x.as_str().unwrap().to_owned()).collect(), force, interactive, one_fs, preserve_root, recursive, dir, verbose);
|
||||
remove_dir(&file, *filename, interactive, verbose);
|
||||
} else if dir && (*filename != ~"/" || !preserve_root) {
|
||||
} else if dir && (*filename != "/".to_owned() || !preserve_root) {
|
||||
remove_dir(&file, *filename, interactive, verbose);
|
||||
} else {
|
||||
if recursive {
|
||||
|
|
|
@ -83,7 +83,7 @@ fn main() {
|
|||
Ok(n) => n,
|
||||
Err(s) => { show_error!(1, "{:s}", s); return; }
|
||||
};
|
||||
let separator = escape_sequences(matches.opt_str("s").unwrap_or(~"\n"));
|
||||
let separator = escape_sequences(matches.opt_str("s").unwrap_or("\n".to_owned()));
|
||||
let terminator = escape_sequences(matches.opt_str("t").unwrap_or(separator.clone()));
|
||||
print_seq(first, step, last, separator, terminator, matches.opt_present("w"));
|
||||
}
|
||||
|
|
16
seq/test.rs
16
seq/test.rs
|
@ -3,28 +3,28 @@ use std::str;
|
|||
|
||||
#[test]
|
||||
fn test_count_up() {
|
||||
let p = Process::output("build/seq", [~"10"]).unwrap();
|
||||
let p = Process::output("build/seq", ["10".to_owned()]).unwrap();
|
||||
let out = str::from_utf8(p.output.as_slice().to_owned()).unwrap().into_owned();
|
||||
assert_eq!(out, ~"1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n");
|
||||
assert_eq!(out, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n".to_owned());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_count_down() {
|
||||
let p = Process::output("build/seq", [~"--", ~"5", ~"-1", ~"1"]).unwrap();
|
||||
let p = Process::output("build/seq", ["--".to_owned(), "5".to_owned(), "-1".to_owned(), "1".to_owned()]).unwrap();
|
||||
let out = str::from_utf8(p.output.as_slice().to_owned()).unwrap().into_owned();
|
||||
assert_eq!(out, ~"5\n4\n3\n2\n1\n");
|
||||
assert_eq!(out, "5\n4\n3\n2\n1\n".to_owned());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_separator_and_terminator() {
|
||||
let p = Process::output("build/seq", [~"-s", ~",", ~"-t", ~"!", ~"2", ~"6"]).unwrap();
|
||||
let p = Process::output("build/seq", ["-s".to_owned(), ",".to_owned(), "-t".to_owned(), "!".to_owned(), "2".to_owned(), "6".to_owned()]).unwrap();
|
||||
let out = str::from_utf8(p.output.as_slice().to_owned()).unwrap().into_owned();
|
||||
assert_eq!(out, ~"2,3,4,5,6!");
|
||||
assert_eq!(out, "2,3,4,5,6!".to_owned());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_equalize_widths() {
|
||||
let p = Process::output("build/seq", [~"-w", ~"5", ~"10"]).unwrap();
|
||||
let p = Process::output("build/seq", ["-w".to_owned(), "5".to_owned(), "10".to_owned()]).unwrap();
|
||||
let out = str::from_utf8(p.output.as_slice().to_owned()).unwrap().into_owned();
|
||||
assert_eq!(out, ~"05\n06\n07\n08\n09\n10\n");
|
||||
assert_eq!(out, "05\n06\n07\n08\n09\n10\n".to_owned());
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ fn main() {
|
|||
m
|
||||
}
|
||||
}
|
||||
None => ~"\n"
|
||||
None => "\n".to_owned()
|
||||
};
|
||||
tac(matches.free, before, regex, separator);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ fn tac(filenames: Vec<~str>, before: bool, _: bool, separator: ~str) {
|
|||
data = buf.into_owned();
|
||||
}
|
||||
let split_vec: ~[&str] = data.split_str(separator).collect();
|
||||
let rev: ~str = split_vec.rev_iter().fold(~"", |a, &b|
|
||||
let rev: ~str = split_vec.iter().rev().fold("".to_owned(), |a, &b|
|
||||
a + if before {
|
||||
separator + b
|
||||
} else {
|
||||
|
|
|
@ -57,7 +57,7 @@ fn options(args: &[~str]) -> Result<Options, ()> {
|
|||
let help = format!("{}\n\nUsage:\n {} {}\n\n{}\n{}",
|
||||
version, program, arguments, usage(brief, opts),
|
||||
comment);
|
||||
let names = m.free.clone().move_iter().collect::<Vec<~str>>().append_one(~"-").as_slice().to_owned();
|
||||
let names = m.free.clone().move_iter().collect::<Vec<~str>>().append_one("-".to_owned()).as_slice().to_owned();
|
||||
let to_print = if m.opt_present("help") { Some(help) }
|
||||
else if m.opt_present("version") { Some(version) }
|
||||
else { None };
|
||||
|
|
|
@ -15,7 +15,7 @@ fn make_file(name: &str) -> io::File {
|
|||
#[test]
|
||||
fn test_increase_file_size() {
|
||||
let mut file = make_file(TFILE1);
|
||||
if !Process::status(PROG, [~"-s", ~"+5K", TFILE1.to_owned()]).unwrap().success() {
|
||||
if !Process::status(PROG, ["-s".to_owned(), "+5K".to_owned(), TFILE1.to_owned()]).unwrap().success() {
|
||||
fail!();
|
||||
}
|
||||
file.seek(0, io::SeekEnd);
|
||||
|
@ -29,7 +29,7 @@ fn test_increase_file_size() {
|
|||
fn test_decrease_file_size() {
|
||||
let mut file = make_file(TFILE2);
|
||||
file.write(bytes!("1234567890"));
|
||||
if !Process::status(PROG, [~"--size=-4", TFILE2.to_owned()]).unwrap().success() {
|
||||
if !Process::status(PROG, ["--size=-4".to_owned(), TFILE2.to_owned()]).unwrap().success() {
|
||||
fail!();
|
||||
}
|
||||
file.seek(0, io::SeekEnd);
|
||||
|
|
|
@ -80,7 +80,7 @@ fn main() {
|
|||
let uname = unsafe { getuname() };
|
||||
let mut output = StrBuf::new();
|
||||
if matches.opt_present("sysname") || matches.opt_present("all")
|
||||
|| !matches.opts_present([~"nodename", ~"release", ~"version", ~"machine"]) {
|
||||
|| !matches.opts_present(["nodename".to_owned(), "release".to_owned(), "version".to_owned(), "machine".to_owned()]) {
|
||||
output.push_str(uname.sysname);
|
||||
output.push_str(" ");
|
||||
}
|
||||
|
|
6
wc/wc.rs
6
wc/wc.rs
|
@ -70,7 +70,7 @@ fn main() {
|
|||
|
||||
let mut files = matches.free.clone();
|
||||
if files.is_empty() {
|
||||
files = vec!(~"-");
|
||||
files = vec!("-".to_owned());
|
||||
}
|
||||
|
||||
wc(files, &matches);
|
||||
|
@ -181,7 +181,7 @@ pub fn wc(files: Vec<~str>, matches: &Matches) {
|
|||
}
|
||||
|
||||
if files.len() > 1 {
|
||||
print_stats(&~"total", total_line_count, total_word_count, total_char_count, total_byte_count, total_longest_line_length, matches, max_str_len);
|
||||
print_stats(&"total".to_owned(), total_line_count, total_word_count, total_char_count, total_byte_count, total_longest_line_length, matches, max_str_len);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ fn print_stats(filename: &~str, line_count: uint, word_count: uint, char_count:
|
|||
print!("{:1$}", byte_count, max_str_len + 1);
|
||||
}
|
||||
|
||||
if *filename != ~"-" {
|
||||
if *filename != "-".to_owned() {
|
||||
println!(" {}", *filename);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -50,7 +50,7 @@ fn main() {
|
|||
println!("yes 1.0.0");
|
||||
return;
|
||||
}
|
||||
let mut string = ~"y";
|
||||
let mut string = "y".to_owned();
|
||||
if !matches.free.is_empty() {
|
||||
string = matches.free.connect(" ");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue