Change 31303 by [EMAIL PROTECTED] on 2007/05/29 08:49:06
Subject: Re: [perl #43015] regex /.*\z/ doesn't matches strings ending
with \n
From: demerphq <[EMAIL PROTECTED]>
Date: Mon, 28 May 2007 19:46:04 +0200
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/regcomp.c#591 edit
... //depot/perl/regexec.c#539 edit
... //depot/perl/t/op/re_tests#121 edit
Differences ...
==== //depot/perl/regcomp.c#591 (text) ====
Index: perl/regcomp.c
--- perl/regcomp.c#590~31131~ 2007-05-03 09:41:29.000000000 -0700
+++ perl/regcomp.c 2007-05-29 01:49:06.000000000 -0700
@@ -4121,7 +4121,6 @@
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 @@
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 @@
first += EXTRA_STEP_2ARGS;
} else /* XXX possible optimisation for /(?=)/ */
first = NEXTOPER(first);
+ first_next= regnext(first);
}
/* Starting-point info. */
==== //depot/perl/regexec.c#539 (text) ====
Index: perl/regexec.c
--- perl/regexec.c#538~31118~ 2007-05-02 07:28:45.000000000 -0700
+++ perl/regexec.c 2007-05-29 01:49:06.000000000 -0700
@@ -1845,7 +1845,7 @@
if (regtry(®info, &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);
==== //depot/perl/t/op/re_tests#121 (text) ====
Index: perl/t/op/re_tests
--- perl/t/op/re_tests#120~31026~ 2007-04-23 02:04:31.000000000 -0700
+++ perl/t/op/re_tests 2007-05-29 01:49:06.000000000 -0700
@@ -1324,3 +1324,5 @@
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 - -
End of Patch.