Skip to content

Commit

Permalink
Patched to compile on Visual Studio.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jul 9, 2017
1 parent cf11d2e commit f5c6383
Showing 1 changed file with 29 additions and 28 deletions.
57 changes: 29 additions & 28 deletions src/physfs.c
Expand Up @@ -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__
{
Expand Down Expand Up @@ -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 ... */

0 comments on commit f5c6383

Please sign in to comment.