2006-11-07 13:03:13 -08:00
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
#include <cstdarg>
|
|
|
|
|
|
|
|
|
|
// See declaration in sysdep.h for explanation of need
|
|
|
|
|
|
2007-04-30 12:58:04 -07:00
|
|
|
int sys_vsnprintf(char* buffer, size_t count, const char* format, va_list argptr)
|
2006-11-07 13:03:13 -08:00
|
|
|
{
|
|
|
|
|
int ret = vsnprintf(buffer, count, format, argptr);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
"The glibc implementation of the functions snprintf() and vsnprintf() conforms
|
|
|
|
|
to the C99 standard ... since glibc version 2.1. Until glibc 2.0.6 they would
|
|
|
|
|
return -1 when the output was truncated."
|
|
|
|
|
- man printf
|
|
|
|
|
|
|
|
|
|
MSVC's _vsnprintf still returns -1, so we want this one to do the same (for
|
|
|
|
|
compatibility), if the output (including the terminating null) is truncated.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (ret >= (int)count)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
return ret;
|
2006-11-15 02:33:51 -08:00
|
|
|
}
|