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.
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);
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);
=item *
-C<pos> in lvalue context now returns a PVMG instead of a PVLV, storing the
-target SV in C<mg_obj>, instead of C<LvTARG()>.
-
-=item *
-
Simplified logic in C<Perl_sv_magic()> introduces a small change of
behaviour for error cases involving unknown magic types. Previously, if
C<Perl_sv_magic()> was passed a magic type unknown to it, it would
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;
}