1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #162 from Arcterus/master

Update for latest Rust
This commit is contained in:
Heather 2014-05-06 23:30:07 -07:00
commit adbc4732f0
22 changed files with 63 additions and 63 deletions

View file

@ -161,7 +161,7 @@ fn help(progname: &str, usage: &str) {
println!(""); println!("");
println(usage); 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 \ The data are encoded as described for the base64 alphabet in RFC \
3548. When\ndecoding, the input may contain newlines in addition \ 3548. When\ndecoding, the input may contain newlines in addition \
to the bytes of the formal\nbase64 alphabet. Use --ignore-garbage \ to the bytes of the formal\nbase64 alphabet. Use --ignore-garbage \

View file

@ -15,7 +15,6 @@ extern crate libc;
use std::io::{print, println}; use std::io::{print, println};
use std::os; use std::os;
use std::str;
use std::str::StrSlice; use std::str::StrSlice;
#[path = "../common/util.rs"] #[path = "../common/util.rs"]
@ -86,17 +85,17 @@ fn main() {
println(name); println(name);
} }
fn strip_dir(fullname :&~str) -> ~str { fn strip_dir(fullname: &~str) -> ~str {
let mut name = ~""; let mut name = StrBuf::new();
for c in fullname.chars_rev() { for c in fullname.chars().rev() {
if c == '/' || c == '\\' { 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 { fn strip_suffix(name: &~str, suffix: &~str) -> ~str {

View file

@ -62,13 +62,13 @@ fn main() {
if matches.opt_present("number-nonblank") { if matches.opt_present("number-nonblank") {
number_mode = NumberNonEmpty; number_mode = NumberNonEmpty;
} }
let show_nonprint = matches.opts_present([~"show-nonprinting", ~"show-all", ~"t", ~"e"]); 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", ~"show-all", ~"e"]); 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", ~"show-all", ~"t"]); 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 squeeze_blank = matches.opt_present("squeeze-blank");
let mut files = matches.free; let mut files = matches.free;
if files.is_empty() { if files.is_empty() {
files = vec!(~"-"); files = vec!("-".to_owned());
} }
exec(files, number_mode, show_nonprint, show_ends, show_tabs, squeeze_blank); exec(files, number_mode, show_nonprint, show_ends, show_tabs, squeeze_blank);

View file

@ -1,32 +1,32 @@
use std::io::process::{Process, ProcessConfig}; use std::io::process::Process;
use std::str; use std::str;
#[test] #[test]
fn test_output_multi_files_print_all_chars() { fn test_output_multi_files_print_all_chars() {
let prog = Process::output("build/cat", let prog = Process::output("build/cat",
[~"cat/fixtures/alpha.txt", ~"cat/fixtures/256.txt", ["cat/fixtures/alpha.txt".to_owned(), "cat/fixtures/256.txt".to_owned(),
~"-A", ~"-n"]).unwrap(); "-A".to_owned(), "-n".to_owned()]).unwrap();
let out = str::from_utf8_owned(prog.output.as_slice().to_owned()).unwrap(); let out = str::from_utf8_owned(prog.output.as_slice().to_owned()).unwrap();
assert_eq!(out, 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] #[test]
fn test_stdin_squeeze() { 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")); 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(); 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] #[test]
fn test_stdin_number_non_blank() { 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")); 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(); 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());
} }

View file

@ -212,7 +212,7 @@ ers of 1000).",
separate_dirs: matches.opt_present("S"), 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); let options_arc = Arc::new(options);

View file

@ -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 }); let ncount = routput.chars().fold(0, |out, ch: char| out + if ch == '\t' { 8 } else { 1 });
(slice.slice_to(m + 1), routput, ncount) (slice.slice_to(m + 1), routput, ncount)
}, },
None => (slice, ~"", 0) None => (slice, "".to_owned(), 0)
} }
} else { } else {
(slice, ~"", 0) (slice, "".to_owned(), 0)
}; };
println!("{}", out); println!("{}", out);
(val, ncount) (val, ncount)

View file

