Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1055 +/- ##
==========================================
+ Coverage 92.29% 92.32% +0.02%
==========================================
Files 38 38
Lines 8714 8717 +3
Branches 429 431 +2
==========================================
+ Hits 8043 8048 +5
+ Misses 532 530 -2
Partials 139 139 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will not alter performance1 warning
Comparing |
| // clear SINGLELINE (so negated brackets also match newline). | ||
| if regex_type == RegexType::Grep { | ||
| options.insert(RegexOptions::REGEX_OPTION_MULTILINE); | ||
| options.insert(RegexOptions::REGEX_OPTION_NEGATE_SINGLELINE); |
There was a problem hiding this comment.
are you sure this makes [^...] match a newline?
i think grep syntax excludes it through a syntax flag, not SINGLELINE
please add a test with a negated bracket, like .*/new[^a]line\.php
| }; | ||
| // Match GNU's "grep" regex type: let '.' match newline and clear | ||
| // SINGLELINE so negated brackets match newline too. | ||
| if ty == RegexType::Grep { |
There was a problem hiding this comment.
please add a locate test too (tests/db_tests.rs)
| }, | ||
| syntax, | ||
| ) | ||
| let mut options = if config.ignore_case { |
There was a problem hiding this comment.
this is now the same code as in RegexMatcher::new, could be dedup, no?
4b712c8 to
3153f18
Compare
|
Thanks for the review. Addressed the comments:
|
|
Commit fb3980f has test result changes: bfs testsuite: |
|
CI note: the failing |
Oniguruma's grep syntax is line-oriented by default, so with -regextype grep, '.' and negated brackets never match a newline in a path. GNU's grep type does. Enable REGEX_OPTION_MULTILINE (dot matches newline) and REGEX_OPTION_NEGATE_SINGLELINE (negated brackets match newline) for the Grep type in both find -regex and locate --regex. Adds an integration test with a filename containing a newline. Fixes uutils#1046
The previous fix enabled MULTILINE and NEGATE_SINGLELINE but kept onig's line-oriented grep syntax, under which negated brackets still do not match a newline. Use GNU regex syntax for RegexType::Grep in both find and locate so '.' and '[^...]' match newlines as GNU find does. Also import Mode/ExistenceMode in the locate test module and keep rustfmt clean. All tests pass locally (294 lib + integration suites). Fixes uutils#1046
Switching to gnu_regex syntax fixed newline matching but broke the GNU BFS regextype_grep suite by changing grep's other regex semantics. Instead, clone onig's grep syntax and disable only SYNTAX_BEHAVIOR_NOT_NEWLINE_IN_NEGATIVE_CC, which is the single behavior that excluded newlines from [^...]. All local tests pass (294 lib tests + integration suites), and rustfmt/clippy are clean.
73be2a8 to
cbe2ef1
Compare
Fixes #1046.
Oniguruma's grep syntax is line-oriented by default, so with -regextype grep, '.' and negated brackets never match a newline in a path. GNU's grep type does.
Enables REGEX_OPTION_MULTILINE (dot matches newline) and REGEX_OPTION_NEGATE_SINGLELINE (negated brackets match newline) for the Grep type in both find -regex and locate --regex. Adds an integration test with a newline-containing filename.
Note: cargo is unavailable locally, so build/tests could not be run here.