1 ################################################################################
5 ## $Date: 2010/03/07 13:15:45 +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 ################################################################################
24 #if !defined(my_snprintf)
25 #if { NEED my_snprintf }
28 my_snprintf(char *buffer, const Size_t len, const char *format, ...)
35 retval = vsnprintf(buffer, len, format, ap);
37 retval = vsprintf(buffer, format, ap);
40 if (retval < 0 || (len > 0 && (Size_t)retval >= len))
41 Perl_croak(aTHX_ "panic: my_snprintf buffer overflow");
50 #define NEED_my_snprintf
60 len = my_snprintf(buf, sizeof buf, "foo%s%d", "bar", 42);
62 mXPUSHs(newSVpv(buf, 0));
67 my($l, $s) = Devel::PPPort::my_snprintf();