_snprintf on MSVC6 doesn't null terminate.
The following functions are from the ezQuake source code and I've thrown in ezQuake's version of va (...)
Code: Select all
// Added by VVD
int qsnprintf(char *buffer, size_t count, char const *format, ...)
{
int ret;
va_list argptr;
if (!count) return 0;
va_start(argptr, format);
ret = _vsnprintf(buffer, count, format, argptr);
buffer[count - 1] = 0;
va_end(argptr);
return ret;
}
int qvsnprintf(char *buffer, size_t count, const char *format, va_list argptr)
{
int ret;
if (!count) return 0;
ret = _vsnprintf(buffer, count, format, argptr);
buffer[count - 1] = 0;
return ret;
}
#define snprintf qsnprintf // vc++ snprintf and vsnprintf are non-standard and not compatible with C99.
#define vsnprintf qvsnprintf // vc++ snprintf and vsnprintf are non-standard and not compatible with C99.
#define strcasecmp stricmp // MSVC has a different name for several standard functions
#define strncasecmp strnicmp // MSVC has a different name for several standard functions
//does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functions.
char *va (char *format, ...)
{
va_list argptr;
static char string[32][2048];
static int idx = 0;
idx++;
if (idx == 32)
idx = 0;
va_start (argptr, format);
vsnprintf (string[idx], sizeof(string[idx]), format, argptr);
va_end (argptr);
return string[idx];
}