diff options
author | Karl Williamson <khw@cpan.org> | 2020-04-24 11:56:39 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2020-10-12 09:45:47 -0600 |
commit | dd2cafb96f113a74d005d5cbdb410971a0588fb2 (patch) | |
tree | 45364e314873fc839f447776f8df74834a163470 /regcomp.c | |
parent | f21ef9aab6235ccc523cb726f29ba21a28883bcb (diff) | |
download | perl-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.c | 51 |
1 files changed, 27 insertions, 24 deletions
@@ -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); |