From: Hugo van der Sanden Date: Thu, 16 Aug 2001 18:50:01 +0000 (+0100) Subject: Re: [ID 20010814.004] pos() doesn't work when using =~m// in list context X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0af80b6034aad516a126a9414dadccac4de7f9dc;p=p5sagit%2Fp5-mst-13.2.git Re: [ID 20010814.004] pos() doesn't work when using =~m// in list context Message-Id: <200108161750.f7GHo1l22207@crypt.compulink.co.uk> p4raw-id: //depot/perl@11696 --- diff --git a/pp_hot.c b/pp_hot.c index db4c3fb..0f4a693 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -1336,6 +1336,22 @@ play_it_again: } } if (global) { + if (pm->op_pmflags & PMf_CONTINUE) { + MAGIC* mg = 0; + if (SvTYPE(TARG) >= SVt_PVMG && SvMAGIC(TARG)) + mg = mg_find(TARG, PERL_MAGIC_regex_global); + if (!mg) { + sv_magic(TARG, (SV*)0, PERL_MAGIC_regex_global, Nullch, 0); + mg = mg_find(TARG, PERL_MAGIC_regex_global); + } + if (rx->startp[0] != -1) { + mg->mg_len = rx->endp[0]; + if (rx->startp[0] == rx->endp[0]) + mg->mg_flags |= MGf_MINMATCH; + else + mg->mg_flags &= ~MGf_MINMATCH; + } + } had_zerolen = (rx->startp[0] != -1 && rx->startp[0] == rx->endp[0]); PUTBACK; /* EVAL blocks may use stack */ diff --git a/t/op/pat.t b/t/op/pat.t index bed2f37..d2d3205 100755 --- a/t/op/pat.t +++ b/t/op/pat.t @@ -6,7 +6,7 @@ $| = 1; -print "1..683\n"; +print "1..684\n"; BEGIN { chdir 't' if -d 't'; @@ -1979,3 +1979,11 @@ print "ok 682\n" if @a == 9 && "@a" eq "f o o \n $a $b b a r"; @a = ("foo\n\x{100}bar" =~ /\C/gs); print "ok 683\n" if @a == 9 && "@a" eq "f o o \n $a $b b a r"; +{ + # [ID 20010814.004] pos() doesn't work when using =~m// in list context + $_ = "ababacadaea"; + $a = join ":", /b./gc; + $b = join ":", /a./gc; + $c = pos; + print "$a $b $c" eq 'ba:ba ad:ae 10' ? "ok 684\n" : "not ok 684\t# $a $b $c\n"; +}