bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: Re: vasnwprintf: Port to older platforms without swprintf
Date: Wed, 22 Mar 2023 19:42:15 +0100	[thread overview]
Message-ID: <5048354.tdWV9SEqCh@nimes> (raw)
In-Reply-To: <7410120.GJh79HuArf@nimes>

[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]

Yesterday I did:
> 	* tests/test-vasnwprintf-posix.c (test_function): Add more tests for the
> 	%c and %lc directives.

Some of these new tests fail on musl libc, FreeBSD, NetBSD, AIX, mingw.
- For musl libc, *BSD, AIX, it's a bug in the swprintf function, and as
  a workaround, I'll just not use swprintf on these platforms.
  For musl libc, I have reported it at
  <https://www.openwall.com/lists/musl/2023/03/22/9>.
- For mingw, I'll continue to use the snwprintf function, but with a small
  workaround.


2023-03-22  Bruno Haible  <bruno@clisp.org>

	vasnwprintf: Fix test failures on FreeBSD, NetBSD, AIX, mingw.
	* m4/printf.m4 (gl_SWPRINTF_WORKS): New macro.
	* m4/vasnprintf.m4 (gl_PREREQ_VASNWPRINTF): Invoke it and define
	HAVE_WORKING_SWPRINTF accordingly.
	* lib/vasnprintf.c: Together with HAVE_SWPRINTF, test also
	HAVE_WORKING_SWPRINTF.
	(VASNPRINTF): If WIDE_CHAR_VERSION && !DCHAR_IS_TCHAR, don't pass a
	wchar_t[] to snprintf. Add a workaround against mingw's snwprintf
	function.
	* doc/posix-functions/swprintf.texi: Document the null wide character
	bug.

2023-03-22  Bruno Haible  <bruno@clisp.org>

	vasnwprintf: Fix a "warning: unused function 'wmax_room_needed'".
	* lib/vasnprintf.c (MAX_ROOM_NEEDED): Adjust #if condition.

2023-03-22  Bruno Haible  <bruno@clisp.org>

	vasnwprintf: Simplify last change.
	* lib/vasnprintf.c (VASNPRINTF): Remove unused variable 'len'.


