Patch: Put local($^I, @ARGV) = ... trick back into perlfaq5
[p5sagit/p5-mst-13.2.git] / sv.h
diff --git a/sv.h b/sv.h
index 7a13905..1d2c235 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -174,7 +174,7 @@ perform the upgrade if necessary.  See C<svtype>.
 #  endif
 #endif
 
-#define SvREFCNT_dec(sv)       sv_free((SV*)sv)
+#define SvREFCNT_dec(sv)       sv_free((SV*)(sv))
 
 #define SVTYPEMASK     0xff
 #define SvTYPE(sv)     ((sv)->sv_flags & SVTYPEMASK)
@@ -407,7 +407,6 @@ struct xpvio {
 #define IOf_UNTAINT    16      /* consider this fp (and its data) "safe" */
 #define IOf_NOLINE     32      /* slurped a pseudo-line from empty file */
 #define IOf_FAKE_DIRP  64      /* xio_dirp is fake (source filters kludge) */
-#define IOf_DIR_UTF8   128     /* readdir tries to return utf8 */
 
 /* The following macros define implementation-independent predicates on SVs. */
 
@@ -488,6 +487,9 @@ Unsets the PV status of an SV.
 Tells an SV that it is a string and disables all other OK bits.
 Will also turn off the UTF8 status.
 
+=for apidoc Am|bool|SvVOK|SV* sv
+Returns a boolean indicating whether the SV contains a v-string.
+
 =for apidoc Am|bool|SvOOK|SV* sv
 Returns a boolean indicating whether the SvIVX is a valid offset value for
 the SvPVX.  This hack is used internally to speed up removal of characters
@@ -557,14 +559,15 @@ Set the length of the string which is in the SV.  See C<SvCUR>.
 
 #define SvOKp(sv)              (SvFLAGS(sv) & (SVp_IOK|SVp_NOK|SVp_POK))
 #define SvIOKp(sv)             (SvFLAGS(sv) & SVp_IOK)
-#define SvIOKp_on(sv)          ((void)SvOOK_off(sv), SvFLAGS(sv) |= SVp_IOK)
+#define SvIOKp_on(sv)          (SvRELEASE_IVX(sv), \
+                                   SvFLAGS(sv) |= SVp_IOK)
 #define SvNOKp(sv)             (SvFLAGS(sv) & SVp_NOK)
 #define SvNOKp_on(sv)          (SvFLAGS(sv) |= SVp_NOK)
 #define SvPOKp(sv)             (SvFLAGS(sv) & SVp_POK)
 #define SvPOKp_on(sv)          (SvFLAGS(sv) |= SVp_POK)
 
 #define SvIOK(sv)              (SvFLAGS(sv) & SVf_IOK)
-#define SvIOK_on(sv)           ((void)SvOOK_off(sv), \
+#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), \
@@ -620,6 +623,7 @@ and leaves the UTF8 status as it was.
                                                  SVf_IVisUV),          \
                                    SvFLAGS(sv) |= (SVf_POK|SVp_POK))
 
+#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))
@@ -1064,10 +1068,35 @@ otherwise.
 #  endif /* USE_5005THREADS */
 #endif /* __GNU__ */
 
+#define SvIsCOW(sv)            ((SvFLAGS(sv) & (SVf_FAKE | SVf_READONLY)) == \
+                                   (SVf_FAKE | SVf_READONLY))
+#define SvIsCOW_shared_hash(sv)        (SvIsCOW(sv) && SvLEN(sv) == 0)
 
 /* flag values for sv_*_flags functions */
 #define SV_IMMEDIATE_UNREF     1
 #define SV_GMAGIC              2
+#define SV_COW_DROP_PV         4
+
+/* 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
+   the value is about to get thrown away, so drop the PV rather than go to
+   the effort of making a read-write copy only for it to get immediately
+   discarded.  */
+
+#define SV_CHECK_THINKFIRST_COW_DROP(sv) if (SvTHINKFIRST(sv)) \
+                                   sv_force_normal_flags(sv, SV_COW_DROP_PV)
+
+#ifdef PERL_COPY_ON_WRITE
+#  define SvRELEASE_IVX(sv)   ((void)((SvFLAGS(sv) & (SVf_OOK|SVf_READONLY|SVf_FAKE)) \
+                               && sv_release_IVX(sv)))
+#  define SvIsCOW_normal(sv)   (SvIsCOW(sv) && SvLEN(sv))
+#else
+#  define SvRELEASE_IVX(sv)   ((void)SvOOK_off(sv))
+#endif /* PERL_COPY_ON_WRITE */
+
+#define SV_CHECK_THINKFIRST(sv) if (SvTHINKFIRST(sv)) \
+                                   sv_force_normal_flags(sv, 0)
+
 
 /* all these 'functions' are now just macros */
 
@@ -1207,4 +1236,5 @@ Returns a pointer to the character buffer.
 struct clone_params {
   AV* stashes;
   UV  flags;
+  PerlInterpreter *proto_perl;
 };