1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 04:27:45 +00:00

Merge pull request #492 from ebfe/fix-build-master

base64, du, realpath: fix build
This commit is contained in:
Alex Lyon 2015-01-09 15:23:48 -08:00
commit 37ada52d0d
3 changed files with 26 additions and 28 deletions

View file

@ -95,28 +95,27 @@ pub fn uumain(args: Vec<String>) -> int {
}
fn decode(input: &mut Reader, ignore_garbage: bool) {
let to_decode = match input.read_to_string() {
let mut to_decode = match input.read_to_string() {
Ok(m) => m,
Err(f) => panic!(f)
};
let slice =
if ignore_garbage {
to_decode.as_slice()
.trim_chars(|&: c: char| {
if !c.is_ascii() {
return false;
};
!(c >= 'a' && c <= 'z' ||
c >= 'A' && c <= 'Z' ||
c >= '0' && c <= '9' ||
c == '+' || c == '/' )
})
} else {
to_decode.as_slice()
};
if ignore_garbage {
let mut clean = String::new();
clean.extend(to_decode.chars().filter(|&c| {
if !c.is_ascii() {
false
} else {
c >= 'a' && c <= 'z' ||
c >= 'A' && c <= 'Z' ||
c >= '0' && c <= '9' ||
c == '+' || c == '/'
}
}));
to_decode = clean;
}
match slice.from_base64() {
match to_decode.as_slice().from_base64() {
Ok(bytes) => {
let mut out = stdout();

View file

@ -20,7 +20,6 @@ use std::num::Float;
use std::option::Option;
use std::path::Path;
use std::sync::{Arc, Future};
use std::str::from_utf8;
use time::Timespec;
#[path = "../common/util.rs"]
@ -232,22 +231,22 @@ ers of 1000).",
Some(s) => {
let mut found_number = false;
let mut found_letter = false;
let mut numbers = vec!();
let mut letters = vec!();
let mut numbers = String::new();
let mut letters = String::new();
for c in s.as_slice().chars() {
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(10) {
found_number = true;
numbers.push(c as u8);
numbers.push(c);
} else if c.is_alphabetic() {
found_letter = true;
letters.push(c);
}
}
let number = from_utf8(numbers.as_slice()).ok().unwrap().parse::<uint>().unwrap();
let multiple = match String::from_chars(letters.as_slice()).as_slice() {
let number = numbers.parse::<uint>().unwrap();
let multiple = match letters.as_slice() {
"K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024,
"T" => 1024 * 1024 * 1024 * 1024, "P" => 1024 * 1024 * 1024 * 1024 * 1024,
"E" => 1024 * 1024 * 1024 * 1024 * 1024 * 1024,
@ -268,7 +267,7 @@ ers of 1000).",
None => 1024
};
let convert_size = |size: u64| -> String {
let convert_size = |&: size: u64| -> String {
if matches.opt_present("human-readable") || matches.opt_present("si") {
if size >= MB {
format!("{:.1}M", (size as f64) / (MB as f64))

View file

@ -51,11 +51,11 @@ pub fn uumain(args: Vec<String>) -> int {
let zero = opts.opt_present("z");
let quiet = opts.opt_present("q");
let mut retcode = 0;
opts.free.iter().map(|x|
if !resolve_path(x.as_slice(), strip, zero, quiet) {
for path in opts.free.iter() {
if !resolve_path(path.as_slice(), strip, zero, quiet) {
retcode = 1
}
).last();
};
}
retcode
}