From: John Peacock Date: Thu, 19 Sep 2002 22:30:58 +0000 (-0400) Subject: Re: [REVISED PATCH] Magic v-strings X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ece467f9b3a755ed36c377ce22236e08f9efdc78;p=p5sagit%2Fp5-mst-13.2.git Re: [REVISED PATCH] Magic v-strings Message-ID: <3D8A8862.3000602@rowman.com> p4raw-id: //depot/perl@17937 --- diff --git a/sv.c b/sv.c index a2570e3..7be4064 100644 --- a/sv.c +++ b/sv.c @@ -3558,6 +3558,12 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags) dtype = SvTYPE(dstr); SvAMAGIC_off(dstr); + if ( SvVOK(dstr) ) + { + /* need to nuke the magic */ + mg_free(dstr); + SvRMAGICAL_off(dstr); + } /* There's a lot of redundancy below but we're going for speed here */ @@ -4013,9 +4019,9 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags) SvIVX(dstr) = SvIVX(sstr); } if (SvVOK(sstr)) { - MAGIC *mg = SvMAGIC(sstr); - sv_magicext(dstr, NULL, PERL_MAGIC_vstring, NULL, - mg->mg_ptr, mg->mg_len); + MAGIC *smg = mg_find(sstr,PERL_MAGIC_vstring); + sv_magic(dstr, NULL, PERL_MAGIC_vstring, + smg->mg_ptr, smg->mg_len); SvRMAGICAL_on(dstr); } } @@ -4788,6 +4794,9 @@ Perl_sv_magic(pTHX_ register SV *sv, SV *obj, int how, const char *name, I32 nam case PERL_MAGIC_vec: vtable = &PL_vtbl_vec; break; + case PERL_MAGIC_vstring: + vtable = 0; + break; case PERL_MAGIC_substr: vtable = &PL_vtbl_substr; break; diff --git a/util.c b/util.c index bd7ba2d..e7a6655 100644 --- a/util.c +++ b/util.c @@ -3961,7 +3961,7 @@ Perl_scan_vstring(pTHX_ char *s, SV *sv) pos++; } SvPOK_on(sv); - sv_magicext(sv,NULL,PERL_MAGIC_vstring,NULL,(const char*)start, pos-start); + sv_magic(sv,NULL,PERL_MAGIC_vstring,(const char*)start, pos-start); SvRMAGICAL_on(sv); } return s;