summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Pinyan <japhy@pobox.com>2001-11-14 11:35:29 -0500
committerJarkko Hietaniemi <jhi@iki.fi>2001-11-16 14:46:17 +0000
commita759488c42337f2d751890dc78d770629879b394 (patch)
tree8342df461ed96deaf63f5d83ed0a052f06c4b411
parent07fcf8ff4a18d7bde9f6b306fe8bbb50d0153ff4 (diff)
downloadperl-a759488c42337f2d751890dc78d770629879b394.tar.gz
Re: [PATCH regcomp.[ch], regexp.h, pp_hot.c, t/op/re_tests] lazy $& and \Z fix
Message-ID: <Pine.GSO.4.21.0111141634020.16649-100000@crusoe.crusoe.net> p4raw-id: //depot/perl@13048
-rw-r--r--pp_hot.c23
-rw-r--r--regcomp.c3
-rw-r--r--regcomp.h1
-rw-r--r--regexp.h1
-rw-r--r--t/op/re_tests8
5 files changed, 16 insertions, 20 deletions
diff --git a/pp_hot.c b/pp_hot.c
index f1274a63e4..77e070fbb7 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1264,9 +1264,7 @@ PP(pp_match)
}
}
}
- if ((!global && rx->nparens)
- || SvTEMP(TARG) || PL_sawampersand)
- r_flags |= REXEC_COPY_STR;
+ r_flags |= REXEC_COPY_STR;
if (SvSCREAM(TARG))
r_flags |= REXEC_SCREAM;
@@ -1291,7 +1289,7 @@ play_it_again:
if (!s)
goto nope;
if ( (rx->reganch & ROPT_CHECK_ALL)
- && !PL_sawampersand
+ && !((rx->reganch & ROPT_SEOL_SEEN) && PL_multiline)
&& ((rx->reganch & ROPT_NOSCAN)
|| !((rx->reganch & RE_INTUIT_TAIL)
&& (r_flags & REXEC_SCREAM)))
@@ -1408,19 +1406,12 @@ yup: /* Confirmed by INTUIT */
rx->sublen = strend - truebase;
goto gotcha;
}
- if (PL_sawampersand) {
- I32 off;
- rx->subbeg = savepvn(t, strend - t);
- rx->sublen = strend - t;
- RX_MATCH_COPIED_on(rx);
- off = rx->startp[0] = s - t;
- rx->endp[0] = off + rx->minlen;
- }
- else { /* startp/endp are used by @- @+. */
- rx->startp[0] = s - truebase;
- rx->endp[0] = s - truebase + rx->minlen;
- }
+ rx->sublen = strend - t;
+ rx->subbeg = savepvn(t, rx->sublen);
+ RX_MATCH_COPIED_on(rx);
+ rx->startp[0] = s - truebase;
+ rx->endp[0] = s - truebase + rx->minlen;
rx->nparens = rx->lastparen = 0; /* used by @- and @+ */
LEAVE_SCOPE(oldsave);
RETPUSHYES;
diff --git a/regcomp.c b/regcomp.c
index 12e03959fd..eabaa8cfa5 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -2016,6 +2016,8 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
r->reganch |= ROPT_EVAL_SEEN;
if (RExC_seen & REG_SEEN_CANY)
r->reganch |= ROPT_CANY_SEEN;
+ if (RExC_seen & REG_SEEN_SEOL)
+ r->reganch |= ROPT_SEOL_SEEN;
Newz(1002, r->startp, RExC_npar, I32);
Newz(1002, r->endp, RExC_npar, I32);
PL_regdata = r->data; /* for regprop() */
@@ -2794,6 +2796,7 @@ tryagain:
break;
case 'Z':
ret = reg_node(pRExC_state, SEOL);
+ RExC_seen |= REG_SEEN_SEOL;
*flagp |= SIMPLE;
nextchar(pRExC_state);
break;
diff --git a/regcomp.h b/regcomp.h
index bbe3a41399..7948853ece 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -311,6 +311,7 @@ struct regnode_charclass_class { /* has [[:blah:]] classes */
#define REG_SEEN_EVAL 8
#define REG_SEEN_CANY 16
#define REG_SEEN_SANY REG_SEEN_CANY /* src bckwrd cmpt */
+#define REG_SEEN_SEOL 32
START_EXTERN_C
diff --git a/regexp.h b/regexp.h
index 6217aaabfb..8366fa25a0 100644
--- a/regexp.h
+++ b/regexp.h
@@ -58,6 +58,7 @@ typedef struct regexp {
#define ROPT_EVAL_SEEN 0x00400
#define ROPT_CANY_SEEN 0x00800
#define ROPT_SANY_SEEN ROPT_CANY_SEEN /* src bckwrd cmpt */
+#define ROPT_SEOL_SEEN 0x01000
/* 0xf800 of reganch is used by PMf_COMPILETIME */
diff --git a/t/op/re_tests b/t/op/re_tests
index 1e80f5031c..c7ab5ad814 100644
--- a/t/op/re_tests
+++ b/t/op/re_tests
@@ -537,7 +537,7 @@ a$ b\na\n y $-[0] 2
a\Z b\na y $-[0] 2
a\z b\na y $-[0] 2
a$ b\na y $-[0] 2
-'a\Z'm a\nb\n bn - -
+'a\Z'm a\nb\n n - -
'a\z'm a\nb\n n - -
'a$'m a\nb\n y $-[0] 0
'a\Z'm b\na\n y $-[0] 2
@@ -555,7 +555,7 @@ aa$ b\naa\n y $-[0] 2
aa\Z b\naa y $-[0] 2
aa\z b\naa y $-[0] 2
aa$ b\naa y $-[0] 2
-'aa\Z'm aa\nb\n bn - -
+'aa\Z'm aa\nb\n n - -
'aa\z'm aa\nb\n n - -
'aa$'m aa\nb\n y $-[0] 0
'aa\Z'm b\naa\n y $-[0] 2
@@ -609,7 +609,7 @@ ab$ b\nab\n y $-[0] 2
ab\Z b\nab y $-[0] 2
ab\z b\nab y $-[0] 2
ab$ b\nab y $-[0] 2
-'ab\Z'm ab\nb\n bn - -
+'ab\Z'm ab\nb\n n - -
'ab\z'm ab\nb\n n - -
'ab$'m ab\nb\n y $-[0] 0
'ab\Z'm b\nab\n y $-[0] 2
@@ -663,7 +663,7 @@ abb$ b\nabb\n y $-[0] 2
abb\Z b\nabb y $-[0] 2
abb\z b\nabb y $-[0] 2
abb$ b\nabb y $-[0] 2
-'abb\Z'm abb\nb\n bn - -
+'abb\Z'm abb\nb\n n - -
'abb\z'm abb\nb\n n - -
'abb$'m abb\nb\n y $-[0] 0
'abb\Z'm b\nabb\n y $-[0] 2