@ -11,7 +11,6 @@
#![feature(macro_rules)] #![feature(macro_rules)]
extern crate getopts; extern crate getopts;
//extern crate libc;
use std::os; use std::os;
use getopts::{ use getopts::{

View file

@ -89,7 +89,7 @@ fn main() {
}; };
match mode { 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(), Table => table(),
List => list(matches.opt_str("list")), List => list(matches.opt_str("list")),
Help => help(NAME, usage), 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> { 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); return Some(0);
} }
for signal in ALL_SIGNALS.iter() { for signal in ALL_SIGNALS.iter() {

View file

@ -13,6 +13,7 @@
extern crate crypto = "rust-crypto"; extern crate crypto = "rust-crypto";
extern crate getopts; extern crate getopts;
extern crate libc;
use std::io::fs::File; use std::io::fs::File;
use std::io::BufferedReader; 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 { fn calc_sum(md5: &mut crypto::md5::Md5, file: &mut File, binary: bool) -> ~str {
let data = let data =
if binary { if binary {
safe_unwrap!(file.read_to_end()) (safe_unwrap!(file.read_to_end())).as_slice().to_owned()
} else { } else {
(safe_unwrap!(file.read_to_str())).into_bytes() (safe_unwrap!(file.read_to_str())).into_bytes()
}; };

@ -1 +1 @@
Subproject commit fd168c53c00475c4fae3efc329301e80451bd967 Subproject commit c5d40913eabdd51c226c06c274e7dd8dcc49d2fe

View file

@ -16,6 +16,7 @@ extern crate libc;
use std::os; use std::os;
use std::io::fs; use std::io::fs;
use std::io::FilePermission;
use std::num::strconv; use std::num::strconv;
#[path = "../common/util.rs"] #[path = "../common/util.rs"]
@ -62,19 +63,19 @@ fn main() {
// Translate a ~str in octal form to u32, default to 755 // Translate a ~str in octal form to u32, default to 755
// Not tested on Windows // Not tested on Windows
let mode_match = matches.opts_str(&[~"mode"]); let mode_match = matches.opts_str(&["mode".to_owned()]);
let mode: u32 = if mode_match.is_some() { let mode: FilePermission = if mode_match.is_some() {
let m = mode_match.unwrap(); let m = mode_match.unwrap();
let res = strconv::from_str_common(m, 8, false, false, false, let res: Option<u32> = strconv::from_str_common(m, 8, false, false, false,
strconv::ExpNone, strconv::ExpNone,
false, false); false, false);
if res.is_some() { if res.is_some() {
res.unwrap() unsafe { std::cast::transmute(res.unwrap()) }
} else { } else {
crash!(1, "no mode given"); crash!(1, "no mode given");
} }
} else { } else {
0o755 unsafe { std::cast::transmute(0o755 as u32) }
}; };
let dirs = matches.free; let dirs = matches.free;
@ -92,7 +93,7 @@ fn print_help(opts: &[getopts::OptGroup]) {
/** /**
* Create the list of new directories * 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(); let mut parent_dirs = Vec::new();
if mk_parents { if mk_parents {
for dir in dirs.iter() { 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 * 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) { match fs::mkdir(path, mode) {
Ok(_) => {}, Ok(_) => {},
Err(e) => { Err(e) => {

View file

@ -43,7 +43,7 @@ fn test_mkdir_dup_dir() {
#[test] #[test]
fn test_mkdir_mode() { fn test_mkdir_mode() {
cleanup(test_dir3); 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(); let exit_success = prog.unwrap().success();
cleanup(test_dir3); cleanup(test_dir3);
assert_eq!(exit_success, true); assert_eq!(exit_success, true);
@ -52,7 +52,7 @@ fn test_mkdir_mode() {
#[test] #[test]
fn test_mkdir_parent() { fn test_mkdir_parent() {
cleanup(test_dir4); 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(); let exit_success = prog.unwrap().success();
cleanup(test_dir4); cleanup(test_dir4);
assert_eq!(exit_success, true); assert_eq!(exit_success, true);

View file

@ -50,7 +50,7 @@ fn main() {
let serial = matches.opt_present("serial"); let serial = matches.opt_present("serial");
let delimiters = match matches.opt_str("delimiters") { let delimiters = match matches.opt_str("delimiters") {
Some(m) => m, Some(m) => m,
None => ~"\t" None => "\t".to_owned()
}; };
paste(matches.free, serial, delimiters); paste(matches.free, serial, delimiters);
} }
@ -64,7 +64,7 @@ fn paste(filenames: Vec<~str>, serial: bool, delimiters: ~str) {
let mut delim_count = 0; let mut delim_count = 0;
if serial { if serial {
for file in files.mut_iter() { for file in files.mut_iter() {
let mut output = ~""; let mut output = "".to_owned();
loop { loop {
output = output + match file.read_line() { output = output + match file.read_line() {
Ok(line) => line.trim_right() + delimiters[delim_count % delimiters.len()], Ok(line) => line.trim_right() + delimiters[delim_count % delimiters.len()],
@ -81,7 +81,7 @@ fn paste(filenames: Vec<~str>, serial: bool, delimiters: ~str) {
} else { } else {
let mut eof = Vec::from_elem(files.len(), false); let mut eof = Vec::from_elem(files.len(), false);
loop { loop {
let mut output = ~""; let mut output = "".to_owned();
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.get(i) {

View file

@ -125,7 +125,7 @@ fn remove(files: Vec<~str>, force: bool, interactive: InteractiveMode, one_fs: b
let file = Path::new(filename.to_owned()); let file = Path::new(filename.to_owned());
if file.exists() { if file.exists() {
if file.is_dir() { if file.is_dir() {
if recursive && (*filename != ~"/" || !preserve_root) { if recursive && (*filename != "/".to_owned() || !preserve_root) {
let walk_dir = match fs::walk_dir(&file) { let walk_dir = match fs::walk_dir(&file) {
Ok(m) => m, Ok(m) => m,
Err(f) => { 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(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); 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); remove_dir(&file, *filename, interactive, verbose);
} else { } else {
if recursive { if recursive {

View file

@ -83,7 +83,7 @@ fn main() {
Ok(n) => n, Ok(n) => n,
Err(s) => { show_error!(1, "{:s}", s); return; } 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())); let terminator = escape_sequences(matches.opt_str("t").unwrap_or(separator.clone()));
print_seq(first, step, last, separator, terminator, matches.opt_present("w")); print_seq(first, step, last, separator, terminator, matches.opt_present("w"));
} }

View file

@ -3,28 +3,28 @@ use std::str;
#[test] #[test]
fn test_count_up() { 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(); 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] #[test]
fn test_count_down() { 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(); 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] #[test]
fn test_separator_and_terminator() { 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(); 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] #[test]
fn test_equalize_widths() { 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(); 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());
} }

View file

@ -58,7 +58,7 @@ fn main() {
m m
} }
} }
None => ~"\n" None => "\n".to_owned()
}; };
tac(matches.free, before, regex, separator); tac(matches.free, before, regex, separator);
} }
@ -77,7 +77,7 @@ fn tac(filenames: Vec<~str>, before: bool, _: bool, separator: ~str) {
data = buf.into_owned(); data = buf.into_owned();
} }
let split_vec: ~[&str] = data.split_str(separator).collect(); 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 { a + if before {
separator + b separator + b
} else { } else {

View file

@ -57,7 +57,7 @@ fn options(args: &[~str]) -> Result<Options, ()> {
let help = format!("{}\n\nUsage:\n {} {}\n\n{}\n{}", let help = format!("{}\n\nUsage:\n {} {}\n\n{}\n{}",
version, program, arguments, usage(brief, opts), version, program, arguments, usage(brief, opts),
comment); 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) } let to_print = if m.opt_present("help") { Some(help) }
else if m.opt_present("version") { Some(version) } else if m.opt_present("version") { Some(version) }
else { None }; else { None };

View file

@ -15,7 +15,7 @@ fn make_file(name: &str) -> io::File {
#[test] #[test]
fn test_increase_file_size() { fn test_increase_file_size() {
let mut file = make_file(TFILE1); 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!(); fail!();
} }
file.seek(0, io::SeekEnd); file.seek(0, io::SeekEnd);
@ -29,7 +29,7 @@ fn test_increase_file_size() {
fn test_decrease_file_size() { fn test_decrease_file_size() {
let mut file = make_file(TFILE2); let mut file = make_file(TFILE2);
file.write(bytes!("1234567890")); 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!(); fail!();
} }
file.seek(0, io::SeekEnd); file.seek(0, io::SeekEnd);

View file

@ -80,7 +80,7 @@ fn main() {
let uname = unsafe { getuname() }; let uname = unsafe { getuname() };
let mut output = StrBuf::new(); let mut output = StrBuf::new();
if matches.opt_present("sysname") || matches.opt_present("all") 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(uname.sysname);
output.push_str(" "); output.push_str(" ");
} }

View file

@ -70,7 +70,7 @@ fn main() {
let mut files = matches.free.clone(); let mut files = matches.free.clone();
if files.is_empty() { if files.is_empty() {
files = vec!(~"-"); files = vec!("-".to_owned());
} }
wc(files, &matches); wc(files, &matches);
@ -181,7 +181,7 @@ pub fn wc(files: Vec<~str>, matches: &Matches) {
} }
if files.len() > 1 { 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); print!("{:1$}", byte_count, max_str_len + 1);
} }
if *filename != ~"-" { if *filename != "-".to_owned() {
println!(" {}", *filename); println!(" {}", *filename);
} }
else { else {

View file

@ -50,7 +50,7 @@ fn main() {
println!("yes 1.0.0"); println!("yes 1.0.0");
return; return;
} }
let mut string = ~"y"; let mut string = "y".to_owned();
if !matches.free.is_empty() { if !matches.free.is_empty() {
string = matches.free.connect(" "); string = matches.free.connect(" ");
} }