-
-
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
expr: improve the GNU compat #7167
Conversation
GNU testsuite comparison:
|
#[derive(Debug, PartialEq)] | ||
enum BraceContent { | ||
Valid, | ||
Invalid, | ||
Unmatched(BraceType), | ||
RegexTooBig, | ||
} |
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.
Somehow I don't understand the purpose of this enum. With the exception of Valid
, its variants are already defined as variants in ExprError
.
match check_posix_regex_errors(&re_string) { | ||
BraceContent::Invalid => match is_valid_curly_content(&re_string) { | ||
Err(ExprError::InvalidBraceContent) => { | ||
return Err(ExprError::InvalidBraceContent) | ||
} | ||
Ok(()) => unreachable!(), | ||
Err(err) => return Err(err), | ||
}, | ||
BraceContent::Unmatched(brace) => return Err(ExprError::UnmatchedBrace(brace)), | ||
BraceContent::Valid => {} | ||
BraceContent::RegexTooBig => return Err(ExprError::RegexTooBig), | ||
} |
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.
It's related to my previous comment about BraceContent
: I think the creation of the errors could be done in check_posix_regex_errors
, thus not needing BraceContent
.
@@ -716,21 +739,6 @@ mod test { | |||
assert_eq!(result.eval_as_string(), ""); | |||
} | |||
|
|||
#[test] | |||
fn starting_stars_become_escaped() { |
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.
Is this functionality removed with this PR?
("", None) => { | ||
// Empty repeating pattern | ||
invalid_content_error = true; | ||
fn check_posix_regex_errors(s: &str) -> BraceContent { |
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.
Did you mean to remove the doc? I wanted to be explicit about the reason why this is needed (vs seeing what errors we get from Oniguruma)
@@ -700,10 +727,6 @@ mod test { | |||
AstNode::parse(&["(", "42"]), | |||
Err(ExprError::ExpectedClosingBraceAfter("42".to_string())) | |||
); | |||
assert_eq!( |
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.
Why was this removed?
@sargas wdyt ?