1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
################################################################################
##
## $Revision: 11 $
## $Author: mhx $
## $Date: 2005/03/10 18:08:41 +0100 $
##
################################################################################
##
## Version 3.x, Copyright (C) 2004-2005, Marcus Holland-Moritz.
## Version 2.x, Copyright (C) 2001, Paul Marquess.
## Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
##
## This program is free software; you can redistribute it and/or
## modify it under the same terms as Perl itself.
##
################################################################################
=provides
SvPV_nolen
sv_2pv_nolen
SvPVbyte
sv_2pvbyte
sv_pvn
sv_pvn_force
=implementation
#ifndef SvPV_nolen
#if { NEED sv_2pv_nolen }
char *
sv_2pv_nolen(pTHX_ register SV *sv)
{
STRLEN n_a;
return sv_2pv(sv, &n_a);
}
#endif
/* Hint: sv_2pv_nolen
* Use the SvPV_nolen() macro instead of sv_2pv_nolen().
*/
/* SvPV_nolen depends on sv_2pv_nolen */
#define SvPV_nolen(sv) \
((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
? SvPVX(sv) : sv_2pv_nolen(sv))
#endif
#ifdef SvPVbyte
/* Hint: SvPVbyte
* Does not work in perl-5.6.1, ppport.h implements a version
* borrowed from perl-5.7.3.
*/
#if { VERSION < 5.7.0 }
#if { NEED sv_2pvbyte }
char *
sv_2pvbyte(pTHX_ register SV *sv, STRLEN *lp)
{
sv_utf8_downgrade(sv,0);
return SvPV(sv,*lp);
}
#endif
/* Hint: sv_2pvbyte
* Use the SvPVbyte() macro instead of sv_2pvbyte().
*/
#undef SvPVbyte
/* SvPVbyte depends on sv_2pvbyte */
#define SvPVbyte(sv, lp) \
((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \
? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp))
#endif
#else
# define SvPVbyte SvPV
# define sv_2pvbyte sv_2pv
#endif
/* sv_2pvbyte_nolen depends on sv_2pv_nolen */
__UNDEFINED__ sv_2pvbyte_nolen sv_2pv_nolen
/* Hint: sv_pvn
* Always use the SvPV() macro instead of sv_pvn().
*/
__UNDEFINED__ sv_pvn(sv, len) SvPV(sv, len)
/* Hint: sv_pvn_force
* Always use the SvPV_force() macro instead of sv_pvn_force().
*/
__UNDEFINED__ sv_pvn_force(sv, len) SvPV_force(sv, len)
=xsinit
#define NEED_sv_2pv_nolen
#define NEED_sv_2pvbyte
=xsubs
IV
SvPVbyte(sv)
SV *sv
PREINIT:
STRLEN len;
const char *str;
CODE:
str = SvPVbyte(sv, len);
RETVAL = strEQ(str, "mhx") ? len : -1;
OUTPUT:
RETVAL
IV
SvPV_nolen(sv)
SV *sv
PREINIT:
const char *str;
CODE:
str = SvPV_nolen(sv);
RETVAL = strEQ(str, "mhx") ? 42 : 0;
OUTPUT:
RETVAL
=tests plan => 2
ok(&Devel::PPPort::SvPVbyte("mhx"), 3);
ok(&Devel::PPPort::SvPV_nolen("mhx"), 42);
|