-
Notifications
You must be signed in to change notification settings - Fork 242
Improve coverage of escapes in character classes #591
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -541,38 +541,46 @@ For hard partial matching, we immediately return a partial match. Otherwise, | |
| carrying on means that a complete match on the current subject will be sought. | ||
| A partial match is returned only if no complete match can be found. */ | ||
|
|
||
| #define CHECK_PARTIAL()\ | ||
| if (Feptr >= mb->end_subject) \ | ||
| { \ | ||
| SCHECK_PARTIAL(); \ | ||
| } | ||
|
|
||
| #define SCHECK_PARTIAL()\ | ||
| if (mb->partial != 0 && \ | ||
| (Feptr > mb->start_used_ptr || mb->allowemptypartial)) \ | ||
| { \ | ||
| mb->hitend = TRUE; \ | ||
| if (mb->partial > 1) return PCRE2_ERROR_PARTIAL; \ | ||
| } | ||
| #define CHECK_PARTIAL() \ | ||
| do { \ | ||
| if (Feptr >= mb->end_subject) \ | ||
| { \ | ||
| SCHECK_PARTIAL(); \ | ||
| } \ | ||
| } \ | ||
| while (0) | ||
|
|
||
| #define SCHECK_PARTIAL() \ | ||
| do { \ | ||
| if (mb->partial != 0 && \ | ||
| (Feptr > mb->start_used_ptr || mb->allowemptypartial)) \ | ||
| { \ | ||
| mb->hitend = TRUE; \ | ||
| if (mb->partial > 1) return PCRE2_ERROR_PARTIAL; \ | ||
| } \ | ||
| } \ | ||
| while (0) | ||
|
|
||
|
|
||
| /* These macros are used to implement backtracking. They simulate a recursive | ||
| call to the match() function by means of a local vector of frames which | ||
| remember the backtracking points. */ | ||
|
|
||
| #define RMATCH(ra,rb)\ | ||
| {\ | ||
| start_ecode = ra;\ | ||
| Freturn_id = rb;\ | ||
| goto MATCH_RECURSE;\ | ||
| L_##rb:;\ | ||
| } | ||
|
|
||
| #define RRETURN(ra)\ | ||
| {\ | ||
| rrc = ra;\ | ||
| goto RETURN_SWITCH;\ | ||
| } | ||
| #define RMATCH(ra,rb) \ | ||
| do { \ | ||
| start_ecode = ra; \ | ||
| Freturn_id = rb; \ | ||
| goto MATCH_RECURSE; \ | ||
| L_##rb:; \ | ||
| } \ | ||
| while (0) | ||
|
Comment on lines
+569
to
+576
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the calling code for the macros like The existing code was creating a block, not an expression, so the trailing semicolon was treated as a (harmless) empty statement. However, it was polluting the coverage statistics with unreached code lines, because those statements were never reached. Using a |
||
|
|
||
| #define RRETURN(ra) \ | ||
| do { \ | ||
| rrc = ra; \ | ||
| goto RETURN_SWITCH; \ | ||
| } \ | ||
| while (0) | ||
|
|
||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,4 +13,6 @@ | |
| /(?<=ab\Cde)X/ | ||
| abZdeX | ||
|
|
||
| /[\C]/ | ||
|
|
||
| # End of testinput21 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,4 +4,6 @@ | |
|
|
||
| /a\Cb/ | ||
|
|
||
| /a[\C]b/ | ||
|
|
||
| # End of testinput23 | ||
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 allowed or not possible?
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 possible (as far as I can tell). I have gone through
check_escape()and made a list of every ESC_ code it can return (when passedinclass=TRUE), and added a case statement and a test for all of those. There should be no other escapes allowed, so I added a catch-all default which only triggers in Debug builds.