From f16f5395cd7a9b31452dfb00255becdc44df8a8a Mon Sep 17 00:00:00 2001 From: "Philip.Hazel" Date: Sun, 26 Jun 2016 16:21:23 +0000 Subject: [PATCH] Add MSVC snprintf fix to pcre2posix.c, which no longer includes pcre2_internal.h. --- ChangeLog | 4 +++- src/pcre2posix.c | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index cbff760..8590d8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -84,7 +84,9 @@ actually affect anything, by sheer luck. 18. Two minor fixes for MSVC compilation: (a) removal of apparently incorrect "const" qualifiers in pcre2test and (b) defining snprintf as _snprintf for -older MSVC compilers. +older MSVC compilers. This has been done both in src/pcre2_internal.h for most +of the library, and also in src/pcre2posix.c, which no longer includes +pcre2_internal.h (see 24 below). 19. Applied Chris Wilson's patch (Bugzilla #1681) to CMakeLists.txt for MSVC static compilation. Subsequently applied Chris Wilson's second patch, putting diff --git a/src/pcre2posix.c b/src/pcre2posix.c index b3fdb26..e7cf9c2 100644 --- a/src/pcre2posix.c +++ b/src/pcre2posix.c @@ -58,6 +58,14 @@ previously been set. */ # define PCRE2POSIX_EXP_DEFN __declspec(dllexport) #endif +/* Older versions of MSVC lack snprintf(). This define allows for +warning/error-free compilation and testing with MSVC compilers back to at least +MSVC 10/2010. Except for VC6 (which is missing some fundamentals and fails). */ + +#if defined(_MSC_VER) && (_MSC_VER < 1900) +#define snprintf _snprintf +#endif + /* Compile-time error numbers start at this value. It should probably never be changed. This #define is a copy of the one in pcre2_internal.h. */