-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refuse to translate if set2 contains more than one unique characters and set1 contains a character class #6472
Refuse to translate if set2 contains more than one unique characters and set1 contains a character class #6472
Conversation
f570cdb
to
202f5b6
Compare
GNU testsuite comparison:
|
202f5b6
to
4c450c8
Compare
GNU testsuite comparison:
|
wahou, bravo :) |
@@ -1386,3 +1386,22 @@ fn check_set1_longer_set2_ends_in_class_with_trunc() { | |||
.args(&["-t", "[:lower:]a", "[:upper:]"]) | |||
.succeeds(); | |||
} | |||
|
|||
fn check_complement_2_unique_in_set2() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn check_complement_2_unique_in_set2() { | |
#[test] | |
fn check_complement_2_unique_in_set2() { |
@@ -262,6 +265,17 @@ impl Sequence { | |||
.flat_map(Self::flatten_all) | |||
.filter_map(to_u8) | |||
.collect(); | |||
let mut set2_uniques = set2_solved.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let mut set2_uniques = set2_solved.clone(); | |
// Ensure set2_solved contains unique elements only | |
let mut set2_uniques = set2_solved.clone(); |
set2_uniques.sort(); | ||
set2_uniques.dedup(); | ||
|
||
if set1.iter().any(|x| matches!(x, Self::Class(_))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if set1.iter().any(|x| matches!(x, Self::Class(_))) | |
// Validate the complement condition | |
if set1.iter().any(|x| matches!(x, Self::Class(_))) |
4c450c8
to
bd772bc
Compare
GNU testsuite comparison:
|
If complementing and translating with a character class, there can only be one unique character in set2.
The underlying issue, [y*] not being expanded to "" was fixed "accidentally" in a previous restructuring of tr. I have simply added the error check here.