This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add a new macro SvVSTRING_mg that returns vstring magic, if any.
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Wed, 17 May 2006 20:54:23 +0000 (20:54 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Wed, 17 May 2006 20:54:23 +0000 (20:54 +0000)
SvVOK used to do that, in stealth mode, but now it returns a
boolean like it used to. Patch suggested by John Peacock.

p4raw-id: //depot/perl@28218

sv.c
sv.h

diff --git a/sv.c b/sv.c
index 4c186ec..c9a4402 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -3676,7 +3676,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags)
        SvFLAGS(dstr) |= sflags & (SVf_IOK|SVp_IOK|SVf_NOK|SVp_NOK|SVf_UTF8
                                   |SVf_AMAGIC);
        {
-           const MAGIC * const smg = SvVOK(sstr);
+           const MAGIC * const smg = SvVSTRING_mg(sstr);
            if (smg) {
                sv_magic(dstr, NULL, PERL_MAGIC_vstring,
                         smg->mg_ptr, smg->mg_len);
diff --git a/sv.h b/sv.h
index 92a8e7f..554fe69 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -949,7 +949,11 @@ in gv.h: */
                                    SvFLAGS(sv) |= (SVf_POK|SVp_POK))
 
 #define SvVOK(sv)              (SvMAGICAL(sv)                          \
+                                && mg_find(sv,PERL_MAGIC_vstring))
+/* returns the vstring magic, if any */
+#define SvVSTRING_mg(sv)       (SvMAGICAL(sv) \
                                 ? mg_find(sv,PERL_MAGIC_vstring) : NULL)
+
 #define SvOOK(sv)              (SvFLAGS(sv) & SVf_OOK)
 #define SvOOK_on(sv)           ((void)SvIOK_off(sv), SvFLAGS(sv) |= SVf_OOK)
 #define SvOOK_off(sv)          ((void)(SvOOK(sv) && sv_backoff(sv)))