Hi All,

Please could you review and test enhancement from attachment "0001-use-mingw-C99-compatible-functions-v-snprintf-instea.patch". It is registered as request https://bugzilla.gnome.org/show_bug.cgi?id=676427 .

Since version 3.15 mingw runtime implement C99 compatible *printf functions in particular {v}snprintf. The difference is visible in libxslt regression test if environment variable PRINTF_EXPONENT_DIGITS is set to 2 - regression tests pass.

Regards,
Roumen
>From 54fce761e87fd90ce7dd816d10b1a20462b21a2b Mon Sep 17 00:00:00 2001
From: Roumen Petrov <bugtr...@roumenpetrov.info>
Date: Sun, 20 May 2012 16:07:54 +0300
Subject: [PATCH] use mingw C99 compatible functions {v}snprintf instead those
 from MSVC runtime

---
 configure.in    |   28 ++++++++++++++++------------
 python/libxml.c |    4 +---
 runsuite.c      |    9 ---------
 runtest.c       |    2 --
 runxmlconf.c    |    7 -------
 testrecurse.c   |    2 --
 6 files changed, 17 insertions(+), 35 deletions(-)

diff --git a/configure.in b/configure.in
index d388878..5454429 100644
--- a/configure.in
+++ b/configure.in
@@ -1497,18 +1497,22 @@ AC_SUBST(CYGWIN_EXTRA_LDFLAGS)
 AC_SUBST(CYGWIN_EXTRA_PYTHON_LIBADD)
 
 dnl Checking the standard string functions availability
-case "$host" in
- *-*-mingw*)
- AC_CHECK_FUNCS(printf sprintf fprintf _snprintf vfprintf vsprintf _vsnprintf sscanf,
-               [AC_DEFINE([snprintf],[_snprintf],[Win32 Std C name mangling work-around])
-                AC_DEFINE([vsnprintf],[_vsnprintf],[Win32 Std C name mangling work-around])],
-               NEED_TRIO=1)
- ;;
- *)
- AC_CHECK_FUNCS(printf sprintf fprintf snprintf vfprintf vsprintf vsnprintf sscanf,,
-               NEED_TRIO=1)
- ;;
-esac
+dnl
+dnl Note mingw* has C99 implementation that produce expected xml numbers
+dnl if code use {v}snprintf functions.
+dnl If you like to activate at run-time C99 compatible number output
+dnl see release note for mingw runtime 3.15:
+dnl  http://sourceforge.net/project/shownotes.php?release_id=24832
+dnl
+dnl Also *win32*config.h files redefine them for various MSC compilers.
+dnl
+dnl So do not redefine {v}snprintf to _{v}snprintf like follwing:
+dnl  AC_DEFINE([snprintf],[_snprintf],[Win32 Std C name mangling work-around])
+dnl  AC_DEFINE([vsnprintf],[_vsnprintf],[Win32 Std C name mangling work-around])
+dnl and do not redefine those functions is C-source files.
+dnl
+AC_CHECK_FUNCS(printf sprintf fprintf snprintf vfprintf vsprintf vsnprintf sscanf,,
+	NEED_TRIO=1)
 
 if test "$with_coverage" = "yes" -a "${GCC}" = "yes"
 then
diff --git a/python/libxml.c b/python/libxml.c
index 3e26e2d..ea4998b 100644
--- a/python/libxml.c
+++ b/python/libxml.c
@@ -28,9 +28,7 @@
 #include "libxml_wrap.h"
 #include "libxml2-py.h"
 
-#if (defined(_MSC_VER) || defined(__MINGW32__)) && !defined(vsnprintf)
-#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
-#elif defined(WITH_TRIO) && !defined(vsnprintf)
+#if defined(WITH_TRIO)
 #include "trio.h"
 #define vsnprintf trio_vsnprintf
 #endif
diff --git a/runsuite.c b/runsuite.c
index e6545fb..c630767 100644
--- a/runsuite.c
+++ b/runsuite.c
@@ -39,15 +39,6 @@ static FILE *logfile = NULL;
 static int verbose = 0;
 
 
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
-
-#define vsnprintf _vsnprintf
-
-#define snprintf _snprintf
-
-#endif
-
 /************************************************************************
  *									*
  *		File name and path utilities				*
diff --git a/runtest.c b/runtest.c
index fa925c1..ff78f02 100644
--- a/runtest.c
+++ b/runtest.c
@@ -194,8 +194,6 @@ static void globfree(glob_t *pglob) {
              free(pglob->gl_pathv[i]);
     }
 }
-#define vsnprintf _vsnprintf
-#define snprintf _snprintf
 #else
 #include <glob.h>
 #endif
diff --git a/runxmlconf.c b/runxmlconf.c
index 8ffb0c9..a50021e 100644
--- a/runxmlconf.c
+++ b/runxmlconf.c
@@ -37,13 +37,6 @@ static int verbose = 0;
 
 #define NB_EXPECTED_ERRORS 15
 
-#if defined(_WIN32) && !defined(__CYGWIN__)
-
-#define vsnprintf _vsnprintf
-
-#define snprintf _snprintf
-
-#endif
 
 const char *skipped_tests[] = {
 /* http://lists.w3.org/Archives/Public/public-xml-testsuite/2008Jul/0000.html */
diff --git a/testrecurse.c b/testrecurse.c
index 3515048..3a52e26 100644
--- a/testrecurse.c
+++ b/testrecurse.c
@@ -148,8 +148,6 @@ static void globfree(glob_t *pglob) {
              free(pglob->gl_pathv[i]);
     }
 }
-#define vsnprintf _vsnprintf
-#define snprintf _snprintf
 #else
 #include <glob.h>
 #endif
-- 
1.7.4.4




_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to