This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
RT#75762: In CURLYX->CURLYM optimization, check before removing parentheses.
authorGeorge Greer <perl@greerga.m-l.org>
Sun, 4 Jul 2010 23:15:06 +0000 (19:15 -0400)
committerRafael Garcia-Suarez <rgs@consttype.org>
Mon, 26 Jul 2010 09:37:24 +0000 (11:37 +0200)
regcomp.c

index 1b22d90..1cc2e10 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -3316,12 +3316,10 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
                        nxt = nxt2;
                    OP(nxt2)  = SUCCEED; /* Whas WHILEM */
                    /* Need to optimize away parenths. */
-                   if (data->flags & SF_IN_PAR) {
+                   if ((data->flags & SF_IN_PAR) && OP(nxt) == CLOSE) {
                        /* Set the parenth number.  */
                        regnode *nxt1 = NEXTOPER(oscan) + EXTRA_STEP_2ARGS; /* OPEN*/
 
-                       if (OP(nxt) != CLOSE)
-                           FAIL("Panic opt close");
                        oscan->flags = (U8)ARG(nxt);
                        if (RExC_open_parens) {
                            RExC_open_parens[ARG(nxt1)-1]=oscan; /*open->CURLYM*/