-
Notifications
You must be signed in to change notification settings - Fork 842
prefetch: use Regex instead of pcre #12576
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
base: master
Are you sure you want to change the base?
Conversation
This is part of the effort to remove pcre dependency.
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.
The migration looks good overall, but there's a functional regression: the original code used PCRE_NOTEMPTY flag in all three pcre_exec() calls, but the new code doesn't pass RE_NOTEMPTY to Regex::exec().
Issue: PCRE_NOTEMPTY prevents matching empty strings, which is important for patterns like .* that could otherwise match at the beginning of an empty string.
Required changes:
- Line 185 in
match():
return _regex.exec(subject, RE_NOTEMPTY);- Line 203 in
capture():
int matchCount = _regex.exec(subject, matches, RE_NOTEMPTY);- Line 234 in
replace():
int matchCount = _regex.exec(subject, matches, RE_NOTEMPTY);This maintains the original PCRE behavior and prevents subtle matching bugs.
- add missing flag to exec()
|
Added the flag back to |
|
[approve ci autest] |
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.
Looks good. Just an observation on logging.
| if (!_re) { | ||
| return false; | ||
| } | ||
|
|
||
| matchCount = pcre_exec(_re, _extra, subject.c_str(), subject.length(), 0, PCRE_NOTEMPTY, nullptr, 0); | ||
| if (matchCount < 0) { | ||
| if (matchCount != PCRE_ERROR_NOMATCH) { | ||
| PrefetchError("matching error %d", matchCount); | ||
| } | ||
| if (_regex.empty()) { | ||
| return false; | ||
| } | ||
|
|
||
| return true; |
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.
There's a few of these PrefetchError's that are lost in the shuffle. I think we should be able to preserve these using a different Regex interface.
Removed redundant REErrorC enum definition.
This is part of the effort to remove pcre dependency.