Repository navigation
Conversation
|
|
||
| #[test] | ||
| #[cfg(unix)] | ||
| fn test_byte_count_redirected_file_position() { |
There was a problem hiding this comment.
This is a performance issue instead of a bug. So test is not needed.
f5ebe5b to
6370450
Compare
| // another process sharing stdin sees EOF. | ||
| if (stat.st_mode as libc::mode_t & libc::S_IFREG) != 0 | ||
| && stat.st_size > 0 | ||
| && let Ok(position) = rustix::fs::seek(&handle, SeekFrom::Current(0)) |
There was a problem hiding this comment.
this now changes the result of ( head -c1; wc -c ) < file, not only the speed.
could you please keep one test for the partial offset case? the old code had a full comment just to protect it
|
The description mentions regression tests, but the diff no longer has any. Please add back at least the partial offset one. Thanks |
|
|
||
| if let Ok(n) = file.seek(SeekFrom::Start(offset as u64)) { | ||
| byte_count = n as usize; | ||
| let block_size = stat.st_blksize as u64; |
There was a problem hiding this comment.
the comment explaining why this allow is needed was removed, please keep a short version
6370450 to
3a352d5
Compare
| .set_stdin(shared) | ||
| .succeeds() | ||
| .stdout_only("5\n"); | ||
| assert_eq!(input.stream_position().unwrap(), 6); |
There was a problem hiding this comment.
could you please also add a test for wc -c - - with a file as stdin? it should print the size then 0
the description still mentions it, along with the EOF and page-aligned tests
3a352d5 to
06643d6
Compare
| @@ -19,7 +19,6 @@ use std::os::fd::{AsFd, AsRawFd}; | |||
| pub trait WordCountable: AsFd + AsRawFd + Read { | |||
There was a problem hiding this comment.
as_raw_fd() isn't called anymore, could AsRawFd be dropped from the bound?
06643d6 to
ebcfbb5
Compare
|
Binary size comparison: |
| #[rstest::rstest] | ||
| #[case::partial(6, 1)] | ||
| #[case::at_eof(6, 6)] | ||
| #[case::page_aligned(4096, 0)] |
There was a problem hiding this comment.
could you please add a page_aligned case with a non zero offset too? nothing covers the .max(position) part
ebcfbb5 to
e0e5080
Compare
Use the current file offset and metadata for byte counts on regular input, advancing stdin to the counted end. Retain final-block probing for pseudo-files and preserve counted bytes when splice falls back. Closes uutils#11610.
e0e5080 to
831e1f4
Compare
Use the current file offset and metadata for byte counts on regular input, advancing stdin to the counted end. Retain final-block probing for pseudo-files and preserve counted bytes when splice falls back.
Regression coverage includes partial offsets, repeated '-' operands, EOF, and page-aligned files. All 60 wc integration tests pass.
Closes #11610.