diff options
author | Rick Delaney <rick@consumercontact.com> | 2004-10-31 17:40:40 -0500 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2004-11-04 09:26:56 +0000 |
commit | 7fba1cd64145def991b6ae509bcdd709edcf43c1 (patch) | |
tree | b5f53479439045e8c37aef6ba45b919440313d9a /regexec.c | |
parent | 1b1d102f0a25a469525d1d8639733ed50d8b39b6 (diff) | |
download | perl-7fba1cd64145def991b6ae509bcdd709edcf43c1.tar.gz |
[perl #3038] Re: $qr = qr/^a$/m; $x =~ $qr; fails
Message-ID: <20041101034040.GC1232@biff.bort.ca>
p4raw-id: //depot/perl@23471
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 27 |
1 files changed, 12 insertions, 15 deletions
@@ -403,6 +403,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos, I32 ml_anch; register char *other_last = Nullch; /* other substr checked before this */ char *check_at = Nullch; /* check substr found at this pos */ + I32 multiline = prog->reganch & PMf_MULTILINE; #ifdef DEBUGGING char *i_strpos = strpos; SV *dsv = PERL_DEBUG_PAD_ZERO(0); @@ -464,7 +465,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos, if (prog->reganch & ROPT_ANCH) { /* Match at beg-of-str or after \n */ ml_anch = !( (prog->reganch & ROPT_ANCH_SINGLE) || ( (prog->reganch & ROPT_ANCH_BOL) - && !PL_multiline ) ); /* Check after \n? */ + && !multiline ) ); /* Check after \n? */ if (!ml_anch) { if ( !(prog->reganch & (ROPT_ANCH_GPOS /* Checked by the caller */ @@ -558,11 +559,11 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos, else if (prog->reganch & ROPT_CANY_SEEN) s = fbm_instr((U8*)(s + start_shift), (U8*)(strend - end_shift), - check, PL_multiline ? FBMrf_MULTILINE : 0); + check, multiline ? FBMrf_MULTILINE : 0); else s = fbm_instr(HOP3(s, start_shift, strend), HOP3(strend, -end_shift, strbeg), - check, PL_multiline ? FBMrf_MULTILINE : 0); + check, multiline ? FBMrf_MULTILINE : 0); /* Update the count-of-usability, remove useless subpatterns, unshift s. */ @@ -631,7 +632,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos, HOP3(HOP3(last1, prog->anchored_offset, strend) + SvCUR(must), -(SvTAIL(must)!=0), strbeg), must, - PL_multiline ? FBMrf_MULTILINE : 0 + multiline ? FBMrf_MULTILINE : 0 ); DEBUG_r(PerlIO_printf(Perl_debug_log, "%s anchored substr `%s%.*s%s'%s", @@ -692,7 +693,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos, s = fbm_instr((unsigned char*)s, (unsigned char*)last + SvCUR(must) - (SvTAIL(must)!=0), - must, PL_multiline ? FBMrf_MULTILINE : 0); + must, multiline ? FBMrf_MULTILINE : 0); DEBUG_r(PerlIO_printf(Perl_debug_log, "%s floating substr `%s%.*s%s'%s", (s ? "Found" : "Contradicts"), PL_colors[0], @@ -1628,6 +1629,7 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char * char *scream_olds; SV* oreplsv = GvSV(PL_replgv); bool do_utf8 = DO_UTF8(sv); + I32 multiline = prog->reganch & PMf_MULTILINE; #ifdef DEBUGGING SV *dsv0 = PERL_DEBUG_PAD_ZERO(0); SV *dsv1 = PERL_DEBUG_PAD_ZERO(1); @@ -1744,7 +1746,7 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char * if (prog->reganch & (ROPT_ANCH & ~ROPT_ANCH_GPOS)) { if (s == startpos && regtry(prog, startpos)) goto got_it; - else if (PL_multiline || (prog->reganch & ROPT_IMPLICIT) + else if (multiline || (prog->reganch & ROPT_IMPLICIT) || (prog->reganch & ROPT_ANCH_MBOL)) /* XXXX SBOL? */ { char *end; @@ -1878,7 +1880,7 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char * end_shift, &scream_pos, 0)) : (s = fbm_instr((unsigned char*)HOP3(s, back_min, strend), (unsigned char*)strend, must, - PL_multiline ? FBMrf_MULTILINE : 0))) ) { + multiline ? FBMrf_MULTILINE : 0))) ) { /* we may be pointing at the wrong string */ if ((flags & REXEC_SCREAM) && RX_MATCH_COPIED(prog)) s = strbeg + (s - SvPVX(sv)); @@ -1979,7 +1981,7 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char * if (SvTAIL(float_real)) { if (memEQ(strend - len + 1, little, len - 1)) last = strend - len + 1; - else if (!PL_multiline) + else if (!multiline) last = memEQ(strend - len, little, len) ? strend - len : Nullch; else @@ -2369,8 +2371,7 @@ S_regmatch(pTHX_ regnode *prog) switch (OP(scan)) { case BOL: - if (locinput == PL_bostr || (PL_multiline && - (nextchr || locinput < PL_regeol) && locinput[-1] == '\n') ) + if (locinput == PL_bostr) { /* regtill = regbol; */ break; @@ -2392,12 +2393,8 @@ S_regmatch(pTHX_ regnode *prog) break; sayNO; case EOL: - if (PL_multiline) - goto meol; - else goto seol; case MEOL: - meol: if ((nextchr || locinput < PL_regeol) && nextchr != '\n') sayNO; break; @@ -3734,7 +3731,7 @@ 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) != MEOL) || + (OP(next) != MEOL || OP(next) == SEOL || OP(next) == EOS)) { ln = n; /* why back off? */ |