mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
cksum: fixed cksum --raw --algorithm
This commit is contained in:
@@ -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
@@ -1 +1 @@
|
||||
�����`�x��f��W���Et�B��l��W^J�0�aX´��8�����5�B��9m��
|
||||
— ‘‰å`Ãxœÿf†øWÑûþEtÞBãÀl«¹W^Jö0šaX´ÓÀ8Á´�‚‹5�BÍÀ9m•Ã
|
||||
Reference in New Issue
Block a user