summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-07-31 16:54:50 -0600
committerKarl Williamson <khw@cpan.org>2015-01-21 22:47:29 -0700
commitc550a918cfa95bcc68772b5447402493b5730715 (patch)
treeae71bfd9b91823c44c56ac7c967bbc1f4cf3a236 /regcomp.c
parent551cedb5d968fde8fe046c53d838e2443711be06 (diff)
downloadperl-c550a918cfa95bcc68772b5447402493b5730715.tar.gz
regcomp.c: Collapse \b, \B cases
The code for these two case: statements was almost identical.
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/regcomp.c b/regcomp.c
index 9c1efc6d99..b0256b7b2d 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -11761,23 +11761,8 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
goto join_posix;
case 'B':
- RExC_seen_zerolen++;
- RExC_seen |= REG_LOOKBEHIND_SEEN;
- op = NBOUND + get_regex_charset(RExC_flags);
- if (op > NBOUNDA) { /* /aa is same as /a */
- op = NBOUNDA;
- }
- else if (op == NBOUNDL) {
- RExC_contains_locale = 1;
- }
- ret = reg_node(pRExC_state, op);
- *flagp |= SIMPLE;
- if ((U8) *(RExC_parse + 1) == '{') {
- /* diag_listed_as: Use "%s" instead of "%s" */
- vFAIL("Use \"\\B\\{\" instead of \"\\B{\"");
- }
- goto finish_meta_pat;
-
+ invert = 1;
+ /* FALLTHROUGH */
case 'b':
RExC_seen_zerolen++;
RExC_seen |= REG_LOOKBEHIND_SEEN;
@@ -11788,11 +11773,16 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
else if (op == BOUNDL) {
RExC_contains_locale = 1;
}
+
+ if (invert) {
+ op += NBOUND - BOUND;
+ }
+
ret = reg_node(pRExC_state, op);
*flagp |= SIMPLE;
if ((U8) *(RExC_parse + 1) == '{') {
/* diag_listed_as: Use "%s" instead of "%s" */
- vFAIL("Use \"\\b\\{\" instead of \"\\b{\"");
+ vFAIL3("Use \"\\%c\\{\" instead of \"\\%c{\"", *RExC_parse, *RExC_parse);
}
goto finish_meta_pat;