1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

expr: Simplify checking of the end of an expression

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
This commit is contained in:
Teemu Pätsi 2025-05-24 21:15:53 +03:00 committed by GitHub
parent 63ce37cf6e
commit 2a862bc385
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -244,13 +244,7 @@ where
{
let mut pattern_chars_clone = pattern_chars.clone();
match pattern_chars_clone.next() {
Some('\\') => {
match pattern_chars_clone.next() {
Some(')') // End of a capturing group
| Some('|') => true, // End of an alternative pattern
_ => false,
}
}
Some('\\') => matches!(pattern_chars_clone.next(), Some(')' | '|')),
None => true, // No characters left
_ => false,
}