[-- Attachment #2: 0001-vasnwprintf-Simplify-last-change.patch --]
[-- Type: text/x-patch, Size: 2038 bytes --]

From b07085538e9ec21a185d49953edec965bf704c4d Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 22 Mar 2023 15:01:53 +0100
Subject: [PATCH 1/3] vasnwprintf: Simplify last change.

* lib/vasnprintf.c (VASNPRINTF): Remove unused variable 'len'.
---
 ChangeLog        | 5 +++++
 lib/vasnprintf.c | 7 +------
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 568db7a8da..e869463550 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-03-22  Bruno Haible  <bruno@clisp.org>
+
+	vasnwprintf: Simplify last change.
+	* lib/vasnprintf.c (VASNPRINTF): Remove unused variable 'len'.
+
 2023-03-22  Bruno Haible  <bruno@clisp.org>
 
 	vasnwprintf tests: Fix link errors on AIX.
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index 8e6596df2f..fa9344b831 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -5885,11 +5885,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                         memset (&state, '\0', sizeof (mbstate_t));
                         {
                           DCHAR_T *destptr = tmpdst;
-                          size_t len = tmpdst_len;
                           const TCHAR_T *src = tmpsrc;
                           size_t srclen = count;
 
-                          for (; srclen > 0; destptr++, len--)
+                          for (; srclen > 0; destptr++)
                             {
                               /* Parse the next multibyte character.  */
                               size_t ret = mbrtowc (destptr, src, srclen, &state);
@@ -5902,10 +5901,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                               src += ret;
                               srclen -= ret;
                             }
-                          /* By the way tmpdst_len was computed, len should now
-                             be 0.  */
-                          if (len != 0)
-                            abort ();
                         }
 # else
                         tmpdst =
-- 
2.34.1


[-- Attachment #3: 0002-vasnwprintf-Fix-a-warning-unused-function-wmax_room_.patch --]
[-- Type: text/x-patch, Size: 1368 bytes --]

From cf3252a50dc8b0c977f558cec3902d7f06857fad Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 22 Mar 2023 17:46:23 +0100
Subject: [PATCH 2/3] vasnwprintf: Fix a "warning: unused function
 'wmax_room_needed'".

* lib/vasnprintf.c (MAX_ROOM_NEEDED): Adjust #if condition.
---
 ChangeLog        | 5 +++++
 lib/vasnprintf.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index e869463550..c6393d949c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-03-22  Bruno Haible  <bruno@clisp.org>
+
+	vasnwprintf: Fix a "warning: unused function 'wmax_room_needed'".
+	* lib/vasnprintf.c (MAX_ROOM_NEEDED): Adjust #if condition.
+
 2023-03-22  Bruno Haible  <bruno@clisp.org>
 
 	vasnwprintf: Simplify last change.
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index fa9344b831..e784dfe37e 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -1610,7 +1610,7 @@ is_borderline (const char *digits, size_t precision)
 
 #endif
 
-#if !USE_SNPRINTF || WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF
+#if !USE_SNPRINTF || (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF
 
 /* Use a different function name, to make it possible that the 'wchar_t'
    parametrization and the 'char' parametrization get compiled in the same
-- 
2.34.1


[-- Attachment #4: 0003-vasnwprintf-Fix-test-failures-on-FreeBSD-NetBSD-AIX-.patch --]
[-- Type: text/x-patch, Size: 18943 bytes --]

From 6b8f2da25eb90ee43212a282d5617f724b19cf21 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 22 Mar 2023 19:39:33 +0100
Subject: [PATCH 3/3] vasnwprintf: Fix test failures on FreeBSD, NetBSD, AIX,
 mingw.

* m4/printf.m4 (gl_SWPRINTF_WORKS): New macro.
* m4/vasnprintf.m4 (gl_PREREQ_VASNWPRINTF): Invoke it and define
HAVE_WORKING_SWPRINTF accordingly.
* lib/vasnprintf.c: Together with HAVE_SWPRINTF, test also
HAVE_WORKING_SWPRINTF.
(VASNPRINTF): If WIDE_CHAR_VERSION && !DCHAR_IS_TCHAR, don't pass a
wchar_t[] to snprintf. Add a workaround against mingw's snwprintf
function.
* doc/posix-functions/swprintf.texi: Document the null wide character
bug.
---
 ChangeLog                         |  14 +++
 doc/posix-functions/swprintf.texi |   7 ++
 lib/vasnprintf.c                  |  20 ++--
 m4/printf.m4                      | 153 +++++++++++++++++++++---------
 m4/vasnprintf.m4                  |  12 ++-
 5 files changed, 155 insertions(+), 51 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c6393d949c..91b03df0b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-03-22  Bruno Haible  <bruno@clisp.org>
+
+	vasnwprintf: Fix test failures on FreeBSD, NetBSD, AIX, mingw.
+	* m4/printf.m4 (gl_SWPRINTF_WORKS): New macro.
+	* m4/vasnprintf.m4 (gl_PREREQ_VASNWPRINTF): Invoke it and define
+	HAVE_WORKING_SWPRINTF accordingly.
+	* lib/vasnprintf.c: Together with HAVE_SWPRINTF, test also
+	HAVE_WORKING_SWPRINTF.
+	(VASNPRINTF): If WIDE_CHAR_VERSION && !DCHAR_IS_TCHAR, don't pass a
+	wchar_t[] to snprintf. Add a workaround against mingw's snwprintf
+	function.
+	* doc/posix-functions/swprintf.texi: Document the null wide character
+	bug.
+
 2023-03-22  Bruno Haible  <bruno@clisp.org>
 
 	vasnwprintf: Fix a "warning: unused function 'wmax_room_needed'".
diff --git a/doc/posix-functions/swprintf.texi b/doc/posix-functions/swprintf.texi
index a87bc06c86..357cfc1ad4 100644
--- a/doc/posix-functions/swprintf.texi
+++ b/doc/posix-functions/swprintf.texi
@@ -41,6 +41,13 @@
 @c https://www.openwall.com/lists/musl/2023/03/20/1
 musl libc 1.2.3.
 @item
+This function is broken when it produces output that contains null wide
+characters on some platforms:
+@c https://www.openwall.com/lists/musl/2023/03/22/9
+musl libc 1.2.3,
+FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2,
+mingw.
+@item
 This function does not support the @samp{b} directive, required by ISO C23,
 on some platforms:
 glibc 2.34, musl libc, macOS 12.5, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2,
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index e784dfe37e..5ea3e45d63 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -158,7 +158,7 @@
 #endif
 #if WIDE_CHAR_VERSION
   /* DCHAR_T is wchar_t.  */
-# if HAVE_DECL__SNWPRINTF || HAVE_SWPRINTF
+# if HAVE_DECL__SNWPRINTF || (HAVE_SWPRINTF && HAVE_WORKING_SWPRINTF)
 #  define TCHAR_T wchar_t
 #  define DCHAR_IS_TCHAR 1
 #  define USE_SNPRINTF 1
@@ -4263,7 +4263,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                                   }
 
                                 *p++ = dp->conversion; /* 'e' or 'E' */
-#   if WIDE_CHAR_VERSION
+#   if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR
                                 {
                                   static const wchar_t decimal_format[] =
                                     { '%', '+', '.', '2', 'd', '\0' };
@@ -4444,7 +4444,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                                               }
                                           }
                                         *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */
