summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2007-05-28 21:46:04 +0200
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2007-05-29 08:49:06 +0000
commit5339e136a9a7fcf6a58c5035f0eaf25e6d680adc (patch)
treeda968966e0f6e798d1a29a99737f72927b65713b
parent37a7450d59b2f524aefb691fe4a055ad9dd6dd98 (diff)
downloadperl-5339e136a9a7fcf6a58c5035f0eaf25e6d680adc.tar.gz
Re: [perl #43015] regex /.*\z/ doesn't matches strings ending with \n
Message-ID: <9b18b3110705281046ib37acb4i7960fe415325270f@mail.gmail.com> p4raw-id: //depot/perl@31303
-rw-r--r--regcomp.c12
-rw-r--r--regexec.c2
-rw-r--r--t/op/re_tests2
3 files changed, 10 insertions, 6 deletions
diff --git a/regcomp.c b/regcomp.c
index baa5d99285..fef161b846 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -4121,7 +4121,6 @@ Perl_re_compile(pTHX_ const SV * const pattern, const U32 pm_flags)
char* exp = SvPV((SV*)pattern, plen);
char* xend = exp + plen;
regnode *scan;
- regnode *first;
I32 flags;
I32 minlen = 0;
I32 sawplus = 0;
@@ -4381,18 +4380,20 @@ reStudy:
struct regnode_charclass_class ch_class; /* pointed to by data */
int stclass_flag;
I32 last_close = 0; /* pointed to by data */
-
- first = scan;
+ regnode *first= scan;
+ regnode *first_next= regnext(first);
+
/* Skip introductions and multiplicators >= 1. */
while ((OP(first) == OPEN && (sawopen = 1)) ||
/* An OR of *one* alternative - should not happen now. */
- (OP(first) == BRANCH && OP(regnext(first)) != BRANCH) ||
+ (OP(first) == BRANCH && OP(first_next) != BRANCH) ||
/* for now we can't handle lookbehind IFMATCH*/
(OP(first) == IFMATCH && !first->flags) ||
(OP(first) == PLUS) ||
(OP(first) == MINMOD) ||
/* An {n,m} with n>0 */
- (PL_regkind[OP(first)] == CURLY && ARG1(first) > 0) )
+ (PL_regkind[OP(first)] == CURLY && ARG1(first) > 0) ||
+ (OP(first) == NOTHING && PL_regkind[OP(first_next)] != END ))
{
if (OP(first) == PLUS)
@@ -4404,6 +4405,7 @@ reStudy:
first += EXTRA_STEP_2ARGS;
} else /* XXX possible optimisation for /(?=)/ */
first = NEXTOPER(first);
+ first_next= regnext(first);
}
/* Starting-point info. */
diff --git a/regexec.c b/regexec.c
index ba0f2b7562..c6dbcc0564 100644
--- a/regexec.c
+++ b/regexec.c
@@ -1845,7 +1845,7 @@ Perl_regexec_flags(pTHX_ REGEXP * const prog, char *stringarg, register char *st
if (regtry(&reginfo, &s))
goto got_it;
after_try:
- if (s >= end)
+ if (s > end)
goto phooey;
if (prog->extflags & RXf_USE_INTUIT) {
s = re_intuit_start(prog, sv, s + 1, strend, flags, NULL);
diff --git a/t/op/re_tests b/t/op/re_tests
index 6eb03a279d..3afdc710a9 100644
--- a/t/op/re_tests
+++ b/t/op/re_tests
@@ -1324,3 +1324,5 @@ foo(\h)bar foo\x{A0}bar y $1 \x{A0}
foo(\h)bar foo\tbar y $1 \t
(\H)(\h) foo\tbar y $1-$2 o-\t
(\h)(\H) foo\tbar y $1-$2 \t-b
+
+.*\z foo\n y - -