This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
add svt_local slot to magic vtable, and fix local $shared
[perl5.git] / mg.c
diff --git a/mg.c b/mg.c
index 703a876..3478b41 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -430,15 +430,12 @@ Perl_mg_localize(pTHX_ SV *sv, SV *nsv)
            continue;
        }
                
-       if ((mg->mg_flags & MGf_COPY) && vtbl->svt_copy) {
-           /* XXX calling the copy method is probably not correct. DAPM */
-           (void)CALL_FPTR(vtbl->svt_copy)(aTHX_ sv, mg, nsv,
-                                   mg->mg_ptr, mg->mg_len);
-       }
-       else {
+       if ((mg->mg_flags & MGf_LOCAL) && vtbl->svt_local)
+           (void)CALL_FPTR(vtbl->svt_local)(aTHX_ nsv, mg);
+       else
            sv_magicext(nsv, mg->mg_obj, mg->mg_type, vtbl,
                            mg->mg_ptr, mg->mg_len);
-       }
+
        /* container types should remain read-only across localization */
        SvFLAGS(nsv) |= SvREADONLY(sv);
     }