This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix deparsing of reversed foreach loops,
[perl5.git] / sv.h
diff --git a/sv.h b/sv.h
index 4edd87f..e80c755 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -567,9 +567,9 @@ Set the length of the string which is in the SV.  See C<SvCUR>.
 #define SvIOK_on(sv)           (SvRELEASE_IVX(sv), \
                                    SvFLAGS(sv) |= (SVf_IOK|SVp_IOK))
 #define SvIOK_off(sv)          (SvFLAGS(sv) &= ~(SVf_IOK|SVp_IOK|SVf_IVisUV))
-#define SvIOK_only(sv)         ((void)SvOK_off(sv), \
+#define SvIOK_only(sv)         (SvOK_off(sv), \
                                    SvFLAGS(sv) |= (SVf_IOK|SVp_IOK))
-#define SvIOK_only_UV(sv)      ((void)SvOK_off_exc_UV(sv), \
+#define SvIOK_only_UV(sv)      (SvOK_off_exc_UV(sv), \
                                    SvFLAGS(sv) |= (SVf_IOK|SVp_IOK))
 
 #define SvIOK_UV(sv)           ((SvFLAGS(sv) & (SVf_IOK|SVf_IVisUV))   \
@@ -585,7 +585,7 @@ Set the length of the string which is in the SV.  See C<SvCUR>.
 #define SvNOK(sv)              (SvFLAGS(sv) & SVf_NOK)
 #define SvNOK_on(sv)           (SvFLAGS(sv) |= (SVf_NOK|SVp_NOK))
 #define SvNOK_off(sv)          (SvFLAGS(sv) &= ~(SVf_NOK|SVp_NOK))
-#define SvNOK_only(sv)         ((void)SvOK_off(sv), \
+#define SvNOK_only(sv)         (SvOK_off(sv), \
                                    SvFLAGS(sv) |= (SVf_NOK|SVp_NOK))
 
 /*
@@ -626,7 +626,7 @@ and leaves the UTF-8 status as it was.
 #define SvVOK(sv)              (SvMAGICAL(sv) && mg_find(sv,'V'))
 #define SvOOK(sv)              (SvFLAGS(sv) & SVf_OOK)
 #define SvOOK_on(sv)           ((void)SvIOK_off(sv), SvFLAGS(sv) |= SVf_OOK)
-#define SvOOK_off(sv)          (SvOOK(sv) && sv_backoff(sv))
+#define SvOOK_off(sv)          ((void)(SvOOK(sv) && sv_backoff(sv)))
 
 #define SvFAKE(sv)             (SvFLAGS(sv) & SVf_FAKE)
 #define SvFAKE_on(sv)          (SvFLAGS(sv) |= SVf_FAKE)
@@ -739,8 +739,14 @@ and leaves the UTF-8 status as it was.
 #define SvLENx(sv) SvLEN(sv)
 #define SvEND(sv)(((XPV*)  SvANY(sv))->xpv_pv + ((XPV*)SvANY(sv))->xpv_cur)
 #define SvENDx(sv) ((PL_Sv = (sv)), SvEND(PL_Sv))
+
+#ifdef DEBUGGING
+#define SvMAGIC(sv)    (*(assert(SvTYPE(sv) >= SVt_PVMG), &((XPVMG*)  SvANY(sv))->xmg_magic))
+#define SvSTASH(sv)    (*(assert(SvTYPE(sv) >= SVt_PVMG), &((XPVMG*)  SvANY(sv))->xmg_stash))
+#else
 #define SvMAGIC(sv)    ((XPVMG*)  SvANY(sv))->xmg_magic
 #define SvSTASH(sv)    ((XPVMG*)  SvANY(sv))->xmg_stash
+#endif
 
 /* Ask a scalar nicely to try to become an IV, if possible.
    Not guaranteed to stay returning void */
@@ -951,6 +957,15 @@ COW)
 Returns a boolean indicating whether the SV is Copy-On-Write shared hash key
 scalar.
 
+=for apidoc Am|void|sv_catpvn_nomg|SV* sv|const char* ptr|STRLEN len
+Like C<sv_catpvn> but doesn't process magic.
+
+=for apidoc Am|void|sv_setsv_nomg|SV* dsv|SV* ssv
+Like C<sv_setsv> but doesn't process magic.
+
+=for apidoc Am|void|sv_catsv_nomg|SV* dsv|SV* ssv
+Like C<sv_catsv> but doesn't process magic.
+
 =cut
 */
 
@@ -1088,6 +1103,7 @@ scalar.
 #define SV_GMAGIC              2
 #define SV_COW_DROP_PV         4
 #define SV_UTF8_NO_ENCODING    8
+#define SV_NOSTEAL             16
 
 /* We are about to replace the SV's current value. So if it's copy on write
    we need to normalise it. Use the SV_COW_DROP_PV flag hint to say that
@@ -1109,7 +1125,7 @@ scalar.
 #define CAN_COW_FLAGS  (SVp_POK|SVf_POK)
 
 #else
-#  define SvRELEASE_IVX(sv)   ((void)SvOOK_off(sv))
+#  define SvRELEASE_IVX(sv)   SvOOK_off(sv)
 #endif /* PERL_COPY_ON_WRITE */
 
 #define SV_CHECK_THINKFIRST(sv) if (SvTHINKFIRST(sv)) \
@@ -1185,7 +1201,7 @@ ssv. May evaluate arguments more than once.
 Like C<SvSetSV>, but does any set magic required afterwards.
 
 =for apidoc Am|void|SvSetMagicSV_nosteal|SV* dsv|SV* ssv
-Like C<SvSetMagicSV>, but does any set magic required afterwards.
+Like C<SvSetSV_nosteal>, but does any set magic required afterwards.
 
 =for apidoc Am|void|SvSHARE|SV* sv
 Arranges for sv to be shared between threads if a suitable module
@@ -1227,10 +1243,7 @@ Returns a pointer to the character buffer.
 #define SvSetSV_nosteal_and(dst,src,finally) \
        STMT_START {                                    \
            if ((dst) != (src)) {                       \
-               U32 tMpF = SvFLAGS(src) & SVs_TEMP;     \
-               SvTEMP_off(src);                        \
-               sv_setsv(dst, src);                     \
-               SvFLAGS(src) |= tMpF;                   \
+               sv_setsv_flags(dst, src, SV_GMAGIC | SV_NOSTEAL);       \
                finally;                                \
            }                                           \
        } STMT_END