--- Original_win32config.h	2015-10-19 09:17:29.220809600 +0100
+++ Fixed_win32config.h	2015-10-19 11:44:08.772737100 +0100
@@ -79,10 +79,49 @@
 #include <direct.h>
 #if defined(_MSC_VER) || defined(__MINGW32__)
 #if _MSC_VER < 1900
-#define snprintf _snprintf
-#endif
-#if _MSC_VER < 1500
-#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
+
+#include <stdarg.h>
+#include <stdio.h>
+
+/* MSC provides a non-compatible version of vsnprintf() which returns -1
+   on truncation rather than the ideal string length.
+   Use this version for cross-platform compatibility
+*/
+static int c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap) {
+    /* _vsnprintf_s does almost what we want from vsnprintf, but it doesn't return
+   	   the number of characters that would have been printed if the buffer had 
+	   been large enough. Instead it returns -1 if _TRUNCATE is specified
+    */
+    const int VSNPRINTF_S_TRUNCATE_FAILURE_CODE = -1;
+    
+    int count = VSNPRINTF_S_TRUNCATE_FAILURE_CODE;
+
+    if (size)
+        count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);  
+
+    if (count == VSNPRINTF_S_TRUNCATE_FAILURE_CODE)
+        count = _vscprintf(format, ap);
+
+    return count;
+}
+
+/* Earlier MSC versions didn't implement the snprintf() function. 
+   The provided _snprintf() is not the same, so we wrap instead
+*/
+static int c99_snprintf(char *buffer, size_t count, const char *format, ... ) {
+    va_list ap;
+	int result = -1;
+    
+	va_start(ap, format);
+    result = c99_vsnprintf(buffer, count, format, ap);
+    va_end(ap);
+
+    return result;
+}
+
+#define snprintf c99_snprintf
+#define vsnprintf(b,c,f,a) c99_vsnprintf(b,c,f,a)
+
 #endif
 #endif
 
