U8 *study_chunk_recursed; /* bitmap of which subs we have moved
through */
U32 study_chunk_recursed_bytes; /* bytes in bitmap */
- I32 in_lookbehind;
- I32 in_lookahead;
+ I32 in_lookaround;
I32 contains_locale;
I32 override_recoding;
I32 recode_x_to_native;
#define RExC_study_chunk_recursed (pRExC_state->study_chunk_recursed)
#define RExC_study_chunk_recursed_bytes \
(pRExC_state->study_chunk_recursed_bytes)
-#define RExC_in_lookbehind (pRExC_state->in_lookbehind)
-#define RExC_in_lookahead (pRExC_state->in_lookahead)
+#define RExC_in_lookaround (pRExC_state->in_lookaround)
#define RExC_contains_locale (pRExC_state->contains_locale)
#define RExC_recode_x_to_native (pRExC_state->recode_x_to_native)
RExC_seen = 0;
RExC_maxlen = 0;
- RExC_in_lookbehind = 0;
- RExC_in_lookahead = 0;
+ RExC_in_lookaround = 0;
RExC_seen_zerolen = *exp == '^' ? -1 : 0;
RExC_recode_x_to_native = 0;
RExC_in_multi_char_class = 0;
I32 after_freeze = 0;
I32 num; /* numeric backreferences */
SV * max_open; /* Max number of unclosed parens */
+ I32 was_in_lookaround = RExC_in_lookaround;
char * parse_start = RExC_parse; /* MJD */
char * const oregcomp_parse = RExC_parse;
*flagp = 0; /* Initialize. */
- if (RExC_in_lookbehind) {
- RExC_in_lookbehind++;
- }
- if (RExC_in_lookahead) {
- RExC_in_lookahead++;
- }
-
/* Having this true makes it feasible to have a lot fewer tests for the
* parse pointer being in scope. For example, we can write
* while(isFOO(*RExC_parse)) RExC_parse++;
lookbehind_alpha_assertions:
RExC_seen |= REG_LOOKBEHIND_SEEN;
- RExC_in_lookbehind++;
/*FALLTHROUGH*/
alpha_assertions:
+ RExC_in_lookaround++;
RExC_seen_zerolen++;
if (! start_arg) {
}
RExC_seen |= REG_LOOKBEHIND_SEEN;
- RExC_in_lookbehind++;
+ RExC_in_lookaround++;
RExC_parse++;
if (RExC_parse >= RExC_end) {
vFAIL("Sequence (?... not terminated");
break;
case '=': /* (?=...) */
RExC_seen_zerolen++;
- RExC_in_lookahead++;
+ RExC_in_lookaround++;
break;
case '!': /* (?!...) */
RExC_seen_zerolen++;
nextchar(pRExC_state);
return ret;
}
+ RExC_in_lookaround++;
break;
case '|': /* (?|...) */
/* branch reset, behave like a (?:...) except that
NOT_REACHED; /* NOTREACHED */
}
- if (RExC_in_lookbehind) {
- RExC_in_lookbehind--;
- }
- if (RExC_in_lookahead) {
- RExC_in_lookahead--;
- }
if (after_freeze > RExC_npar)
RExC_npar = after_freeze;
+
+ RExC_in_lookaround = was_in_lookaround;
+
return(ret);
}
RExC_seen |= REG_GPOS_SEEN;
goto finish_meta_pat;
case 'K':
- if (!RExC_in_lookbehind && !RExC_in_lookahead) {
+ if (!RExC_in_lookaround) {
RExC_seen_zerolen++;
ret = reg_node(pRExC_state, KEEPS);
/* XXX:dmq : disabling in-place substitution seems to
Too many nested open parens in regex; marked by <-- HERE in m/(( <-- HERE a))/ at - line 3.
########
# NAME \K not permitted in lookahead
-$x =~ /(?=a\Ka)a/;
+qr/(?=a\Ka)a/;
EXPECT
\K not permitted in lookahead/lookbehind in regex; marked by <-- HERE in m/(?=a\K <-- HERE a)a/ at - line 1.
########
+# NAME \K not permitted in lookahead (alpha)
+no warnings 'experimental::alpha_assertions';
+qr/(*positive_lookahead:a\Ka)a/;
+EXPECT
+\K not permitted in lookahead/lookbehind in regex; marked by <-- HERE in m/(*positive_lookahead:a\K <-- HERE a)a/ at - line 2.
+########
+# NAME \K not permitted in negative lookahead
+qr/(?!a\Ka)a/;
+EXPECT
+\K not permitted in lookahead/lookbehind in regex; marked by <-- HERE in m/(?!a\K <-- HERE a)a/ at - line 1.
+########
+# NAME \K not permitted in negative lookahead (alpha)
+no warnings 'experimental::alpha_assertions';
+qr/(*negative_lookahead:a\Ka)a/;
+EXPECT
+\K not permitted in lookahead/lookbehind in regex; marked by <-- HERE in m/(*negative_lookahead:a\K <-- HERE a)a/ at - line 2.
+########
# NAME \K not permitted in lookbehind
-$x =~ /(?<=a\Ka)a/;
+qr/(?<=a\Ka)a/;
EXPECT
\K not permitted in lookahead/lookbehind in regex; marked by <-- HERE in m/(?<=a\K <-- HERE a)a/ at - line 1.
########
+# NAME \K not permitted in lookbehind (alpha)
+no warnings 'experimental::alpha_assertions';
+qr/(*positive_lookbehind:a\Ka)a/;
+EXPECT
+\K not permitted in lookahead/lookbehind in regex; marked by <-- HERE in m/(*positive_lookbehind:a\K <-- HERE a)a/ at - line 2.
+########
+# NAME \K not permitted in negative lookbehind
+qr/(?<!a\Ka)a/;
+EXPECT
+\K not permitted in lookahead/lookbehind in regex; marked by <-- HERE in m/(?<!a\K <-- HERE a)a/ at - line 1.
+########
+# NAME \K not permitted in negative lookbehind (alpha)
+no warnings 'experimental::alpha_assertions';
+qr/(*negative_lookbehind:a\Ka)a/;
+EXPECT
+\K not permitted in lookahead/lookbehind in regex; marked by <-- HERE in m/(*negative_lookbehind:a\K <-- HERE a)a/ at - line 2.
+########
+# NAME \K is permitted after the lookahead GH#18123
+qr/(?=(?=x)x)\K/;
+EXPECT
+OPTIONS nonfatal
+########
# NAME numeric parsing buffer overflow in numeric.c
0=~/\p{nV:-0}/
EXPECT