Skip to content

Commit bdb91f3

Browse files
hvdskhwilliamson
authored andcommitted
study_chunk: avoid transforming ops while enframed
gh16947: the outer frame may be in the middle of looking at the part of the program we would rewrite. Let the outer frame deal with it.
1 parent c0443cc commit bdb91f3

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

regcomp.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4616,10 +4616,14 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
46164616
* parsing code, as each (?:..) is handled by a different invocation of
46174617
* reg() -- Yves
46184618
*/
4619-
if (PL_regkind[OP(scan)] == EXACT && OP(scan) != LEXACT
4620-
&& OP(scan) != LEXACT_REQ8)
4619+
if (PL_regkind[OP(scan)] == EXACT
4620+
&& OP(scan) != LEXACT
4621+
&& OP(scan) != LEXACT_REQ8
4622+
&& !frame
4623+
) {
46214624
join_exact(pRExC_state, scan, &min_subtract, &unfolded_multi_char,
46224625
0, NULL, depth + 1);
4626+
}
46234627

46244628
/* Follow the next-chain of the current node and optimize
46254629
away all the NOTHINGs from it. */
@@ -5344,8 +5348,9 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
53445348
&& isALPHA_A(*s)
53455349
&& ( OP(scan) == EXACTFAA
53465350
|| ( OP(scan) == EXACTFU
5347-
&& ! HAS_NONLATIN1_SIMPLE_FOLD_CLOSURE(*s))))
5348-
{
5351+
&& ! HAS_NONLATIN1_SIMPLE_FOLD_CLOSURE(*s)))
5352+
&& !frame
5353+
) {
53495354
U8 mask = ~ ('A' ^ 'a'); /* These differ in just one bit */
53505355

53515356
OP(scan) = ANYOFM;
@@ -5438,16 +5443,17 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
54385443

54395444
/* This temporary node can now be turned into EXACTFU, and
54405445
* must, as regexec.c doesn't handle it */
5441-
if (OP(next) == EXACTFU_S_EDGE) {
5446+
if (OP(next) == EXACTFU_S_EDGE && !frame) {
54425447
OP(next) = EXACTFU;
54435448
}
54445449

54455450
if ( STR_LEN(next) == 1
54465451
&& isALPHA_A(* STRING(next))
54475452
&& ( OP(next) == EXACTFAA
54485453
|| ( OP(next) == EXACTFU
5449-
&& ! HAS_NONLATIN1_SIMPLE_FOLD_CLOSURE(* STRING(next)))))
5450-
{
5454+
&& ! HAS_NONLATIN1_SIMPLE_FOLD_CLOSURE(* STRING(next))))
5455+
&& !frame
5456+
) {
54515457
/* These differ in just one bit */
54525458
U8 mask = ~ ('A' ^ 'a');
54535459

@@ -5594,7 +5600,9 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
55945600
if ( OP(oscan) == CURLYX && data
55955601
&& data->flags & SF_IN_PAR
55965602
&& !(data->flags & SF_HAS_EVAL)
5597-
&& !deltanext && minnext == 1 ) {
5603+
&& !deltanext && minnext == 1
5604+
&& !frame
5605+
) {
55985606
/* Try to optimize to CURLYN. */
55995607
regnode *nxt = NEXTOPER(oscan) + EXTRA_STEP_2ARGS;
56005608
regnode * const nxt1 = nxt;
@@ -5644,10 +5652,10 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
56445652
&& !(data->flags & SF_HAS_EVAL)
56455653
&& !deltanext /* atom is fixed width */
56465654
&& minnext != 0 /* CURLYM can't handle zero width */
5647-
56485655
/* Nor characters whose fold at run-time may be
56495656
* multi-character */
56505657
&& ! (RExC_seen & REG_UNFOLDED_MULTI_SEEN)
5658+
&& !frame
56515659
) {
56525660
/* XXXX How to optimize if data == 0? */
56535661
/* Optimize to a simpler form. */

0 commit comments

Comments
 (0)