workaround for implementation "speciality" in snprintf() and vsnprintf() from Microsoft
This commit is contained in:
parent
00d2ebd8c6
commit
6e221f4c52
@ -37,10 +37,32 @@
|
|||||||
# define HAVE_VSNPRINTF
|
# define HAVE_VSNPRINTF
|
||||||
# define HAVE_STDARG_H
|
# define HAVE_STDARG_H
|
||||||
#endif
|
#endif
|
||||||
#if defined(__WATCOMC__) || defined(_MSC_VER)
|
#if defined(__WATCOMC__)
|
||||||
# define HAVE__SNPRINTF
|
# define HAVE__SNPRINTF
|
||||||
# define HAVE__VSNPRINTF
|
# define HAVE__VSNPRINTF
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
/* It is need to fix implementation "speciality" in snprintf() and vsnprintf() from Microsoft. */
|
||||||
|
int snprintf( char *buffer, size_t sizeOfBuffer, const char *format, ... )
|
||||||
|
{
|
||||||
|
va_list argptr;
|
||||||
|
va_start(argptr, format);
|
||||||
|
int r = _vsnprintf( buffer, sizeOfBuffer, format, argptr );
|
||||||
|
if( r == -1 || r == sizeOfBuffer )
|
||||||
|
buffer[sizeOfBuffer-1] = '\0';
|
||||||
|
va_end(argptr);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
# define HAVE_SNPRINTF 1
|
||||||
|
int vsnprintf( char *buffer, size_t sizeOfBuffer, const char *format, va_list argptr )
|
||||||
|
{
|
||||||
|
int r = _vsnprintf( buffer, sizeOfBuffer, format, argptr );
|
||||||
|
if( r == -1 || r == sizeOfBuffer )
|
||||||
|
buffer[sizeOfBuffer-1] = '\0';
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
# define HAVE_VSNPRINTF 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_SNPRINTF
|
#ifndef HAVE_SNPRINTF
|
||||||
# if defined(HAVE__SNPRINTF)
|
# if defined(HAVE__SNPRINTF)
|
||||||
|
Reference in New Issue
Block a user