mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
Merge pull request #344 from ebfe/fix-build-master
Fix build with rust master
This commit is contained in:
commit
b8def68668
18 changed files with 51 additions and 51 deletions
|
@ -92,9 +92,9 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
|
||||
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,
|
||||
Err(f) => fail!(f.to_str())
|
||||
Err(f) => fail!(f.to_string())
|
||||
};
|
||||
|
||||
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()) {
|
||||
Ok(_) => {}
|
||||
Err(f) => { crash!(1, "{}", f.to_str()); }
|
||||
Err(f) => { crash!(1, "{}", f.to_string()); }
|
||||
}
|
||||
match out.flush() {
|
||||
Ok(_) => {}
|
||||
Err(f) => { crash!(1, "{}", f.to_str()); }
|
||||
Err(f) => { crash!(1, "{}", f.to_string()); }
|
||||
}
|
||||
}
|
||||
Err(s) => {
|
||||
error!("error: {}", s.to_str());
|
||||
error!("error: {}", s.to_string());
|
||||
fail!()
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ fn encode(input: &mut Reader, line_wrap: uint) {
|
|||
};
|
||||
let to_encode = match input.read_to_end() {
|
||||
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);
|
||||
|
||||
|
|
|
@ -284,7 +284,7 @@ fn open(path: &str) -> Option<(Box<Reader>, bool)> {
|
|||
match File::open(&std::path::Path::new(path)) {
|
||||
Ok(f) => Some((box f as Box<Reader>, false)),
|
||||
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
|
||||
},
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ macro_rules! crash_if_err(
|
|||
($exitcode:expr, $exp:expr) => (
|
||||
match $exp {
|
||||
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),+) => (
|
||||
match write!($fd, $($args),+) {
|
||||
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),+) => (
|
||||
match writeln!($fd, $($args),+) {
|
||||
Ok(_) => {}
|
||||
Err(f) => { fail!(f.to_str()); }
|
||||
Err(f) => { fail!(f.to_string()); }
|
||||
}
|
||||
)
|
||||
)
|
||||
|
@ -89,7 +89,7 @@ macro_rules! safe_unwrap(
|
|||
($exp:expr) => (
|
||||
match $exp {
|
||||
Ok(m) => m,
|
||||
Err(f) => crash!(1, "{}", f.to_str())
|
||||
Err(f) => crash!(1, "{}", f.to_string())
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
14
cp/cp.rs
14
cp/cp.rs
|
@ -102,15 +102,15 @@ fn copy(matches: getopts::Matches) {
|
|||
Err(e) => if e.kind == io::FileNotFound {
|
||||
false
|
||||
} else {
|
||||
error!("error: {:s}", e.to_str());
|
||||
error!("error: {:s}", e.to_string());
|
||||
fail!()
|
||||
}
|
||||
};
|
||||
|
||||
if same_file {
|
||||
error!("error: \"{:s}\" and \"{:s}\" are the same file",
|
||||
source.display().to_str(),
|
||||
dest.display().to_str());
|
||||
source.display().to_string(),
|
||||
dest.display().to_string());
|
||||
fail!();
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ fn copy(matches: getopts::Matches) {
|
|||
|
||||
if io_result.is_err() {
|
||||
let err = io_result.unwrap_err();
|
||||
error!("error: {:s}", err.to_str());
|
||||
error!("error: {:s}", err.to_string());
|
||||
fail!();
|
||||
}
|
||||
} else {
|
||||
|
@ -129,7 +129,7 @@ fn copy(matches: getopts::Matches) {
|
|||
|
||||
for source in sources.iter() {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -137,13 +137,13 @@ fn copy(matches: getopts::Matches) {
|
|||
|
||||
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);
|
||||
|
||||
if io_result.is_err() {
|
||||
let err = io_result.unwrap_err();
|
||||
error!("error: {:s}", err.to_str());
|
||||
error!("error: {:s}", err.to_string());
|
||||
fail!()
|
||||
}
|
||||
}
|
||||
|
|
14
cut/cut.rs
14
cut/cut.rs
|
@ -56,7 +56,7 @@ fn cut_bytes<T: Reader>(mut reader: BufferedReader<T>,
|
|||
let mut out = BufferedWriter::new(std::io::stdio::stdout_raw());
|
||||
let (use_delim, out_delim) = match opts.out_delim.clone() {
|
||||
Some(delim) => (true, delim),
|
||||
None => (false, "".to_str())
|
||||
None => (false, "".to_string())
|
||||
};
|
||||
|
||||
'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 (use_delim, out_delim) = match opts.out_delim.clone() {
|
||||
Some(delim) => (true, delim),
|
||||
None => (false, "".to_str())
|
||||
None => (false, "".to_string())
|
||||
};
|
||||
|
||||
'newline: loop {
|
||||
|
@ -363,7 +363,7 @@ fn cut_files(mut filenames: Vec<String>, mode: Mode) -> int {
|
|||
let mut stdin_read = false;
|
||||
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() {
|
||||
if filename.as_slice() == "-" {
|
||||
|
@ -486,7 +486,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
match matches.opt_str("delimiter") {
|
||||
Some(delim) => {
|
||||
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 {
|
||||
Ok(Fields(ranges,
|
||||
FieldOptions {
|
||||
|
@ -498,7 +498,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
None => Ok(Fields(ranges,
|
||||
FieldOptions {
|
||||
delimiter: "\t".to_str(),
|
||||
delimiter: "\t".to_string(),
|
||||
out_delimeter: out_delim,
|
||||
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() => {
|
||||
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 {
|
||||
|
|
|
@ -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 {
|
||||
println!("{}", signal.value)
|
||||
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);
|
||||
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() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ fn mkdir(path: &Path, mode: FilePermission) {
|
|||
match fs::mkdir(path, mode) {
|
||||
Ok(_) => {},
|
||||
Err(e) => {
|
||||
crash!(1, "test {}", e.to_str());
|
||||
crash!(1, "test {}", e.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ fn main() {
|
|||
// XXX: this all just assumes that the IO works correctly
|
||||
let mut out = File::open_mode(&Path::new(outfile), Truncate, Write).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()) {
|
||||
Err(e) => fail!("{}", e),
|
||||
|
|
4
nl/nl.rs
4
nl/nl.rs
|
@ -158,9 +158,9 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
// nl implements the main functionality for an individual buffer.
|
||||
fn nl<T: Reader> (reader: &mut BufferedReader<T>, settings: &Settings) {
|
||||
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.
|
||||
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;
|
||||
// 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.
|
||||
|
|
|
@ -66,7 +66,7 @@ fn paste(filenames: Vec<String>, serial: bool, delimiters: &str) {
|
|||
}
|
||||
)
|
||||
).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;
|
||||
if serial {
|
||||
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 {
|
||||
break
|
||||
} else {
|
||||
crash!(1, "{}", f.to_str())
|
||||
crash!(1, "{}", f.to_string())
|
||||
}
|
||||
}
|
||||
delim_count += 1;
|
||||
|
@ -102,7 +102,7 @@ fn paste(filenames: Vec<String>, serial: bool, delimiters: &str) {
|
|||
*eof.get_mut(i) = true;
|
||||
eof_count += 1;
|
||||
} else {
|
||||
crash!(1, "{}", f.to_str());
|
||||
crash!(1, "{}", f.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
6
rm/rm.rs
6
rm/rm.rs
|
@ -136,7 +136,7 @@ fn remove(files: Vec<String>, force: bool, interactive: InteractiveMode, one_fs:
|
|||
let walk_dir = match fs::walk_dir(&file) {
|
||||
Ok(m) => m,
|
||||
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);
|
||||
|
@ -177,7 +177,7 @@ fn remove_dir(path: &Path, name: &str, interactive: InteractiveMode, verbose: bo
|
|||
match fs::rmdir(path) {
|
||||
Ok(_) => if verbose { println!("Removed '{}'", name); },
|
||||
Err(f) => {
|
||||
show_error!("{}", f.to_str());
|
||||
show_error!("{}", f.to_string());
|
||||
return Err(1);
|
||||
}
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ fn remove_file(path: &Path, name: &str, interactive: InteractiveMode, verbose: b
|
|||
match fs::unlink(path) {
|
||||
Ok(_) => if verbose { println!("Removed '{}'", name); },
|
||||
Err(f) => {
|
||||
show_error!("{}", f.to_str());
|
||||
show_error!("{}", f.to_string());
|
||||
return Err(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
Ok(m) => m,
|
||||
Err(f) => {
|
||||
show_error!("{}", f.to_str());
|
||||
show_error!("{}", f.to_string());
|
||||
return Err(1);
|
||||
}
|
||||
};
|
||||
|
@ -111,7 +111,7 @@ fn remove_dir(path: &Path, dir: &str, ignore: bool, parents: bool, verbose: bool
|
|||
}
|
||||
}
|
||||
Err(f) => {
|
||||
show_error!("{}", f.to_str());
|
||||
show_error!("{}", f.to_string());
|
||||
r = Err(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ macro_rules! pipe_write(
|
|||
if f.kind == io::BrokenPipe {
|
||||
return
|
||||
} 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 value = first + i as f64 * step;
|
||||
while !done_printing(value, step, last) {
|
||||
let istr = value.to_str();
|
||||
let istr = value.to_string();
|
||||
let ilen = istr.len();
|
||||
let before_dec = istr.as_slice().find('.').unwrap_or(ilen);
|
||||
if pad && before_dec < padding {
|
||||
|
|
|
@ -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>
|
||||
}
|
||||
);
|
||||
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") {
|
||||
// removes blank line that is inserted otherwise
|
||||
let mut buf = data.into_string();
|
||||
|
|
|
@ -144,7 +144,7 @@ impl Reader for NamedReader {
|
|||
|
||||
fn with_path<T>(path: &Path, cb: || -> IoResult<T>) -> IoResult<T> {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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())) {
|
||||
Ok(m) => m,
|
||||
Err(f) => {
|
||||
crash!(1, "{}", f.to_str())
|
||||
crash!(1, "{}", f.to_string())
|
||||
}
|
||||
};
|
||||
match fs::stat(rfile.path()) {
|
||||
Ok(stat) => (stat.size, Reference),
|
||||
Err(f) => {
|
||||
show_error!("{}", f.to_str());
|
||||
show_error!("{}", f.to_string());
|
||||
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()) {
|
||||
Ok(stat) => stat.size,
|
||||
Err(f) => {
|
||||
show_warning!("{}", f.to_str());
|
||||
show_warning!("{}", f.to_string());
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
@ -143,13 +143,13 @@ fn truncate(no_create: bool, _: bool, reference: Option<String>, size: Option<St
|
|||
match file.truncate(tsize as i64) {
|
||||
Ok(_) => {}
|
||||
Err(f) => {
|
||||
show_error!("{}", f.to_str());
|
||||
show_error!("{}", f.to_string());
|
||||
return Err(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(f) => {
|
||||
show_error!("{}", f.to_str());
|
||||
show_error!("{}", f.to_string());
|
||||
return Err(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ fn print_time() {
|
|||
|
||||
fn get_uptime(boot_time: Option<time_t>) -> i64 {
|
||||
let proc_uptime = File::open(&Path::new("/proc/uptime"))
|
||||
.read_to_str();
|
||||
.read_to_string();
|
||||
|
||||
let uptime_text = match proc_uptime {
|
||||
Ok(s) => s,
|
||||
|
|
4
wc/wc.rs
4
wc/wc.rs
|
@ -177,7 +177,7 @@ pub fn wc(files: Vec<String>, matches: &Matches) -> StdResult<(), int> {
|
|||
}
|
||||
|
||||
// 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() {
|
||||
|
@ -240,7 +240,7 @@ fn open(path: String) -> StdResult<BufferedReader<Box<Reader>>, int> {
|
|||
Ok(BufferedReader::new(reader))
|
||||
},
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue