1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 04:27:45 +00:00

Merge pull request #344 from ebfe/fix-build-master

Fix build with rust master
This commit is contained in:
Heather 2014-07-09 12:51:58 +04:00
commit b8def68668
18 changed files with 51 additions and 51 deletions

View file

@ -92,9 +92,9 @@ pub fn uumain(args: Vec<String>) -> int {
} }
fn decode(input: &mut Reader, ignore_garbage: bool) { fn decode(input: &mut Reader, ignore_garbage: bool) {
let mut to_decode = match input.read_to_str() { let mut to_decode = match input.read_to_string() {
Ok(m) => m, Ok(m) => m,
Err(f) => fail!(f.to_str()) Err(f) => fail!(f.to_string())
}; };
to_decode = str::replace(to_decode.as_slice(), "\n", ""); to_decode = str::replace(to_decode.as_slice(), "\n", "");
@ -112,15 +112,15 @@ fn decode(input: &mut Reader, ignore_garbage: bool) {
match out.write(bytes.as_slice()) { match out.write(bytes.as_slice()) {
Ok(_) => {} Ok(_) => {}
Err(f) => { crash!(1, "{}", f.to_str()); } Err(f) => { crash!(1, "{}", f.to_string()); }
} }
match out.flush() { match out.flush() {
Ok(_) => {} Ok(_) => {}
Err(f) => { crash!(1, "{}", f.to_str()); } Err(f) => { crash!(1, "{}", f.to_string()); }
} }
} }
Err(s) => { Err(s) => {
error!("error: {}", s.to_str()); error!("error: {}", s.to_string());
fail!() fail!()
} }
} }
@ -137,7 +137,7 @@ fn encode(input: &mut Reader, line_wrap: uint) {
}; };
let to_encode = match input.read_to_end() { let to_encode = match input.read_to_end() {
Ok(m) => m, Ok(m) => m,
Err(f) => fail!(f.to_str()) Err(f) => fail!(f.to_string())
}; };
let encoded = to_encode.as_slice().to_base64(b64_conf); let encoded = to_encode.as_slice().to_base64(b64_conf);

View file

@ -284,7 +284,7 @@ fn open(path: &str) -> Option<(Box<Reader>, bool)> {
match File::open(&std::path::Path::new(path)) { match File::open(&std::path::Path::new(path)) {
Ok(f) => Some((box f as Box<Reader>, false)), Ok(f) => Some((box f as Box<Reader>, false)),
Err(e) => { Err(e) => {
(writeln!(stderr(), "cat: {0:s}: {1:s}", path, e.to_str())).unwrap(); (writeln!(stderr(), "cat: {0:s}: {1:s}", path, e.to_string())).unwrap();
None None
}, },
} }

View file

@ -59,7 +59,7 @@ macro_rules! crash_if_err(
($exitcode:expr, $exp:expr) => ( ($exitcode:expr, $exp:expr) => (
match $exp { match $exp {
Ok(m) => m, Ok(m) => m,
Err(f) => crash!($exitcode, "{}", f.to_str()) Err(f) => crash!($exitcode, "{}", f.to_string())
} }
) )
) )
@ -69,7 +69,7 @@ macro_rules! safe_write(
($fd:expr, $($args:expr),+) => ( ($fd:expr, $($args:expr),+) => (
match write!($fd, $($args),+) { match write!($fd, $($args),+) {
Ok(_) => {} Ok(_) => {}
Err(f) => { fail!(f.to_str()); } Err(f) => { fail!(f.to_string()); }
} }
) )
) )
@ -79,7 +79,7 @@ macro_rules! safe_writeln(
($fd:expr, $($args:expr),+) => ( ($fd:expr, $($args:expr),+) => (
match writeln!($fd, $($args),+) { match writeln!($fd, $($args),+) {
Ok(_) => {} Ok(_) => {}
Err(f) => { fail!(f.to_str()); } Err(f) => { fail!(f.to_string()); }
} }
) )
) )
@ -89,7 +89,7 @@ macro_rules! safe_unwrap(
($exp:expr) => ( ($exp:expr) => (
match $exp { match $exp {
Ok(m) => m, Ok(m) => m,
Err(f) => crash!(1, "{}", f.to_str()) Err(f) => crash!(1, "{}", f.to_string())
} }
) )
) )

View file

