my_snprintf
#if !defined(my_snprintf) #if { NEED my_snprintf }
int my_snprintf(char *buffer, const Size_t len, const char *format, ...) { dTHX; int retval; va_list ap; va_start(ap, format); #ifdef HAS_VSNPRINTF retval = vsnprintf(buffer, len, format, ap); #else retval = vsprintf(buffer, format, ap); #endif va_end(ap); if (retval < 0 || (len > 0 && (Size_t)retval >= len)) Perl_croak(aTHX_ "panic: my_snprintf buffer overflow"); return retval; }
#endif #endif
#define NEED_my_snprintf
void my_snprintf() PREINIT: char buf[128]; int len; PPCODE: len = my_snprintf(buf, sizeof buf, "foo%s%d", "bar", 42); mXPUSHi(len); mXPUSHs(newSVpv(buf, 0)); XSRETURN(2);
my($l, $s) = Devel::PPPort::my_snprintf(); ok($l, 8); ok($s, "foobar42");
5 POD Errors
The following errors were encountered while parsing the POD:
- Around line 12:
Unknown directive: =provides
- Around line 16:
Unknown directive: =implementation
- Around line 42:
Unknown directive: =xsinit
- Around line 46:
Unknown directive: =xsubs
- Around line 59:
Unknown directive: =tests