mirror of
https://github.com/uutils/coreutils
synced 2024-11-16 17:58:06 +00:00
commit
196254be3b
2 changed files with 4 additions and 4 deletions
|
@ -32,7 +32,7 @@ fn bsd_sum(mut reader: Box<Read>) -> (usize, u16) {
|
|||
blocks_read += 1;
|
||||
for &byte in buf[..n].iter() {
|
||||
checksum = (checksum >> 1) + ((checksum & 1) << 15);
|
||||
checksum += byte as u16;
|
||||
checksum = checksum.wrapping_add(byte as u16);
|
||||
}
|
||||
},
|
||||
_ => break,
|
||||
|
@ -45,14 +45,14 @@ fn bsd_sum(mut reader: Box<Read>) -> (usize, u16) {
|
|||
fn sysv_sum(mut reader: Box<Read>) -> (usize, u16) {
|
||||
let mut buf = [0; 512];
|
||||
let mut blocks_read = 0;
|
||||
let mut ret = 0;
|
||||
let mut ret = 0u32;
|
||||
|
||||
loop {
|
||||
match reader.read(&mut buf) {
|
||||
Ok(n) if n != 0 => {
|
||||
blocks_read += 1;
|
||||
for &byte in buf[..n].iter() {
|
||||
ret += byte as u32;
|
||||
ret = ret.wrapping_add(byte as u32);
|
||||
}
|
||||
},
|
||||
_ => break,
|
||||
|
|
|
@ -65,7 +65,7 @@ fn test_sysv_multiple_files() {
|
|||
fn test_sysv_stdin() {
|
||||
let (at, mut ucmd) = testing(UTIL_NAME);
|
||||
let input = at.read("lorem_ipsum.txt");
|
||||
let result = ucmd.run_piped_stdin(input);
|
||||
let result = ucmd.arg("-s").run_piped_stdin(input);
|
||||
|
||||
assert_empty_stderr!(result);
|
||||
assert!(result.success);
|
||||
|
|
Loading…
Reference in a new issue