mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 21:17:46 +00:00
Merge pull request #480 from slapresta/fix-deprecation-warnings
Fix deprecation warnings
This commit is contained in:
commit
7b00a85c69
9 changed files with 21 additions and 21 deletions
|
@ -1,7 +1,6 @@
|
|||
use std::io::{File, Truncate, ReadWrite};
|
||||
use std::os;
|
||||
use std::path::Path;
|
||||
use std::str::replace;
|
||||
|
||||
static TEMPLATE: &'static str = "\
|
||||
extern crate @UTIL_CRATE@;
|
||||
|
@ -31,7 +30,7 @@ fn main() {
|
|||
};
|
||||
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);
|
||||
|
||||
match out.write(main.as_bytes()) {
|
||||
|
|
|
@ -25,6 +25,7 @@ use getopts::{
|
|||
optopt,
|
||||
usage,
|
||||
};
|
||||
use std::borrow::ToOwned;
|
||||
|
||||
#[path = "../common/util.rs"]
|
||||
mod util;
|
||||
|
@ -142,7 +143,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
"~".into_string()
|
||||
"~".to_owned()
|
||||
};
|
||||
|
||||
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 {
|
||||
let test_path = simple_backup_path(path, &".~1~".into_string());
|
||||
let test_path = simple_backup_path(path, &".~1~".to_owned());
|
||||
if test_path.exists() {
|
||||
return numbered_backup_path(path);
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ pub fn parse_options(settings: &mut ::Settings, opts: &getopts::Matches) -> Vec<
|
|||
match opts.opt_str("i") {
|
||||
None => {}
|
||||
Some(val) => {
|
||||
let conv: Option<u64> = from_str(val.as_slice());
|
||||
let conv: Option<u64> = val.as_slice().parse();
|
||||
match conv {
|
||||
None => {
|
||||
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") {
|
||||
None => {}
|
||||
Some(val) => {
|
||||
let conv: Option<uint> = from_str(val.as_slice());
|
||||
let conv: Option<uint> = val.as_slice().parse();
|
||||
match conv {
|
||||
None => {
|
||||
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") {
|
||||
None => {}
|
||||
Some(val) => {
|
||||
let conv: Option<u64> = from_str(val.as_slice());
|
||||
let conv: Option<u64> = val.as_slice().parse();
|
||||
match conv {
|
||||
None => {
|
||||
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") {
|
||||
None => {}
|
||||
Some(val) => {
|
||||
let conv: Option<u64> = from_str(val.as_slice());
|
||||
let conv: Option<u64> = val.as_slice().parse();
|
||||
match conv {
|
||||
None => {
|
||||
errs.push(String::from_str("Illegal value for -l"));
|
||||
|
|
|
@ -26,7 +26,7 @@ fn parse_float(mut s: &str) -> Result<f64, String> {
|
|||
if s.starts_with("+") {
|
||||
s = s.slice_from(1);
|
||||
}
|
||||
match from_str(s) {
|
||||
match s.parse() {
|
||||
Some(n) => Ok(n),
|
||||
None => Err(format!("seq: invalid floating point argument: {}", s))
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ fn integers(a: &[u8], b: &[u8], cond: IntegerCondition) -> bool {
|
|||
(Ok(a), Ok(b)) => (a, b),
|
||||
_ => 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),
|
||||
_ => return false,
|
||||
};
|
||||
|
@ -140,7 +140,7 @@ fn integers(a: &[u8], b: &[u8], cond: IntegerCondition) -> bool {
|
|||
|
||||
fn isatty(fd: &[u8]) -> bool {
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ fn parse_size(size: &str) -> (u64, TruncateMode) {
|
|||
}
|
||||
slice
|
||||
}.to_string();
|
||||
let mut number = match from_str::<u64>(bytes.as_slice()) {
|
||||
let mut number: u64 = match bytes.as_slice().parse() {
|
||||
Some(num) => num,
|
||||
None => {
|
||||
crash!(1, "'{}' is not a valid number.", size)
|
||||
|
|
|
@ -15,7 +15,6 @@ extern crate getopts;
|
|||
extern crate libc;
|
||||
|
||||
use std::io;
|
||||
use std::str::from_str;
|
||||
|
||||
#[path = "../common/util.rs"]
|
||||
mod util;
|
||||
|
@ -29,7 +28,7 @@ fn tabstops_parse(s: String) -> Vec<uint> {
|
|||
let words = s.as_slice().split(',').collect::<Vec<&str>>();
|
||||
|
||||
let nums = words.into_iter()
|
||||
.map(|sn| from_str::<uint>(sn)
|
||||
.map(|sn| sn.parse()
|
||||
.unwrap_or_else(
|
||||
|| crash!(1, "{}\n", "tab size contains invalid character(s)"))
|
||||
)
|
||||
|
@ -225,4 +224,3 @@ fn unexpand(options: Options) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use std::io::process::Command;
|
||||
use std::io::fs::{rmdir, PathExtensions};
|
||||
use std::borrow::ToOwned;
|
||||
|
||||
static EXE: &'static str = "./mkdir";
|
||||
static TEST_DIR1: &'static str = "mkdir_test1";
|
||||
|
@ -9,8 +10,8 @@ static TEST_DIR4: &'static str = "mkdir_test4/mkdir_test4_1";
|
|||
static TEST_DIR5: &'static str = "mkdir_test5/mkdir_test5_1";
|
||||
|
||||
fn cleanup(dir: &'static str) {
|
||||
let d = dir.into_string();
|
||||
let p = Path::new(d.into_string());
|
||||
let d = dir.to_owned();
|
||||
let p = Path::new(d.to_owned());
|
||||
if p.exists() {
|
||||
rmdir(&p).unwrap();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ use std::io::process::Command;
|
|||
use std::io::fs::PathExtensions;
|
||||
use std::io::pipe::PipeStream;
|
||||
use std::str::from_utf8;
|
||||
use std::borrow::ToOwned;
|
||||
|
||||
static EXE: &'static str = "./mv";
|
||||
|
||||
|
@ -27,8 +28,8 @@ fn run(cmd: &mut Command) -> CmdResult {
|
|||
let prog = cmd.spawn().unwrap().wait_with_output().unwrap();
|
||||
CmdResult {
|
||||
success: prog.status.success(),
|
||||
stderr: from_utf8(prog.error.as_slice()).unwrap().into_string(),
|
||||
stdout: from_utf8(prog.output.as_slice()).unwrap().into_string(),
|
||||
stderr: from_utf8(prog.error.as_slice()).unwrap().to_owned(),
|
||||
stdout: from_utf8(prog.output.as_slice()).unwrap().to_owned(),
|
||||
}
|
||||
}
|
||||
fn run_interactive(cmd: &mut Command, f: |&mut PipeStream|) -> CmdResult {
|
||||
|
@ -40,8 +41,8 @@ fn run_interactive(cmd: &mut Command, f: |&mut PipeStream|) -> CmdResult {
|
|||
let prog = command.wait_with_output().unwrap();
|
||||
CmdResult {
|
||||
success: prog.status.success(),
|
||||
stderr: from_utf8(prog.error.as_slice()).unwrap().into_string(),
|
||||
stdout: from_utf8(prog.output.as_slice()).unwrap().into_string(),
|
||||
stderr: from_utf8(prog.error.as_slice()).unwrap().to_owned(),
|
||||
stdout: from_utf8(prog.output.as_slice()).unwrap().to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue