This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [perl #41491] Incorrect regexp warning.
authorYves Orton <demerphq@gmail.com>
Tue, 13 Feb 2007 19:09:17 +0000 (20:09 +0100)
committerH.Merijn Brand <h.m.brand@xs4all.nl>
Tue, 13 Feb 2007 19:36:56 +0000 (19:36 +0000)
Message-ID: <9b18b3110702131009l6a0867a3m8317c9d62328f834@mail.gmail.com>

p4raw-id: //depot/perl@30264

regcomp.c

index 5f1efdc..8b108f5 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -186,10 +186,11 @@ typedef struct RExC_state_t {
  * Flags to be passed up and down.
  */
 #define        WORST           0       /* Worst case. */
-#define        HASWIDTH        0x1     /* Known to match non-null strings. */
-#define        SIMPLE          0x2     /* Simple enough to be STAR/PLUS operand. */
-#define        SPSTART         0x4     /* Starts with * or +. */
-#define TRYAGAIN       0x8     /* Weeded out a declaration. */
+#define        HASWIDTH        0x01    /* Known to match non-null strings. */
+#define        SIMPLE          0x02    /* Simple enough to be STAR/PLUS operand. */
+#define        SPSTART         0x04    /* Starts with * or +. */
+#define TRYAGAIN       0x08    /* Weeded out a declaration. */
+#define POSTPONED      0x10    /* (?1),(?&name), (??{...}) or similar */
 
 #define REG_NODE_NUM(x) ((x) ? (int)((x)-RExC_emit_start) : -1)
 
@@ -5242,6 +5243,7 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth)
                if (*RExC_parse != ')')
                    FAIL("Sequence (?R) not terminated");
                ret = reg_node(pRExC_state, GOSTART);
+               *flagp |= POSTPONED;
                nextchar(pRExC_state);
                return ret;
                /*notreached*/
@@ -5322,6 +5324,7 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth)
                 Set_Node_Length(ret, 1 + regarglen[OP(ret)]); /* MJD */
                Set_Node_Offset(ret, parse_start); /* MJD */
 
+                *flagp |= POSTPONED;
                 nextchar(pRExC_state);
                 return ret;
             } /* named and numeric backreferences */
@@ -5338,6 +5341,7 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth)
                    vFAIL3("Sequence (%.*s...) not recognized", RExC_parse-seqstart, seqstart);
                    /*NOTREACHED*/
                }
+               *flagp |= POSTPONED;
                paren = *RExC_parse++;
                /* FALL THROUGH */
            case '{':           /* (?{...}) */
@@ -6016,7 +6020,7 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
        goto do_curly;
     }
   nest_check:
-    if (!SIZE_ONLY && !(flags&HASWIDTH) && max > REG_INFTY/3 && ckWARN(WARN_REGEXP)) {
+    if (!SIZE_ONLY && !(flags&(HASWIDTH|POSTPONED)) && max > REG_INFTY/3 && ckWARN(WARN_REGEXP)) {
        vWARN3(RExC_parse,
               "%.*s matches null string many times",
               (int)(RExC_parse >= origparse ? RExC_parse - origparse : 0),
@@ -6451,7 +6455,7 @@ tryagain:
                }
                return(NULL);
        }
-       *flagp |= flags&(HASWIDTH|SPSTART|SIMPLE);
+       *flagp |= flags&(HASWIDTH|SPSTART|SIMPLE|POSTPONED);
        break;
     case '|':
     case ')':