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 defined(PERL_USE_GCC_BRACE_GROUPS)
30 # define vnewSVpvf(pat, args) ({ SV *_sv = newSV(0); sv_vsetpvfn(_sv, (pat), strlen((pat)), (args), Null(SV**), 0, Null(bool*)); _sv; })
32 # define vnewSVpvf(pat, args) ((PL_Sv = newSV(0)), sv_vsetpvfn(PL_Sv, (pat), strlen((pat)), (args), Null(SV**), 0, Null(bool*)), PL_Sv)
36 #if { VERSION >= 5.004 } && !defined(sv_vcatpvf)
37 # define sv_vcatpvf(sv, pat, args) sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
40 #if { VERSION >= 5.004 } && !defined(sv_vsetpvf)
41 # define sv_vsetpvf(sv, pat, args) sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
44 #if { VERSION >= 5.004 } && !defined(sv_catpvf_mg)
45 #if { NEED sv_catpvf_mg }
48 sv_catpvf_mg(pTHX_ SV * const sv, const char * const pat, ...)
52 sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
60 #ifdef PERL_IMPLICIT_CONTEXT
61 #if { VERSION >= 5.004 } && !defined(sv_catpvf_mg_nocontext)
62 #if { NEED sv_catpvf_mg_nocontext }
65 sv_catpvf_mg_nocontext(SV * const sv, const char * const pat, ...)
70 sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
79 /* sv_catpvf_mg depends on sv_catpvf_mg_nocontext */
81 # ifdef PERL_IMPLICIT_CONTEXT
82 # define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext
84 # define sv_catpvf_mg Perl_sv_catpvf_mg
88 #if { VERSION >= 5.004 } && !defined(sv_vcatpvf_mg)
89 # define sv_vcatpvf_mg(sv, pat, args) \
91 sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \
96 #if { VERSION >= 5.004 } && !defined(sv_setpvf_mg)
97 #if { NEED sv_setpvf_mg }
100 sv_setpvf_mg(pTHX_ SV * const sv, const char * const pat, ...)
104 sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
112 #ifdef PERL_IMPLICIT_CONTEXT
113 #if { VERSION >= 5.004 } && !defined(sv_setpvf_mg_nocontext)
114 #if { NEED sv_setpvf_mg_nocontext }
117 sv_setpvf_mg_nocontext(SV * const sv, const char * const pat, ...)
122 sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
131 /* sv_setpvf_mg depends on sv_setpvf_mg_nocontext */
133 # ifdef PERL_IMPLICIT_CONTEXT
134 # define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext
136 # define sv_setpvf_mg Perl_sv_setpvf_mg
140 #if { VERSION >= 5.004 } && !defined(sv_vsetpvf_mg)
141 # define sv_vsetpvf_mg(sv, pat, args) \
143 sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \
150 #define NEED_sv_catpvf_mg
151 #define NEED_sv_catpvf_mg_nocontext
152 #define NEED_sv_setpvf_mg
153 #define NEED_sv_setpvf_mg_nocontext
157 static SV * test_vnewSVpvf(pTHX_ const char *pat, ...)
162 #if { VERSION >= 5.004 }
163 sv = vnewSVpvf(pat, &args);
165 sv = newSVpv((char *) pat, 0);
171 static void test_sv_vcatpvf(pTHX_ SV *sv, const char *pat, ...)
175 #if { VERSION >= 5.004 }
176 sv_vcatpvf(sv, pat, &args);
178 sv_catpv(sv, (char *) pat);
183 static void test_sv_vsetpvf(pTHX_ SV *sv, const char *pat, ...)
187 #if { VERSION >= 5.004 }
188 sv_vsetpvf(sv, pat, &args);
190 sv_setpv(sv, (char *) pat);
200 RETVAL = test_vnewSVpvf(aTHX_ "%s-%d", "Perl", 42);
208 RETVAL = newSVsv(sv);
209 test_sv_vcatpvf(aTHX_ RETVAL, "%s-%d", "Perl", 42);
217 RETVAL = newSVsv(sv);
218 test_sv_vsetpvf(aTHX_ RETVAL, "%s-%d", "Perl", 42);
226 #if { VERSION >= 5.004 }
227 sv_catpvf_mg(sv, "%s-%d", "Perl", 42);
231 Perl_sv_catpvf_mg(sv)
234 #if { VERSION >= 5.004 }
235 Perl_sv_catpvf_mg(aTHX_ sv, "%s-%d", "-Perl", 43);
239 sv_catpvf_mg_nocontext(sv)
242 #if { VERSION >= 5.004 }
243 #ifdef PERL_IMPLICIT_CONTEXT
244 sv_catpvf_mg_nocontext(sv, "%s-%d", "-Perl", 44);
246 sv_catpvf_mg(sv, "%s-%d", "-Perl", 44);
254 #if { VERSION >= 5.004 }
255 sv_setpvf_mg(sv, "%s-%d", "mhx", 42);
259 Perl_sv_setpvf_mg(sv)
262 #if { VERSION >= 5.004 }
263 Perl_sv_setpvf_mg(aTHX_ sv, "%s-%d", "foo", 43);
267 sv_setpvf_mg_nocontext(sv)
270 #if { VERSION >= 5.004 }
271 #ifdef PERL_IMPLICIT_CONTEXT
272 sv_setpvf_mg_nocontext(sv, "%s-%d", "bar", 44);
274 sv_setpvf_mg(sv, "%s-%d", "bar", 44);
282 tie %h, 'Tie::StdHash';
286 is(&Devel::PPPort::vnewSVpvf(), ivers($]) >= ivers("5.004") ? 'Perl-42' : '%s-%d');
287 is(&Devel::PPPort::sv_vcatpvf('1-2-3-'), ivers($]) >= ivers("5.004") ? '1-2-3-Perl-42' : '1-2-3-%s-%d');
288 is(&Devel::PPPort::sv_vsetpvf('1-2-3-'), ivers($]) >= ivers("5.004") ? 'Perl-42' : '%s-%d');
290 &Devel::PPPort::sv_catpvf_mg($h{foo});
291 is($h{foo}, ivers($]) >= ivers("5.004") ? 'foo-Perl-42' : 'foo-');
293 &Devel::PPPort::Perl_sv_catpvf_mg($h{foo});
294 is($h{foo}, ivers($]) >= ivers("5.004") ? 'foo-Perl-42-Perl-43' : 'foo-');
296 &Devel::PPPort::sv_catpvf_mg_nocontext($h{foo});
297 is($h{foo}, ivers($]) >= ivers("5.004") ? 'foo-Perl-42-Perl-43-Perl-44' : 'foo-');
299 &Devel::PPPort::sv_setpvf_mg($h{bar});
300 is($h{bar}, ivers($]) >= ivers("5.004") ? 'mhx-42' : '');
302 &Devel::PPPort::Perl_sv_setpvf_mg($h{bar});
303 is($h{bar}, ivers($]) >= ivers("5.004") ? 'foo-43' : '');
305 &Devel::PPPort::sv_setpvf_mg_nocontext($h{bar});
306 is($h{bar}, ivers($]) >= ivers("5.004") ? 'bar-44' : '');