-#   if WIDE_CHAR_VERSION
+#   if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR
                                         {
                                           static const wchar_t decimal_format[] =
                                             { '%', '+', '.', '2', 'd', '\0' };
@@ -4721,7 +4721,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                                   }
 
                                 *p++ = dp->conversion; /* 'e' or 'E' */
-#   if WIDE_CHAR_VERSION
+#   if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR
                                 {
                                   static const wchar_t decimal_format[] =
                                     /* Produce the same number of exponent digits
@@ -4914,7 +4914,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                                               }
                                           }
                                         *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */
-#   if WIDE_CHAR_VERSION
+#   if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR
                                         {
                                           static const wchar_t decimal_format[] =
                                             /* Produce the same number of exponent digits
@@ -5706,7 +5706,15 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 # endif
                               }
                             else
-                              count = retcount;
+                              {
+                                count = retcount;
+# if WIDE_CHAR_VERSION && defined __MINGW32__
+                                if (count == 0 && dp->conversion == 'c')
+                                  /* snwprintf returned 0 instead of 1.  But it
+                                     wrote a null wide character.  */
+                                  count = 1;
+# endif
+                              }
                           }
                       }
 #endif
diff --git a/m4/printf.m4 b/m4/printf.m4
index 1096b87dc2..3cf8c87b1a 100644
--- a/m4/printf.m4
+++ b/m4/printf.m4
@@ -1,4 +1,4 @@
-# printf.m4 serial 76
+# printf.m4 serial 77
 dnl Copyright (C) 2003, 2007-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -1732,6 +1732,72 @@ AC_DEFUN([gl_VSNPRINTF_ZEROSIZE_C99]
     ])
 ])
 
