1 ################################################################################
5 ## $Date: 2010/03/07 13:15:44 +0100 $
7 ################################################################################
9 ## Version 3.x, Copyright (C) 2004-2010, 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 ################################################################################
25 #if { VERSION < 5.6.0 }
26 # define D_PPP_CONSTPV_ARG(x) ((char *) (x))
28 # define D_PPP_CONSTPV_ARG(x) (x)
31 __UNDEFINED__ newSVpvn(data,len) ((data) \
32 ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \
35 __UNDEFINED__ newSVpvn_utf8(s, len, u) newSVpvn_flags((s), (len), (u) ? SVf_UTF8 : 0)
37 __UNDEFINED__ SVf_UTF8 0
39 #ifndef newSVpvn_flags
41 #if { NEED newSVpvn_flags }
44 newSVpvn_flags(pTHX_ const char *s, STRLEN len, U32 flags)
46 SV *sv = newSVpvn(D_PPP_CONSTPV_ARG(s), len);
47 SvFLAGS(sv) |= (flags & SVf_UTF8);
48 return (flags & SVs_TEMP) ? sv_2mortal(sv) : sv;
57 #define NEED_newSVpvn_flags
64 mXPUSHs(newSVpvn("test", 4));
65 mXPUSHs(newSVpvn("test", 2));
66 mXPUSHs(newSVpvn("test", 0));
67 mXPUSHs(newSVpvn(NULL, 2));
68 mXPUSHs(newSVpvn(NULL, 0));
74 XPUSHs(newSVpvn_flags("test", 4, SVs_TEMP));
75 XPUSHs(newSVpvn_flags("test", 2, SVs_TEMP));
76 XPUSHs(newSVpvn_flags("test", 0, SVs_TEMP));
77 XPUSHs(newSVpvn_flags(NULL, 2, SVs_TEMP));
78 XPUSHs(newSVpvn_flags(NULL, 0, SVs_TEMP));
84 XPUSHs(newSVpvn_flags("test", 4, SVs_TEMP|SVf_UTF8));
89 my @s = &Devel::PPPort::newSVpvn();
97 @s = &Devel::PPPort::newSVpvn_flags();
105 @s = &Devel::PPPort::newSVpvn_utf8();
109 if ($] >= 5.008001) {
111 ok(utf8::is_utf8($s[0]));
114 skip("skip: no is_utf8()", 0);