1 ################################################################################
5 ## $Date: 2006/01/14 18:08:01 +0100 $
7 ################################################################################
9 ## Version 3.x, Copyright (C) 2004-2006, Marcus Holland-Moritz.
10 ## Version 2.x, Copyright (C) 2001, Paul Marquess.
11 ## Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
13 ## This program is free software; you can redistribute it and/or
14 ## modify it under the same terms as Perl itself.
16 ################################################################################
31 #if { NEED sv_2pv_nolen }
34 sv_2pv_nolen(pTHX_ register SV *sv)
37 return sv_2pv(sv, &n_a);
43 * Use the SvPV_nolen() macro instead of sv_2pv_nolen().
46 /* SvPV_nolen depends on sv_2pv_nolen */
47 #define SvPV_nolen(sv) \
48 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
49 ? SvPVX(sv) : sv_2pv_nolen(sv))
56 * Does not work in perl-5.6.1, ppport.h implements a version
57 * borrowed from perl-5.7.3.
60 #if { VERSION < 5.7.0 }
62 #if { NEED sv_2pvbyte }
65 sv_2pvbyte(pTHX_ register SV *sv, STRLEN *lp)
67 sv_utf8_downgrade(sv,0);
74 * Use the SvPVbyte() macro instead of sv_2pvbyte().
79 /* SvPVbyte depends on sv_2pvbyte */
80 #define SvPVbyte(sv, lp) \
81 ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \
82 ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp))
88 # define SvPVbyte SvPV
89 # define sv_2pvbyte sv_2pv
93 /* sv_2pvbyte_nolen depends on sv_2pv_nolen */
94 __UNDEFINED__ sv_2pvbyte_nolen sv_2pv_nolen
97 * Always use the SvPV() macro instead of sv_pvn().
99 __UNDEFINED__ sv_pvn(sv, len) SvPV(sv, len)
101 /* Hint: sv_pvn_force
102 * Always use the SvPV_force() macro instead of sv_pvn_force().
104 __UNDEFINED__ sv_pvn_force(sv, len) SvPV_force(sv, len)
108 #define NEED_sv_2pv_nolen
109 #define NEED_sv_2pvbyte
120 str = SvPVbyte(sv, len);
121 RETVAL = strEQ(str, "mhx") ? (IV) len : (IV) -1;
131 str = SvPV_nolen(sv);
132 RETVAL = strEQ(str, "mhx") ? 42 : 0;
138 ok(&Devel::PPPort::SvPVbyte("mhx"), 3);
139 ok(&Devel::PPPort::SvPV_nolen("mhx"), 42);