diff options
Diffstat (limited to 'include/compat/stdio.h')
| -rw-r--r-- | include/compat/stdio.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/include/compat/stdio.h b/include/compat/stdio.h index 2ccdeeb..d9b8725 100644 --- a/include/compat/stdio.h +++ b/include/compat/stdio.h | |||
| @@ -57,7 +57,25 @@ int posix_rename(const char *oldpath, const char *newpath); | |||
| 57 | #endif | 57 | #endif |
| 58 | 58 | ||
| 59 | #if defined(_MSC_VER) && _MSC_VER < 1900 | 59 | #if defined(_MSC_VER) && _MSC_VER < 1900 |
| 60 | #define snprintf _snprintf | 60 | #include <stdarg.h> |
| 61 | |||
| 62 | static inline int | ||
| 63 | libressl_snprintf(char *str, size_t size, const char *format, ...) | ||
| 64 | { | ||
| 65 | va_list ap; | ||
| 66 | int ret; | ||
| 67 | |||
| 68 | va_start(ap, format); | ||
| 69 | ret = _vsnprintf(str, size, format, ap); | ||
| 70 | va_end(ap); | ||
| 71 | |||
| 72 | /* _vsnprintf does not NUL-terminate when the output is truncated. */ | ||
| 73 | if (size != 0) | ||
| 74 | str[size - 1] = '\0'; | ||
| 75 | |||
| 76 | return ret; | ||
| 77 | } | ||
| 78 | #define snprintf libressl_snprintf | ||
| 61 | #endif | 79 | #endif |
| 62 | 80 | ||
| 63 | #endif | 81 | #endif |