+dnl Test whether the swprintf function works correctly when it produces output
+dnl that contains null wide characters.
+dnl Result is gl_cv_func_swprintf_works.
+
+AC_DEFUN([gl_SWPRINTF_WORKS],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CHECK_FUNCS_ONCE([swprintf])
+  AC_CACHE_CHECK([whether swprintf works],
+    [gl_cv_func_swprintf_works],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#ifndef __USE_MINGW_ANSI_STDIO
+# define __USE_MINGW_ANSI_STDIO 1
+#endif
+#include <stdio.h>
+#include <wchar.h>
+int main()
+{
+  int result = 0;
+  { /* This test fails on musl, FreeBSD, NetBSD, OpenBSD, macOS, AIX.  */
+    wchar_t buf[5] = { 0xBEEF, 0xBEEF, 0xBEEF, 0xBEEF, 0xBEEF };
+    int ret = swprintf (buf, 4, L"%cz", '\0');
+    /* Expected result:
+         ret = 2, buf[0] = 0x0, buf[1] = 0x7a, buf[2] = 0x0, buf[3] = 0xbeef
+       musl libc 1.2.3:
+         ret = 2, buf[0] = 0x0, buf[1] = 0x0, buf[2] = 0x0, buf[3] = 0x0
+         Reported at <https://www.openwall.com/lists/musl/2023/03/22/9>.
+       FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2:
+         ret = 2, buf[0] = 0x0, buf[1] = 0xbeef, buf[2] = 0xbeef, buf[3] = 0xbeef
+     */
+    if (ret < 0 || buf[1] != 'z')
+      result |= 1;
+  }
+  { /* This test fails on mingw.  */
+    wchar_t buf[2];
+    int ret = swprintf (buf, 2, L"%lc", (wint_t)0);
+    /* Expected: ret = 1
+       mingw:    ret = 0
+     */
+    if (ret != 1)
+      result |= 2;
+  }
+  return result;
+}]])],
+        [gl_cv_func_swprintf_works=yes],
+        [gl_cv_func_swprintf_works=no],
+        [case "$host_os" in
+                               # Guess yes on glibc systems.
+           *-gnu* | gnu*)      gl_cv_func_swprintf_works="guessing yes";;
+                               # Guess no on musl systems.
+           *-musl* | midipix*) gl_cv_func_swprintf_works="guessing yes";;
+                               # Guess no on FreeBSD, NetBSD, OpenBSD, macOS, AIX.
+           freebsd* | midnightbsd* | netbsd* | openbsd* | darwin* | aix*)
+                               gl_cv_func_swprintf_works="guessing no";;
+                               # Guess no on native Windows.
+           mingw* | pw*)       gl_cv_func_swprintf_works="guessing no";;
+                               # If we don't know, obey --enable-cross-guesses.
+           *)                  gl_cv_func_swprintf_works="$gl_cross_guess_normal";;
+         esac
+        ])
+    ])
+])
+
 dnl The results of these tests on various platforms are:
 dnl
 dnl 1 = gl_PRINTF_SIZES_C99
