a typeglob. SVt_PVLV represents a scalar that delegates to another scalar
behind the scenes. It is used, e.g., for the return value of C<substr> and
for tied hash and array elements. It can hold any scalar value, including
-a typeglob. SVt_REGEXP is for regular expressions. SVt_INVLIST is for Perl
+a typeglob. SVt_REGEXP is for regular
+expressions. SVt_INVLIST is for Perl
core internal use only.
SVt_PVMG represents a "normal" scalar (not a typeglob, regular expression,
and faster.
=for apidoc Am|void|SvREFCNT_dec|SV* sv
-Decrements the reference count of the given SV. I<sv> may be NULL.
+Decrements the reference count of the given SV. I<sv> may be NULL.
=for apidoc Am|void|SvREFCNT_dec_NN|SV* sv
Same as SvREFCNT_dec, but can only be used if you know I<sv>
U32 xlow;
U32 xhigh;
} xpad_cop_seq; /* used by pad.c for cop_sequence */
- I32 xbm_useful;
};
union _xivu {
_XPV_HEAD;
union _xivu xiv_u;
union _xnvu xnv_u;
- STRLEN xlv_targoff;
+ union {
+ STRLEN xlvu_targoff;
+ SSize_t xlvu_stargoff;
+ } xlv_targoff_u;
STRLEN xlv_targlen;
SV* xlv_targ;
char xlv_type; /* k=keys .=pos x=substr v=vec /=join/re
char xlv_flags; /* 1 = negative offset 2 = negative len */
};
+#define xlv_targoff xlv_targoff_u.xlvu_targoff
+
struct xpvinvlist {
_XPV_HEAD;
IV prev_index;
Unsets the NV/IV status of an SV.
=for apidoc Am|U32|SvOK|SV* sv
-Returns a U32 value indicating whether the value is defined. This is
+Returns a U32 value indicating whether the value is defined. This is
only meaningful for scalars.
=for apidoc Am|U32|SvIOKp|SV* sv
=for apidoc Am|char*|SvPVX|SV* sv
Returns a pointer to the physical string in the SV. The SV must contain a
-string. Prior to 5.9.3 it is not safe to execute this macro unless the SV's
+string. Prior to 5.9.3 it is not safe
+to execute this macro unless the SV's
type >= SVt_PV.
This is also used to store the name of an autoloaded subroutine in an XS
#if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
# define SvVALID(sv) ({ const SV *const _svvalid = (const SV*)(sv); \
- if (SvFLAGS(_svvalid) & SVpbm_VALID) \
+ if (SvFLAGS(_svvalid) & SVpbm_VALID && !SvSCREAM(_svvalid)) \
assert(!isGV_with_GP(_svvalid)); \
(SvFLAGS(_svvalid) & SVpbm_VALID); \
})
# define SvVALID_on(sv) ({ SV *const _svvalid = MUTABLE_SV(sv); \
assert(!isGV_with_GP(_svvalid)); \
+ assert(!SvSCREAM(_svvalid)); \
(SvFLAGS(_svvalid) |= SVpbm_VALID); \
})
# define SvVALID_off(sv) ({ SV *const _svvalid = MUTABLE_SV(sv); \
assert(!isGV_with_GP(_svvalid)); \
+ assert(!SvSCREAM(_svvalid)); \
(SvFLAGS(_svvalid) &= ~SVpbm_VALID); \
})
# define SvTAIL(sv) ({ const SV *const _svtail = (const SV *)(sv); \
- assert(SvTYPE(_svtail) != SVt_PVAV); \
- assert(SvTYPE(_svtail) != SVt_PVHV); \
+ assert(SvTYPE(_svtail) != SVt_PVAV); \
+ assert(SvTYPE(_svtail) != SVt_PVHV); \
+ assert(!SvSCREAM(_svtail)); \
(SvFLAGS(sv) & (SVpbm_TAIL|SVpbm_VALID)) \
== (SVpbm_TAIL|SVpbm_VALID); \
})
#else
-# define SvVALID(sv) (SvFLAGS(sv) & SVpbm_VALID)
+# define SvVALID(sv) ((SvFLAGS(sv) & SVpbm_VALID) && !SvSCREAM(sv))
# define SvVALID_on(sv) (SvFLAGS(sv) |= SVpbm_VALID)
# define SvVALID_off(sv) (SvFLAGS(sv) &= ~SVpbm_VALID)
# define SvTAIL(sv) ((SvFLAGS(sv) & (SVpbm_TAIL|SVpbm_VALID)) \
#if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
# define BmUSEFUL(sv) \
(*({ SV *const _bmuseful = MUTABLE_SV(sv); \
- assert(SvTYPE(_bmuseful) == SVt_PVMG); \
+ assert(SvTYPE(_bmuseful) >= SVt_PVIV); \
assert(SvVALID(_bmuseful)); \
- assert(!SvNOK(_bmuseful)); \
- &(((XPVMG*) SvANY(_bmuseful))->xnv_u.xbm_useful); \
+ assert(!SvIOK(_bmuseful)); \
+ &(((XPVIV*) SvANY(_bmuseful))->xiv_u.xivu_iv); \
}))
#else
-# define BmUSEFUL(sv) ((XPVMG*) SvANY(sv))->xnv_u.xbm_useful
+# define BmUSEFUL(sv) ((XPVIV*) SvANY(sv))->xiv_u.xivu_iv
#endif
#define LvTYPE(sv) ((XPVLV*) SvANY(sv))->xlv_type
#define LvTARG(sv) ((XPVLV*) SvANY(sv))->xlv_targ
#define LvTARGOFF(sv) ((XPVLV*) SvANY(sv))->xlv_targoff
+#define LvSTARGOFF(sv) ((XPVLV*) SvANY(sv))->xlv_targoff_u.xlvu_stargoff
#define LvTARGLEN(sv) ((XPVLV*) SvANY(sv))->xlv_targlen
#define LvFLAGS(sv) ((XPVLV*) SvANY(sv))->xlv_flags
Untaints an SV. Be I<very> careful with this routine, as it short-circuits
some of Perl's fundamental security features. XS module authors should not
use this function unless they fully understand all the implications of
-unconditionally untainting the value. Untainting should be done in the
+unconditionally untainting the value. Untainting should be done in the
standard perl fashion, via a carefully crafted regexp, rather than directly
untainting variables.
going to update the C<SvPVX> directly. Processes get magic.
Note that coercing an arbitrary scalar into a plain PV will potentially
-strip useful data from it. For example if the SV was C<SvROK>, then the
+strip useful data from it. For example if the SV was C<SvROK>, then the
referent will have its reference count decremented, and the SV itself may
be converted to an C<SvPOK> scalar with a string buffer containing a value
such as C<"ARRAY(0x1234)">.
Note that there is no guarantee that the return value of C<SvPV()> is
equal to C<SvPVX(sv)>, or that C<SvPVX(sv)> contains valid data, or that
successive calls to C<SvPV(sv)> will return the same pointer value each
-time. This is due to the way that things like overloading and
+time. This is due to the way that things like overloading and
Copy-On-Write are handled. In these cases, the return value may point to
a temporary buffer or similar. If you absolutely need the SvPVX field to
be valid (for example, if you intend to write to it), then see
Guarantees to evaluate sv only once; use the more efficient C<SvPVbyte>
otherwise.
-=for apidoc Am|bool|SvIsCOW|SV* sv
-Returns a boolean indicating whether the SV is Copy-On-Write (either shared
+=for apidoc Am|U32|SvIsCOW|SV* sv
+Returns a U32 value indicating whether the SV is Copy-On-Write (either shared
hash key scalars, or full Copy On Write scalars if 5.9.0 is configured for
COW).
#define sv_catpvn_nomg_maybeutf8(dsv, sstr, slen, is_utf8) \
sv_catpvn_flags(dsv, sstr, slen, (is_utf8)?SV_CATUTF8:SV_CATBYTES)
-#ifdef PERL_CORE
+#if defined(PERL_CORE) || defined(PERL_EXT)
# define sv_or_pv_len_utf8(sv, pv, bytelen) \
(SvGAMAGIC(sv) \
? utf8_length((U8 *)(pv), (U8 *)(pv)+(bytelen)) \
: sv_len_utf8(sv))
-# define sv_or_pv_pos_u2b(sv,s,p,lp) S_sv_or_pv_pos_u2b(aTHX_ sv,s,p,lp)
#endif
/*
Expands the character buffer in the SV so that it has room for the
indicated number of bytes (remember to reserve space for an extra trailing
NUL character). Calls C<sv_grow> to perform the expansion if necessary.
-Returns a pointer to the character buffer. SV must be of type >= SVt_PV. One
+Returns a pointer to the character
+buffer. SV must be of type >= SVt_PV. One
alternative is to call C<sv_grow> if you are not sure of the type of SV.
=cut
== (SVt_PVLV|SVf_FAKE))
-#ifdef PERL_NEW_COPY_ON_WRITE
+#ifdef PERL_ANY_COW
# define SvGROW(sv,len) \
(SvIsCOW(sv) || SvLEN(sv) < (len) ? sv_grow(sv,len) : SvPVX(sv))
#else