summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-04-24 11:56:39 -0600
committerKarl Williamson <khw@cpan.org>2020-10-12 09:45:47 -0600
commitdd2cafb96f113a74d005d5cbdb410971a0588fb2 (patch)
tree45364e314873fc839f447776f8df74834a163470 /regcomp.c
parentf21ef9aab6235ccc523cb726f29ba21a28883bcb (diff)
downloadperl-dd2cafb96f113a74d005d5cbdb410971a0588fb2.tar.gz
regcomp.c: regpiece(): Refactor two 'if's
I think this makes it clearer the commonalities of the * and + quantifiers.
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/regcomp.c b/regcomp.c
index dc5a9764fd..d98342848c 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -12756,32 +12756,35 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
}
if ((flags&SIMPLE)) {
- if (min == 0 && max == REG_INFTY) {
+ if (max == REG_INFTY) {
+ if (min == 1) {
+ reginsert(pRExC_state, PLUS, ret, depth+1);
+ MARK_NAUGHTY(3);
+ 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
+ * */
+ }
- /* 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
- * */
+ reginsert(pRExC_state, STAR, ret, depth+1);
+ MARK_NAUGHTY(4);
+ goto done_main_op;
}
- reginsert(pRExC_state, STAR, ret, depth+1);
- MARK_NAUGHTY(4);
- goto done_main_op;
- }
- if (min == 1 && max == REG_INFTY) {
- reginsert(pRExC_state, PLUS, ret, depth+1);
- MARK_NAUGHTY(3);
- goto done_main_op;
}
MARK_NAUGHTY_EXP(2, 2);
reginsert(pRExC_state, CURLY, ret, depth+1);