Skip to content

study_chunk: avoid transforming ops while enframed #17715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions regcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4616,10 +4616,14 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
* parsing code, as each (?:..) is handled by a different invocation of
* reg() -- Yves
*/
if (PL_regkind[OP(scan)] == EXACT && OP(scan) != LEXACT
&& OP(scan) != LEXACT_REQ8)
if (PL_regkind[OP(scan)] == EXACT
&& OP(scan) != LEXACT
&& OP(scan) != LEXACT_REQ8
&& !frame
) {
join_exact(pRExC_state, scan, &min_subtract, &unfolded_multi_char,
0, NULL, depth + 1);
}

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

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

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

if ( STR_LEN(next) == 1
&& isALPHA_A(* STRING(next))
&& ( OP(next) == EXACTFAA
|| ( OP(next) == EXACTFU
&& ! HAS_NONLATIN1_SIMPLE_FOLD_CLOSURE(* STRING(next)))))
{
&& ! HAS_NONLATIN1_SIMPLE_FOLD_CLOSURE(* STRING(next))))
&& !frame
) {
/* These differ in just one bit */
U8 mask = ~ ('A' ^ 'a');

Expand Down Expand Up @@ -5594,7 +5600,9 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
if ( OP(oscan) == CURLYX && data
&& data->flags & SF_IN_PAR
&& !(data->flags & SF_HAS_EVAL)
&& !deltanext && minnext == 1 ) {
&& !deltanext && minnext == 1
&& !frame
) {
/* Try to optimize to CURLYN. */
regnode *nxt = NEXTOPER(oscan) + EXTRA_STEP_2ARGS;
regnode * const nxt1 = nxt;
Expand Down Expand Up @@ -5644,10 +5652,10 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
&& !(data->flags & SF_HAS_EVAL)
&& !deltanext /* atom is fixed width */
&& minnext != 0 /* CURLYM can't handle zero width */

/* Nor characters whose fold at run-time may be
* multi-character */
&& ! (RExC_seen & REG_UNFOLDED_MULTI_SEEN)
&& !frame
) {
/* XXXX How to optimize if data == 0? */
/* Optimize to a simpler form. */
Expand Down