join: operate on bytes instead of Strings#2851
Merged
sylvestre merged 3 commits intouutils:masterfrom Jan 16, 2022
Merged
Conversation
Contributor
|
Would you please add tests for this? |
Contributor
Author
|
My original thinking was that this was supposed to be an internal change, but it does fix a few bugs, so I was able to add two tests after all. The binary files in the latter are formatted such that they can be reused for testing |
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.
This PR switches join from operating on Strings to operating on bytes.
This more closely matches the GNU behavior, but comes at some cost. The high level points are:
-zoption is added (an easy change once this is merged) -- something that can't be safely done with Rust String operations-iflag no longer functions for non-ASCII letters\r\n) are now treated as two separate characters (again, matching GNU's join behavior)If the coreutils were designed today, there might have been different choices made, but if the goal is a drop-in replacement for GNU, this change is necessary.
Note that this does not get the 8-bit-t test to actually pass, as that's blocked on upgrading to clap 3.0 for the
allow_invalid_utf8()method. It does incidentally fix sp-vs-blank, since we're now explicitly splitting on certain values, rather than relying on Rust's default whitespace detection. Related: #2634Part of switching from Strings to Vec is replacing calls to
print!(...)/println!(...)tostdout().write_all(...), which involves more explicit error handling, so that's where a lot of the diff comes from.