[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
vasnprintf on mingw
From: |
Bruno Haible |
Subject: |
vasnprintf on mingw |
Date: |
Sat, 10 Apr 2010 21:40:54 +0200 |
User-agent: |
KMail/1.9.9 |
On mingw, I got these test failures:
> test-snprintf-posix.h:2979: assertion failed
>
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.
> FAIL: test-snprintf-posix.exe
>
> test-sprintf-posix.h:2965: assertion failed
>
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.
> FAIL: test-sprintf-posix.exe
>
> test-vasnprintf-posix.c:3486: assertion failed
>
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.
> FAIL: test-vasnprintf-posix.exe
>
> test-vasprintf-posix.c:3467: assertion failed
>
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.
> FAIL: test-vasprintf-posix.exe
>
> test-snprintf-posix.h:2979: assertion failed
>
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.
> FAIL: test-vsnprintf-posix.exe
>
> test-sprintf-posix.h:2965: assertion failed
>
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.
> FAIL: test-vsprintf-posix.exe
The reason is that the m4/printf.m4 tests determines the bugs of the function
snprintf in libmingwex.a, but vasnprintf.c then called _snprintf in msvcrt.dll,
which has more bugs.
Should m4/printf.m4 use _snprintf, not snprintf?
Or should vasnprintf.c use snprintf, not _snprintf?
I'm going for the second option, for two reasons:
- gnulib users expect to see a replacement that shrinks over time, as mingw
gets improved and fewer bugs remain in mingw's *printf functions.
- libintl users under mingw expect not to see bugs that are present in
msvcrt's *printf but fixed in mingw's *printf.
It has the consequence that libintl-8.dll will contain more stuff from
libmingwex.a.
2010-04-10 Bruno Haible <address@hidden>
vasnprintf: Fix multiple test failures on mingw.
* lib/vasnprintf.c (SNPRINTF) [mingw]: Define to snprintf, not
_snprintf, or snwprintf, not _snwprintf.
--- lib/vasnprintf.c.orig Sat Apr 10 21:29:23 2010
+++ lib/vasnprintf.c Sat Apr 10 21:28:39 2010
@@ -148,8 +148,14 @@
# 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
@@ -167,8 +173,15 @@
# 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