1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 13:37:48 +00:00

Fix deprecation warnings on latest nightlies

This commit is contained in:
Santiago Lapresta 2014-12-25 19:55:32 +01:00
parent 8644b75a85
commit d142168365
7 changed files with 13 additions and 15 deletions

View file

@ -1,7 +1,6 @@
use std::io::{File, Truncate, ReadWrite}; use std::io::{File, Truncate, ReadWrite};
use std::os; use std::os;
use std::path::Path; use std::path::Path;
use std::str::replace;
static TEMPLATE: &'static str = "\ static TEMPLATE: &'static str = "\
extern crate @UTIL_CRATE@; extern crate @UTIL_CRATE@;
@ -31,7 +30,7 @@ fn main() {
}; };
let outfile = args[2].as_slice(); let outfile = args[2].as_slice();
let main = std::str::replace(TEMPLATE, "@UTIL_CRATE@", crat); let main = TEMPLATE.replace("@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);
match out.write(main.as_bytes()) { match out.write(main.as_bytes()) {

View file

@ -25,6 +25,7 @@ use getopts::{
optopt, optopt,
usage, usage,
}; };
use std::borrow::ToOwned;
#[path = "../common/util.rs"] #[path = "../common/util.rs"]
mod util; mod util;
@ -142,7 +143,7 @@ pub fn uumain(args: Vec<String>) -> int {
} }
} }
} else { } else {
"~".into_string() "~".to_owned()
}; };
if matches.opt_present("T") && matches.opt_present("t") { if matches.opt_present("T") && matches.opt_present("t") {
@ -347,7 +348,7 @@ fn numbered_backup_path(path: &Path) -> Path {
} }
fn existing_backup_path(path: &Path, suffix: &String) -> Path { fn existing_backup_path(path: &Path, suffix: &String) -> Path {
let test_path = simple_backup_path(path, &".~1~".into_string()); let test_path = simple_backup_path(path, &".~1~".to_owned());
if test_path.exists() { if test_path.exists() {
return numbered_backup_path(path); return numbered_backup_path(path);
} }

View file

@ -71,7 +71,7 @@ pub fn parse_options(settings: &mut ::Settings, opts: &getopts::Matches) -> Vec<
match opts.opt_str("i") { match opts.opt_str("i") {
None => {} None => {}
Some(val) => { Some(val) => {
let conv: Option<u64> = from_str(val.as_slice()); let conv: Option<u64> = val.as_slice().parse();
match conv { match conv {
None => { None => {
errs.push(String::from_str("Illegal value for -i")); errs.push(String::from_str("Illegal value for -i"));
@ -83,7 +83,7 @@ pub fn parse_options(settings: &mut ::Settings, opts: &getopts::Matches) -> Vec<
match opts.opt_str("w") { match opts.opt_str("w") {
None => {} None => {}
Some(val) => { Some(val) => {
let conv: Option<uint> = from_str(val.as_slice()); let conv: Option<uint> = val.as_slice().parse();
match conv { match conv {
None => { None => {
errs.push(String::from_str("Illegal value for -w")); errs.push(String::from_str("Illegal value for -w"));
@ -95,7 +95,7 @@ pub fn parse_options(settings: &mut ::Settings, opts: &getopts::Matches) -> Vec<
match opts.opt_str("v") { match opts.opt_str("v") {
None => {} None => {}
Some(val) => { Some(val) => {
let conv: Option<u64> = from_str(val.as_slice()); let conv: Option<u64> = val.as_slice().parse();
match conv { match conv {
None => { None => {
errs.push(String::from_str("Illegal value for -v")); errs.push(String::from_str("Illegal value for -v"));
@ -107,7 +107,7 @@ pub fn parse_options(settings: &mut ::Settings, opts: &getopts::Matches) -> Vec<
match opts.opt_str("l") { match opts.opt_str("l") {
None => {} None => {}
Some(val) => { Some(val) => {
let conv: Option<u64> = from_str(val.as_slice()); let conv: Option<u64> = val.as_slice().parse();
match conv { match conv {
None => { None => {
errs.push(String::from_str("Illegal value for -l")); errs.push(String::from_str("Illegal value for -l"));

View file

@ -26,7 +26,7 @@ fn parse_float(mut s: &str) -> Result<f64, String> {
if s.starts_with("+") { if s.starts_with("+") {
s = s.slice_from(1); s = s.slice_from(1);
} }
match from_str(s) { match s.parse() {
Some(n) => Ok(n), Some(n) => Ok(n),
None => Err(format!("seq: invalid floating point argument: {}", s)) None => Err(format!("seq: invalid floating point argument: {}", s))
} }

View file

@ -124,7 +124,7 @@ fn integers(a: &[u8], b: &[u8], cond: IntegerCondition) -> bool {
(Ok(a), Ok(b)) => (a, b), (Ok(a), Ok(b)) => (a, b),
_ => return false, _ => return false,
}; };
let (a, b): (i64, i64) = match (from_str(a), from_str(b)) { let (a, b): (i64, i64) = match (a.parse(), b.parse()) {
(Some(a), Some(b)) => (a, b), (Some(a), Some(b)) => (a, b),
_ => return false, _ => return false,
}; };
@ -140,7 +140,7 @@ fn integers(a: &[u8], b: &[u8], cond: IntegerCondition) -> bool {
fn isatty(fd: &[u8]) -> bool { fn isatty(fd: &[u8]) -> bool {
use libc::{isatty}; use libc::{isatty};
from_utf8(fd).ok().and_then(|s| from_str(s)) from_utf8(fd).ok().and_then(|s| s.parse())
.map(|i| unsafe { isatty(i) == 1 }).unwrap_or(false) .map(|i| unsafe { isatty(i) == 1 }).unwrap_or(false)
} }

View file

@ -184,7 +184,7 @@ fn parse_size(size: &str) -> (u64, TruncateMode) {
} }
slice slice
}.to_string(); }.to_string();
let mut number = match from_str::<u64>(bytes.as_slice()) { let mut number: u64 = match bytes.as_slice().parse() {
Some(num) => num, Some(num) => num,
None => { None => {
crash!(1, "'{}' is not a valid number.", size) crash!(1, "'{}' is not a valid number.", size)

View file

@ -15,7 +15,6 @@ extern crate getopts;
extern crate libc; extern crate libc;
use std::io; use std::io;
use std::str::from_str;
#[path = "../common/util.rs"] #[path = "../common/util.rs"]
mod util; mod util;
@ -29,7 +28,7 @@ fn tabstops_parse(s: String) -> Vec<uint> {
let words = s.as_slice().split(',').collect::<Vec<&str>>(); let words = s.as_slice().split(',').collect::<Vec<&str>>();
let nums = words.into_iter() let nums = words.into_iter()
.map(|sn| from_str::<uint>(sn) .map(|sn| sn.parse()
.unwrap_or_else( .unwrap_or_else(
|| crash!(1, "{}\n", "tab size contains invalid character(s)")) || crash!(1, "{}\n", "tab size contains invalid character(s)"))
) )
@ -225,4 +224,3 @@ fn unexpand(options: Options) {
} }
} }
} }