tr: A [:lower:]/[:upper:] in set2 must be matched in set1 #6445
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.
If there is a [:lower:] or [:upper:] in set2, then there must be a [:lower:] or [:upper:] at the same logical position in set1
So
To accomplish this change I have done the following things:
flatten error checks (take early exits from
solve_set_characters
instead of nestingif
s)simplify CharStar (
[c*]
) handling code by simply replacing CharStar with a CharRepeat of appropriate lengthswitch flatten() from
Sequence -> u8
toSequence -> Char
The main idea here is that to correctly implement the tr behaviour, one has to flatten everything but [:upper:]/[:lower:] into the underlying string of chars and then check if the character class in the one set is at the same position in the other set:
This apparent behavior is supported by these two GNU tr invocations: