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

expr: Simplify parsing special cases for $ in regex

This commit is contained in:
Teemu Pätsi 2025-05-24 21:17:20 +03:00
parent 2a862bc385
commit ab5cf74185
No known key found for this signature in database

View file

@ -185,14 +185,8 @@ impl StringOp {
| ('\\', false) => re_string.push(curr), | ('\\', false) => re_string.push(curr),
_ => re_string.push_str(r"\^"), _ => re_string.push_str(r"\^"),
}, },
'$' => { '$' if !curr_is_escaped && !is_end_of_expression(&pattern_chars) => {
if is_end_of_expression(&pattern_chars) { re_string.push_str(r"\$");
re_string.push(curr);
} else if !curr_is_escaped {
re_string.push_str(r"\$");
} else {
re_string.push(curr);
}
} }
'\\' if !curr_is_escaped && pattern_chars.peek().is_none() => { '\\' if !curr_is_escaped && pattern_chars.peek().is_none() => {
return Err(ExprError::TrailingBackslash); return Err(ExprError::TrailingBackslash);