mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
cksum: fixed cksum --raw --algorithm
This commit is contained in:
parent
96271ffa3c
commit
c7b15ddce9
2 changed files with 18 additions and 7 deletions
|
@ -176,16 +176,27 @@ where
|
||||||
.map_err_context(|| "failed to read input".to_string())?;
|
.map_err_context(|| "failed to read input".to_string())?;
|
||||||
|
|
||||||
if options.raw {
|
if options.raw {
|
||||||
match decode(sum.clone()) {
|
match options.algo_name {
|
||||||
Ok(bytes) => {
|
ALGORITHM_OPTIONS_CRC
|
||||||
stdout().write_all(&bytes)?;
|
| ALGORITHM_OPTIONS_SYSV
|
||||||
}
|
| ALGORITHM_OPTIONS_BSD => {
|
||||||
Err(_) => {
|
|
||||||
//bsd, sysv and crc have output generated without encode()
|
|
||||||
let bytes = sum.parse::<u32>().unwrap().to_be_bytes();
|
let bytes = sum.parse::<u32>().unwrap().to_be_bytes();
|
||||||
|
let mut first_nonzero = 0;
|
||||||
|
for byte in bytes {
|
||||||
|
if byte != 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
first_nonzero += 1;
|
||||||
|
}
|
||||||
|
stdout().write_all(&bytes[first_nonzero..])?;
|
||||||
|
}
|
||||||
|
_ =>{
|
||||||
|
let bytes = decode(sum).unwrap();
|
||||||
stdout().write_all(&bytes)?;
|
stdout().write_all(&bytes)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
// The BSD checksum output is 5 digit integer
|
// The BSD checksum output is 5 digit integer
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>`<60>x<EFBFBD><0B>f<><1E>W<EFBFBD><57><EFBFBD>Et<45>B<><42>l<EFBFBD><6C>W^J<>0<EFBFBD>aX´<08><>8<EFBFBD><38><EFBFBD><EFBFBD><EFBFBD>5<15>B<EFBFBD><42>9m<11><>
|
— ‘‰å`Ãxœÿf†øWÑûþEtÞBãÀl«¹W^Jö0šaX´ÓÀ8Á´<C381>‚‹5<15>BÍÀ9m•Ã
|
Loading…
Add table
Add a link
Reference in a new issue