-
-
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 detection of errors #7119
base: main
Are you sure you want to change the base?
Conversation
GNU testsuite comparison:
|
535c98c
to
980b287
Compare
GNU testsuite comparison:
|
d21dbe6
to
8fae3c2
Compare
GNU testsuite comparison:
|
GNU testsuite comparison:
|
src/uu/expr/src/syntax_tree.rs
Outdated
parts[1].trim().parse::<u32>(), | ||
) { | ||
// Ensure both numbers are within valid range and first <= second | ||
first <= second && first <= 32767 && second <= 32767 |
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.
Not sure whether this is an improvement, but from a logical point of view the middle check is not necessary.
first <= second && first <= 32767 && second <= 32767 | |
first <= second && second <= 32767 |
@@ -197,6 +208,93 @@ const PRECEDENCE: &[&[(&str, BinOp)]] = &[ | |||
&[(":", BinOp::String(StringOp::Match))], | |||
]; | |||
|
|||
fn check_brace_content_and_matching(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.
I think this parser is not completely correct. It returns BraceContent::Invalid
for the following edge cases whereas they seem to work with GNU expr
:
$ expr ab : "\\{\\(\\}\\)"
$ expr ab : "\\(\\{\\)\\}"
$ cargo run -q expr ab : "\\{\\(\\}\\)"
expr: Invalid content of \{\}
$ cargo run -q expr ab : "\\(\\{\\)\\}"
expr: Invalid content of \{\}
But I think it's something for a future PR.
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.
Overall it looks good.
Fixes se5 in expr.pl
Fixes se6 in expr.pl
Should fix bre3, bre4, bre7 and bre8 in expr.pl and bre42, bre43, bre44, bre47 and bre48
Fixes bre50 in expr.pl
Fix bre49 in expr.pl
Should make bre33 pass in expr.pl
GNU testsuite comparison:
|
GNU testsuite comparison:
|
GNU testsuite comparison:
|
comments fixed |
Reduces the number of remaining issues in tests/expr/expr.pl