mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 21:47:46 +00:00
hashsum: fix build
This commit is contained in:
parent
2d488bf2b2
commit
c62bacb9fa
1 changed files with 16 additions and 16 deletions
|
@ -63,12 +63,12 @@ fn detect_algo(program: &str, matches: &getopts::Matches) -> (&'static str, Box<
|
||||||
let mut alg: Option<Box<Digest>> = None;
|
let mut alg: Option<Box<Digest>> = None;
|
||||||
let mut name: &'static str = "";
|
let mut name: &'static str = "";
|
||||||
match program {
|
match program {
|
||||||
"md5sum" => ("MD5", box Md5::new() as Box<Digest>),
|
"md5sum" => ("MD5", Box::new(Md5::new()) as Box<Digest>),
|
||||||
"sha1sum" => ("SHA1", box Sha1::new() as Box<Digest>),
|
"sha1sum" => ("SHA1", Box::new(Sha1::new()) as Box<Digest>),
|
||||||
"sha224sum" => ("SHA224", box Sha224::new() as Box<Digest>),
|
"sha224sum" => ("SHA224", Box::new(Sha224::new()) as Box<Digest>),
|
||||||
"sha256sum" => ("SHA256", box Sha256::new() as Box<Digest>),
|
"sha256sum" => ("SHA256", Box::new(Sha256::new()) as Box<Digest>),
|
||||||
"sha384sum" => ("SHA384", box Sha384::new() as Box<Digest>),
|
"sha384sum" => ("SHA384", Box::new(Sha384::new()) as Box<Digest>),
|
||||||
"sha512sum" => ("SHA512", box Sha512::new() as Box<Digest>),
|
"sha512sum" => ("SHA512", Box::new(Sha512::new()) as Box<Digest>),
|
||||||
_ => {
|
_ => {
|
||||||
{
|
{
|
||||||
let mut set_or_crash = |&mut: n, val| -> () {
|
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;
|
name = n;
|
||||||
alg = Some(val);
|
alg = Some(val);
|
||||||
};
|
};
|
||||||
if matches.opt_present("md5") { set_or_crash("MD5", box Md5::new()) };
|
if matches.opt_present("md5") { set_or_crash("MD5", Box::new(Md5::new())) };
|
||||||
if matches.opt_present("sha1") { set_or_crash("SHA1", box Sha1::new()) };
|
if matches.opt_present("sha1") { set_or_crash("SHA1", Box::new(Sha1::new())) };
|
||||||
if matches.opt_present("sha224") { set_or_crash("SHA224", box Sha224::new()) };
|
if matches.opt_present("sha224") { set_or_crash("SHA224", Box::new(Sha224::new())) };
|
||||||
if matches.opt_present("sha256") { set_or_crash("SHA256", box Sha256::new()) };
|
if matches.opt_present("sha256") { set_or_crash("SHA256", Box::new(Sha256::new())) };
|
||||||
if matches.opt_present("sha384") { set_or_crash("SHA384", box Sha384::new()) };
|
if matches.opt_present("sha384") { set_or_crash("SHA384", Box::new(Sha384::new())) };
|
||||||
if matches.opt_present("sha512") { set_or_crash("SHA512", box Sha512::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!") };
|
if alg.is_none() { crash!(1, "You must specify hash algorithm!") };
|
||||||
(name, alg.unwrap())
|
(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 program = args[0].clone();
|
||||||
let binary = Path::new(program.as_slice());
|
let binary = Path::new(program.as_slice());
|
||||||
let binary_name = binary.filename_str().unwrap();
|
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));
|
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> {
|
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 = 0u;
|
let mut bad_format = 0;
|
||||||
let mut failed = 0u;
|
let mut failed = 0;
|
||||||
let binary_marker = if binary {
|
let binary_marker = if binary {
|
||||||
"*"
|
"*"
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue