#define sv_2mortal Perl_sv_2mortal
#define sv_2nv Perl_sv_2nv
#define sv_2pv Perl_sv_2pv
+#define sv_2pv_nolen Perl_sv_2pv_nolen
#define sv_2uv Perl_sv_2uv
#define sv_add_arena Perl_sv_add_arena
#define sv_backoff Perl_sv_backoff
#define sv_peek Perl_sv_peek
#define sv_pos_b2u Perl_sv_pos_b2u
#define sv_pos_u2b Perl_sv_pos_u2b
+#define sv_pv Perl_sv_pv
#define sv_pvn Perl_sv_pvn
#define sv_pvn_force Perl_sv_pvn_force
#define sv_ref Perl_sv_ref
#define sv_2mortal CPerlObj::Perl_sv_2mortal
#define sv_2nv CPerlObj::Perl_sv_2nv
#define sv_2pv CPerlObj::Perl_sv_2pv
+#define sv_2pv_nolen CPerlObj::Perl_sv_2pv_nolen
#define sv_2uv CPerlObj::Perl_sv_2uv
#define sv_add_arena CPerlObj::Perl_sv_add_arena
#define sv_backoff CPerlObj::Perl_sv_backoff
#define sv_peek CPerlObj::Perl_sv_peek
#define sv_pos_b2u CPerlObj::Perl_sv_pos_b2u
#define sv_pos_u2b CPerlObj::Perl_sv_pos_u2b
+#define sv_pv CPerlObj::Perl_sv_pv
#define sv_pvn CPerlObj::Perl_sv_pvn
#define sv_pvn_force CPerlObj::Perl_sv_pvn_force
#define sv_ref CPerlObj::Perl_sv_ref
sv_2mortal
sv_2nv
sv_2pv
+sv_2pv_nolen
sv_2uv
sv_add_arena
sv_backoff
sv_newref
sv_nv
sv_peek
+sv_pv
sv_pvn
sv_pvn_force
sv_ref
#define sv_2nv pPerl->Perl_sv_2nv
#undef sv_2pv
#define sv_2pv pPerl->Perl_sv_2pv
+#undef sv_2pv_nolen
+#define sv_2pv_nolen pPerl->Perl_sv_2pv_nolen
#undef sv_2uv
#define sv_2uv pPerl->Perl_sv_2uv
#undef sv_add_arena
#define sv_pos_b2u pPerl->Perl_sv_pos_b2u
#undef sv_pos_u2b
#define sv_pos_u2b pPerl->Perl_sv_pos_u2b
+#undef sv_pv
+#define sv_pv pPerl->Perl_sv_pv
#undef sv_pvn
#define sv_pvn pPerl->Perl_sv_pvn
#undef sv_pvn_force
SvIV(SV*)
SvNV(SV*)
SvPV(SV*, STRLEN len)
+ SvPV_nolen(SV*)
which will automatically coerce the actual scalar type into an IV, double,
or string.
In the C<SvPV> macro, the length of the string returned is placed into the
-variable C<len> (this is a macro, so you do I<not> use C<&len>). If you do not
-care what the length of the data is, use the global variable C<PL_na>, though
-this is rather less efficient than using a local variable. Remember,
-however, that Perl allows arbitrary strings of data that may both contain
-NULs and might not be terminated by a NUL.
+variable C<len> (this is a macro, so you do I<not> use C<&len>). If you do
+not care what the length of the data is, use the C<SvPV_nolen> macro.
+Historically the C<SvPV> macro with the global variable C<PL_na> has been
+used in this case. But that can be quite inefficient because C<PL_na> must
+be accessed in thread-local storage in threaded Perl. In any case, remember
+that Perl allows arbitrary strings of data that may both contain NULs and
+might not be terminated by a NUL.
If you want to know if the scalar value is TRUE, you can use:
A convenience variable which is typically used with C<SvPV> when one doesn't
care about the length of the string. It is usually more efficient to
-declare a local variable and use that instead.
+either declare a local variable and use that instead or to use the C<SvPV_nolen>
+macro.
=item New
Returns a pointer to the string in the SV, or a stringified form of the SV
if the SV does not contain a string. Handles 'get' magic.
- char* SvPV (SV* sv, int len )
+ char* SvPV (SV* sv, int len)
=item SvPV_force
char* SvPV_force(SV* sv, int len)
+=item SvPV_nolen
+
+Returns a pointer to the string in the SV, or a stringified form of the SV
+if the SV does not contain a string. Handles 'get' magic.
+
+ char* SvPV (SV* sv)
=item SvPVX
VIRTUAL void do_sv_dump _((I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bool dumpops, STRLEN pvlim));
VIRTUAL void magic_dump _((MAGIC *mg));
VIRTUAL void reginitcolors _((void));
+VIRTUAL char* sv_2pv_nolen _((SV* sv));
+VIRTUAL char* sv_pv _((SV *sv));
}
char *
+sv_2pv_nolen(register SV *sv)
+{
+ STRLEN n_a;
+ return sv_2pv(sv, &n_a);
+}
+
+char *
sv_2pv(register SV *sv, STRLEN *lp)
{
register char *s;
}
char *
+sv_pv(SV *sv)
+{
+ STRLEN n_a;
+
+ if (SvPOK(sv))
+ return SvPVX(sv);
+
+ return sv_2pv(sv, &n_a);
+}
+
+char *
sv_pvn(SV *sv, STRLEN *lp)
{
if (SvPOK(sv)) {
#define SvPV_force(sv, lp) sv_pvn_force(sv, &lp)
#define SvPV(sv, lp) sv_pvn(sv, &lp)
+#define SvPV_nolen(sv) sv_pv(sv)
#define SvIVx(sv) sv_iv(sv)
#define SvUVx(sv) sv_uv(sv)
#define SvNVx(sv) sv_nv(sv)
((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \
? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvn_force(sv, &lp))
+#undef SvPV_nolen
+#define SvPV_nolen(sv) \
+ (SvPOK(sv) ? SvPVX(sv) : sv_2pv_nolen(sv))
+
#ifdef __GNUC__
# undef SvIVx
# undef SvUVx