summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1998-10-25 06:33:43 +0000
committerGurusamy Sarathy <gsar@cpan.org>1998-10-25 06:33:43 +0000
commit33c2748902d07b7ec367f87ad66e61e89f2aa994 (patch)
treefde7996e8953d60e19976c0365224c3ba03cf565 /mg.c
parent2e7e7c6ca2ccdf33926d1330538338beae355adb (diff)
downloadperl-33c2748902d07b7ec367f87ad66e61e89f2aa994.tar.gz
integrate changes#1982,2014,2021 (from maint-5.005)
p4raw-link: @2021 on //depot/maint-5.005/perl: ece095e7b265a16d4ec3543b1418100f9c635a87 p4raw-link: @2014 on //depot/maint-5.005/perl: cca0b9804acab4b7678c0f185888d57497a5c2a9 p4raw-link: @1982 on //depot/maint-5.005/perl: fe676099d996f70caaedeb6ae85adc3ee59d2240 p4raw-id: //depot/perl@2059
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/mg.c b/mg.c
index 49ad9beea9..9532b38742 100644
--- a/mg.c
+++ b/mg.c
@@ -280,7 +280,9 @@ mg_copy(SV *sv, SV *nsv, char *key, I32 klen)
MAGIC* mg;
for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
if (isUPPER(mg->mg_type)) {
- sv_magic(nsv, mg->mg_obj, toLOWER(mg->mg_type), key, klen);
+ sv_magic(nsv,
+ mg->mg_type == 'P' ? SvTIED_obj(sv, mg) : mg->mg_obj,
+ toLOWER(mg->mg_type), key, klen);
count++;
}
}
@@ -1039,7 +1041,7 @@ magic_getnkeys(SV *sv, MAGIC *mg)
if (hv) {
(void) hv_iterinit(hv);
- if (!SvRMAGICAL(hv) || !mg_find((SV*)hv,'P'))
+ if (! SvTIED_mg((SV*)hv, 'P'))
i = HvKEYS(hv);
else {
/*SUPPRESS 560*/
@@ -1064,13 +1066,13 @@ magic_setnkeys(SV *sv, MAGIC *mg)
/* caller is responsible for stack switching/cleanup */
STATIC int
-magic_methcall(MAGIC *mg, char *meth, I32 flags, int n, SV *val)
+magic_methcall(SV *sv, MAGIC *mg, char *meth, I32 flags, int n, SV *val)
{
dSP;
PUSHMARK(SP);
EXTEND(SP, n);
- PUSHs(mg->mg_obj);
+ PUSHs(SvTIED_obj(sv, mg));
if (n > 1) {
if (mg->mg_ptr) {
if (mg->mg_len >= 0)
@@ -1099,7 +1101,7 @@ magic_methpack(SV *sv, MAGIC *mg, char *meth)
SAVETMPS;
PUSHSTACKi(PERLSI_MAGIC);
- if (magic_methcall(mg, meth, G_SCALAR, 2, NULL)) {
+ if (magic_methcall(sv, mg, meth, G_SCALAR, 2, NULL)) {
sv_setsv(sv, *PL_stack_sp--);
}
@@ -1124,7 +1126,7 @@ magic_setpack(SV *sv, MAGIC *mg)
dSP;
ENTER;
PUSHSTACKi(PERLSI_MAGIC);
- magic_methcall(mg, "STORE", G_SCALAR|G_DISCARD, 3, sv);
+ magic_methcall(sv, mg, "STORE", G_SCALAR|G_DISCARD, 3, sv);
POPSTACK;
LEAVE;
return 0;
@@ -1146,7 +1148,7 @@ magic_sizepack(SV *sv, MAGIC *mg)
ENTER;
SAVETMPS;
PUSHSTACKi(PERLSI_MAGIC);
- if (magic_methcall(mg, "FETCHSIZE", G_SCALAR, 2, NULL)) {
+ if (magic_methcall(sv, mg, "FETCHSIZE", G_SCALAR, 2, NULL)) {
sv = *PL_stack_sp--;
retval = (U32) SvIV(sv)-1;
}
@@ -1163,7 +1165,7 @@ int magic_wipepack(SV *sv, MAGIC *mg)
ENTER;
PUSHSTACKi(PERLSI_MAGIC);
PUSHMARK(SP);
- XPUSHs(mg->mg_obj);
+ XPUSHs(SvTIED_obj(sv, mg));
PUTBACK;
perl_call_method("CLEAR", G_SCALAR|G_DISCARD);
POPSTACK;
@@ -1182,7 +1184,7 @@ magic_nextpack(SV *sv, MAGIC *mg, SV *key)
PUSHSTACKi(PERLSI_MAGIC);
PUSHMARK(SP);
EXTEND(SP, 2);
- PUSHs(mg->mg_obj);
+ PUSHs(SvTIED_obj(sv, mg));
if (SvOK(key))
PUSHs(key);
PUTBACK;