Browse Source

add _snprintf() wrapper.

tags/v1.9.12
Yasuhiro Fujii 7 years ago
parent
commit
f76cd1b840
2 changed files with 23 additions and 6 deletions
  1. +22
    -2
      windows/JackCompilerDeps_os.h
  2. +1
    -4
      windows/JackSystemDeps_os.h

+ 22
- 2
windows/JackCompilerDeps_os.h View File

@@ -40,9 +40,29 @@
#endif

#if defined(_MSC_VER) /* Added by JE - 31-01-2012 */
#define vsnprintf _vsnprintf
#define snprintf _snprintf
#define strdup _strdup
#if _MSC_VER < 1900
// This wrapper is not fully standard-compliant. _snprintf() does not
// distinguish whether a result is truncated or a format error occurs.
inline int vsnprintf(char* buf, size_t buf_len, const char* fmt, va_list args)
{
int str_len = _vsnprintf(buf, buf_len - 1, fmt, args);
if (str_len == buf_len - 1 || str_len < 0) {
buf[buf_len - 1] = '\0';
return buf_len - 1;
}
return str_len;
}

inline int snprintf(char* buf, size_t buf_len, const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
int str_len = vsnprintf(buf, buf_len, fmt, args);
va_end(args);
return str_len;
}
#endif
#endif

#endif

+ 1
- 4
windows/JackSystemDeps_os.h View File

@@ -22,6 +22,7 @@
#define __JackSystemDeps_WIN32__

#include <windows.h>
#include "JackCompilerDeps.h"

#ifndef PATH_MAX
#define PATH_MAX 512
@@ -49,10 +50,6 @@
#define JACK_DEBUG false
#endif

#if defined(_MSC_VER)
#define snprintf _snprintf
#endif

inline int setenv(const char* name, const char* value, int overwrite)
{
if (overwrite == 0 && getenv(name) != NULL) {


Loading…
Cancel
Save