Delete the files which #31710 should have removed.
[p5sagit/p5-mst-13.2.git] / ext / Devel / PPPort / parts / inc / SvPV
CommitLineData
adfe19db 1################################################################################
2##
679ad62d 3## $Revision: 15 $
adfe19db 4## $Author: mhx $
679ad62d 5## $Date: 2007/08/12 23:57:47 +0200 $
adfe19db 6##
7################################################################################
8##
d2dacc4f 9## Version 3.x, Copyright (C) 2004-2007, Marcus Holland-Moritz.
adfe19db 10## Version 2.x, Copyright (C) 2001, Paul Marquess.
11## Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
12##
13## This program is free software; you can redistribute it and/or
14## modify it under the same terms as Perl itself.
15##
16################################################################################
17
18=provides
19
679ad62d 20__UNDEFINED__
adfe19db 21SvPVbyte
22sv_2pvbyte
679ad62d 23sv_2pv_flags
24sv_pvn_force_flags
adfe19db 25
679ad62d 26=dontwarn
adfe19db 27
679ad62d 28NEED_sv_2pv_flags
adfe19db 29
679ad62d 30=implementation
adfe19db 31
679ad62d 32/* Backwards compatibility stuff... :-( */
33#if !defined(NEED_sv_2pv_flags) && defined(NEED_sv_2pv_nolen)
34# define NEED_sv_2pv_flags
35#endif
36#if !defined(NEED_sv_2pv_flags_GLOBAL) && defined(NEED_sv_2pv_nolen_GLOBAL)
37# define NEED_sv_2pv_flags_GLOBAL
adfe19db 38#endif
39
40/* Hint: sv_2pv_nolen
679ad62d 41 * Use the SvPV_nolen() or SvPV_nolen_const() macros instead of sv_2pv_nolen().
adfe19db 42 */
43
679ad62d 44__UNDEFINED__ sv_2pv_nolen(sv) SvPV_nolen(sv)
adfe19db 45
46#ifdef SvPVbyte
47
48/* Hint: SvPVbyte
49 * Does not work in perl-5.6.1, ppport.h implements a version
50 * borrowed from perl-5.7.3.
51 */
52
53#if { VERSION < 5.7.0 }
54
55#if { NEED sv_2pvbyte }
56
57char *
58sv_2pvbyte(pTHX_ register SV *sv, STRLEN *lp)
4a582685 59{
adfe19db 60 sv_utf8_downgrade(sv,0);
61 return SvPV(sv,*lp);
62}
63
64#endif
65
66/* Hint: sv_2pvbyte
67 * Use the SvPVbyte() macro instead of sv_2pvbyte().
68 */
69
70#undef SvPVbyte
71
adfe19db 72#define SvPVbyte(sv, lp) \
73 ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \
74 ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp))
75
76#endif
77
78#else
79
80# define SvPVbyte SvPV
81# define sv_2pvbyte sv_2pv
82
83#endif
84
679ad62d 85__UNDEFINED__ sv_2pvbyte_nolen(sv) sv_2pv_nolen(sv)
adfe19db 86
87/* Hint: sv_pvn
88 * Always use the SvPV() macro instead of sv_pvn().
89 */
90__UNDEFINED__ sv_pvn(sv, len) SvPV(sv, len)
91
04fc8b94 92/* Hint: sv_pvn_force
adfe19db 93 * Always use the SvPV_force() macro instead of sv_pvn_force().
94 */
95__UNDEFINED__ sv_pvn_force(sv, len) SvPV_force(sv, len)
96
679ad62d 97/* If these are undefined, they're not handled by the core anyway */
98__UNDEFINED__ SV_IMMEDIATE_UNREF 0
99__UNDEFINED__ SV_GMAGIC 0
100__UNDEFINED__ SV_COW_DROP_PV 0
101__UNDEFINED__ SV_UTF8_NO_ENCODING 0
102__UNDEFINED__ SV_NOSTEAL 0
103__UNDEFINED__ SV_CONST_RETURN 0
104__UNDEFINED__ SV_MUTABLE_RETURN 0
105__UNDEFINED__ SV_SMAGIC 0
106__UNDEFINED__ SV_HAS_TRAILING_NUL 0
107__UNDEFINED__ SV_COW_SHARED_HASH_KEYS 0
108
109#if { VERSION < 5.7.2 }
110
111#if { NEED sv_2pv_flags }
112
113char *
114sv_2pv_flags(pTHX_ SV *sv, STRLEN *lp, I32 flags)
115{
116 STRLEN n_a = (STRLEN) flags;
117 return sv_2pv(sv, lp ? lp : &n_a);
118}
119
120#endif
121
122#if { NEED sv_pvn_force_flags }
123
124char *
125sv_pvn_force_flags(pTHX_ SV *sv, STRLEN *lp, I32 flags)
126{
127 STRLEN n_a = (STRLEN) flags;
128 return sv_pvn_force(sv, lp ? lp : &n_a);
129}
130
131#endif
132
133#endif
134
135__UNDEFINED__ SvPV_const(sv, lp) SvPV_flags_const(sv, lp, SV_GMAGIC)
136__UNDEFINED__ SvPV_mutable(sv, lp) SvPV_flags_mutable(sv, lp, SV_GMAGIC)
137
138__UNDEFINED__ SvPV_flags(sv, lp, flags) \
139 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
140 ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pv_flags(sv, &lp, flags))
141
142__UNDEFINED__ SvPV_flags_const(sv, lp, flags) \
143 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
144 ? ((lp = SvCUR(sv)), SvPVX_const(sv)) : \
145 (const char*) sv_2pv_flags(sv, &lp, flags|SV_CONST_RETURN))
146
147__UNDEFINED__ SvPV_flags_const_nolen(sv, flags) \
148 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
149 ? SvPVX_const(sv) : \
150 (const char*) sv_2pv_flags(sv, 0, flags|SV_CONST_RETURN))
151
152__UNDEFINED__ SvPV_flags_mutable(sv, lp, flags) \
153 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
154 ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) : \
155 sv_2pv_flags(sv, &lp, flags|SV_MUTABLE_RETURN))
156
157__UNDEFINED__ SvPV_force(sv, lp) SvPV_force_flags(sv, lp, SV_GMAGIC)
158__UNDEFINED__ SvPV_force_nolen(sv) SvPV_force_flags_nolen(sv, SV_GMAGIC)
159__UNDEFINED__ SvPV_force_mutable(sv, lp) SvPV_force_flags_mutable(sv, lp, SV_GMAGIC)
160__UNDEFINED__ SvPV_force_nomg(sv, lp) SvPV_force_flags(sv, lp, 0)
161__UNDEFINED__ SvPV_force_nomg_nolen(sv) SvPV_force_flags_nolen(sv, 0)
162
163__UNDEFINED__ SvPV_force_flags(sv, lp, flags) \
164 ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \
165 ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvn_force_flags(sv, &lp, flags))
166
167__UNDEFINED__ SvPV_force_flags_nolen(sv, flags) \
168 ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \
169 ? SvPVX(sv) : sv_pvn_force_flags(sv, 0, flags))
170
171__UNDEFINED__ SvPV_force_flags_mutable(sv, lp, flags) \
172 ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \
173 ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) \
174 : sv_pvn_force_flags(sv, &lp, flags|SV_MUTABLE_RETURN))
175
176__UNDEFINED__ SvPV_nolen(sv) \
177 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
178 ? SvPVX(sv) : sv_2pv_flags(sv, 0, SV_GMAGIC))
179
180__UNDEFINED__ SvPV_nolen_const(sv) \
181 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
182 ? SvPVX_const(sv) : sv_2pv_flags(sv, 0, SV_GMAGIC|SV_CONST_RETURN))
183
184__UNDEFINED__ SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0)
185__UNDEFINED__ SvPV_nomg_const(sv, lp) SvPV_flags_const(sv, lp, 0)
186__UNDEFINED__ SvPV_nomg_const_nolen(sv) SvPV_flags_const_nolen(sv, 0)
187
adfe19db 188=xsinit
189
679ad62d 190#define NEED_sv_2pv_flags
191#define NEED_sv_pvn_force_flags
adfe19db 192#define NEED_sv_2pvbyte
193
194=xsubs
195
196IV
197SvPVbyte(sv)
198 SV *sv
199 PREINIT:
679ad62d 200 char *str;
adfe19db 201 STRLEN len;
adfe19db 202 CODE:
203 str = SvPVbyte(sv, len);
0d0f8426 204 RETVAL = strEQ(str, "mhx") ? (IV) len : (IV) -1;
adfe19db 205 OUTPUT:
206 RETVAL
207
208IV
209SvPV_nolen(sv)
210 SV *sv
211 PREINIT:
679ad62d 212 char *str;
adfe19db 213 CODE:
214 str = SvPV_nolen(sv);
9132e1a3 215 RETVAL = strEQ(str, "mhx") ? 42 : 0;
adfe19db 216 OUTPUT:
217 RETVAL
218
679ad62d 219IV
220SvPV_const(sv)
221 SV *sv
222 PREINIT:
223 const char *str;
224 STRLEN len;
225 CODE:
226 str = SvPV_const(sv, len);
227 RETVAL = len + (strEQ(str, "mhx") ? 40 : 0);
228 OUTPUT:
229 RETVAL
230
231IV
232SvPV_mutable(sv)
233 SV *sv
234 PREINIT:
235 char *str;
236 STRLEN len;
237 CODE:
238 str = SvPV_mutable(sv, len);
239 RETVAL = len + (strEQ(str, "mhx") ? 41 : 0);
240 OUTPUT:
241 RETVAL
242
243IV
244SvPV_flags(sv)
245 SV *sv
246 PREINIT:
247 char *str;
248 STRLEN len;
249 CODE:
250 str = SvPV_flags(sv, len, SV_GMAGIC);
251 RETVAL = len + (strEQ(str, "mhx") ? 42 : 0);
252 OUTPUT:
253 RETVAL
254
255IV
256SvPV_flags_const(sv)
257 SV *sv
258 PREINIT:
259 const char *str;
260 STRLEN len;
261 CODE:
262 str = SvPV_flags_const(sv, len, SV_GMAGIC);
263 RETVAL = len + (strEQ(str, "mhx") ? 43 : 0);
264 OUTPUT:
265 RETVAL
266
267IV
268SvPV_flags_const_nolen(sv)
269 SV *sv
270 PREINIT:
271 const char *str;
272 CODE:
273 str = SvPV_flags_const_nolen(sv, SV_GMAGIC);
274 RETVAL = strEQ(str, "mhx") ? 47 : 0;
275 OUTPUT:
276 RETVAL
277
278IV
279SvPV_flags_mutable(sv)
280 SV *sv
281 PREINIT:
282 char *str;
283 STRLEN len;
284 CODE:
285 str = SvPV_flags_mutable(sv, len, SV_GMAGIC);
286 RETVAL = len + (strEQ(str, "mhx") ? 45 : 0);
287 OUTPUT:
288 RETVAL
289
290IV
291SvPV_force(sv)
292 SV *sv
293 PREINIT:
294 char *str;
295 STRLEN len;
296 CODE:
297 str = SvPV_force(sv, len);
298 RETVAL = len + (strEQ(str, "mhx") ? 46 : 0);
299 OUTPUT:
300 RETVAL
301
302IV
303SvPV_force_nolen(sv)
304 SV *sv
305 PREINIT:
306 char *str;
307 CODE:
308 str = SvPV_force_nolen(sv);
309 RETVAL = strEQ(str, "mhx") ? 50 : 0;
310 OUTPUT:
311 RETVAL
312
313IV
314SvPV_force_mutable(sv)
315 SV *sv
316 PREINIT:
317 char *str;
318 STRLEN len;
319 CODE:
320 str = SvPV_force_mutable(sv, len);
321 RETVAL = len + (strEQ(str, "mhx") ? 48 : 0);
322 OUTPUT:
323 RETVAL
324
325IV
326SvPV_force_nomg(sv)
327 SV *sv
328 PREINIT:
329 char *str;
330 STRLEN len;
331 CODE:
332 str = SvPV_force_nomg(sv, len);
333 RETVAL = len + (strEQ(str, "mhx") ? 49 : 0);
334 OUTPUT:
335 RETVAL
336
337IV
338SvPV_force_nomg_nolen(sv)
339 SV *sv
340 PREINIT:
341 char *str;
342 CODE:
343 str = SvPV_force_nomg_nolen(sv);
344 RETVAL = strEQ(str, "mhx") ? 53 : 0;
345 OUTPUT:
346 RETVAL
347
348IV
349SvPV_force_flags(sv)
350 SV *sv
351 PREINIT:
352 char *str;
353 STRLEN len;
354 CODE:
355 str = SvPV_force_flags(sv, len, SV_GMAGIC);
356 RETVAL = len + (strEQ(str, "mhx") ? 51 : 0);
357 OUTPUT:
358 RETVAL
359
360IV
361SvPV_force_flags_nolen(sv)
362 SV *sv
363 PREINIT:
364 char *str;
365 CODE:
366 str = SvPV_force_flags_nolen(sv, SV_GMAGIC);
367 RETVAL = strEQ(str, "mhx") ? 55 : 0;
368 OUTPUT:
369 RETVAL
370
371IV
372SvPV_force_flags_mutable(sv)
373 SV *sv
374 PREINIT:
375 char *str;
376 STRLEN len;
377 CODE:
378 str = SvPV_force_flags_mutable(sv, len, SV_GMAGIC);
379 RETVAL = len + (strEQ(str, "mhx") ? 53 : 0);
380 OUTPUT:
381 RETVAL
382
383IV
384SvPV_nolen_const(sv)
385 SV *sv
386 PREINIT:
387 const char *str;
388 CODE:
389 str = SvPV_nolen_const(sv);
390 RETVAL = strEQ(str, "mhx") ? 57 : 0;
391 OUTPUT:
392 RETVAL
393
394IV
395SvPV_nomg(sv)
396 SV *sv
397 PREINIT:
398 char *str;
399 STRLEN len;
400 CODE:
401 str = SvPV_nomg(sv, len);
402 RETVAL = len + (strEQ(str, "mhx") ? 55 : 0);
403 OUTPUT:
404 RETVAL
405
406IV
407SvPV_nomg_const(sv)
408 SV *sv
409 PREINIT:
410 const char *str;
411 STRLEN len;
412 CODE:
413 str = SvPV_nomg_const(sv, len);
414 RETVAL = len + (strEQ(str, "mhx") ? 56 : 0);
415 OUTPUT:
416 RETVAL
417
418IV
419SvPV_nomg_const_nolen(sv)
420 SV *sv
421 PREINIT:
422 const char *str;
423 CODE:
424 str = SvPV_nomg_const_nolen(sv);
425 RETVAL = strEQ(str, "mhx") ? 60 : 0;
426 OUTPUT:
427 RETVAL
428
429
430=tests plan => 20
431
432my $mhx = "mhx";
433
434ok(&Devel::PPPort::SvPVbyte($mhx), 3);
435
436my $i = 42;
437
438ok(&Devel::PPPort::SvPV_nolen($mhx), $i++);
439ok(&Devel::PPPort::SvPV_const($mhx), $i++);
440ok(&Devel::PPPort::SvPV_mutable($mhx), $i++);
441ok(&Devel::PPPort::SvPV_flags($mhx), $i++);
442ok(&Devel::PPPort::SvPV_flags_const($mhx), $i++);
443
444ok(&Devel::PPPort::SvPV_flags_const_nolen($mhx), $i++);
445ok(&Devel::PPPort::SvPV_flags_mutable($mhx), $i++);
446ok(&Devel::PPPort::SvPV_force($mhx), $i++);
447ok(&Devel::PPPort::SvPV_force_nolen($mhx), $i++);
448ok(&Devel::PPPort::SvPV_force_mutable($mhx), $i++);
449
450ok(&Devel::PPPort::SvPV_force_nomg($mhx), $i++);
451ok(&Devel::PPPort::SvPV_force_nomg_nolen($mhx), $i++);
452ok(&Devel::PPPort::SvPV_force_flags($mhx), $i++);
453ok(&Devel::PPPort::SvPV_force_flags_nolen($mhx), $i++);
454ok(&Devel::PPPort::SvPV_force_flags_mutable($mhx), $i++);
adfe19db 455
679ad62d 456ok(&Devel::PPPort::SvPV_nolen_const($mhx), $i++);
457ok(&Devel::PPPort::SvPV_nomg($mhx), $i++);
458ok(&Devel::PPPort::SvPV_nomg_const($mhx), $i++);
459ok(&Devel::PPPort::SvPV_nomg_const_nolen($mhx), $i++);
adfe19db 460