1
0
forked from 0ad/0ad
0ad/source/lib/sysdep/unix/printf.cpp
Ykkrosh 3705caae7a Fixed assert vs debug_assert.
Noted that the code won't compile unless SDL was compiled with X11
support (which my copy wasn't).

This was SVN commit r4645.
2006-11-15 10:33:51 +00:00

27 lines
689 B
C++

#include "precompiled.h"
#include <cstdio>
#include <cstdarg>
// See declaration in sysdep.h for explanation of need
int vsnprintf2(char* buffer, size_t count, const char* format, va_list argptr)
{
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;
}