1################################################################################
2##
3##  Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz.
4##  Version 2.x, Copyright (C) 2001, Paul Marquess.
5##  Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
6##
7##  This program is free software; you can redistribute it and/or
8##  modify it under the same terms as Perl itself.
9##
10################################################################################
11
12=provides
13
14__UNDEFINED__
15SvPVbyte
16sv_2pvbyte
17sv_2pv
18sv_2pv_flags
19sv_pvn_force_flags
20
21=implementation
22
23/* Hint: sv_2pv_nolen
24 * Use the SvPV_nolen() or SvPV_nolen_const() macros instead of sv_2pv_nolen().
25 */
26
27__UNDEFINED__  sv_2pv_nolen(sv)   SvPV_nolen(sv)
28
29#ifdef SvPVbyte
30
31/* Hint: SvPVbyte
32 * Does not work in perl-5.6.1, ppport.h implements a version
33 * borrowed from perl-5.7.3.
34 */
35
36#if { VERSION < 5.7.0 }
37
38__UNDEFINED__ sv_2pvbyte(sv, lp) (sv_utf8_downgrade((sv), 0), SvPV((sv), *(lp)))
39
40/* Hint: sv_2pvbyte
41 * Use the SvPVbyte() macro instead of sv_2pvbyte().
42 */
43
44/* Replace sv_2pvbyte with SvPVbyte */
45
46#undef SvPVbyte
47
48#define SvPVbyte(sv, lp)                                                \
49        ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK)                \
50         ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp))
51
52#endif
53
54#else
55
56#  define SvPVbyte          SvPV
57#  define sv_2pvbyte        sv_2pv
58
59#endif
60
61__UNDEFINED__  sv_2pvbyte_nolen(sv)  sv_2pv_nolen(sv)
62
63/* Hint: sv_pvn
64 * Always use the SvPV() macro instead of sv_pvn().
65 */
66
67/* Replace sv_pvn with SvPV */
68
69/* Hint: sv_pvn_force
70 * Always use the SvPV_force() macro instead of sv_pvn_force().
71 */
72
73/* Replace sv_pvn_force with SvPV_force */
74
75/* If these are undefined, they're not handled by the core anyway */
76__UNDEFINED__  SV_IMMEDIATE_UNREF       0
77__UNDEFINED__  SV_GMAGIC                0
78__UNDEFINED__  SV_COW_DROP_PV           0
79__UNDEFINED__  SV_UTF8_NO_ENCODING      0
80__UNDEFINED__  SV_CONST_RETURN          0
81__UNDEFINED__  SV_MUTABLE_RETURN        0
82__UNDEFINED__  SV_SMAGIC                0
83__UNDEFINED__  SV_HAS_TRAILING_NUL      0
84__UNDEFINED__  SV_COW_SHARED_HASH_KEYS  0
85
86#if { VERSION < 5.7.2 }
87#
88/* Fix sv_2pv for Perl < 5.7.2 - view https://github.com/Dual-Life/Devel-PPPort/issues/231 */
89
90# ifdef sv_2pv
91#  undef sv_2pv
92# endif
93
94# if defined(PERL_USE_GCC_BRACE_GROUPS)
95  __UNDEFINED__ sv_2pv(sv, lp) ({ SV *_sv_2pv = (sv); STRLEN sv_2pv_dummy_; STRLEN *_lp_2pv = (lp); _lp_2pv = _lp_2pv ? : &sv_2pv_dummy_; SvPOKp(_sv_2pv) ? ((*(_lp_2pv) = SvCUR(_sv_2pv)), SvPVX(_sv_2pv)) : Perl_sv_2pv(aTHX_ _sv_2pv, (_lp_2pv)); })
96# else
97  __UNDEFINED__ sv_2pv(sv, lp) (SvPOKp(sv) ? ((*((lp) ? (lp) : &PL_na) = SvCUR(sv)), SvPVX(sv)) : Perl_sv_2pv(aTHX_ (sv), (lp)))
98# endif
99
100#endif
101
102#if { VERSION < 5.7.2 }
103
104/* Define sv_2pv_flags for Perl < 5.7.2 which does not have it at all */
105
106#if defined(PERL_USE_GCC_BRACE_GROUPS)
107  __UNDEFINED__ sv_2pv_flags(sv, lp, flags) ({ SV *_sv = (sv); STRLEN sv_2pv_dummy_; const I32 _flags = (flags); STRLEN *_lp = lp; _lp = _lp ? : &sv_2pv_dummy_; (!(_flags & SV_GMAGIC) && SvGMAGICAL(_sv)) ? ({ char *_pv; SvGMAGICAL_off(_sv); _pv = sv_2pv(_sv, _lp); SvGMAGICAL_on(_sv); _pv; }) : sv_2pv(_sv, _lp); })
108  __UNDEFINED__ sv_pvn_force_flags(sv, lp, flags) ({ SV *_sv = (sv); STRLEN sv_2pv_dummy_; const I32 _flags = (flags); STRLEN *_lp = lp; _lp = _lp ? : &sv_2pv_dummy_; (!(_flags & SV_GMAGIC) && SvGMAGICAL(_sv)) ? ({ char *_pv; SvGMAGICAL_off(_sv); _pv = sv_pvn_force(_sv, _lp); SvGMAGICAL_on(_sv); _pv; }) : sv_pvn_force(_sv, _lp); })
109#else
110  __UNDEFINED__ sv_2pv_flags(sv, lp, flags) ((PL_Sv = (sv)), (!((flags) & SV_GMAGIC) && SvGMAGICAL(PL_Sv)) ? (SvGMAGICAL_off(PL_Sv), (PL_Xpv = (XPV *)sv_2pv(PL_Sv, (lp) ? (lp) : &PL_na)), SvGMAGICAL_on(PL_Sv), (char *)PL_Xpv) : sv_2pv(PL_Sv, (lp) ? (lp) : &PL_na))
111  __UNDEFINED__ sv_pvn_force_flags(sv, lp, flags) ((PL_Sv = (sv)), (!((flags) & SV_GMAGIC) && SvGMAGICAL(PL_Sv)) ? (SvGMAGICAL_off(PL_Sv), (PL_Xpv = (XPV *)sv_pvn_force(PL_Sv, (lp) ? (lp) : &PL_na)), SvGMAGICAL_on(PL_Sv), (char *)PL_Xpv) : sv_pvn_force(PL_Sv, (lp) ? (lp) : &PL_na))
112#endif
113
114#elif { VERSION < 5.17.2 }
115
116/* Fix sv_2pv_flags for Perl < 5.17.2 */
117
118# ifdef sv_2pv_flags
119#  undef sv_2pv_flags
120# endif
121
122# if defined(PERL_USE_GCC_BRACE_GROUPS)
123  __UNDEFINED__ sv_2pv_flags(sv, lp, flags) ({ SV *_sv_2pv = (sv); STRLEN sv_2pv_dummy_; const I32 _flags_2pv = (flags); STRLEN *_lp_2pv = (lp); _lp_2pv = _lp_2pv ? : &sv_2pv_dummy_; ((!(_flags_2pv & SV_GMAGIC) || !SvGMAGICAL(_sv_2pv)) && SvPOKp(_sv_2pv)) ? ((*(_lp_2pv) = SvCUR(_sv_2pv)), SvPVX(_sv_2pv)) : Perl_sv_2pv_flags(aTHX_ _sv_2pv, (_lp_2pv), (_flags_2pv)); })
124# else
125  __UNDEFINED__ sv_2pv_flags(sv, lp, flags) (((!((flags) & SV_GMAGIC) || !SvGMAGICAL(sv)) && SvPOKp(sv)) ? ((*((lp) ? (lp) : &PL_na) = SvCUR(sv)), SvPVX(sv)) : Perl_sv_2pv_flags(aTHX_ (sv), (lp), (flags)))
126# endif
127
128#endif
129
130#if { VERSION < 5.8.8 } || ( { VERSION >= 5.9.0 } && { VERSION < 5.9.3 } )
131# define D_PPP_SVPV_NOLEN_LP_ARG &PL_na
132#else
133# define D_PPP_SVPV_NOLEN_LP_ARG 0
134#endif
135
136__UNDEFINED__  SvPV_const(sv, lp)      SvPV_flags_const(sv, lp, SV_GMAGIC)
137__UNDEFINED__  SvPV_mutable(sv, lp)    SvPV_flags_mutable(sv, lp, SV_GMAGIC)
138
139__UNDEFINED__  SvPV_flags(sv, lp, flags) \
140                 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
141                  ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pv_flags(sv, &lp, flags))
142
143__UNDEFINED__  SvPV_flags_const(sv, lp, flags) \
144                 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
145                  ? ((lp = SvCUR(sv)), SvPVX_const(sv)) : \
146                  (const char*) sv_2pv_flags(sv, &lp, flags|SV_CONST_RETURN))
147
148__UNDEFINED__  SvPV_flags_const_nolen(sv, flags) \
149                 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
150                  ? SvPVX_const(sv) : \
151                  (const char*) sv_2pv_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, flags|SV_CONST_RETURN))
152
153__UNDEFINED__  SvPV_flags_mutable(sv, lp, flags) \
154                 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
155                  ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) : \
156                  sv_2pv_flags(sv, &lp, flags|SV_MUTABLE_RETURN))
157
158__UNDEFINED__  SvPV_force(sv, lp) SvPV_force_flags(sv, lp, SV_GMAGIC)
159__UNDEFINED__  SvPV_force_nolen(sv) SvPV_force_flags_nolen(sv, SV_GMAGIC)
160__UNDEFINED__  SvPV_force_mutable(sv, lp) SvPV_force_flags_mutable(sv, lp, SV_GMAGIC)
161__UNDEFINED__  SvPV_force_nomg(sv, lp) SvPV_force_flags(sv, lp, 0)
162__UNDEFINED__  SvPV_force_nomg_nolen(sv) SvPV_force_flags_nolen(sv, 0)
163
164__UNDEFINED__  SvPV_force_flags(sv, lp, flags) \
165                 ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \
166                 ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvn_force_flags(sv, &lp, flags))
167
168__UNDEFINED__  SvPV_force_flags_nolen(sv, flags) \
169                 ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \
170                 ? SvPVX(sv) : sv_pvn_force_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, flags))
171
172__UNDEFINED__  SvPV_force_flags_mutable(sv, lp, flags) \
173                 ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \
174                 ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) \
175                  : sv_pvn_force_flags(sv, &lp, flags|SV_MUTABLE_RETURN))
176
177__UNDEFINED__  SvPV_nolen(sv) \
178                 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
179                  ? SvPVX(sv) : sv_2pv_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC))
180
181__UNDEFINED__  SvPV_nolen_const(sv) \
182                 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
183                  ? SvPVX_const(sv) : sv_2pv_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC|SV_CONST_RETURN))
184#  if defined(PERL_USE_GCC_BRACE_GROUPS)
185__UNDEFINED__  SvPVx_nolen_const(sv) ({SV *sV_ = (sv); SvPV_nolen_const(sV_); })
186#  else
187__UNDEFINED__  SvPVx_nolen_const(sv)  (PL_Sv = sv, SvPV_nolen_const(PL_Sv))
188#  endif
189
190__UNDEFINED__  SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0)
191__UNDEFINED__  SvPV_nomg_const(sv, lp) SvPV_flags_const(sv, lp, 0)
192__UNDEFINED__  SvPV_nomg_const_nolen(sv) SvPV_flags_const_nolen(sv, 0)
193__UNDEFINED__  SvPV_nomg_nolen(sv) ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
194                                    ? SvPVX(sv) : sv_2pv_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, 0))
195
196__UNDEFINED__  SvPV_renew(sv,n) STMT_START { SvLEN_set(sv, n); \
197                 SvPV_set((sv), (char *) saferealloc(          \
198                       (Malloc_t)SvPVX(sv), (MEM_SIZE)((n)))); \
199               } STMT_END
200
201__UNDEFINED__  SvPVCLEAR(sv) sv_setpvs((sv), "")
202
203=xsubs
204
205IV
206SvPVbyte(sv)
207        SV *sv
208        PREINIT:
209                char *str;
210                STRLEN len;
211        CODE:
212                str = SvPVbyte(sv, len);
213                RETVAL = strEQ(str, "mhx") ? (IV) len : (IV) -1;
214        OUTPUT:
215                RETVAL
216
217IV
218SvPV_nolen(sv)
219        SV *sv
220        PREINIT:
221                char *str;
222        CODE:
223                str = SvPV_nolen(sv);
224                RETVAL = strEQ(str, "mhx") ? 42 : 0;
225        OUTPUT:
226                RETVAL
227
228IV
229SvPV_const(sv)
230        SV *sv
231        PREINIT:
232                const char *str;
233                STRLEN len;
234        CODE:
235                str = SvPV_const(sv, len);
236                RETVAL = len + (strEQ(str, "mhx") ? 40 : 0);
237        OUTPUT:
238                RETVAL
239
240IV
241SvPV_mutable(sv)
242        SV *sv
243        PREINIT:
244                char *str;
245                STRLEN len;
246        CODE:
247                str = SvPV_mutable(sv, len);
248                RETVAL = len + (strEQ(str, "mhx") ? 41 : 0);
249        OUTPUT:
250                RETVAL
251
252IV
253SvPV_flags(sv)
254        SV *sv
255        PREINIT:
256                char *str;
257                STRLEN len;
258        CODE:
259                str = SvPV_flags(sv, len, SV_GMAGIC);
260                RETVAL = len + (strEQ(str, "mhx") ? 42 : 0);
261        OUTPUT:
262                RETVAL
263
264IV
265SvPV_flags_const(sv)
266        SV *sv
267        PREINIT:
268                const char *str;
269                STRLEN len;
270        CODE:
271                str = SvPV_flags_const(sv, len, SV_GMAGIC);
272                RETVAL = len + (strEQ(str, "mhx") ? 43 : 0);
273        OUTPUT:
274                RETVAL
275
276IV
277SvPV_flags_const_nolen(sv)
278        SV *sv
279        PREINIT:
280                const char *str;
281        CODE:
282                str = SvPV_flags_const_nolen(sv, SV_GMAGIC);
283                RETVAL = strEQ(str, "mhx") ? 47 : 0;
284        OUTPUT:
285                RETVAL
286
287IV
288SvPV_flags_mutable(sv)
289        SV *sv
290        PREINIT:
291                char *str;
292                STRLEN len;
293        CODE:
294                str = SvPV_flags_mutable(sv, len, SV_GMAGIC);
295                RETVAL = len + (strEQ(str, "mhx") ? 45 : 0);
296        OUTPUT:
297                RETVAL
298
299IV
300SvPV_force(sv)
301        SV *sv
302        PREINIT:
303                char *str;
304                STRLEN len;
305        CODE:
306                str = SvPV_force(sv, len);
307                RETVAL = len + (strEQ(str, "mhx") ? 46 : 0);
308        OUTPUT:
309                RETVAL
310
311IV
312SvPV_force_nolen(sv)
313        SV *sv
314        PREINIT:
315                char *str;
316        CODE:
317                str = SvPV_force_nolen(sv);
318                RETVAL = strEQ(str, "mhx") ? 50 : 0;
319        OUTPUT:
320                RETVAL
321
322IV
323SvPV_force_mutable(sv)
324        SV *sv
325        PREINIT:
326                char *str;
327                STRLEN len;
328        CODE:
329                str = SvPV_force_mutable(sv, len);
330                RETVAL = len + (strEQ(str, "mhx") ? 48 : 0);
331        OUTPUT:
332                RETVAL
333
334IV
335SvPV_force_nomg(sv)
336        SV *sv
337        PREINIT:
338                char *str;
339                STRLEN len;
340        CODE:
341                str = SvPV_force_nomg(sv, len);
342                RETVAL = len + (strEQ(str, "mhx") ? 49 : 0);
343        OUTPUT:
344                RETVAL
345
346IV
347SvPV_force_nomg_nolen(sv)
348        SV *sv
349        PREINIT:
350                char *str;
351        CODE:
352                str = SvPV_force_nomg_nolen(sv);
353                RETVAL = strEQ(str, "mhx") ? 53 : 0;
354        OUTPUT:
355                RETVAL
356
357IV
358SvPV_force_flags(sv)
359        SV *sv
360        PREINIT:
361                char *str;
362                STRLEN len;
363        CODE:
364                str = SvPV_force_flags(sv, len, SV_GMAGIC);
365                RETVAL = len + (strEQ(str, "mhx") ? 51 : 0);
366        OUTPUT:
367                RETVAL
368
369IV
370SvPV_force_flags_nolen(sv)
371        SV *sv
372        PREINIT:
373                char *str;
374        CODE:
375                str = SvPV_force_flags_nolen(sv, SV_GMAGIC);
376                RETVAL = strEQ(str, "mhx") ? 55 : 0;
377        OUTPUT:
378                RETVAL
379
380IV
381SvPV_force_flags_mutable(sv)
382        SV *sv
383        PREINIT:
384                char *str;
385                STRLEN len;
386        CODE:
387                str = SvPV_force_flags_mutable(sv, len, SV_GMAGIC);
388                RETVAL = len + (strEQ(str, "mhx") ? 53 : 0);
389        OUTPUT:
390                RETVAL
391
392IV
393SvPV_nolen_const(sv)
394        SV *sv
395        PREINIT:
396                const char *str;
397        CODE:
398                str = SvPV_nolen_const(sv);
399                RETVAL = strEQ(str, "mhx") ? 57 : 0;
400        OUTPUT:
401                RETVAL
402
403IV
404SvPV_nomg(sv)
405        SV *sv
406        PREINIT:
407                char *str;
408                STRLEN len;
409        CODE:
410                str = SvPV_nomg(sv, len);
411                RETVAL = len + (strEQ(str, "mhx") ? 55 : 0);
412        OUTPUT:
413                RETVAL
414
415IV
416SvPV_nomg_const(sv)
417        SV *sv
418        PREINIT:
419                const char *str;
420                STRLEN len;
421        CODE:
422                str = SvPV_nomg_const(sv, len);
423                RETVAL = len + (strEQ(str, "mhx") ? 56 : 0);
424        OUTPUT:
425                RETVAL
426
427IV
428SvPV_nomg_const_nolen(sv)
429        SV *sv
430        PREINIT:
431                const char *str;
432        CODE:
433                str = SvPV_nomg_const_nolen(sv);
434                RETVAL = strEQ(str, "mhx") ? 60 : 0;
435        OUTPUT:
436                RETVAL
437
438IV
439SvPV_nomg_nolen(sv)
440        SV *sv
441        PREINIT:
442                char *str;
443        CODE:
444                str = SvPV_nomg_nolen(sv);
445                RETVAL = strEQ(str, "mhx") ? 61 : 0;
446        OUTPUT:
447                RETVAL
448
449void
450SvPV_renew(sv, nlen, insv)
451        SV *sv
452        STRLEN nlen
453        SV *insv
454        PREINIT:
455                STRLEN slen;
456                const char *str;
457        PPCODE:
458                str = SvPV_const(insv, slen);
459                XPUSHs(sv);
460                mXPUSHi(SvLEN(sv));
461                SvPV_renew(sv, nlen);
462                Copy(str, SvPVX(sv), slen + 1, char);
463                SvCUR_set(sv, slen);
464                mXPUSHi(SvLEN(sv));
465
466void
467SvPVCLEAR(sv)
468        SV *sv
469        CODE:
470                SvPVCLEAR(sv);
471
472
473SV *
474sv_2pv(sv)
475        SV *sv
476        PREINIT:
477                STRLEN len;
478                const char *str;
479        CODE:
480                str = sv_2pv(sv, &len);
481                RETVAL = newSVpvn(str, len);
482        OUTPUT:
483                RETVAL
484
485
486=tests plan => 53
487
488my $mhx = "mhx";
489
490is(&Devel::PPPort::SvPVbyte($mhx), 3);
491
492my $i = 42;
493
494is(&Devel::PPPort::SvPV_nolen($mhx), $i++);
495is(&Devel::PPPort::SvPV_const($mhx), $i++);
496is(&Devel::PPPort::SvPV_mutable($mhx), $i++);
497is(&Devel::PPPort::SvPV_flags($mhx), $i++);
498is(&Devel::PPPort::SvPV_flags_const($mhx), $i++);
499
500is(&Devel::PPPort::SvPV_flags_const_nolen($mhx), $i++);
501is(&Devel::PPPort::SvPV_flags_mutable($mhx), $i++);
502is(&Devel::PPPort::SvPV_force($mhx), $i++);
503is(&Devel::PPPort::SvPV_force_nolen($mhx), $i++);
504is(&Devel::PPPort::SvPV_force_mutable($mhx), $i++);
505
506is(&Devel::PPPort::SvPV_force_nomg($mhx), $i++);
507is(&Devel::PPPort::SvPV_force_nomg_nolen($mhx), $i++);
508is(&Devel::PPPort::SvPV_force_flags($mhx), $i++);
509is(&Devel::PPPort::SvPV_force_flags_nolen($mhx), $i++);
510is(&Devel::PPPort::SvPV_force_flags_mutable($mhx), $i++);
511
512is(&Devel::PPPort::SvPV_nolen_const($mhx), $i++);
513is(&Devel::PPPort::SvPV_nomg($mhx), $i++);
514is(&Devel::PPPort::SvPV_nomg_const($mhx), $i++);
515is(&Devel::PPPort::SvPV_nomg_const_nolen($mhx), $i++);
516is(&Devel::PPPort::SvPV_nomg_nolen($mhx), $i++);
517
518$mhx = 42; is(&Devel::PPPort::SvPV_nolen($mhx), 0);
519$mhx = 42; is(&Devel::PPPort::SvPV_const($mhx), 2);
520$mhx = 42; is(&Devel::PPPort::SvPV_mutable($mhx), 2);
521$mhx = 42; is(&Devel::PPPort::SvPV_flags($mhx), 2);
522$mhx = 42; is(&Devel::PPPort::SvPV_flags_const($mhx), 2);
523
524$mhx = 42; is(&Devel::PPPort::SvPV_flags_const_nolen($mhx), 0);
525$mhx = 42; is(&Devel::PPPort::SvPV_flags_mutable($mhx), 2);
526$mhx = 42; is(&Devel::PPPort::SvPV_force($mhx), 2);
527$mhx = 42; is(&Devel::PPPort::SvPV_force_nolen($mhx), 0);
528$mhx = 42; is(&Devel::PPPort::SvPV_force_mutable($mhx), 2);
529
530$mhx = 42; is(&Devel::PPPort::SvPV_force_nomg($mhx), 2);
531$mhx = 42; is(&Devel::PPPort::SvPV_force_nomg_nolen($mhx), 0);
532$mhx = 42; is(&Devel::PPPort::SvPV_force_flags($mhx), 2);
533$mhx = 42; is(&Devel::PPPort::SvPV_force_flags_nolen($mhx), 0);
534$mhx = 42; is(&Devel::PPPort::SvPV_force_flags_mutable($mhx), 2);
535
536$mhx = 42; is(&Devel::PPPort::SvPV_nolen_const($mhx), 0);
537$mhx = 42; is(&Devel::PPPort::SvPV_nomg($mhx), 2);
538$mhx = 42; is(&Devel::PPPort::SvPV_nomg_const($mhx), 2);
539$mhx = 42; is(&Devel::PPPort::SvPV_nomg_const_nolen($mhx), 0);
540$mhx = 42; is(&Devel::PPPort::SvPV_nomg_nolen($mhx), 0);
541
542&Devel::PPPort::SvPVCLEAR($mhx);
543is($mhx, "");
544
545my $str = "";
546&Devel::PPPort::SvPV_force($str);
547my($s2, $before, $after) = &Devel::PPPort::SvPV_renew($str, 81, "x"x80);
548is($str, "x"x80);
549is($s2, "x"x80);
550ok($before < 81);
551is($after, 81);
552
553$str = "x"x400;
554&Devel::PPPort::SvPV_force($str);
555($s2, $before, $after) = &Devel::PPPort::SvPV_renew($str, 41, "x"x40);
556is($str, "x"x40);
557is($s2, "x"x40);
558ok($before > 41);
559is($after, 41);
560
561is(&Devel::PPPort::sv_2pv(42), "42");
562is(&Devel::PPPort::sv_2pv(0.15), "0.15");
563is(&Devel::PPPort::sv_2pv("string"), "string");
564