vasnprintf: Fix multiple test failures on mingw.
authorBruno Haible <bruno@clisp.org>
Sat, 10 Apr 2010 19:40:23 +0000 (21:40 +0200)
committerIan Beckwith <ianb@erislabs.net>
Mon, 19 Apr 2010 15:29:16 +0000 (16:29 +0100)
(cherry picked from commit 067d1f10627e25eb1af323b56b6dbc7d8e74ba57)

ChangeLog
lib/vasnprintf.c

index 18f1bc3..debd789 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2010-04-10  Bruno Haible  <bruno@clisp.org>
 
+       vasnprintf: Fix multiple test failures on mingw.
+       * lib/vasnprintf.c (SNPRINTF) [mingw]: Define to snprintf, not
+       _snprintf, or snwprintf, not _snwprintf.
+
+2010-04-10  Bruno Haible  <bruno@clisp.org>
+
        write: Fix a C++ test error on mingw.
        * lib/unistd.in.h (write): Use _GL_CXXALIAS_SYS_CAST.
 
index 79854ed..794fb85 100644 (file)
 # define USE_SNPRINTF 1
 # if HAVE_DECL__SNWPRINTF
    /* On Windows, the function swprintf() has a different signature than
-      on Unix; we use the _snwprintf() function instead.  */
-#  define SNPRINTF _snwprintf
+      on Unix; we use the function _snwprintf() or - on mingw - snwprintf()
+      instead.  The mingw function snwprintf() has fewer bugs than the
+      MSVCRT function _snwprintf(), so prefer that.  */
+#  if defined __MINGW32__
+#   define SNPRINTF snwprintf
+#  else
+#   define SNPRINTF _snwprintf
+#  endif
 # else
    /* Unix.  */
 #  define SNPRINTF swprintf
 #  define USE_SNPRINTF 0
 # endif
 # if HAVE_DECL__SNPRINTF
-   /* Windows.  */
-#  define SNPRINTF _snprintf
+   /* Windows.  The mingw function snprintf() has fewer bugs than the MSVCRT
+      function _snprintf(), so prefer that.  */
+#  if defined __MINGW32__
+#   define SNPRINTF snprintf
+    /* Here we need to call the native snprintf, not rpl_snprintf.  */
+#   undef snprintf
+#  else
+#   define SNPRINTF _snprintf
+#  endif
 # else
    /* Unix.  */
 #  define SNPRINTF snprintf