diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2020-04-10 03:40:48 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2020-04-10 03:40:48 +0000 |
commit | 503c0227622254c0ae3209a1fa72bcb68bb450bc (patch) | |
tree | 48df20533f300f819504c15af33cdc03fc386a93 /Build/source/libs/gd/libgd-src/src/snprintf.c | |
parent | a9d86b73ecf95b83666e16c4d90e348c4958a63b (diff) |
libgd 2.3.0
git-svn-id: svn://tug.org/texlive/trunk@54636 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/gd/libgd-src/src/snprintf.c')
-rw-r--r-- | Build/source/libs/gd/libgd-src/src/snprintf.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Build/source/libs/gd/libgd-src/src/snprintf.c b/Build/source/libs/gd/libgd-src/src/snprintf.c new file mode 100644 index 00000000000..33d1b42c81d --- /dev/null +++ b/Build/source/libs/gd/libgd-src/src/snprintf.c @@ -0,0 +1,25 @@ +/* Provide a snprintf on Windows for older Visual Studio builds. + * VS2013 and older do not support C99 snprintf(). The subsitute _snprintf() + * does not correctly NUL-terminate buffers in case of overflow. + * This implementation emulates the ISO C99 snprintf() for VS2013 and older. + */ + +#if defined(_MSC_VER) && _MSC_VER < 1900 + +#include <stdio.h> +#include <stdarg.h> + +int snprintf(char* buf, size_t len, const char* fmt, ...) +{ + int n; + va_list ap; + va_start(ap, fmt); + + n = _vscprintf(fmt, ap); + vsnprintf_s(buf, len, _TRUNCATE, fmt, ap); + + va_end(ap); + return n; +} + +#endif |