From 16eb5365105fd7ab1815c325059d04765892205f Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Thu, 16 Jun 2011 14:51:33 -0700 Subject: [PATCH] Revert "pos in lvalue context now returns a PVMG instead of a PVLV." MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This reverts commit 571f0e8653a532c34edde36e797ecba446978b1c. I’m afraid I have to revert this, as it does not modify sv_reftype accordingly, and doing so would add *more* complexity (the opposite of what that commit was trying to achieve) and slow down ref() at run time, by making it search for pos magic. --- mg.c | 6 ++++-- pod/perldelta.pod | 5 ----- pp.c | 6 ++++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/mg.c b/mg.c index 64c7d20..1bdf5c4 100644 --- a/mg.c +++ b/mg.c @@ -2064,9 +2064,10 @@ int Perl_magic_getpos(pTHX_ SV *sv, MAGIC *mg) { dVAR; - SV *const lsv = mg->mg_obj; + SV* const lsv = LvTARG(sv); PERL_ARGS_ASSERT_MAGIC_GETPOS; + PERL_UNUSED_ARG(mg); if (SvTYPE(lsv) >= SVt_PVMG && SvMAGIC(lsv)) { MAGIC * const found = mg_find(lsv, PERL_MAGIC_regex_global); @@ -2086,13 +2087,14 @@ int Perl_magic_setpos(pTHX_ SV *sv, MAGIC *mg) { dVAR; - SV *const lsv = mg->mg_obj; + SV* const lsv = LvTARG(sv); SSize_t pos; STRLEN len; STRLEN ulen = 0; MAGIC* found; PERL_ARGS_ASSERT_MAGIC_SETPOS; + PERL_UNUSED_ARG(mg); if (SvTYPE(lsv) >= SVt_PVMG && SvMAGIC(lsv)) found = mg_find(lsv, PERL_MAGIC_regex_global); diff --git a/pod/perldelta.pod b/pod/perldelta.pod index a70e6a6..cbb1bfc 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -867,11 +867,6 @@ last place where the core stores data beyond SvLEN(). =item * -C in lvalue context now returns a PVMG instead of a PVLV, storing the -target SV in C, instead of C. - -=item * - Simplified logic in C introduces a small change of behaviour for error cases involving unknown magic types. Previously, if C was passed a magic type unknown to it, it would diff --git a/pp.c b/pp.c index f87e0dd..385f1be 100644 --- a/pp.c +++ b/pp.c @@ -361,8 +361,10 @@ PP(pp_pos) dVAR; dSP; dPOPss; if (PL_op->op_flags & OPf_MOD || LVRET) { - SV * const ret = sv_2mortal(newSV_type(SVt_PVMG)); /* Not TARG RT#67838 */ - sv_magic(ret, sv, PERL_MAGIC_pos, NULL, 0); + SV * const ret = sv_2mortal(newSV_type(SVt_PVLV)); /* Not TARG RT#67838 */ + sv_magic(ret, NULL, PERL_MAGIC_pos, NULL, 0); + LvTYPE(ret) = '.'; + LvTARG(ret) = SvREFCNT_inc_simple(sv); PUSHs(ret); /* no SvSETMAGIC */ RETURN; } -- 2.7.4