4 * Poor substitute for a real vsnprintf() function for systems
5 * that don't have them...
14 #if !defined(HAVE_VSNPRINTF) && !defined(HAVE__VSNPRINTF)
16 #define BUFFER_SIZE 65536 /* Bigger than any string we might print... */
18 static char snprintf_buffer
[BUFFER_SIZE
];
20 int vsnprintf(char *str
, size_t size
, const char *format
, va_list ap
)
24 if (size
> BUFFER_SIZE
) {
25 nasm_panic("vsnprintf: size (%d) > BUFFER_SIZE (%d)",
30 rv
= vsprintf(snprintf_buffer
, format
, ap
);
31 if (rv
>= BUFFER_SIZE
)
32 nasm_panic("vsnprintf buffer overflow");
35 if ((size_t)rv
< size
-1)
39 memcpy(str
, snprintf_buffer
, bytes
);