Repository navigation
Conversation
conv=unblock trimmed each read buffer on its own, as if it began on a record boundary, so a read ending inside a record split it into two lines and shifted every later record in that read. Keep the record length and the trailing spaces not yet written in Converter across reads, and end a final incomplete record in finish. Fixes uutils#15818
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #15818
conv=unblocktrimmed each read buffer as if it started on a record boundary. When a read ended inside a record, the rest of that record was written as a second line, and every later record in the buffer was shifted. Withcbs=80and the default 512-byte block size (512 is not a multiple of 80), ten 80-byte records came out asREC0toREC6, thenREC7,REC8andREC9each preceded by 48 spaces, then a stray empty line. Short reads from a pipe did the same.Converteralready keeps the record length across reads forconv=block. It now does the same forconv=unblock: it keeps the position in the current record and the trailing spaces not yet written, drops them only when the record is complete, andfinishends a last incomplete record with a newline. The pending spaces are written in pieces ofPAD_CHUNK, so a hugecbsstill does not allocatecbsbytes. The order of conversion for the three unblock modes is unchanged.I added two unit tests in
blocks.rs(a record and its trailing spaces split over several reads, andcbs=usize::MAX) and two tests intest_dd.rs(the default block size from the issue, andibs=3 obs=3including aconv=asciicase). The new tests fail on current main and pass with this change.cargo fmt,cargo clippy -p uu_dd --all-targets -- -D warnings,cargo test -p uu_ddandcargo test --test tests test_ddpass. Tested on macOS only.