@ -102,15 +102,15 @@ fn copy(matches: getopts::Matches) {
Err(e) => if e.kind == io::FileNotFound { Err(e) => if e.kind == io::FileNotFound {
false false
} else { } else {
error!("error: {:s}", e.to_str()); error!("error: {:s}", e.to_string());
fail!() fail!()
} }
}; };
if same_file { if same_file {
error!("error: \"{:s}\" and \"{:s}\" are the same file", error!("error: \"{:s}\" and \"{:s}\" are the same file",
source.display().to_str(), source.display().to_string(),
dest.display().to_str()); dest.display().to_string());
fail!(); fail!();
} }
@ -118,7 +118,7 @@ fn copy(matches: getopts::Matches) {
if io_result.is_err() { if io_result.is_err() {
let err = io_result.unwrap_err(); let err = io_result.unwrap_err();
error!("error: {:s}", err.to_str()); error!("error: {:s}", err.to_string());
fail!(); fail!();
} }
} else { } else {
@ -129,7 +129,7 @@ fn copy(matches: getopts::Matches) {
for source in sources.iter() { for source in sources.iter() {
if fs::stat(source).unwrap().kind != io::TypeFile { if fs::stat(source).unwrap().kind != io::TypeFile {
error!("error: \"{:s}\" is not a file", source.display().to_str()); error!("error: \"{:s}\" is not a file", source.display().to_string());
continue; continue;
} }
@ -137,13 +137,13 @@ fn copy(matches: getopts::Matches) {
full_dest.push(source.filename_str().unwrap()); full_dest.push(source.filename_str().unwrap());
println!("{:s}", full_dest.display().to_str()); println!("{:s}", full_dest.display().to_string());
let io_result = fs::copy(source, &full_dest); let io_result = fs::copy(source, &full_dest);
if io_result.is_err() { if io_result.is_err() {
let err = io_result.unwrap_err(); let err = io_result.unwrap_err();
error!("error: {:s}", err.to_str()); error!("error: {:s}", err.to_string());
fail!() fail!()
} }
} }

View file

@ -56,7 +56,7 @@ fn cut_bytes<T: Reader>(mut reader: BufferedReader<T>,
let mut out = BufferedWriter::new(std::io::stdio::stdout_raw()); let mut out = BufferedWriter::new(std::io::stdio::stdout_raw());
let (use_delim, out_delim) = match opts.out_delim.clone() { let (use_delim, out_delim) = match opts.out_delim.clone() {
Some(delim) => (true, delim), Some(delim) => (true, delim),
None => (false, "".to_str()) None => (false, "".to_string())
}; };
'newline: loop { 'newline: loop {
@ -106,7 +106,7 @@ fn cut_characters<T: Reader>(mut reader: BufferedReader<T>,
let mut out = BufferedWriter::new(std::io::stdio::stdout_raw()); let mut out = BufferedWriter::new(std::io::stdio::stdout_raw());
let (use_delim, out_delim) = match opts.out_delim.clone() { let (use_delim, out_delim) = match opts.out_delim.clone() {
Some(delim) => (true, delim), Some(delim) => (true, delim),
None => (false, "".to_str()) None => (false, "".to_string())
}; };
'newline: loop { 'newline: loop {
@ -363,7 +363,7 @@ fn cut_files(mut filenames: Vec<String>, mode: Mode) -> int {
let mut stdin_read = false; let mut stdin_read = false;
let mut exit_code = 0; let mut exit_code = 0;
if filenames.len() == 0 { filenames.push("-".to_str()); } if filenames.len() == 0 { filenames.push("-".to_string()); }
for filename in filenames.iter() { for filename in filenames.iter() {
if filename.as_slice() == "-" { if filename.as_slice() == "-" {
@ -486,7 +486,7 @@ pub fn uumain(args: Vec<String>) -> int {
match matches.opt_str("delimiter") { match matches.opt_str("delimiter") {
Some(delim) => { Some(delim) => {
if delim.as_slice().char_len() != 1 { if delim.as_slice().char_len() != 1 {
Err("the delimiter must be a single character".to_str()) Err("the delimiter must be a single character".to_string())
} else { } else {
Ok(Fields(ranges, Ok(Fields(ranges,
FieldOptions { FieldOptions {
@ -498,7 +498,7 @@ pub fn uumain(args: Vec<String>) -> int {
} }
None => Ok(Fields(ranges, None => Ok(Fields(ranges,
FieldOptions { FieldOptions {
delimiter: "\t".to_str(), delimiter: "\t".to_string(),
out_delimeter: out_delim, out_delimeter: out_delim,
only_delimited: only_delimited only_delimited: only_delimited
})) }))
@ -507,9 +507,9 @@ pub fn uumain(args: Vec<String>) -> int {
) )
} }
(ref b, ref c, ref f) if b.is_some() || c.is_some() || f.is_some() => { (ref b, ref c, ref f) if b.is_some() || c.is_some() || f.is_some() => {
Err("only one type of list may be specified".to_str()) Err("only one type of list may be specified".to_string())
} }
_ => Err("you must specify a list of bytes, characters, or fields".to_str()) _ => Err("you must specify a list of bytes, characters, or fields".to_string())
}; };
match mode_parse { match mode_parse {

View file

@ -125,7 +125,7 @@ fn print_signal(signal_name_or_value: &str) {
if signal.name == signal_name_or_value || (format!("SIG{}", signal.name).as_slice()) == signal_name_or_value { if signal.name == signal_name_or_value || (format!("SIG{}", signal.name).as_slice()) == signal_name_or_value {
println!("{}", signal.value) println!("{}", signal.value)
exit!(EXIT_OK as i32) exit!(EXIT_OK as i32)
} else if signal_name_or_value == signal.value.to_str().as_slice() { } else if signal_name_or_value == signal.value.to_string().as_slice() {
println!("{}", signal.name); println!("{}", signal.name);
exit!(EXIT_OK as i32) exit!(EXIT_OK as i32)
} }
@ -169,7 +169,7 @@ fn signal_by_name_or_value(signal_name_or_value: &str) -> Option<uint> {
} }
for signal in ALL_SIGNALS.iter() { for signal in ALL_SIGNALS.iter() {
let long_name = format!("SIG{}", signal.name); let long_name = format!("SIG{}", signal.name);
if signal.name == signal_name_or_value || (signal_name_or_value == signal.value.to_str().as_slice()) || (long_name.as_slice() == signal_name_or_value) { if signal.name == signal_name_or_value || (signal_name_or_value == signal.value.to_string().as_slice()) || (long_name.as_slice() == signal_name_or_value) {
return Some(signal.value); return Some(signal.value);
} }
} }

View file

@ -157,7 +157,7 @@ fn mkdir(path: &Path, mode: FilePermission) {
match fs::mkdir(path, mode) { match fs::mkdir(path, mode) {
Ok(_) => {}, Ok(_) => {},
Err(e) => { Err(e) => {
crash!(1, "test {}", e.to_str()); crash!(1, "test {}", e.to_string());
} }
} }
} }

View file

@ -39,7 +39,7 @@ fn main() {
// 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();
let mut input = File::open(&Path::new("uutils/uutils.rs")).unwrap(); let mut input = File::open(&Path::new("uutils/uutils.rs")).unwrap();
let main = input.read_to_str().unwrap().replace("@CRATES@", crates.as_slice()).replace("@UTIL_MAP@", util_map.as_slice()); let main = input.read_to_string().unwrap().replace("@CRATES@", crates.as_slice()).replace("@UTIL_MAP@", util_map.as_slice());
match out.write(main.as_bytes()) { match out.write(main.as_bytes()) {
Err(e) => fail!("{}", e), Err(e) => fail!("{}", e),

View file

@ -158,9 +158,9 @@ pub fn uumain(args: Vec<String>) -> int {
// nl implements the main functionality for an individual buffer. // nl implements the main functionality for an individual buffer.
fn nl<T: Reader> (reader: &mut BufferedReader<T>, settings: &Settings) { fn nl<T: Reader> (reader: &mut BufferedReader<T>, settings: &Settings) {
let mut line_no = settings.starting_line_number; let mut line_no = settings.starting_line_number;
// The current line number's width as a string. Using to_str is inefficient // The current line number's width as a string. Using to_string is inefficient
// but since we only do it once, it should not hurt. // but since we only do it once, it should not hurt.
let mut line_no_width = line_no.to_str().len(); let mut line_no_width = line_no.to_string().len();
let line_no_width_initial = line_no_width; let line_no_width_initial = line_no_width;
// Stores the smallest integer with one more digit than line_no, so that // Stores the smallest integer with one more digit than line_no, so that
// when line_no >= line_no_threshold, we need to use one more digit. // when line_no >= line_no_threshold, we need to use one more digit.

View file

@ -66,7 +66,7 @@ fn paste(filenames: Vec<String>, serial: bool, delimiters: &str) {
} }
) )
).collect(); ).collect();
let delimiters: Vec<String> = delimiters.chars().map(|x| x.to_str()).collect(); let delimiters: Vec<String> = delimiters.chars().map(|x| x.to_string()).collect();
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() {
@ -80,7 +80,7 @@ fn paste(filenames: Vec<String>, serial: bool, delimiters: &str) {
Err(f) => if f.kind == io::EndOfFile { Err(f) => if f.kind == io::EndOfFile {
break break
} else { } else {
crash!(1, "{}", f.to_str()) crash!(1, "{}", f.to_string())
} }
} }
delim_count += 1; delim_count += 1;
@ -102,7 +102,7 @@ fn paste(filenames: Vec<String>, serial: bool, delimiters: &str) {
*eof.get_mut(i) = true; *eof.get_mut(i) = true;
eof_count += 1; eof_count += 1;
} else { } else {
crash!(1, "{}", f.to_str()); crash!(1, "{}", f.to_string());
} }
} }
} }

View file

@ -136,7 +136,7 @@ fn remove(files: Vec<String>, force: bool, interactive: InteractiveMode, one_fs:
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) => {
crash!(1, "{}", f.to_str()); crash!(1, "{}", f.to_string());
} }
}; };
r = remove(walk_dir.map(|x| x.as_str().unwrap().to_string()).collect(), force, interactive, one_fs, preserve_root, recursive, dir, verbose).and(r); r = remove(walk_dir.map(|x| x.as_str().unwrap().to_string()).collect(), force, interactive, one_fs, preserve_root, recursive, dir, verbose).and(r);
@ -177,7 +177,7 @@ fn remove_dir(path: &Path, name: &str, interactive: InteractiveMode, verbose: bo
match fs::rmdir(path) { match fs::rmdir(path) {
Ok(_) => if verbose { println!("Removed '{}'", name); }, Ok(_) => if verbose { println!("Removed '{}'", name); },
Err(f) => { Err(f) => {
show_error!("{}", f.to_str()); show_error!("{}", f.to_string());
return Err(1); return Err(1);
} }
} }
@ -197,7 +197,7 @@ fn remove_file(path: &Path, name: &str, interactive: InteractiveMode, verbose: b
match fs::unlink(path) { match fs::unlink(path) {
Ok(_) => if verbose { println!("Removed '{}'", name); }, Ok(_) => if verbose { println!("Removed '{}'", name); },
Err(f) => { Err(f) => {
show_error!("{}", f.to_str()); show_error!("{}", f.to_string());
return Err(1); return Err(1);
} }
} }

View file

@ -90,7 +90,7 @@ fn remove_dir(path: &Path, dir: &str, ignore: bool, parents: bool, verbose: bool
let mut walk_dir = match fs::walk_dir(path) { let mut walk_dir = match fs::walk_dir(path) {
Ok(m) => m, Ok(m) => m,
Err(f) => { Err(f) => {
show_error!("{}", f.to_str()); show_error!("{}", f.to_string());
return Err(1); return Err(1);
} }
}; };
@ -111,7 +111,7 @@ fn remove_dir(path: &Path, dir: &str, ignore: bool, parents: bool, verbose: bool
} }
} }
Err(f) => { Err(f) => {
show_error!("{}", f.to_str()); show_error!("{}", f.to_string());
r = Err(1); r = Err(1);
} }
} }

View file

@ -24,7 +24,7 @@ macro_rules! pipe_write(
if f.kind == io::BrokenPipe { if f.kind == io::BrokenPipe {
return return
} else { } else {
fail!("{}", f.to_str()) fail!("{}", f.to_string())
} }
} }
) )
@ -232,7 +232,7 @@ fn print_seq(first: f64, step: f64, last: f64, largest_dec: uint, separator: Str
let mut i = 0i; let mut i = 0i;
let mut value = first + i as f64 * step; let mut value = first + i as f64 * step;
while !done_printing(value, step, last) { while !done_printing(value, step, last) {
let istr = value.to_str(); let istr = value.to_string();
let ilen = istr.len(); let ilen = istr.len();
let before_dec = istr.as_slice().find('.').unwrap_or(ilen); let before_dec = istr.as_slice().find('.').unwrap_or(ilen);
if pad && before_dec < padding { if pad && before_dec < padding {

View file

@ -78,7 +78,7 @@ fn tac(filenames: Vec<String>, before: bool, _: bool, separator: &str) {
box crash_if_err!(1, io::File::open(&Path::new(filename))) as Box<Reader> box crash_if_err!(1, io::File::open(&Path::new(filename))) as Box<Reader>
} }
); );
let mut data = crash_if_err!(1, file.read_to_str()); let mut data = crash_if_err!(1, file.read_to_string());
if data.as_slice().ends_with("\n") { if data.as_slice().ends_with("\n") {
// removes blank line that is inserted otherwise // removes blank line that is inserted otherwise
let mut buf = data.into_string(); let mut buf = data.into_string();

View file

@ -144,7 +144,7 @@ impl Reader for NamedReader {
fn with_path<T>(path: &Path, cb: || -> IoResult<T>) -> IoResult<T> { fn with_path<T>(path: &Path, cb: || -> IoResult<T>) -> IoResult<T> {
match cb() { match cb() {
Err(f) => { warn(format!("{}: {}", path.display(), f.to_str()).as_slice()); Err(f) } Err(f) => { warn(format!("{}: {}", path.display(), f.to_string()).as_slice()); Err(f) }
okay => okay okay => okay
} }
} }

View file

@ -105,13 +105,13 @@ fn truncate(no_create: bool, _: bool, reference: Option<String>, size: Option<St
let rfile = match File::open(&Path::new(rfilename.clone())) { let rfile = match File::open(&Path::new(rfilename.clone())) {
Ok(m) => m, Ok(m) => m,
Err(f) => { Err(f) => {
crash!(1, "{}", f.to_str()) crash!(1, "{}", f.to_string())
} }
}; };
match fs::stat(rfile.path()) { match fs::stat(rfile.path()) {
Ok(stat) => (stat.size, Reference), Ok(stat) => (stat.size, Reference),
Err(f) => { Err(f) => {
show_error!("{}", f.to_str()); show_error!("{}", f.to_string());
return Err(1); return Err(1);
} }
} }
@ -127,7 +127,7 @@ fn truncate(no_create: bool, _: bool, reference: Option<String>, size: Option<St
let fsize = match fs::stat(file.path()) { let fsize = match fs::stat(file.path()) {
Ok(stat) => stat.size, Ok(stat) => stat.size,
Err(f) => { Err(f) => {
show_warning!("{}", f.to_str()); show_warning!("{}", f.to_string());
continue; continue;
} }
}; };
@ -143,13 +143,13 @@ fn truncate(no_create: bool, _: bool, reference: Option<String>, size: Option<St
match file.truncate(tsize as i64) { match file.truncate(tsize as i64) {
Ok(_) => {} Ok(_) => {}
Err(f) => { Err(f) => {
show_error!("{}", f.to_str()); show_error!("{}", f.to_string());
return Err(1); return Err(1);
} }
} }
} }
Err(f) => { Err(f) => {
show_error!("{}", f.to_str()); show_error!("{}", f.to_string());
return Err(1); return Err(1);
} }
} }

View file

@ -154,7 +154,7 @@ fn print_time() {
fn get_uptime(boot_time: Option<time_t>) -> i64 { fn get_uptime(boot_time: Option<time_t>) -> i64 {
let proc_uptime = File::open(&Path::new("/proc/uptime")) let proc_uptime = File::open(&Path::new("/proc/uptime"))
.read_to_str(); .read_to_string();
let uptime_text = match proc_uptime { let uptime_text = match proc_uptime {
Ok(s) => s, Ok(s) => s,

View file

@ -177,7 +177,7 @@ pub fn wc(files: Vec<String>, matches: &Matches) -> StdResult<(), int> {
} }
// used for formatting // used for formatting
max_str_len = total_byte_count.to_str().len(); max_str_len = total_byte_count.to_string().len();
} }
for result in results.iter() { for result in results.iter() {
@ -240,7 +240,7 @@ fn open(path: String) -> StdResult<BufferedReader<Box<Reader>>, int> {
Ok(BufferedReader::new(reader)) Ok(BufferedReader::new(reader))
}, },
Err(e) => { Err(e) => {
show_error!("wc: {0:s}: {1:s}", path, e.desc.to_str()); show_error!("wc: {0:s}: {1:s}", path, e.desc.to_string());
Err(1) Err(1)
} }
} }