Skip to content

Conversation

cvonelm
Copy link
Contributor

@cvonelm cvonelm commented Jun 15, 2024

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.

@cvonelm cvonelm force-pushed the issue-6344-complement-error-if-2-uniques branch 2 times, most recently from f570cdb to 202f5b6 Compare June 15, 2024 12:31
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/tr/tr is no longer failing!

@cvonelm cvonelm force-pushed the issue-6344-complement-error-if-2-uniques branch from 202f5b6 to 4c450c8 Compare June 16, 2024 19:32
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/tr/tr is no longer failing!

@sylvestre
Copy link
Contributor

GNU testsuite comparison:

Congrats! The gnu test tests/tr/tr is no longer failing!

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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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(_)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if set1.iter().any(|x| matches!(x, Self::Class(_)))
// Validate the complement condition
if set1.iter().any(|x| matches!(x, Self::Class(_)))

@cvonelm cvonelm force-pushed the issue-6344-complement-error-if-2-uniques branch from 4c450c8 to bd772bc Compare June 21, 2024 12:49
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/tr/tr is no longer failing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants