Patched to compile on Visual Studio.

This commit is contained in:
Ryan C. Gordon 2017-07-09 18:17:33 -04:00
parent cf11d2ec99
commit f5c6383b4b
1 changed files with 29 additions and 28 deletions

View File

@ -13,6 +13,35 @@
#define __PHYSICSFS_INTERNAL__
#include "physfs_internal.h"
#if defined(_MSC_VER)
#include <stdarg.h>
/* this code came from https://stackoverflow.com/a/8712996 */
int __PHYSFS_msvc_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
{
int count = -1;
if (size != 0)
count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
if (count == -1)
count = _vscprintf(format, ap);
return count;
}
int __PHYSFS_msvc_snprintf(char *outBuf, size_t size, const char *format, ...)
{
int count;
va_list ap;
va_start(ap, format);
count = __PHYSFS_msvc_vsnprintf(outBuf, size, format, ap);
va_end(ap);
return count;
}
#endif
typedef struct __PHYSFS_DIRHANDLE__
{
@ -2983,33 +3012,5 @@ static void setDefaultAllocator(void)
} /* if */
} /* setDefaultAllocator */
#if defined(_MSC_VER)
/* this code came from https://stackoverflow.com/a/8712996 */
int __PHYSFS_msvc_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
{
int count = -1;
if (size != 0)
count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
if (count == -1)
count = _vscprintf(format, ap);
return count;
}
int __PHYSFS_msvc_snprintf(char *outBuf, size_t size, const char *format, ...)
{
int count;
va_list ap;
va_start(ap, format);
count = c99_vsnprintf(outBuf, size, format, ap);
va_end(ap);
return count;
}
#endif
/* end of physfs.c ... */