From: Yves Orton Date: Mon, 28 May 2007 19:46:04 +0000 (+0200) Subject: Re: [perl #43015] regex /.*\z/ doesn't matches strings ending with \n X-Git-Tag: accepted/trunk/20130322.191538~15170 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5339e136a9a7fcf6a58c5035f0eaf25e6d680adc;p=platform%2Fupstream%2Fperl.git Re: [perl #43015] regex /.*\z/ doesn't matches strings ending with \n Message-ID: <9b18b3110705281046ib37acb4i7960fe415325270f@mail.gmail.com> p4raw-id: //depot/perl@31303 --- diff --git a/regcomp.c b/regcomp.c index baa5d99..fef161b 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 ba0f2b7..c6dbcc0 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(®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); diff --git a/t/op/re_tests b/t/op/re_tests index 6eb03a2..3afdc71 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 - -