join: operate on bytes instead of Strings #2851
Merged
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:
-z
option is added (an easy change once this is merged) -- something that can't be safely done with Rust String operations-i
flag 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.