expr: improve the detection of errors #7119
Closed
sylvestre wants to merge 15 commits intouutils:mainfrom
sylvestre:expr_pl
Closed
expr: improve the detection of errors #7119sylvestre wants to merge 15 commits intouutils:mainfrom sylvestre:expr_pl
sylvestre wants to merge 15 commits intouutils:mainfrom
sylvestre:expr_pl
Conversation
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
cakebaker
reviewed
Jan 13, 2025
cakebaker
reviewed
Jan 13, 2025
cakebaker
reviewed
Jan 13, 2025
cakebaker
reviewed
Jan 13, 2025
cakebaker
reviewed
Jan 13, 2025
cakebaker
reviewed
Jan 13, 2025
cakebaker
reviewed
Jan 13, 2025
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 |
Contributor
There was a problem hiding this comment.
Not sure whether this is an improvement, but from a logical point of view the middle check is not necessary.
Suggested change
| first <= second && first <= 32767 && second <= 32767 | |
| first <= second && second <= 32767 |
cakebaker
reviewed
Jan 13, 2025
cakebaker
reviewed
Jan 13, 2025
| &[(":", BinOp::String(StringOp::Match))], | ||
| ]; | ||
|
|
||
| fn check_brace_content_and_matching(s: &str) -> BraceContent { |
Contributor
There was a problem hiding this comment.
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.
cakebaker
reviewed
Jan 13, 2025
Contributor
cakebaker
left a comment
There was a problem hiding this comment.
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: |
Contributor
Author
|
comments fixed |
Contributor
Author
|
moved here: #7119 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reduces the number of remaining issues in tests/expr/expr.pl