diff options
-rw-r--r-- | regcomp_debug.c | 6 | ||||
-rw-r--r-- | regcomp_study.c | 15 | ||||
-rw-r--r-- | t/re/pat_re_eval.t | 4 |
3 files changed, 20 insertions, 5 deletions
diff --git a/regcomp_debug.c b/regcomp_debug.c index 74f080a9d9..589ca6991f 100644 --- a/regcomp_debug.c +++ b/regcomp_debug.c @@ -83,8 +83,12 @@ Perl_debug_studydata(pTHX_ const char *where, scan_data_t *data, DECLARE_AND_GET_RE_DEBUG_FLAGS; DEBUG_OPTIMISE_MORE_r({ - if (!data) + if (!data) { + Perl_re_indentf(aTHX_ "%s: NO DATA", + depth, + where); return; + } Perl_re_indentf(aTHX_ "%s: M/S/D: %" IVdf "/%" IVdf "/%" IVdf " Pos:%" IVdf "/%" IVdf " Flags: 0x%" UVXf, depth, where, diff --git a/regcomp_study.c b/regcomp_study.c index 296de3f7e4..88672077d7 100644 --- a/regcomp_study.c +++ b/regcomp_study.c @@ -2688,23 +2688,26 @@ Perl_study_chunk(pTHX_ stopmin = min; DEBUG_STUDYDATA("after-whilem accept", data, depth, is_inf, min, stopmin, delta); } + DEBUG_STUDYDATA("PRE CURLYX_TO_CURLYN", data, depth, is_inf, min, stopmin, delta); /* Try powerful optimization CURLYX => CURLYN. */ if ( RE_OPTIMIZE_CURLYX_TO_CURLYN && OP(oscan) == CURLYX && data - && data->flags & SF_IN_PAR - && !(data->flags & SF_HAS_EVAL) + && !pRExC_state->code_blocks /* XXX: for now disable whenever eval + is seen anywhere. We need a better + way. */ + && ( ( data->flags & (SF_IN_PAR|SF_HAS_EVAL) ) == SF_IN_PAR ) && !deltanext && minnext == 1 && mutate_ok ) { + DEBUG_STUDYDATA("CURLYX_TO_CURLYN", data, depth, is_inf, min, stopmin, delta); /* Try to optimize to CURLYN. */ regnode *nxt = REGNODE_AFTER_type(oscan, tregnode_CURLYX); regnode * const nxt1 = nxt; #ifdef DEBUGGING regnode *nxt2; #endif - /* Skip open. */ nxt = regnext(nxt); if (!REGNODE_SIMPLE(OP(nxt)) @@ -2741,10 +2744,15 @@ Perl_study_chunk(pTHX_ } nogo: + DEBUG_STUDYDATA("PRE CURLYX_TO_CURLYM", data, depth, is_inf, min, stopmin, delta); + /* Try optimization CURLYX => CURLYM. */ if ( RE_OPTIMIZE_CURLYX_TO_CURLYM && OP(oscan) == CURLYX && data + && !pRExC_state->code_blocks /* XXX: for now disable whenever eval + is seen anywhere. We need a better + way. */ && !(data->flags & (SF_HAS_PAR|SF_HAS_EVAL)) && !deltanext /* atom is fixed width */ && minnext != 0 /* CURLYM can't handle zero width */ @@ -2753,6 +2761,7 @@ Perl_study_chunk(pTHX_ && !(RExC_seen & REG_UNFOLDED_MULTI_SEEN) && mutate_ok ) { + DEBUG_STUDYDATA("CURLYX_TO_CURLYM", data, depth, is_inf, min, stopmin, delta); /* XXXX How to optimize if data == 0? */ /* Optimize to a simpler form. */ regnode *nxt = REGNODE_AFTER_type(oscan, tregnode_CURLYX); /* OPEN */ diff --git a/t/re/pat_re_eval.t b/t/re/pat_re_eval.t index 95c2e33322..77a8f2b845 100644 --- a/t/re/pat_re_eval.t +++ b/t/re/pat_re_eval.t @@ -168,7 +168,9 @@ sub run_tests { [ 1, qr#^((??{"(?:bla|)"}))((??{$nested_tags}))$#, "bla blubb <bla><blubb></blubb></bla>", "a b <bla><blubb></blubb></bla>" ], [ 1, qr#^((??{"(?!)?"}))((??{$nested_tags}))$#, "bla blubb <bla><blubb></blubb></bla>", "a b <bla><blubb></blubb></bla>" ], [ 1, qr#^((??{"(?:|<(/?bla)>)"}))((??{$nested_tags}))\1$#, "bla blubb <bla><blubb></blubb></bla>", "a b <bla><blubb></blubb></bla>" ], - [ 0, qr#^((??{"(?!)"}))?((??{$nested_tags}))(?!)$#, "bla blubb undef", "a b undef" ], + [ 0, qr#^((??{"(?!)"}))?((??{$nested_tags}))(?!)$#, # changed in perl 5.37.7 + "bla blubb blub blu bl b bl b undef", + "a b b u l b l b undef" ], ) { #"#silence vim highlighting $c++; |