Merge pull request #240 from phandasm/vs-snprintf

Don't define snprintf macro under MSVC
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dca3617..54f1f2a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -108,6 +108,7 @@
 check_function_exists(getprogname HAVE_GETPROGNAME)
 check_function_exists(localtime_r HAVE_LOCALTIME_R)
 check_function_exists(setmode HAVE_SETMODE)
+check_symbol_exists(snprintf stdio.h HAVE_SNPRINTF)
 check_symbol_exists(strcasecmp strings.h HAVE_STRCASECMP)
 check_function_exists(strdup HAVE_STRDUP)
 check_function_exists(stricmp HAVE_STRICMP)
diff --git a/cmake-config.h.in b/cmake-config.h.in
index b234acb..544adbd 100644
--- a/cmake-config.h.in
+++ b/cmake-config.h.in
@@ -36,6 +36,7 @@
 #cmakedefine HAVE_NULLABLE
 #cmakedefine HAVE_OPENSSL
 #cmakedefine HAVE_SETMODE
+#cmakedefine HAVE_SNPRINTF
 #cmakedefine HAVE_STRCASECMP
 #cmakedefine HAVE_STRDUP
 #cmakedefine HAVE_STRICMP
diff --git a/lib/compat.h b/lib/compat.h
index 257e0ab..c16da7b 100644
--- a/lib/compat.h
+++ b/lib/compat.h
@@ -94,7 +94,7 @@
 #if !defined(HAVE_FILENO) && defined(HAVE__FILENO)
 #define fileno _fileno
 #endif
-#if defined(HAVE__SNPRINTF)
+#if !defined(HAVE_SNPRINTF) && defined(HAVE__SNPRINTF)
 #define snprintf _snprintf
 #endif
 #if defined(HAVE__STRDUP)