@@ -1756,6 +1822,7 @@ AC_DEFUN([gl_VSNPRINTF_ZEROSIZE_C99]
 dnl 10 = gl_SNPRINTF_DIRECTIVE_N
 dnl 21 = gl_SNPRINTF_SIZE1
 dnl 22 = gl_VSNPRINTF_ZEROSIZE_C99
+dnl 23 = gl_SWPRINTF_WORKS
 dnl
 dnl 1 = checking whether printf supports size specifiers as in C99...
 dnl 2 = checking whether printf supports 'long double' arguments...
@@ -1779,48 +1846,48 @@ AC_DEFUN([gl_VSNPRINTF_ZEROSIZE_C99]
 dnl 20 = checking whether snprintf fully supports the 'n' directive...
 dnl 21 = checking whether snprintf respects a size of 1...
 dnl 22 = checking whether vsnprintf respects a zero size as in C99...
+dnl 23 = checking whether swprintf works...
 dnl
 dnl . = yes, # = no.
-checking whether snprintf truncates the result as in C99... yes
 dnl
-dnl                                  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22
-dnl   musl libc 1.2.3                .  .  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
-dnl   glibc 2.35                     .  .  .  .  .  .  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .
-dnl   glibc 2.5                      .  .  .  .  .  #  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .
-dnl   glibc 2.3.6                    .  .  .  .  #  #  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .
-dnl   FreeBSD 13.0                   .  .  .  .  #  #  .  .  .  #  .  .  .  .  .  #  .  .  .  .  .  .
-dnl   FreeBSD 5.4, 6.1               .  .  .  .  #  #  .  .  .  #  .  .  .  #  .  #  .  .  .  .  .  .
-dnl   Mac OS X 10.13.5               .  .  .  #  #  #  .  #  .  #  .  .  .  .  .  .  .  .  .  #  .  .
-dnl   Mac OS X 10.5.8                .  .  .  #  #  #  .  .  .  #  .  .  .  #  .  .  .  .  .  .  .  .
-dnl   Mac OS X 10.3.9                .  .  .  .  #  #  .  .  .  #  .  .  .  #  .  #  .  .  .  .  .  .
-dnl   OpenBSD 6.0, 6.7               .  .  .  .  #  #  .  .  .  #  .  .  .  .  .  #  .  .  .  .  .  .
-dnl   OpenBSD 3.9, 4.0               .  .  #  #  #  #  #  .  #  #  .  #  .  #  .  #  .  .  .  .  .  .
-dnl   Cygwin 1.7.0 (2009)            .  .  .  #  .  #  .  .  ?  ?  .  .  .  .  .  ?  .  .  .  .  .  .
-dnl   Cygwin 1.5.25 (2008)           .  .  .  #  #  #  .  .  #  ?  .  .  .  .  .  #  .  .  .  .  .  .
-dnl   Cygwin 1.5.19 (2006)           #  .  .  #  #  #  #  .  #  ?  .  #  .  #  #  #  .  .  .  .  .  .
-dnl   Solaris 11.4                   .  .  #  #  #  #  .  .  #  #  .  .  .  #  .  .  .  .  .  .  .  .
-dnl   Solaris 11.3                   .  .  .  .  #  #  .  .  #  #  .  .  .  .  .  .  .  .  .  .  .  .
-dnl   Solaris 11.0                   .  .  #  #  #  #  .  .  #  #  .  .  .  #  .  .  .  .  .  .  .  .
-dnl   Solaris 10                     .  .  #  #  #  #  .  .  #  #  .  .  .  #  #  .  .  .  .  .  .  .
-dnl   Solaris 2.6 ... 9              #  .  #  #  #  #  #  .  #  #  .  .  .  #  #  .  .  .  #  .  .  .
-dnl   Solaris 2.5.1                  #  .  #  #  #  #  #  .  #  #  .  .  .  #  .  .  #  #  #  #  #  #
-dnl   AIX 7.1                        .  .  #  #  #  #  .  .  .  #  .  .  .  #  #  .  .  .  .  .  .  .
-dnl   AIX 5.2                        .  .  #  #  #  #  .  .  .  #  .  .  .  #  .  .  .  .  .  .  .  .
-dnl   AIX 4.3.2, 5.1                 #  .  #  #  #  #  #  .  .  #  .  .  .  #  .  .  .  .  #  .  .  .
-dnl   HP-UX 11.31                    .  .  .  .  #  #  .  .  .  ?  .  .  .  #  .  .  .  .  #  #  .  .
-dnl   HP-UX 11.{00,11,23}            #  .  .  .  #  #  #  .  .  ?  .  .  .  #  .  .  .  .  #  #  .  #
-dnl   HP-UX 10.20                    #  .  #  .  #  #  #  .  ?  ?  .  .  #  #  .  .  .  .  #  #  ?  #
-dnl   IRIX 6.5                       #  .  #  #  #  #  #  .  #  #  .  .  .  #  .  .  .  .  #  .  .  .
-dnl   OSF/1 5.1                      #  .  #  #  #  #  #  .  .  ?  .  .  .  #  .  .  .  .  #  .  .  #
-dnl   OSF/1 4.0d                     #  .  #  #  #  #  #  .  .  ?  .  .  .  #  .  .  #  #  #  #  #  #
-dnl   NetBSD 9.0                     .  .  .  .  #  #  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .
-dnl   NetBSD 5.0                     .  .  .  #  #  #  .  .  .  #  .  .  .  #  .  #  .  .  .  .  .  .
-dnl   NetBSD 4.0                     .  ?  ?  ?  ?  #  ?  .  ?  #  .  ?  ?  ?  ?  ?  .  .  .  ?  ?  ?
-dnl   NetBSD 3.0                     .  .  .  .  #  #  #  .  ?  #  #  #  ?  #  .  #  .  .  .  .  .  .
-dnl   Haiku                          .  .  .  #  #  #  #  .  #  ?  .  .  .  .  .  ?  .  .  ?  .  .  .
-dnl   BeOS                           #  #  .  #  #  #  #  .  ?  ?  #  .  ?  .  #  ?  .  .  ?  .  .  .
-dnl   Android 4.3                    .  .  #  #  #  #  #  #  #  ?  .  #  .  #  .  #  .  .  .  #  .  .
-dnl   old mingw / msvcrt             #  #  #  #  #  #  #  .  .  ?  #  #  .  #  #  ?  .  #  #  #  .  .
-dnl   MSVC 9                         #  #  #  #  #  #  #  #  .  ?  #  #  .  #  #  ?  #  #  #  #  .  .
-dnl   mingw 2009-2011                .  #  .  #  .  #  .  .  .  ?  #  #  .  .  .  ?  .  .  .  .  .  .
-dnl   mingw-w64 2011                 #  #  #  #  #  #  #  .  .  ?  #  #  .  #  #  ?  .  #  #  #  .  .
+dnl                                  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
+dnl   musl libc 1.2.3                .  .  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  #
+dnl   glibc 2.35                     .  .  .  .  .  .  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .  .
+dnl   glibc 2.5                      .  .  .  .  .  #  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .  ?
+dnl   glibc 2.3.6                    .  .  .  .  #  #  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .  ?
+dnl   FreeBSD 13.0                   .  .  .  .  #  #  .  .  .  #  .  .  .  .  .  #  .  .  .  .  .  .  #
+dnl   FreeBSD 5.4, 6.1               .  .  .  .  #  #  .  .  .  #  .  .  .  #  .  #  .  .  .  .  .  .  #
+dnl   Mac OS X 10.13.5               .  .  .  #  #  #  .  #  .  #  .  .  .  .  .  .  .  .  .  #  .  .  #
+dnl   Mac OS X 10.5.8                .  .  .  #  #  #  .  .  .  #  .  .  .  #  .  .  .  .  .  .  .  .  #
+dnl   Mac OS X 10.3.9                .  .  .  .  #  #  .  .  .  #  .  .  .  #  .  #  .  .  .  .  .  .  #
+dnl   OpenBSD 6.0, 6.7               .  .  .  .  #  #  .  .  .  #  .  .  .  .  .  #  .  .  .  .  .  .  #
+dnl   OpenBSD 3.9, 4.0               .  .  #  #  #  #  #  .  #  #  .  #  .  #  .  #  .  .  .  .  .  .  #
+dnl   Cygwin 1.7.0 (2009)            .  .  .  #  .  #  .  .  ?  ?  .  .  .  .  .  ?  .  .  .  .  .  .  ?
+dnl   Cygwin 1.5.25 (2008)           .  .  .  #  #  #  .  .  #  ?  .  .  .  .  .  #  .  .  .  .  .  .  ?
+dnl   Cygwin 1.5.19 (2006)           #  .  .  #  #  #  #  .  #  ?  .  #  .  #  #  #  .  .  .  .  .  .  ?
+dnl   Solaris 11.4                   .  .  #  #  #  #  .  .  #  #  .  .  .  #  .  .  .  .  .  .  .  .  .
+dnl   Solaris 11.3                   .  .  .  .  #  #  .  .  #  #  .  .  .  .  .  .  .  .  .  .  .  .  .
+dnl   Solaris 11.0                   .  .  #  #  #  #  .  .  #  #  .  .  .  #  .  .  .  .  .  .  .  .  ?
+dnl   Solaris 10                     .  .  #  #  #  #  .  .  #  #  .  .  .  #  #  .  .  .  .  .  .  .  ?
+dnl   Solaris 2.6 ... 9              #  .  #  #  #  #  #  .  #  #  .  .  .  #  #  .  .  .  #  .  .  .  ?
+dnl   Solaris 2.5.1                  #  .  #  #  #  #  #  .  #  #  .  .  .  #  .  .  #  #  #  #  #  #  ?
+dnl   AIX 7.1                        .  .  #  #  #  #  .  .  .  #  .  .  .  #  #  .  .  .  .  .  .  .  #
+dnl   AIX 5.2                        .  .  #  #  #  #  .  .  .  #  .  .  .  #  .  .  .  .  .  .  .  .  #
+dnl   AIX 4.3.2, 5.1                 #  .  #  #  #  #  #  .  .  #  .  .  .  #  .  .  .  .  #  .  .  .  #
+dnl   HP-UX 11.31                    .  .  .  .  #  #  .  .  .  ?  .  .  .  #  .  .  .  .  #  #  .  .  ?
+dnl   HP-UX 11.{00,11,23}            #  .  .  .  #  #  #  .  .  ?  .  .  .  #  .  .  .  .  #  #  .  #  ?
+dnl   HP-UX 10.20                    #  .  #  .  #  #  #  .  ?  ?  .  .  #  #  .  .  .  .  #  #  ?  #  ?
+dnl   IRIX 6.5                       #  .  #  #  #  #  #  .  #  #  .  .  .  #  .  .  .  .  #  .  .  .  #
+dnl   OSF/1 5.1                      #  .  #  #  #  #  #  .  .  ?  .  .  .  #  .  .  .  .  #  .  .  #  ?
+dnl   OSF/1 4.0d                     #  .  #  #  #  #  #  .  .  ?  .  .  .  #  .  .  #  #  #  #  #  #  ?
+dnl   NetBSD 9.0                     .  .  .  .  #  #  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .  #
+dnl   NetBSD 5.0                     .  .  .  #  #  #  .  .  .  #  .  .  .  #  .  #  .  .  .  .  .  .  #
+dnl   NetBSD 4.0                     .  ?  ?  ?  ?  #  ?  .  ?  #  .  ?  ?  ?  ?  ?  .  .  .  ?  ?  ?  #
+dnl   NetBSD 3.0                     .  .  .  .  #  #  #  .  ?  #  #  #  ?  #  .  #  .  .  .  .  .  .  #
+dnl   Haiku                          .  .  .  #  #  #  #  .  #  ?  .  .  .  .  .  ?  .  .  ?  .  .  .  ?
+dnl   BeOS                           #  #  .  #  #  #  #  .  ?  ?  #  .  ?  .  #  ?  .  .  ?  .  .  .  ?
+dnl   Android 4.3                    .  .  #  #  #  #  #  #  #  ?  .  #  .  #  .  #  .  .  .  #  .  .  ?
+dnl   old mingw / msvcrt             #  #  #  #  #  #  #  .  .  ?  #  #  .  #  #  ?  .  #  #  #  .  .  #
+dnl   MSVC 9                         #  #  #  #  #  #  #  #  .  ?  #  #  .  #  #  ?  #  #  #  #  .  .  #
+dnl   mingw 2009-2011                .  #  .  #  .  #  .  .  .  ?  #  #  .  .  .  ?  .  .  .  .  .  .  #
+dnl   mingw-w64 2011                 #  #  #  #  #  #  #  .  .  ?  #  #  .  #  #  ?  .  #  #  #  .  .  #
diff --git a/m4/vasnprintf.m4 b/m4/vasnprintf.m4
index 26ed82a731..911e77c874 100644
--- a/m4/vasnprintf.m4
+++ b/m4/vasnprintf.m4
@@ -1,4 +1,4 @@
-# vasnprintf.m4 serial 44
+# vasnprintf.m4 serial 45
 dnl Copyright (C) 2002-2004, 2006-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -94,8 +94,16 @@ AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF]
 # Prerequisites of lib/vasnwprintf.c.
 AC_DEFUN_ONCE([gl_PREREQ_VASNWPRINTF],
 [
-  AC_CHECK_FUNCS([swprintf wcsnlen mbrtowc])
+  AC_CHECK_FUNCS_ONCE([swprintf wcsnlen mbrtowc])
   AC_CHECK_DECLS([_snwprintf], , , [[#include <stdio.h>]])
+  gl_SWPRINTF_WORKS
+  case "$gl_cv_func_swprintf_works" in
+    *yes)
+      AC_DEFINE([HAVE_WORKING_SWPRINTF], [1],
+        [Define if the swprintf function works correctly when it produces output
+         that contains null wide characters.])
+      ;;
+  esac
   gl_MUSL_LIBC
   gl_PREREQ_VASNXPRINTF
 ])
-- 
2.34.1


  parent reply	other threads:[~2023-03-22 18:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20 18:29 vasnwprintf: Port to older platforms without swprintf Bruno Haible
2023-03-21 16:52 ` Bruno Haible
2023-03-22 13:45   ` Bruno Haible
2023-03-22 18:42   ` Bruno Haible [this message]
2023-03-22 20:28     ` Bruno Haible
2023-03-22 20:34     ` Bruno Haible

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5048354.tdWV9SEqCh@nimes \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).