1 ################################################################################
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.
7 ## This program is free software; you can redistribute it and/or
8 ## modify it under the same terms as Perl itself.
10 ################################################################################
19 sv_catpvf_mg_nocontext
23 sv_setpvf_mg_nocontext
28 #if { VERSION >= 5.004 } && !defined(vnewSVpvf)
29 #if { NEED vnewSVpvf }
32 vnewSVpvf(pTHX_ const char *pat, va_list *args)
34 register SV *sv = newSV(0);
35 sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*));
42 #if { VERSION >= 5.004 } && !defined(sv_vcatpvf)
43 # define sv_vcatpvf(sv, pat, args) sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
46 #if { VERSION >= 5.004 } && !defined(sv_vsetpvf)
47 # define sv_vsetpvf(sv, pat, args) sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
50 #if { VERSION >= 5.004 } && !defined(sv_catpvf_mg)
51 #if { NEED sv_catpvf_mg }
54 sv_catpvf_mg(pTHX_ SV *sv, const char *pat, ...)
58 sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
66 #ifdef PERL_IMPLICIT_CONTEXT
67 #if { VERSION >= 5.004 } && !defined(sv_catpvf_mg_nocontext)
68 #if { NEED sv_catpvf_mg_nocontext }
71 sv_catpvf_mg_nocontext(SV *sv, const char *pat, ...)
76 sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
85 /* sv_catpvf_mg depends on sv_catpvf_mg_nocontext */
87 # ifdef PERL_IMPLICIT_CONTEXT
88 # define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext
90 # define sv_catpvf_mg Perl_sv_catpvf_mg
94 #if { VERSION >= 5.004 } && !defined(sv_vcatpvf_mg)
95 # define sv_vcatpvf_mg(sv, pat, args) \
97 sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \
102 #if { VERSION >= 5.004 } && !defined(sv_setpvf_mg)
103 #if { NEED sv_setpvf_mg }
106 sv_setpvf_mg(pTHX_ SV *sv, const char *pat, ...)
110 sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
118 #ifdef PERL_IMPLICIT_CONTEXT
119 #if { VERSION >= 5.004 } && !defined(sv_setpvf_mg_nocontext)
120 #if { NEED sv_setpvf_mg_nocontext }
123 sv_setpvf_mg_nocontext(SV *sv, const char *pat, ...)
128 sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
137 /* sv_setpvf_mg depends on sv_setpvf_mg_nocontext */
139 # ifdef PERL_IMPLICIT_CONTEXT
140 # define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext
142 # define sv_setpvf_mg Perl_sv_setpvf_mg
146 #if { VERSION >= 5.004 } && !defined(sv_vsetpvf_mg)
147 # define sv_vsetpvf_mg(sv, pat, args) \
149 sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \
156 #define NEED_vnewSVpvf
157 #define NEED_sv_catpvf_mg
158 #define NEED_sv_catpvf_mg_nocontext
159 #define NEED_sv_setpvf_mg
160 #define NEED_sv_setpvf_mg_nocontext
164 static SV * test_vnewSVpvf(pTHX_ const char *pat, ...)
169 #if { VERSION >= 5.004 }
170 sv = vnewSVpvf(pat, &args);
172 sv = newSVpv((char *) pat, 0);
178 static void test_sv_vcatpvf(pTHX_ SV *sv, const char *pat, ...)
182 #if { VERSION >= 5.004 }
183 sv_vcatpvf(sv, pat, &args);
185 sv_catpv(sv, (char *) pat);
190 static void test_sv_vsetpvf(pTHX_ SV *sv, const char *pat, ...)
194 #if { VERSION >= 5.004 }
195 sv_vsetpvf(sv, pat, &args);
197 sv_setpv(sv, (char *) pat);
207 RETVAL = test_vnewSVpvf(aTHX_ "%s-%d", "Perl", 42);
215 RETVAL = newSVsv(sv);
216 test_sv_vcatpvf(aTHX_ RETVAL, "%s-%d", "Perl", 42);
224 RETVAL = newSVsv(sv);
225 test_sv_vsetpvf(aTHX_ RETVAL, "%s-%d", "Perl", 42);
233 #if { VERSION >= 5.004 }
234 sv_catpvf_mg(sv, "%s-%d", "Perl", 42);
238 Perl_sv_catpvf_mg(sv)
241 #if { VERSION >= 5.004 }
242 Perl_sv_catpvf_mg(aTHX_ sv, "%s-%d", "-Perl", 43);
246 sv_catpvf_mg_nocontext(sv)
249 #if { VERSION >= 5.004 }
250 #ifdef PERL_IMPLICIT_CONTEXT
251 sv_catpvf_mg_nocontext(sv, "%s-%d", "-Perl", 44);
253 sv_catpvf_mg(sv, "%s-%d", "-Perl", 44);
261 #if { VERSION >= 5.004 }
262 sv_setpvf_mg(sv, "%s-%d", "mhx", 42);
266 Perl_sv_setpvf_mg(sv)
269 #if { VERSION >= 5.004 }
270 Perl_sv_setpvf_mg(aTHX_ sv, "%s-%d", "foo", 43);
274 sv_setpvf_mg_nocontext(sv)
277 #if { VERSION >= 5.004 }
278 #ifdef PERL_IMPLICIT_CONTEXT
279 sv_setpvf_mg_nocontext(sv, "%s-%d", "bar", 44);
281 sv_setpvf_mg(sv, "%s-%d", "bar", 44);
289 tie %h, 'Tie::StdHash';
293 ok(&Devel::PPPort::vnewSVpvf(), "$]" >= 5.004 ? 'Perl-42' : '%s-%d');
294 ok(&Devel::PPPort::sv_vcatpvf('1-2-3-'), "$]" >= 5.004 ? '1-2-3-Perl-42' : '1-2-3-%s-%d');
295 ok(&Devel::PPPort::sv_vsetpvf('1-2-3-'), "$]" >= 5.004 ? 'Perl-42' : '%s-%d');
297 &Devel::PPPort::sv_catpvf_mg($h{foo});
298 ok($h{foo}, "$]" >= 5.004 ? 'foo-Perl-42' : 'foo-');
300 &Devel::PPPort::Perl_sv_catpvf_mg($h{foo});
301 ok($h{foo}, "$]" >= 5.004 ? 'foo-Perl-42-Perl-43' : 'foo-');
303 &Devel::PPPort::sv_catpvf_mg_nocontext($h{foo});
304 ok($h{foo}, "$]" >= 5.004 ? 'foo-Perl-42-Perl-43-Perl-44' : 'foo-');
306 &Devel::PPPort::sv_setpvf_mg($h{bar});
307 ok($h{bar}, "$]" >= 5.004 ? 'mhx-42' : '');
309 &Devel::PPPort::Perl_sv_setpvf_mg($h{bar});
310 ok($h{bar}, "$]" >= 5.004 ? 'foo-43' : '');
312 &Devel::PPPort::sv_setpvf_mg_nocontext($h{bar});
313 ok($h{bar}, "$]" >= 5.004 ? 'bar-44' : '');