1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 20:47:46 +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) { 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, Ok(m) => m,
Err(f) => panic!(f) Err(f) => panic!(f)
}; };
let slice = if ignore_garbage {
if ignore_garbage { let mut clean = String::new();
to_decode.as_slice() clean.extend(to_decode.chars().filter(|&c| {
.trim_chars(|&: c: char| { if !c.is_ascii() {
if !c.is_ascii() { false
return false; } else {
}; c >= 'a' && c <= 'z' ||
!(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' ||
c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' ||
c >= '0' && c <= '9' || c == '+' || c == '/'
c == '+' || c == '/' ) }
}) }));
} else { to_decode = clean;
to_decode.as_slice() }
};
match slice.from_base64() { match to_decode.as_slice().from_base64() {
Ok(bytes) => { Ok(bytes) => {
let mut out = stdout(); let mut out = stdout();

View file

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