From: Yves Orton Date: Sun, 17 Feb 2008 15:39:22 +0000 (+0000) Subject: Fix perlbug 50114 and document what the code does a bit better X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=639081d6f95c9b3121be1c0c372070f2e0ca4eaf;p=p5sagit%2Fp5-mst-13.2.git Fix perlbug 50114 and document what the code does a bit better p4raw-id: //depot/perl@33324 --- diff --git a/regcomp.c b/regcomp.c index 1959730..c4313ae 100644 --- 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); } diff --git a/t/op/re_tests b/t/op/re_tests index c2397e6..3df3745 100644 --- a/t/op/re_tests +++ b/t/op/re_tests @@ -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 - - +