summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-02-19 17:33:59 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-02-19 17:33:59 +0000
commit1aeab75ab913b2442f1de7300d375422255ad122 (patch)
tree8f24e16b46838bf5ab71c8e0a10feb37319d76b2 /regexec.c
parent87d7fd28459b8274079ce3260d3e07e306aa70d8 (diff)
downloadperl-1aeab75ab913b2442f1de7300d375422255ad122.tar.gz
fix bug in backtracking optimizer (from Makoto Ishisone
<ishisone@sra.co.jp>) p4raw-id: //depot/perl@5151
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/regexec.c b/regexec.c
index e63fa6f070..f9f2cc0535 100644
--- a/regexec.c
+++ b/regexec.c
@@ -3045,8 +3045,14 @@ S_regmatch(pTHX_ regnode *prog)
n = regrepeat(scan, n);
locinput = PL_reginput;
if (ln < n && PL_regkind[(U8)OP(next)] == EOL &&
- (!PL_multiline || OP(next) == SEOL))
+ (!PL_multiline || OP(next) == SEOL || OP(next) == EOS)) {
ln = n; /* why back off? */
+ /* ...because $ and \Z can match before *and* after
+ newline at the end. Consider "\n\n" =~ /\n+\Z\n/.
+ We should back off by one in this case. */
+ if (UCHARAT(PL_reginput - 1) == '\n' && OP(next) != EOS)
+ ln--;
+ }
REGCP_SET;
if (paren) {
while (n >= ln) {