mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 13:37:48 +00:00
Update for recent std::ascii changes
This commit is contained in:
parent
e04c09a8ba
commit
aff936da99
5 changed files with 18 additions and 15 deletions
|
@ -17,6 +17,7 @@ extern crate getopts;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
#[phase(plugin, link)] extern crate log;
|
#[phase(plugin, link)] extern crate log;
|
||||||
|
|
||||||
|
use std::ascii::AsciiExt;
|
||||||
use std::io::{println, File, stdout};
|
use std::io::{println, File, stdout};
|
||||||
use std::io::stdio::stdin_raw;
|
use std::io::stdio::stdin_raw;
|
||||||
|
|
||||||
|
@ -105,14 +106,13 @@ fn decode(input: &mut Reader, ignore_garbage: bool) {
|
||||||
if ignore_garbage {
|
if ignore_garbage {
|
||||||
to_decode.as_slice()
|
to_decode.as_slice()
|
||||||
.trim_chars(|&: c: char| {
|
.trim_chars(|&: c: char| {
|
||||||
let num = match c.to_ascii_opt() {
|
if !c.is_ascii() {
|
||||||
Some(ascii) => ascii.as_byte(),
|
return false;
|
||||||
None => return false
|
|
||||||
};
|
};
|
||||||
!(num >= 'a' as u8 && num <= 'z' as u8 ||
|
!(c >= 'a' && c <= 'z' ||
|
||||||
num >= 'A' as u8 && num <= 'Z' as u8 ||
|
c >= 'A' && c <= 'Z' ||
|
||||||
num >= '0' as u8 && num <= '9' as u8 ||
|
c >= '0' && c <= '9' ||
|
||||||
num == '+' as u8 || num == '/' as u8)
|
c == '+' || c == '/' )
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
to_decode.as_slice()
|
to_decode.as_slice()
|
||||||
|
|
|
@ -18,6 +18,7 @@ extern crate regex;
|
||||||
extern crate crypto;
|
extern crate crypto;
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
|
|
||||||
|
use std::ascii::AsciiExt;
|
||||||
use std::io::fs::File;
|
use std::io::fs::File;
|
||||||
use std::io::stdio::stdin_raw;
|
use std::io::stdio::stdin_raw;
|
||||||
use std::io::BufferedReader;
|
use std::io::BufferedReader;
|
||||||
|
@ -212,13 +213,13 @@ fn hashsum(algoname: &str, mut digest: Box<Digest>, files: Vec<String>, binary:
|
||||||
let mut buffer = file;
|
let mut buffer = file;
|
||||||
for (i, line) in buffer.lines().enumerate() {
|
for (i, line) in buffer.lines().enumerate() {
|
||||||
let line = safe_unwrap!(line);
|
let line = safe_unwrap!(line);
|
||||||
let (ck_filename, sum, binary_check): (_, Vec<Ascii>, _) = match gnu_re.captures(line.as_slice()) {
|
let (ck_filename, sum, binary_check) = match gnu_re.captures(line.as_slice()) {
|
||||||
Some(caps) => (caps.name("fileName").unwrap(),
|
Some(caps) => (caps.name("fileName").unwrap(),
|
||||||
caps.name("digest").unwrap().to_ascii().iter().map(|ch| ch.to_lowercase()).collect(),
|
caps.name("digest").unwrap().to_ascii_lowercase(),
|
||||||
caps.name("binary").unwrap() == "*"),
|
caps.name("binary").unwrap() == "*"),
|
||||||
None => match bsd_re.captures(line.as_slice()) {
|
None => match bsd_re.captures(line.as_slice()) {
|
||||||
Some(caps) => (caps.name("fileName").unwrap(),
|
Some(caps) => (caps.name("fileName").unwrap(),
|
||||||
caps.name("digest").unwrap().to_ascii().iter().map(|ch| ch.to_lowercase()).collect(),
|
caps.name("digest").unwrap().to_ascii_lowercase(),
|
||||||
true),
|
true),
|
||||||
None => {
|
None => {
|
||||||
bad_format += 1;
|
bad_format += 1;
|
||||||
|
@ -233,8 +234,8 @@ fn hashsum(algoname: &str, mut digest: Box<Digest>, files: Vec<String>, binary:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let mut ckf = safe_unwrap!(File::open(&Path::new(ck_filename)));
|
let mut ckf = safe_unwrap!(File::open(&Path::new(ck_filename)));
|
||||||
let real_sum: Vec<Ascii> = safe_unwrap!(digest_reader(&mut digest, &mut ckf, binary_check))
|
let real_sum = safe_unwrap!(digest_reader(&mut digest, &mut ckf, binary_check))
|
||||||
.as_slice().to_ascii().iter().map(|ch| ch.to_lowercase()).collect();
|
.as_slice().to_ascii_lowercase();
|
||||||
if sum.as_slice() == real_sum.as_slice() {
|
if sum.as_slice() == real_sum.as_slice() {
|
||||||
if !quiet {
|
if !quiet {
|
||||||
pipe_println!("{}: OK", ck_filename);
|
pipe_println!("{}: OK", ck_filename);
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
||||||
|
use std::ascii::AsciiExt;
|
||||||
use std::io::{File, Open, ReadWrite, fs};
|
use std::io::{File, Open, ReadWrite, fs};
|
||||||
use std::io::fs::PathExtensions;
|
use std::io::fs::PathExtensions;
|
||||||
|
|
||||||
|
@ -191,8 +192,8 @@ fn parse_size(size: &str) -> (u64, TruncateMode) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if size.char_at(size.len() - 1).is_alphabetic() {
|
if size.char_at(size.len() - 1).is_alphabetic() {
|
||||||
number *= match size.char_at(size.len() - 1).to_ascii().to_uppercase().as_char() {
|
number *= match size.char_at(size.len() - 1).to_ascii_uppercase() {
|
||||||
'B' => match size.char_at(size.len() - 2).to_ascii().to_uppercase().as_char() {
|
'B' => match size.char_at(size.len() - 2).to_ascii_uppercase() {
|
||||||
'K' => 1000,
|
'K' => 1000,
|
||||||
'M' => 1000 * 1000,
|
'M' => 1000 * 1000,
|
||||||
'G' => 1000 * 1000 * 1000,
|
'G' => 1000 * 1000 * 1000,
|
||||||
|
|
|
@ -69,7 +69,7 @@ impl Uniq {
|
||||||
};
|
};
|
||||||
let sliced = line.as_slice().slice(slice_start, slice_stop).into_string();
|
let sliced = line.as_slice().slice(slice_start, slice_stop).into_string();
|
||||||
if self.ignore_case {
|
if self.ignore_case {
|
||||||
sliced.into_ascii_upper()
|
sliced.into_ascii_uppercase()
|
||||||
} else {
|
} else {
|
||||||
sliced
|
sliced
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
||||||
|
use std::ascii::AsciiExt;
|
||||||
use std::str::from_utf8;
|
use std::str::from_utf8;
|
||||||
use std::io::{print, File, BufferedReader};
|
use std::io::{print, File, BufferedReader};
|
||||||
use std::io::fs::PathExtensions;
|
use std::io::fs::PathExtensions;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue