summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-10-04 21:54:06 -0600
committerKarl Williamson <khw@cpan.org>2020-10-12 09:45:47 -0600
commit01f72ca30b1f3af6817d4c6c6157af7bd14e46a2 (patch)
tree61a4a0752f9d25600e342391f5d70a624ad2d804 /regcomp.c
parentfb138e5e855d79e3ee5c76dba85bc993f729c00f (diff)
downloadperl-01f72ca30b1f3af6817d4c6c6157af7bd14e46a2.tar.gz
regcomp.c: regpiece: Move chunk of code for clarity
This changes an error branch to be goto'd out of the mainline code. The large chunk being in the middle obscured the comonality of the slightly different non-error cases. The branch is moved to the bottom of the routine, and croaks, so there is no return. This is a modification to a suggestion by Hugo van der Sanden.
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/regcomp.c b/regcomp.c
index b7218b0cb6..47e1e28b21 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -12775,22 +12775,8 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
goto done_main_op;
}
else if (min == 0) {
-
- /* Going from 0..inf is currently forbidden in wildcard
- * subpatterns. The only reason is to make it harder to
- * write patterns that take a long long time to halt, and
- * because the use of this construct isn't necessary in
- * matching Unicode property values */
- if (RExC_pm_flags & PMf_WILDCARD) {
- RExC_parse++;
- /* diag_listed_as: Use of %s is not allowed in Unicode
- property wildcard subpatterns in regex; marked by
- <-- HERE in m/%s/ */
- vFAIL("Use of quantifier '*' is not allowed in"
- " Unicode property wildcard subpatterns");
- /* Note, don't need to worry about {0,}, as a '}' isn't
- * legal at all in wildcards, so wouldn't get this far
- * */
+ if (UNLIKELY(RExC_pm_flags & PMf_WILDCARD)) {
+ goto min0_maxINF_wildcard_forbidden;
}
reginsert(pRExC_state, STAR, ret, depth+1);
@@ -12873,6 +12859,25 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
}
return(ret);
+
+ min0_maxINF_wildcard_forbidden:
+
+ /* Here we are in a wildcard match, and the minimum match length is 0, and
+ * the max could be infinity. This is currently forbidden. The only
+ * reason is to make it harder to write patterns that take a long long time
+ * to halt, and because the use of this construct isn't necessary in
+ * matching Unicode property values */
+ RExC_parse++;
+ /* diag_listed_as: Use of %s is not allowed in Unicode property wildcard
+ subpatterns in regex; marked by <-- HERE in m/%s/
+ */
+ vFAIL("Use of quantifier '*' is not allowed in Unicode property wildcard"
+ " subpatterns");
+
+ /* Note, don't need to worry about the input being '{0,}', as a '}' isn't
+ * legal at all in wildcards, so can't get this far */
+
+ NOT_REACHED; /*NOTREACHED*/
}
STATIC bool