mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +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())?;
|
||||
|
||||
if options.raw {
|
||||
match decode(sum.clone()) {
|
||||
Ok(bytes) => {
|
||||
stdout().write_all(&bytes)?;
|
||||
}
|
||||
Err(_) => {
|
||||
//bsd, sysv and crc have output generated without encode()
|
||||
match options.algo_name {
|
||||
ALGORITHM_OPTIONS_CRC
|
||||
| ALGORITHM_OPTIONS_SYSV
|
||||
| ALGORITHM_OPTIONS_BSD => {
|
||||
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)?;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
// 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