1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 05:27:45 +00:00

hashsum: fix build

This commit is contained in:
Michael Gehring 2015-01-10 13:18:15 +01:00
parent 2d488bf2b2
commit c62bacb9fa

View file

@ -63,12 +63,12 @@ fn detect_algo(program: &str, matches: &getopts::Matches) -> (&'static str, Box<
let mut alg: Option<Box<Digest>> = None;
let mut name: &'static str = "";
match program {
"md5sum" => ("MD5", box Md5::new() as Box<Digest>),
"sha1sum" => ("SHA1", box Sha1::new() as Box<Digest>),
"sha224sum" => ("SHA224", box Sha224::new() as Box<Digest>),
"sha256sum" => ("SHA256", box Sha256::new() as Box<Digest>),
"sha384sum" => ("SHA384", box Sha384::new() as Box<Digest>),
"sha512sum" => ("SHA512", box Sha512::new() as Box<Digest>),
"md5sum" => ("MD5", Box::new(Md5::new()) as Box<Digest>),
"sha1sum" => ("SHA1", Box::new(Sha1::new()) as Box<Digest>),
"sha224sum" => ("SHA224", Box::new(Sha224::new()) as Box<Digest>),
"sha256sum" => ("SHA256", Box::new(Sha256::new()) as Box<Digest>),
"sha384sum" => ("SHA384", Box::new(Sha384::new()) as Box<Digest>),
"sha512sum" => ("SHA512", Box::new(Sha512::new()) as Box<Digest>),
_ => {
{
let mut set_or_crash = |&mut: n, val| -> () {
@ -76,12 +76,12 @@ fn detect_algo(program: &str, matches: &getopts::Matches) -> (&'static str, Box<
name = n;
alg = Some(val);
};
if matches.opt_present("md5") { set_or_crash("MD5", box Md5::new()) };
if matches.opt_present("sha1") { set_or_crash("SHA1", box Sha1::new()) };
if matches.opt_present("sha224") { set_or_crash("SHA224", box Sha224::new()) };
if matches.opt_present("sha256") { set_or_crash("SHA256", box Sha256::new()) };
if matches.opt_present("sha384") { set_or_crash("SHA384", box Sha384::new()) };
if matches.opt_present("sha512") { set_or_crash("SHA512", box Sha512::new()) };
if matches.opt_present("md5") { set_or_crash("MD5", Box::new(Md5::new())) };
if matches.opt_present("sha1") { set_or_crash("SHA1", Box::new(Sha1::new())) };
if matches.opt_present("sha224") { set_or_crash("SHA224", Box::new(Sha224::new())) };
if matches.opt_present("sha256") { set_or_crash("SHA256", Box::new(Sha256::new())) };
if matches.opt_present("sha384") { set_or_crash("SHA384", Box::new(Sha384::new())) };
if matches.opt_present("sha512") { set_or_crash("SHA512", Box::new(Sha512::new())) };
}
if alg.is_none() { crash!(1, "You must specify hash algorithm!") };
(name, alg.unwrap())
@ -89,7 +89,7 @@ fn detect_algo(program: &str, matches: &getopts::Matches) -> (&'static str, Box<
}
}
pub fn uumain(args: Vec<String>) -> int {
pub fn uumain(args: Vec<String>) -> isize {
let program = args[0].clone();
let binary = Path::new(program.as_slice());
let binary_name = binary.filename_str().unwrap();
@ -167,9 +167,9 @@ fn usage(program: &str, binary_name: &str, opts: &[getopts::OptGroup]) {
pipe_print!("{}", getopts::usage("Compute and check message digests.", opts));
}
fn hashsum(algoname: &str, mut digest: Box<Digest>, files: Vec<String>, binary: bool, check: bool, tag: bool, status: bool, quiet: bool, strict: bool, warn: bool) -> Result<(), int> {
let mut bad_format = 0u;
let mut failed = 0u;
fn hashsum(algoname: &str, mut digest: Box<Digest>, files: Vec<String>, binary: bool, check: bool, tag: bool, status: bool, quiet: bool, strict: bool, warn: bool) -> Result<(), isize> {
let mut bad_format = 0;
let mut failed = 0;
let binary_marker = if binary {
"*"
} else {