Fix perlbug 50114 and document what the code does a bit better
Yves Orton [Sun, 17 Feb 2008 15:39:22 +0000 (15:39 +0000)]
p4raw-id: //depot/perl@33324

regcomp.c
t/op/re_tests

index 1959730..c4313ae 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -4462,7 +4462,17 @@ reStudy:
         regnode *first= scan;
         regnode *first_next= regnext(first);
        
-       /* Skip introductions and multiplicators >= 1. */
+       /*
+        * Skip introductions and multiplicators >= 1
+        * so that we can extract the 'meat' of the pattern that must 
+        * match in the large if() sequence following.
+        * NOTE that EXACT is NOT covered here, as it is normally
+        * picked up by the optimiser separately. 
+        *
+        * This is unfortunate as the optimiser isnt handling lookahead
+        * properly currently.
+        *
+        */
        while ((OP(first) == OPEN && (sawopen = 1)) ||
               /* An OR of *one* alternative - should not happen now. */
            (OP(first) == BRANCH && OP(first_next) != BRANCH) ||
@@ -4474,16 +4484,17 @@ reStudy:
            (PL_regkind[OP(first)] == CURLY && ARG1(first) > 0) ||
            (OP(first) == NOTHING && PL_regkind[OP(first_next)] != END ))
        {
-               
+               /* 
+                * the only op that could be a regnode is PLUS, all the rest
+                * will be regnode_1 or regnode_2.
+                *
+                */
                if (OP(first) == PLUS)
                    sawplus = 1;
                else
                    first += regarglen[OP(first)];
-               if (OP(first) == IFMATCH) {
-                   first = NEXTOPER(first);
-                   first += EXTRA_STEP_2ARGS;
-               } else  /* XXX possible optimisation for /(?=)/  */
-                   first = NEXTOPER(first);
+               
+               first = NEXTOPER(first);
                first_next= regnext(first);
        }
 
index c2397e6..3df3745 100644 (file)
@@ -1341,3 +1341,6 @@ foo(\h)bar        foo\tbar        y       $1      \t
 .*\z   foo\n   y       -       -
 ^(?:(\d)x)?\d$ 1       y       ${\(defined($1)?1:0)}   0       
 .*?(?:(\w)|(\w))x      abx     y       $1-$2   b-
+
+0{50}  000000000000000000000000000000000000000000000000000     y       -       -
+