mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 13:07:46 +00:00
Fix build as well as most deprecation warnings
This commit is contained in:
parent
be37a74af3
commit
d50d4f54b9
8 changed files with 23 additions and 25 deletions
|
@ -111,7 +111,7 @@ pub fn get_pw_from_args(free: &Vec<String>) -> Option<c_passwd> {
|
|||
let username = free[0].as_slice();
|
||||
|
||||
// Passed user as id
|
||||
if username.chars().all(|c| c.is_digit()) {
|
||||
if username.chars().all(|c| c.is_digit(10)) {
|
||||
let id = from_str::<u32>(username).unwrap();
|
||||
let pw_pointer = unsafe { getpwuid(id as uid_t) };
|
||||
|
||||
|
@ -138,7 +138,7 @@ pub fn get_pw_from_args(free: &Vec<String>) -> Option<c_passwd> {
|
|||
}
|
||||
|
||||
pub fn get_group(groupname: &str) -> Option<c_group> {
|
||||
let group = if groupname.chars().all(|c| c.is_digit()) {
|
||||
let group = if groupname.chars().all(|c| c.is_digit(10)) {
|
||||
unsafe { getgrgid(from_str::<gid_t>(groupname).unwrap()) }
|
||||
} else {
|
||||
unsafe { getgrnam(groupname.to_c_str().unwrap() as *const c_char) }
|
||||
|
|
|
@ -235,10 +235,10 @@ ers of 1000).",
|
|||
let mut numbers = vec!();
|
||||
let mut letters = vec!();
|
||||
for c in s.as_slice().chars() {
|
||||
if found_letter && c.is_digit() || !found_number && !c.is_digit() {
|
||||
if found_letter && c.is_digit(10) || !found_number && !c.is_digit(10) {
|
||||
show_error!("invalid --block-size argument '{}'", s);
|
||||
return 1;
|
||||
} else if c.is_digit() {
|
||||
} else if c.is_digit(10) {
|
||||
found_number = true;
|
||||
numbers.push(c as u8);
|
||||
} else if c.is_alphabetic() {
|
||||
|
|
|
@ -81,16 +81,14 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
|
||||
fn handle_obsolete(args: &[String]) -> (Vec<String>, Option<String>) {
|
||||
let mut args = args.to_vec();
|
||||
let mut i = 0;
|
||||
while i < args.len() {
|
||||
if args[i].as_slice().char_at(0) == '-' && args[i].len() > 1 && args[i].as_slice().char_at(1).is_digit() {
|
||||
return (args.clone(),
|
||||
Some(args.remove(i).unwrap().as_slice().slice_from(1).to_string()));
|
||||
for (i, arg) in args.iter().enumerate() {
|
||||
let slice = arg.as_slice();
|
||||
if slice.char_at(0) == '-' && slice.len() > 1 && slice.char_at(1).is_digit(10) {
|
||||
return (args.slice_to(i).to_vec() + args.slice_from(i + 1),
|
||||
Some(slice.slice_from(1).to_string()));
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
(args, None)
|
||||
(args.to_vec(), None)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
extern crate getopts;
|
||||
|
||||
use std::char;
|
||||
use std::char::UnicodeChar;
|
||||
use std::io::{stdin};
|
||||
use std::io::{BufferedReader, BytesReader};
|
||||
use std::io::fs::File;
|
||||
|
@ -145,7 +145,7 @@ fn obsolete(options: &[String]) -> (Vec<String>, Option<uint>) {
|
|||
let len = current.len();
|
||||
for pos in range(1, len) {
|
||||
// Ensure that the argument is only made out of digits
|
||||
if !char::is_digit(current[pos] as char) { break; }
|
||||
if !UnicodeChar::is_numeric(current[pos] as char) { break; }
|
||||
|
||||
// If this is the last number
|
||||
if pos == len - 1 {
|
||||
|
|
|
@ -105,7 +105,7 @@ fn handle_obsolete(mut args: Vec<String>) -> (Vec<String>, Option<String>) {
|
|||
while i < args.len() {
|
||||
// this is safe because slice is valid when it is referenced
|
||||
let slice: &str = unsafe { std::mem::transmute(args[i].as_slice()) };
|
||||
if slice.char_at(0) == '-' && slice.len() > 1 && slice.char_at(1).is_digit() {
|
||||
if slice.char_at(0) == '-' && slice.len() > 1 && slice.char_at(1).is_digit(10) {
|
||||
let val = slice.slice_from(1);
|
||||
match from_str(val) {
|
||||
Some(num) => {
|
||||
|
|
|
@ -105,7 +105,7 @@ fn skip_zeros(mut char_a: char, char_iter: &mut Chars, ret: Ordering) -> Orderin
|
|||
while char_a == '0' {
|
||||
char_a = match char_iter.next() { None => return Equal, Some(t) => t };
|
||||
}
|
||||
if char_a.is_digit() { ret } else { Equal }
|
||||
if char_a.is_digit(10) { ret } else { Equal }
|
||||
}
|
||||
|
||||
/// Compares two decimal fractions as strings (n < 1)
|
||||
|
@ -122,15 +122,15 @@ fn frac_compare(a: &String, b: &String) -> Ordering {
|
|||
char_a = match a_chars.next() { None => 0 as char, Some(t) => t };
|
||||
char_b = match b_chars.next() { None => 0 as char, Some(t) => t };
|
||||
// hit the end at the same time, they are equal
|
||||
if !char_a.is_digit() {
|
||||
if !char_a.is_digit(10) {
|
||||
return Equal;
|
||||
}
|
||||
}
|
||||
if char_a.is_digit() && char_b.is_digit() {
|
||||
if char_a.is_digit(10) && char_b.is_digit(10) {
|
||||
(char_a as int).cmp(&(char_b as int))
|
||||
} else if char_a.is_digit() {
|
||||
} else if char_a.is_digit(10) {
|
||||
skip_zeros(char_a, a_chars, Greater)
|
||||
} else if char_b.is_digit() {
|
||||
} else if char_b.is_digit(10) {
|
||||
skip_zeros(char_b, b_chars, Less)
|
||||
} else { Equal }
|
||||
} else if char_a == DECIMAL_PT {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
extern crate getopts;
|
||||
|
||||
use std::char;
|
||||
use std::char::UnicodeChar;
|
||||
use std::io::{stdin};
|
||||
use std::io::{BufferedReader, BytesReader};
|
||||
use std::io::fs::File;
|
||||
|
@ -165,7 +165,7 @@ fn obsolete(options: &[String]) -> (Vec<String>, Option<uint>) {
|
|||
let len = current.len();
|
||||
for pos in range(1, len) {
|
||||
// Ensure that the argument is only made out of digits
|
||||
if !char::is_digit(current[pos] as char) { break; }
|
||||
if !UnicodeChar::is_numeric(current[pos] as char) { break; }
|
||||
|
||||
// If this is the last number
|
||||
if pos == len - 1 {
|
||||
|
|
|
@ -46,7 +46,7 @@ fn main() {
|
|||
let binary = Path::new(args[0].as_slice());
|
||||
let binary_as_util = binary.filename_str().unwrap();
|
||||
|
||||
match umap.find_equiv(binary_as_util) {
|
||||
match umap.get(binary_as_util) {
|
||||
Some(&uumain) => {
|
||||
os::set_exit_status(uumain(args));
|
||||
return
|
||||
|
@ -70,7 +70,7 @@ fn main() {
|
|||
args.remove(0);
|
||||
let util = args[0].as_slice();
|
||||
|
||||
match umap.find_equiv(util) {
|
||||
match umap.get(util) {
|
||||
Some(&uumain) => {
|
||||
os::set_exit_status(uumain(args.clone()));
|
||||
return
|
||||
|
@ -80,7 +80,7 @@ fn main() {
|
|||
// see if they want help on a specific util
|
||||
if args.len() >= 2 {
|
||||
let util = args[1].as_slice();
|
||||
match umap.find_equiv(util) {
|
||||
match umap.get(util) {
|
||||
Some(&uumain) => {
|
||||
os::set_exit_status(uumain(vec![util.to_string(), "--help".to_string()]));
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue