Update for recent std::ascii changes

This commit is contained in:
Florian Hahn 2014-12-30 20:11:06 +01:00
parent e04c09a8ba
commit aff936da99
5 changed files with 18 additions and 15 deletions

View file

@ -17,6 +17,7 @@ extern crate getopts;
extern crate libc;
#[phase(plugin, link)] extern crate log;
use std::ascii::AsciiExt;
use std::io::{println, File, stdout};
use std::io::stdio::stdin_raw;
@ -105,14 +106,13 @@ fn decode(input: &mut Reader, ignore_garbage: bool) {
if ignore_garbage {
to_decode.as_slice()
.trim_chars(|&: c: char| {
let num = match c.to_ascii_opt() {
Some(ascii) => ascii.as_byte(),
None => return false
if !c.is_ascii() {
return false;
};
!(num >= 'a' as u8 && num <= 'z' as u8 ||
num >= 'A' as u8 && num <= 'Z' as u8 ||
num >= '0' as u8 && num <= '9' as u8 ||
num == '+' as u8 || num == '/' as u8)
!(c >= 'a' && c <= 'z' ||
c >= 'A' && c <= 'Z' ||
c >= '0' && c <= '9' ||
c == '+' || c == '/' )
})
} else {
to_decode.as_slice()

View file

@ -18,6 +18,7 @@ extern crate regex;
extern crate crypto;
extern crate getopts;
use std::ascii::AsciiExt;
use std::io::fs::File;
use std::io::stdio::stdin_raw;
use std::io::BufferedReader;
@ -212,13 +213,13 @@ fn hashsum(algoname: &str, mut digest: Box<Digest>, files: Vec<String>, binary:
let mut buffer = file;
for (i, line) in buffer.lines().enumerate() {
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(),
caps.name("digest").unwrap().to_ascii().iter().map(|ch| ch.to_lowercase()).collect(),
caps.name("digest").unwrap().to_ascii_lowercase(),
caps.name("binary").unwrap() == "*"),
None => match bsd_re.captures(line.as_slice()) {
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),
None => {
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 real_sum: Vec<Ascii> = safe_unwrap!(digest_reader(&mut digest, &mut ckf, binary_check))
.as_slice().to_ascii().iter().map(|ch| ch.to_lowercase()).collect();
let real_sum = safe_unwrap!(digest_reader(&mut digest, &mut ckf, binary_check))
.as_slice().to_ascii_lowercase();
if sum.as_slice() == real_sum.as_slice() {
if !quiet {
pipe_println!("{}: OK", ck_filename);

View file

@ -14,6 +14,7 @@
extern crate getopts;
extern crate libc;
use std::ascii::AsciiExt;
use std::io::{File, Open, ReadWrite, fs};
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() {
number *= match size.char_at(size.len() - 1).to_ascii().to_uppercase().as_char() {
'B' => match size.char_at(size.len() - 2).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_uppercase() {
'K' => 1000,
'M' => 1000 * 1000,
'G' => 1000 * 1000 * 1000,

View file

@ -69,7 +69,7 @@ impl Uniq {
};
let sliced = line.as_slice().slice(slice_start, slice_stop).into_string();
if self.ignore_case {
sliced.into_ascii_upper()
sliced.into_ascii_uppercase()
} else {
sliced
}

View file

@ -14,6 +14,7 @@
extern crate getopts;
extern crate libc;
use std::ascii::AsciiExt;
use std::str::from_utf8;
use std::io::{print, File, BufferedReader};
use std::io::fs::PathExtensions;