Skip to content

Conversation

cvonelm
Copy link
Contributor

@cvonelm cvonelm commented Jun 30, 2024

tr detects if a class in set2 is matched by a class at the correct position in set1 after it has expanded everything before the class:

So

tr 'abcd[:upper:]' 'a-d[:lower:]'

should not fail

Fixes #6445

tr detects if a class in set2 is matched by a class at the correct position in set1 after it has expanded everything before the class in both sets:

So

tr 'abcd[:upper:]' 'a-d[:lower:]'

should not fail
Copy link

GNU testsuite comparison:

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

@sylvestre
Copy link
Contributor

GNU testsuite comparison:

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

Sweet!

Self::Char(c) => Box::new(std::iter::once(*c)),
Self::CharRange(l, r) => Box::new(*l..=*r),
Self::CharStar(c) => Box::new(std::iter::repeat(*c)),
Self::CharRepeat(c, n) => Box::new(std::iter::repeat(*c).take(*n)),
Self::Class(class) => match class {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could do
Box::new(match class

to avoid the Box::new duplication, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The arms of the match all return slightly different types of iterators over Sequence, so unless there is Rust trick I am missing, we have to Box them right there to stop Rust from complaining about the match arms having icompatible types.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, sorry, my bad :)

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