In a testdir build on Mac OS X 10.5.8, I see these test failures:

FAIL: test-snprintf-posix
FAIL: test-sprintf-posix
FAIL: test-vasnprintf-posix
FAIL: test-vasnwprintf-posix
FAIL: test-vasprintf-posix
FAIL: test-vsnprintf-posix
FAIL: test-vsprintf-posix

In particular:

$ cat test-vasnprintf-posix.log 
../../gltests/test-vasnprintf-posix.c:4245: assertion 'strcmp (result, " 33") 
== 0' failed
FAIL test-vasnprintf-posix (exit status: 134)

This test shows a Mac OS X bug: %#.0x with argument 0 produce "0" instead of "".
The bug is fixed in Mac OS X 10.7.0.

It's old, but since this platform is more useful for debugging than
newer macOS releases (as it has a working gdb and a working 'dtruss'),
I'm adding a workaround.


2023-10-03  Bruno Haible  <br...@clisp.org>

        *printf-posix: Work around bug with %#.0x on Mac OS X 10.6.
        * lib/vasnprintf.c (VASNPRINTF): Enable NEED_PRINTF_UNBOUNDED_PRECISION-
        guarded code also for NEED_PRINTF_FLAG_ALT_PRECISION_ZERO. Set
        prec_ourselves to 1 if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO, precision is
        0, and the directive is 'x' or 'X'. If prec_ourselves, remove the "0"
        output if required.
        * m4/printf.m4 (gl_PRINTF_FLAG_ALT_PRECISION_ZERO): New macro.
        * m4/vasnprintf.m4 (gl_PREREQ_VASNPRINTF_FLAG_ALT_PRECISION_ZERO): New
        macro.
        (gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS): Invoke it.
        * m4/dprintf-posix.m4 (gl_FUNC_DPRINTF_IS_POSIX): Require
        gl_PRINTF_FLAG_ALT_PRECISION_ZERO and test its result.
        * m4/fprintf-posix.m4 (gl_FUNC_FPRINTF_IS_POSIX): Likewise.
        * m4/obstack-printf-posix.m4 (gl_FUNC_OBSTACK_PRINTF_IS_POSIX):
        Likewise.
        * m4/snprintf-posix.m4 (gl_FUNC_SNPRINTF_IS_POSIX): Likewise.
        * m4/sprintf-posix.m4 (gl_FUNC_SPRINTF_IS_POSIX): Likewise.
        * m4/vasnprintf-posix.m4 (gl_FUNC_VASNPRINTF_IS_POSIX): Likewise.
        * m4/vasprintf-posix.m4 (gl_FUNC_VASPRINTF_IS_POSIX): Likewise.
        * m4/vdprintf-posix.m4 (gl_FUNC_VDPRINTF_IS_POSIX): Likewise.
        * m4/vfprintf-posix.m4 (gl_FUNC_VFPRINTF_IS_POSIX): Likewise.
        * m4/vsnprintf-posix.m4 (gl_FUNC_VSNPRINTF_IS_POSIX): Likewise.
        * m4/vsprintf-posix.m4 (gl_FUNC_VSPRINTF_IS_POSIX): Likewise.
        * doc/glibc-functions/asprintf.texi: Mention the %#.0x bug.
        * doc/glibc-functions/obstack_printf.texi: Likewise.
        * doc/glibc-functions/obstack_vprintf.texi: Likewise.
        * doc/glibc-functions/vasprintf.texi: Likewise.
        * doc/posix-functions/dprintf.texi: Likewise.
        * doc/posix-functions/fprintf.texi: Likewise.
        * doc/posix-functions/fwprintf.texi: Likewise.
        * doc/posix-functions/printf.texi: Likewise.
        * doc/posix-functions/snprintf.texi: Likewise.
        * doc/posix-functions/sprintf.texi: Likewise.
        * doc/posix-functions/swprintf.texi: Likewise.
        * doc/posix-functions/vdprintf.texi: Likewise.
        * doc/posix-functions/vfprintf.texi: Likewise.
        * doc/posix-functions/vfwprintf.texi: Likewise.
        * doc/posix-functions/vprintf.texi: Likewise.
        * doc/posix-functions/vsnprintf.texi: Likewise.
        * doc/posix-functions/vsprintf.texi: Likewise.
        * doc/posix-functions/vswprintf.texi: Likewise.
        * doc/posix-functions/vwprintf.texi: Likewise.
        * doc/posix-functions/wprintf.texi: Likewise.

diff --git a/doc/glibc-functions/asprintf.texi 
b/doc/glibc-functions/asprintf.texi
index 017220f66f..19602929cc 100644
--- a/doc/glibc-functions/asprintf.texi
+++ b/doc/glibc-functions/asprintf.texi
@@ -71,6 +71,10 @@
 with zeroes) on some platforms:
 Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, Solaris 11.0, Cygwin 1.5.x.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 This function produces wrong output for the @samp{lc} directive with a NUL
 wide character argument on some platforms:
 glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, 
Solaris 11.4, and others.
diff --git a/doc/glibc-functions/obstack_printf.texi 
b/doc/glibc-functions/obstack_printf.texi
index e74327db21..975b255274 100644
--- a/doc/glibc-functions/obstack_printf.texi
+++ b/doc/glibc-functions/obstack_printf.texi
@@ -73,6 +73,10 @@
 with zeroes) on some platforms:
 Mac OS X 10.5, FreeBSD 13.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, Solaris 11.0, 
Cygwin 1.5.x, mingw, MSVC/clang.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 Solaris 10/x86, mingw, MSVC/clang.
diff --git a/doc/glibc-functions/obstack_vprintf.texi 
b/doc/glibc-functions/obstack_vprintf.texi
index 1799832b58..a3ec3d364b 100644
--- a/doc/glibc-functions/obstack_vprintf.texi
+++ b/doc/glibc-functions/obstack_vprintf.texi
@@ -73,6 +73,10 @@
 with zeroes) on some platforms:
 Mac OS X 10.5, FreeBSD 13.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, Solaris 11.0, 
Cygwin 1.5.x, mingw, MSVC/clang.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 Solaris 10/x86, mingw, MSVC/clang.
diff --git a/doc/glibc-functions/vasprintf.texi 
b/doc/glibc-functions/vasprintf.texi
index 91cf7d5635..b33ad91642 100644
--- a/doc/glibc-functions/vasprintf.texi
+++ b/doc/glibc-functions/vasprintf.texi
@@ -71,6 +71,10 @@
 with zeroes) on some platforms:
 Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, Solaris 11.0, Cygwin 1.5.x.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 This function produces wrong output for the @samp{lc} directive with a NUL
 wide character argument on some platforms:
 glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, 
Solaris 11.4, and others.
diff --git a/doc/posix-functions/dprintf.texi b/doc/posix-functions/dprintf.texi
index 92b73a97b5..b109398793 100644
--- a/doc/posix-functions/dprintf.texi
+++ b/doc/posix-functions/dprintf.texi
@@ -47,6 +47,10 @@
 with zeroes, or wrong capitalization) on some platforms:
 Solaris 11.4.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 AIX 7.1.
diff --git a/doc/posix-functions/fprintf.texi b/doc/posix-functions/fprintf.texi
index e08ece4869..7bd9ff50d8 100644
--- a/doc/posix-functions/fprintf.texi
+++ b/doc/posix-functions/fprintf.texi
@@ -66,6 +66,10 @@
 with zeroes, or wrong capitalization) on some platforms:
 Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, Solaris 11.4, 
Cygwin 1.5.x, mingw, MSVC/clang.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 AIX 7.1, Solaris 10/x86, mingw, MSVC/clang.
diff --git a/doc/posix-functions/fwprintf.texi 
b/doc/posix-functions/fwprintf.texi
index db42363cfa..fed553f2b5 100644
--- a/doc/posix-functions/fwprintf.texi
+++ b/doc/posix-functions/fwprintf.texi
@@ -30,6 +30,10 @@
 glibc 2.34, musl libc, macOS 12.5, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2,
 AIX 7.2, HP-UX 11, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 The @code{%m} directive is not portable, use @code{%s} mapped to an
 argument of @code{strerror(errno)} (or a version of @code{strerror_r})
 instead.
diff --git a/doc/posix-functions/printf.texi b/doc/posix-functions/printf.texi
index 4af0105b66..12ba645734 100644
--- a/doc/posix-functions/printf.texi
+++ b/doc/posix-functions/printf.texi
@@ -66,6 +66,10 @@
 with zeroes, or wrong capitalization) on some platforms:
 Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, Solaris 11.4, 
Cygwin 1.5.x, mingw, MSVC/clang.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 AIX 7.1, Solaris 10/x86, mingw, MSVC/clang.
diff --git a/doc/posix-functions/snprintf.texi 
b/doc/posix-functions/snprintf.texi
index 7446b88f5f..f907e9cc7f 100644
--- a/doc/posix-functions/snprintf.texi
+++ b/doc/posix-functions/snprintf.texi
@@ -77,6 +77,10 @@
 with zeroes, or wrong capitalization) on some platforms:
 Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, Solaris 11.4, 
Cygwin 1.5.x, mingw, MSVC/clang.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 AIX 7.1, Solaris 10/x86, mingw, MSVC/clang.
diff --git a/doc/posix-functions/sprintf.texi b/doc/posix-functions/sprintf.texi
index 8cd5de619f..2652acdebc 100644
--- a/doc/posix-functions/sprintf.texi
+++ b/doc/posix-functions/sprintf.texi
@@ -66,6 +66,10 @@
 with zeroes, or wrong capitalization) on some platforms:
 Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, Solaris 11.4, 
Cygwin 1.5.x, mingw, MSVC/clang.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 AIX 7.1, Solaris 10/x86, mingw, MSVC/clang.
diff --git a/doc/posix-functions/swprintf.texi 
b/doc/posix-functions/swprintf.texi
index 6029adbb66..6e139ae0d8 100644
--- a/doc/posix-functions/swprintf.texi
+++ b/doc/posix-functions/swprintf.texi
@@ -66,6 +66,10 @@
 glibc 2.34, musl libc, macOS 12.5, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2,
 AIX 7.2, HP-UX 11, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 The @code{%m} directive is not portable, use @code{%s} mapped to an
 argument of @code{strerror(errno)} (or a version of @code{strerror_r})
 instead.
diff --git a/doc/posix-functions/vdprintf.texi 
b/doc/posix-functions/vdprintf.texi
index 05f001d707..22ac3d17b4 100644
--- a/doc/posix-functions/vdprintf.texi
+++ b/doc/posix-functions/vdprintf.texi
@@ -47,6 +47,10 @@
 with zeroes, or wrong capitalization) on some platforms:
 Solaris 11.4.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 AIX 7.1.
diff --git a/doc/posix-functions/vfprintf.texi 
b/doc/posix-functions/vfprintf.texi
index c80599e06a..94bd3a75d4 100644
--- a/doc/posix-functions/vfprintf.texi
+++ b/doc/posix-functions/vfprintf.texi
@@ -66,6 +66,10 @@
 with zeroes, or wrong capitalization) on some platforms:
 Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, Solaris 11.4, 
Cygwin 1.5.x, mingw, MSVC/clang.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 AIX 7.1, Solaris 10/x86, mingw, MSVC/clang.
diff --git a/doc/posix-functions/vfwprintf.texi 
b/doc/posix-functions/vfwprintf.texi
index 0712269aa4..5669b56711 100644
--- a/doc/posix-functions/vfwprintf.texi
+++ b/doc/posix-functions/vfwprintf.texi
@@ -30,6 +30,10 @@
 glibc 2.34, musl libc, macOS 12.5, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2,
 AIX 7.2, HP-UX 11, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 The @code{%m} directive is not portable, use @code{%s} mapped to an
 argument of @code{strerror(errno)} (or a version of @code{strerror_r})
 instead.
diff --git a/doc/posix-functions/vprintf.texi b/doc/posix-functions/vprintf.texi
index 733032c5f4..8877376b91 100644
--- a/doc/posix-functions/vprintf.texi
+++ b/doc/posix-functions/vprintf.texi
@@ -66,6 +66,10 @@
 with zeroes, or wrong capitalization) on some platforms:
 Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, Solaris 11.4, 
Cygwin 1.5.x, mingw, MSVC/clang.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 AIX 7.1, Solaris 10/x86, mingw, MSVC/clang.
diff --git a/doc/posix-functions/vsnprintf.texi 
b/doc/posix-functions/vsnprintf.texi
index c00aec68dd..5bc943fde3 100644
--- a/doc/posix-functions/vsnprintf.texi
+++ b/doc/posix-functions/vsnprintf.texi
@@ -70,6 +70,10 @@
 with zeroes, or wrong capitalization) on some platforms:
 Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, Solaris 11.4, 
Cygwin 1.5.x, mingw, MSVC/clang.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 AIX 7.1, Solaris 10/x86, mingw, MSVC/clang.
diff --git a/doc/posix-functions/vsprintf.texi 
b/doc/posix-functions/vsprintf.texi
index 84bf7eec6f..4e726f96b0 100644
--- a/doc/posix-functions/vsprintf.texi
+++ b/doc/posix-functions/vsprintf.texi
@@ -66,6 +66,10 @@
 with zeroes, or wrong capitalization) on some platforms:
 Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, Solaris 11.4, 
Cygwin 1.5.x, mingw, MSVC/clang.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 AIX 7.1, Solaris 10/x86, mingw, MSVC/clang.
diff --git a/doc/posix-functions/vswprintf.texi 
b/doc/posix-functions/vswprintf.texi
index 7512a2d023..9fee75e929 100644
--- a/doc/posix-functions/vswprintf.texi
+++ b/doc/posix-functions/vswprintf.texi
@@ -32,6 +32,10 @@
 glibc 2.34, musl libc, macOS 12.5, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2,
 AIX 7.2, HP-UX 11, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 The @code{%m} directive is not portable, use @code{%s} mapped to an
 argument of @code{strerror(errno)} (or a version of @code{strerror_r})
 instead.
diff --git a/doc/posix-functions/vwprintf.texi 
b/doc/posix-functions/vwprintf.texi
index 1e364288f6..19f96fd241 100644
--- a/doc/posix-functions/vwprintf.texi
+++ b/doc/posix-functions/vwprintf.texi
@@ -33,6 +33,10 @@
 glibc 2.34, musl libc, macOS 12.5, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2,
 AIX 7.2, HP-UX 11, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 The @code{%m} directive is not portable, use @code{%s} mapped to an
 argument of @code{strerror(errno)} (or a version of @code{strerror_r})
 instead.
diff --git a/doc/posix-functions/wprintf.texi b/doc/posix-functions/wprintf.texi
index c4d58fab2e..8c977ab506 100644
--- a/doc/posix-functions/wprintf.texi
+++ b/doc/posix-functions/wprintf.texi
@@ -33,6 +33,10 @@
 glibc 2.34, musl libc, macOS 12.5, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2,
 AIX 7.2, HP-UX 11, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
 @item
+printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
+incorrect result (non-empty) on some platforms:
+Mac OS X 10.6.
+@item
 The @code{%m} directive is not portable, use @code{%s} mapped to an
 argument of @code{strerror(errno)} (or a version of @code{strerror_r})
 instead.
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index 815c7c5098..2cfdbe97bd 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -5622,24 +5622,24 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
               {
                 arg_type type = a.arg[dp->arg_index].type;
                 int flags = dp->flags;
-#if (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || 
NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || 
NEED_PRINTF_UNBOUNDED_PRECISION
+#if (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || 
NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || 
NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
                 int has_width;
 #endif
-#if !USE_SNPRINTF || WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || 
USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || 
NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || 
NEED_PRINTF_UNBOUNDED_PRECISION
+#if !USE_SNPRINTF || WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || 
USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || 
NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || 
NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
                 size_t width;
 #endif
-#if !USE_SNPRINTF || (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || 
!HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (WIDE_CHAR_VERSION && 
MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST 
|| NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+#if !USE_SNPRINTF || (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || 
!HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (WIDE_CHAR_VERSION && 
MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST 
|| NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || 
NEED_PRINTF_UNBOUNDED_PRECISION
                 int has_precision;
                 size_t precision;
 #endif
-#if NEED_PRINTF_UNBOUNDED_PRECISION
+#if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
                 int prec_ourselves;
 #else
 #               define prec_ourselves 0
 #endif
 #if (WIDE_CHAR_VERSION && MUSL_LIBC) || NEED_PRINTF_FLAG_LEFTADJUST
 #               define pad_ourselves 1
-#elif !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || 
NEED_PRINTF_UNBOUNDED_PRECISION
+#elif !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || 
NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
                 int pad_ourselves;
 #else
 #               define pad_ourselves 0
@@ -5654,10 +5654,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                 TCHAR_T *tmp;
 #endif
 
-#if (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || 
NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || 
NEED_PRINTF_UNBOUNDED_PRECISION
+#if (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || 
NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || 
NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
                 has_width = 0;
 #endif
-#if !USE_SNPRINTF || WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || 
USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || 
NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || 
NEED_PRINTF_UNBOUNDED_PRECISION
+#if !USE_SNPRINTF || WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || 
USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || 
NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || 
NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
                 width = 0;
                 if (dp->width_start != dp->width_end)
                   {
@@ -5685,13 +5685,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                           width = xsum (xtimes (width, 10), *digitp++ - '0');
                         while (digitp != dp->width_end);
                       }
-# if (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || 
NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || 
NEED_PRINTF_UNBOUNDED_PRECISION
+# if (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || 
NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || 
NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
                     has_width = 1;
 # endif
                   }
 #endif
 
-#if !USE_SNPRINTF || (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || 
!HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (WIDE_CHAR_VERSION && 
MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST 
|| NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+#if !USE_SNPRINTF || (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || 
!HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (WIDE_CHAR_VERSION && 
MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST 
|| NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || 
NEED_PRINTF_UNBOUNDED_PRECISION
                 has_precision = 0;
                 precision = 6;
                 if (dp->precision_start != dp->precision_end)
@@ -5724,9 +5724,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 #endif
 
                 /* Decide whether to handle the precision ourselves.  */
-#if NEED_PRINTF_UNBOUNDED_PRECISION
+#if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
                 switch (dp->conversion)
                   {
+# if NEED_PRINTF_UNBOUNDED_PRECISION
                   case 'd': case 'i': case 'u':
                   case 'b':
                   #if SUPPORT_GNU_PRINTF_DIRECTIVES \
@@ -5734,9 +5735,21 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                   case 'B':
                   #endif
                   case 'o':
-                  case 'x': case 'X': case 'p':
                     prec_ourselves = has_precision && (precision > 0);
                     break;
+# endif
+                  case 'x': case 'X': case 'p':
+                    prec_ourselves =
+                      has_precision
+                      && (0
+# if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO
+                          || (precision == 0)
+# endif
+# if NEED_PRINTF_UNBOUNDED_PRECISION
+                          || (precision > 0)
+# endif
+                         );
+                    break;
                   default:
                     prec_ourselves = 0;
                     break;
@@ -5744,7 +5757,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 #endif
 
                 /* Decide whether to perform the padding ourselves.  */
-#if !((WIDE_CHAR_VERSION && MUSL_LIBC) || NEED_PRINTF_FLAG_LEFTADJUST) && 
(!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || 
NEED_PRINTF_UNBOUNDED_PRECISION)
+#if !((WIDE_CHAR_VERSION && MUSL_LIBC) || NEED_PRINTF_FLAG_LEFTADJUST) && 
(!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || 
NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION)
                 switch (dp->conversion)
                   {
 # if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO
@@ -6508,7 +6521,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                       }
 #endif
 
-#if NEED_PRINTF_UNBOUNDED_PRECISION
+#if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
                     if (prec_ourselves)
                       {
                         /* Handle the precision.  */
@@ -6568,6 +6581,15 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 
                             count += insert;
                           }
+# if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO
+                        else if (precision == 0
+                                 && move == 1
+                                 && prec_ptr[prefix_count] == '0')
+                          {
+                            /* Replace the "0" result with an empty string.  */
+                            count = prefix_count;
+                          }
+# endif
                       }
 #endif
 
@@ -6722,7 +6744,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                     /* Here count <= allocated - length.  */
 
                     /* Perform padding.  */
-#if (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || 
NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || 
NEED_PRINTF_UNBOUNDED_PRECISION
+#if (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || 
NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || 
NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
                     if (pad_ourselves && has_width)
                       {
                         size_t w;
diff --git a/m4/dprintf-posix.m4 b/m4/dprintf-posix.m4
index 3d964a6dce..d6d0539c5e 100644
--- a/m4/dprintf-posix.m4
+++ b/m4/dprintf-posix.m4
@@ -1,4 +1,4 @@
-# dprintf-posix.m4 serial 7
+# dprintf-posix.m4 serial 8
 dnl Copyright (C) 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,
@@ -33,6 +33,7 @@ AC_DEFUN([gl_FUNC_DPRINTF_IS_POSIX]
   AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
   AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
+  AC_REQUIRE([gl_PRINTF_FLAG_ALT_PRECISION_ZERO])
   AC_REQUIRE([gl_PRINTF_PRECISION])
   AC_REQUIRE([gl_PRINTF_ENOMEM])
   gl_cv_func_dprintf_posix=no
@@ -68,13 +69,17 @@ AC_DEFUN([gl_FUNC_DPRINTF_IS_POSIX]
                                                           *yes)
                                                             case 
"$gl_cv_func_printf_flag_zero" in
                                                               *yes)
-                                                                case 
"$gl_cv_func_printf_precision" in
+                                                                case 
"$gl_cv_func_printf_flag_alt_precision_zero" in
                                                                   *yes)
-                                                                    case 
"$gl_cv_func_printf_enomem" in
+                                                                    case 
"$gl_cv_func_printf_precision" in
                                                                       *yes)
-                                                                        # 
dprintf exists and is
-                                                                        # 
already POSIX compliant.
-                                                                        
gl_cv_func_dprintf_posix=yes
+                                                                        case 
"$gl_cv_func_printf_enomem" in
+                                                                          *yes)
+                                                                            # 
dprintf exists and is
+                                                                            # 
already POSIX compliant.
+                                                                            
gl_cv_func_dprintf_posix=yes
+                                                                            ;;
+                                                                        esac
                                                                         ;;
                                                                     esac
                                                                     ;;
diff --git a/m4/fprintf-posix.m4 b/m4/fprintf-posix.m4
index 67ecbf353b..4d2c1e57c7 100644
--- a/m4/fprintf-posix.m4
+++ b/m4/fprintf-posix.m4
@@ -1,4 +1,4 @@
-# fprintf-posix.m4 serial 18
+# fprintf-posix.m4 serial 19
 dnl Copyright (C) 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,
@@ -33,6 +33,7 @@ AC_DEFUN([gl_FUNC_FPRINTF_IS_POSIX]
   AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
   AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
+  AC_REQUIRE([gl_PRINTF_FLAG_ALT_PRECISION_ZERO])
   AC_REQUIRE([gl_PRINTF_PRECISION])
   AC_REQUIRE([gl_PRINTF_ENOMEM])
   gl_cv_func_fprintf_posix=no
@@ -66,13 +67,17 @@ AC_DEFUN([gl_FUNC_FPRINTF_IS_POSIX]
                                                         *yes)
                                                           case 
"$gl_cv_func_printf_flag_zero" in
                                                             *yes)
-                                                              case 
"$gl_cv_func_printf_precision" in
+                                                              case 
"$gl_cv_func_printf_flag_alt_precision_zero" in
                                                                 *yes)
-                                                                  case 
"$gl_cv_func_printf_enomem" in
+                                                                  case 
"$gl_cv_func_printf_precision" in
                                                                     *yes)
-                                                                      # 
fprintf exists and is
-                                                                      # 
already POSIX compliant.
-                                                                      
gl_cv_func_fprintf_posix=yes
+                                                                      case 
"$gl_cv_func_printf_enomem" in
+                                                                        *yes)
+                                                                          # 
fprintf exists and is
+                                                                          # 
already POSIX compliant.
+                                                                          
gl_cv_func_fprintf_posix=yes
+                                                                          ;;
+                                                                      esac
                                                                       ;;
                                                                   esac
                                                                   ;;
diff --git a/m4/obstack-printf-posix.m4 b/m4/obstack-printf-posix.m4
index d306b8426d..8c0de32536 100644
--- a/m4/obstack-printf-posix.m4
+++ b/m4/obstack-printf-posix.m4
@@ -1,4 +1,4 @@
-# obstack-printf-posix.m4 serial 8
+# obstack-printf-posix.m4 serial 9
 dnl Copyright (C) 2008-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,
@@ -37,6 +37,7 @@ AC_DEFUN([gl_FUNC_OBSTACK_PRINTF_IS_POSIX]
   AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
   AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
+  AC_REQUIRE([gl_PRINTF_FLAG_ALT_PRECISION_ZERO])
   AC_REQUIRE([gl_PRINTF_PRECISION])
   AC_REQUIRE([gl_PRINTF_ENOMEM])
   gl_cv_func_obstack_printf_posix=no
@@ -72,13 +73,17 @@ AC_DEFUN([gl_FUNC_OBSTACK_PRINTF_IS_POSIX]
                                                           *yes)
                                                             case 
"$gl_cv_func_printf_flag_zero" in
                                                               *yes)
-                                                                case 
"$gl_cv_func_printf_precision" in
+                                                                case 
"$gl_cv_func_printf_flag_alt_precision_zero" in
                                                                   *yes)
-                                                                    case 
"$gl_cv_func_printf_enomem" in
+                                                                    case 
"$gl_cv_func_printf_precision" in
                                                                       *yes)
-                                                                        # 
obstack_printf exists and is
-                                                                        # 
already POSIX compliant.
-                                                                        
gl_cv_func_obstack_printf_posix=yes
+                                                                        case 
"$gl_cv_func_printf_enomem" in
+                                                                          *yes)
+                                                                            # 
obstack_printf exists and is
+                                                                            # 
already POSIX compliant.
+                                                                            
gl_cv_func_obstack_printf_posix=yes
+                                                                            ;;
+                                                                        esac
                                                                         ;;
                                                                     esac
                                                                     ;;
diff --git a/m4/printf.m4 b/m4/printf.m4
index d0d15eb969..729847b0aa 100644
--- a/m4/printf.m4
+++ b/m4/printf.m4
@@ -1,4 +1,4 @@
-# printf.m4 serial 86
+# printf.m4 serial 87
 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,
@@ -1260,6 +1260,50 @@ AC_DEFUN([gl_PRINTF_FLAG_ZERO]
     ])
 ])
 
+dnl Test whether the *printf family of functions supports the # flag with a
+dnl zero precision and a zero value in the 'x' and 'X' directives correctly.
+dnl ISO C and POSIX specify that for the 'd', 'i', 'b', 'o', 'u', 'x', 'X'
+dnl directives: "The result of converting a zero value with a precision of
+dnl zero is no characters."  But on Mac OS X 10.5, for the 'x', 'X' directives,
+dnl when a # flag is present, the output is "0" instead of "".
+dnl Result is gl_cv_func_printf_flag_alt_precision_zero.
+
+AC_DEFUN([gl_PRINTF_FLAG_ALT_PRECISION_ZERO],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether printf supports the alternative flag with a zero 
precision],
+    [gl_cv_func_printf_flag_alt_precision_zero],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdio.h>
+static char buf[10];
+int main ()
+{
+  int result = 0;
+  if (sprintf (buf, "%#.0x %d", 0, 33, 44) > 0 + 3)
+    result |= 1;
+  return result;
+}]])],
+        [gl_cv_func_printf_flag_alt_precision_zero=yes],
+        [gl_cv_func_printf_flag_alt_precision_zero=no],
+        [
+changequote(,)dnl
+         case "$host_os" in
+           # Guess no only on macOS 10..12 systems.
+           darwin[0-9] | darwin[0-9].* | \
+           darwin1[0-9] | darwin1[0-9].* | \
+           darwin2[0-1] | darwin2[0-1].*)
+                    gl_cv_func_printf_flag_alt_precision_zero="guessing no" ;;
+           darwin*) gl_cv_func_printf_flag_alt_precision_zero="guessing yes" ;;
+           *)       gl_cv_func_printf_flag_alt_precision_zero="guessing yes" ;;
+         esac
+changequote([,])dnl
+        ])
+    ])
+])
+
 dnl Test whether the *printf family of functions supports large precisions.
 dnl On mingw, precisions larger than 512 are treated like 512, in integer,
 dnl floating-point or pointer output. On Solaris 10/x86, precisions larger
@@ -2083,17 +2127,18 @@ AC_DEFUN([gl_SWPRINTF_DIRECTIVE_LC]
 dnl 14 = gl_PRINTF_FLAG_GROUPING
 dnl 15 = gl_PRINTF_FLAG_LEFTADJUST
 dnl 16 = gl_PRINTF_FLAG_ZERO
-dnl 17 = gl_PRINTF_PRECISION
-dnl 18 = gl_PRINTF_ENOMEM
-dnl 19 = gl_SNPRINTF_PRESENCE
-dnl 20 = gl_SNPRINTF_TRUNCATION_C99
-dnl 21 = gl_SNPRINTF_RETVAL_C99
-dnl 22 = gl_SNPRINTF_DIRECTIVE_N
-dnl 23 = gl_SNPRINTF_SIZE1
-dnl 24 = gl_VSNPRINTF_ZEROSIZE_C99
-dnl 25 = gl_SWPRINTF_WORKS
-dnl 26 = gl_SWPRINTF_DIRECTIVE_LA
-dnl 27 = gl_SWPRINTF_DIRECTIVE_LC
+dnl 17 = gl_PRINTF_FLAG_ALT_PRECISION_ZERO
+dnl 18 = gl_PRINTF_PRECISION
+dnl 19 = gl_PRINTF_ENOMEM
+dnl 20 = gl_SNPRINTF_PRESENCE
+dnl 21 = gl_SNPRINTF_TRUNCATION_C99
+dnl 22 = gl_SNPRINTF_RETVAL_C99
+dnl 23 = gl_SNPRINTF_DIRECTIVE_N
+dnl 24 = gl_SNPRINTF_SIZE1
+dnl 25 = gl_VSNPRINTF_ZEROSIZE_C99
+dnl 26 = gl_SWPRINTF_WORKS
+dnl 27 = gl_SWPRINTF_DIRECTIVE_LA
+dnl 28 = gl_SWPRINTF_DIRECTIVE_LC
 dnl
 dnl 1 = checking whether printf supports size specifiers as in C99...
 dnl 2 = checking whether printf supports size specifiers as in C23...
@@ -2111,58 +2156,59 @@ AC_DEFUN([gl_SWPRINTF_DIRECTIVE_LC]
 dnl 14 = checking whether printf supports the grouping flag...
 dnl 15 = checking whether printf supports the left-adjust flag correctly...
 dnl 16 = checking whether printf supports the zero flag correctly...
-dnl 17 = checking whether printf supports large precisions...
-dnl 18 = checking whether printf survives out-of-memory conditions...
-dnl 19 = checking for snprintf...
-dnl 20 = checking whether snprintf truncates the result as in C99...
-dnl 21 = checking whether snprintf returns a byte count as in C99...
-dnl 22 = checking whether snprintf fully supports the 'n' directive...
-dnl 23 = checking whether snprintf respects a size of 1...
-dnl 24 = checking whether vsnprintf respects a zero size as in C99...
-dnl 25 = checking whether swprintf works...
-dnl 26 = checking whether swprintf supports the 'La' and 'LA' directives...
-dnl 27 = checking whether swprintf supports the 'lc' directive...
+dnl 17 = checking whether printf supports the alternative flag with a zero 
precision...
+dnl 18 = checking whether printf supports large precisions...
+dnl 19 = checking whether printf survives out-of-memory conditions...
+dnl 20 = checking for snprintf...
+dnl 21 = checking whether snprintf truncates the result as in C99...
+dnl 22 = checking whether snprintf returns a byte count as in C99...
+dnl 23 = checking whether snprintf fully supports the 'n' directive...
+dnl 24 = checking whether snprintf respects a size of 1...
+dnl 25 = checking whether vsnprintf respects a zero size as in C99...
+dnl 26 = checking whether swprintf works...
+dnl 27 = checking whether swprintf supports the 'La' and 'LA' directives...
+dnl 28 = checking whether swprintf supports the 'lc' directive...
 dnl
 dnl . = yes, # = no.
 dnl
-dnl                                  1  2  3  4  5  6  7  8  9 10 11 12 13 14 
15 16 17 18 19 20 21 22 23 24 25 26 27
-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 24 25 26 27 28
+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/snprintf-posix.m4 b/m4/snprintf-posix.m4
index 010ca5aea2..f15cd4b497 100644
--- a/m4/snprintf-posix.m4
+++ b/m4/snprintf-posix.m4
@@ -1,4 +1,4 @@
-# snprintf-posix.m4 serial 18
+# snprintf-posix.m4 serial 19
 dnl Copyright (C) 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,
@@ -33,6 +33,7 @@ AC_DEFUN([gl_FUNC_SNPRINTF_IS_POSIX]
   AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
   AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
+  AC_REQUIRE([gl_PRINTF_FLAG_ALT_PRECISION_ZERO])
   AC_REQUIRE([gl_PRINTF_PRECISION])
   AC_REQUIRE([gl_PRINTF_ENOMEM])
   gl_cv_func_snprintf_posix=no
@@ -73,23 +74,27 @@ AC_DEFUN([gl_FUNC_SNPRINTF_IS_POSIX]
                                                           *yes)
                                                             case 
"$gl_cv_func_printf_flag_zero" in
                                                               *yes)
-                                                                case 
"$gl_cv_func_printf_precision" in
+                                                                case 
"$gl_cv_func_printf_flag_alt_precision_zero" in
                                                                   *yes)
-                                                                    case 
"$gl_cv_func_printf_enomem" in
+                                                                    case 
"$gl_cv_func_printf_precision" in
                                                                       *yes)
-                                                                        case 
"$gl_cv_func_snprintf_truncation_c99" in
+                                                                        case 
"$gl_cv_func_printf_enomem" in
                                                                           *yes)
-                                                                            
case "$gl_cv_func_snprintf_retval_c99" in
+                                                                            
case "$gl_cv_func_snprintf_truncation_c99" in
                                                                               
*yes)
-                                                                               
 case "$gl_cv_func_snprintf_directive_n" in
+                                                                               
 case "$gl_cv_func_snprintf_retval_c99" in
                                                                                
   *yes)
-                                                                               
     case "$gl_cv_func_snprintf_size1" in
+                                                                               
     case "$gl_cv_func_snprintf_directive_n" in
                                                                                
       *yes)
-                                                                               
         case "$gl_cv_func_vsnprintf_zerosize_c99" in
+                                                                               
         case "$gl_cv_func_snprintf_size1" in
                                                                                
           *yes)
-                                                                               
             # snprintf exists and is
-                                                                               
             # already POSIX compliant.
-                                                                               
             gl_cv_func_snprintf_posix=yes
+                                                                               
             case "$gl_cv_func_vsnprintf_zerosize_c99" in
+                                                                               
               *yes)
+                                                                               
                 # snprintf exists and is
+                                                                               
                 # already POSIX compliant.
+                                                                               
                 gl_cv_func_snprintf_posix=yes
+                                                                               
                 ;;
+                                                                               
             esac
                                                                                
             ;;
                                                                                
         esac
                                                                                
         ;;
diff --git a/m4/sprintf-posix.m4 b/m4/sprintf-posix.m4
index 09a4ec8e57..cdbc813435 100644
--- a/m4/sprintf-posix.m4
+++ b/m4/sprintf-posix.m4
@@ -1,4 +1,4 @@
-# sprintf-posix.m4 serial 16
+# sprintf-posix.m4 serial 17
 dnl Copyright (C) 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,
@@ -33,6 +33,7 @@ AC_DEFUN([gl_FUNC_SPRINTF_IS_POSIX]
   AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
   AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
+  AC_REQUIRE([gl_PRINTF_FLAG_ALT_PRECISION_ZERO])
   AC_REQUIRE([gl_PRINTF_PRECISION])
   AC_REQUIRE([gl_PRINTF_ENOMEM])
   gl_cv_func_sprintf_posix=no
@@ -66,13 +67,17 @@ AC_DEFUN([gl_FUNC_SPRINTF_IS_POSIX]
                                                         *yes)
                                                           case 
"$gl_cv_func_printf_flag_zero" in
                                                             *yes)
-                                                              case 
"$gl_cv_func_printf_precision" in
+                                                              case 
"$gl_cv_func_printf_flag_alt_precision_zero" in
                                                                 *yes)
-                                                                  case 
"$gl_cv_func_printf_enomem" in
+                                                                  case 
"$gl_cv_func_printf_precision" in
                                                                     *yes)
-                                                                      # 
sprintf exists and is
-                                                                      # 
already POSIX compliant.
-                                                                      
gl_cv_func_sprintf_posix=yes
+                                                                      case 
"$gl_cv_func_printf_enomem" in
+                                                                        *yes)
+                                                                          # 
sprintf exists and is
+                                                                          # 
already POSIX compliant.
+                                                                          
gl_cv_func_sprintf_posix=yes
+                                                                          ;;
+                                                                      esac
                                                                       ;;
                                                                   esac
                                                                   ;;
diff --git a/m4/vasnprintf-posix.m4 b/m4/vasnprintf-posix.m4
index f72fb51094..63046e1608 100644
--- a/m4/vasnprintf-posix.m4
+++ b/m4/vasnprintf-posix.m4
@@ -1,4 +1,4 @@
-# vasnprintf-posix.m4 serial 17
+# vasnprintf-posix.m4 serial 18
 dnl Copyright (C) 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,
@@ -32,6 +32,7 @@ AC_DEFUN_ONCE([gl_FUNC_VASNPRINTF_IS_POSIX]
   AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
   AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
+  AC_REQUIRE([gl_PRINTF_FLAG_ALT_PRECISION_ZERO])
   AC_REQUIRE([gl_PRINTF_PRECISION])
   AC_REQUIRE([gl_PRINTF_ENOMEM])
   gl_cv_func_vasnprintf_posix=no
@@ -66,15 +67,19 @@ AC_DEFUN_ONCE([gl_FUNC_VASNPRINTF_IS_POSIX]
                                                         *yes)
                                                           case 
"$gl_cv_func_printf_flag_zero" in
                                                             *yes)
-                                                              case 
"$gl_cv_func_printf_precision" in
+                                                              case 
"$gl_cv_func_printf_flag_alt_precision_zero" in
                                                                 *yes)
-                                                                  case 
"$gl_cv_func_printf_enomem" in
+                                                                  case 
"$gl_cv_func_printf_precision" in
                                                                     *yes)
-                                                                      if test 
$ac_cv_func_vasnprintf = yes; then
-                                                                        # 
vasnprintf exists and is
-                                                                        # 
already POSIX compliant.
-                                                                        
gl_cv_func_vasnprintf_posix=yes
-                                                                      fi
+                                                                      case 
"$gl_cv_func_printf_enomem" in
+                                                                        *yes)
+                                                                          if 
test $ac_cv_func_vasnprintf = yes; then
+                                                                            # 
vasnprintf exists and is
+                                                                            # 
already POSIX compliant.
+                                                                            
gl_cv_func_vasnprintf_posix=yes
+                                                                          fi
+                                                                          ;;
+                                                                      esac
                                                                       ;;
                                                                   esac
                                                                   ;;
diff --git a/m4/vasnprintf.m4 b/m4/vasnprintf.m4
index df87b9e798..77da782188 100644
--- a/m4/vasnprintf.m4
+++ b/m4/vasnprintf.m4
@@ -1,4 +1,4 @@
-# vasnprintf.m4 serial 50
+# vasnprintf.m4 serial 51
 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,
@@ -367,6 +367,22 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO]
   esac
 ])
 
+# Extra prerequisites of lib/vasnprintf.c for supporting the # flag with a
+# zero precision and a zero value in the 'x' and 'X' directives.
+AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ALT_PRECISION_ZERO],
+[
+  AC_REQUIRE([gl_PRINTF_FLAG_ALT_PRECISION_ZERO])
+  case "$gl_cv_func_printf_flag_alt_precision_zero" in
+    *yes)
+      ;;
+    *)
+      AC_DEFINE([NEED_PRINTF_FLAG_ALT_PRECISION_ZERO], [1],
+        [Define if the vasnprintf implementation needs special code for the
+         # flag with a zero precision and a zero value in the 'x' and 'X' 
directives.])
+      ;;
+  esac
+])
+
 # Extra prerequisites of lib/vasnprintf.c for supporting large precisions.
 AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION],
 [
@@ -425,6 +441,7 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS]
   gl_PREREQ_VASNPRINTF_FLAG_GROUPING
   gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST
   gl_PREREQ_VASNPRINTF_FLAG_ZERO
+  gl_PREREQ_VASNPRINTF_FLAG_ALT_PRECISION_ZERO
   gl_PREREQ_VASNPRINTF_PRECISION
   gl_PREREQ_VASNPRINTF_ENOMEM
 ])
diff --git a/m4/vasprintf-posix.m4 b/m4/vasprintf-posix.m4
index 3c7a6540bd..09d306d01d 100644
--- a/m4/vasprintf-posix.m4
+++ b/m4/vasprintf-posix.m4
@@ -1,4 +1,4 @@
-# vasprintf-posix.m4 serial 17
+# vasprintf-posix.m4 serial 18
 dnl Copyright (C) 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,
@@ -33,6 +33,7 @@ AC_DEFUN([gl_FUNC_VASPRINTF_IS_POSIX]
   AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
   AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
+  AC_REQUIRE([gl_PRINTF_FLAG_ALT_PRECISION_ZERO])
   AC_REQUIRE([gl_PRINTF_PRECISION])
   AC_REQUIRE([gl_PRINTF_ENOMEM])
   gl_cv_func_vasprintf_posix=no
@@ -67,15 +68,19 @@ AC_DEFUN([gl_FUNC_VASPRINTF_IS_POSIX]
                                                         *yes)
                                                           case 
"$gl_cv_func_printf_flag_zero" in
                                                             *yes)
-                                                              case 
"$gl_cv_func_printf_precision" in
+                                                              case 
"$gl_cv_func_printf_flag_alt_precision_zero" in
                                                                 *yes)
-                                                                  case 
"$gl_cv_func_printf_enomem" in
+                                                                  case 
"$gl_cv_func_printf_precision" in
                                                                     *yes)
-                                                                      if test 
$ac_cv_func_vasprintf = yes; then
-                                                                        # 
vasprintf exists and is
-                                                                        # 
already POSIX compliant.
-                                                                        
gl_cv_func_vasprintf_posix=yes
-                                                                      fi
+                                                                      case 
"$gl_cv_func_printf_enomem" in
+                                                                        *yes)
+                                                                          if 
test $ac_cv_func_vasprintf = yes; then
+                                                                            # 
vasprintf exists and is
+                                                                            # 
already POSIX compliant.
+                                                                            
gl_cv_func_vasprintf_posix=yes
+                                                                          fi
+                                                                          ;;
+                                                                      esac
                                                                       ;;
                                                                   esac
                                                                   ;;
diff --git a/m4/vdprintf-posix.m4 b/m4/vdprintf-posix.m4
index e4b57924cd..57d3b23483 100644
--- a/m4/vdprintf-posix.m4
+++ b/m4/vdprintf-posix.m4
@@ -1,4 +1,4 @@
-# vdprintf-posix.m4 serial 7
+# vdprintf-posix.m4 serial 8
 dnl Copyright (C) 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,
@@ -33,6 +33,7 @@ AC_DEFUN([gl_FUNC_VDPRINTF_IS_POSIX]
   AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
   AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
+  AC_REQUIRE([gl_PRINTF_FLAG_ALT_PRECISION_ZERO])
   AC_REQUIRE([gl_PRINTF_PRECISION])
   AC_REQUIRE([gl_PRINTF_ENOMEM])
   gl_cv_func_vdprintf_posix=no
@@ -68,13 +69,17 @@ AC_DEFUN([gl_FUNC_VDPRINTF_IS_POSIX]
                                                           *yes)
                                                             case 
"$gl_cv_func_printf_flag_zero" in
                                                               *yes)
-                                                                case 
"$gl_cv_func_printf_precision" in
+                                                                case 
"$gl_cv_func_printf_flag_alt_precision_zero" in
                                                                   *yes)
-                                                                    case 
"$gl_cv_func_printf_enomem" in
+                                                                    case 
"$gl_cv_func_printf_precision" in
                                                                       *yes)
-                                                                        # 
vdprintf exists and is
-                                                                        # 
already POSIX compliant.
-                                                                        
gl_cv_func_vdprintf_posix=yes
+                                                                        case 
"$gl_cv_func_printf_enomem" in
+                                                                          *yes)
+                                                                            # 
vdprintf exists and is
+                                                                            # 
already POSIX compliant.
+                                                                            
gl_cv_func_vdprintf_posix=yes
+                                                                            ;;
+                                                                        esac
                                                                         ;;
                                                                     esac
                                                                     ;;
diff --git a/m4/vfprintf-posix.m4 b/m4/vfprintf-posix.m4
index 6b51c50ada..063bb86a40 100644
--- a/m4/vfprintf-posix.m4
+++ b/m4/vfprintf-posix.m4
@@ -1,4 +1,4 @@
-# vfprintf-posix.m4 serial 18
+# vfprintf-posix.m4 serial 19
 dnl Copyright (C) 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,
@@ -33,6 +33,7 @@ AC_DEFUN([gl_FUNC_VFPRINTF_IS_POSIX]
   AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
   AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
+  AC_REQUIRE([gl_PRINTF_FLAG_ALT_PRECISION_ZERO])
   AC_REQUIRE([gl_PRINTF_PRECISION])
   AC_REQUIRE([gl_PRINTF_ENOMEM])
   gl_cv_func_vfprintf_posix=no
@@ -66,13 +67,17 @@ AC_DEFUN([gl_FUNC_VFPRINTF_IS_POSIX]
                                                         *yes)
                                                           case 
"$gl_cv_func_printf_flag_zero" in
                                                             *yes)
-                                                              case 
"$gl_cv_func_printf_precision" in
+                                                              case 
"$gl_cv_func_printf_flag_alt_precision_zero" in
                                                                 *yes)
-                                                                  case 
"$gl_cv_func_printf_enomem" in
+                                                                  case 
"$gl_cv_func_printf_precision" in
                                                                     *yes)
-                                                                      # 
vfprintf exists and is
-                                                                      # 
already POSIX compliant.
-                                                                      
gl_cv_func_vfprintf_posix=yes
+                                                                      case 
"$gl_cv_func_printf_enomem" in
+                                                                        *yes)
+                                                                          # 
vfprintf exists and is
+                                                                          # 
already POSIX compliant.
+                                                                          
gl_cv_func_vfprintf_posix=yes
+                                                                          ;;
+                                                                      esac
                                                                       ;;
                                                                   esac
                                                                   ;;
diff --git a/m4/vsnprintf-posix.m4 b/m4/vsnprintf-posix.m4
index b47715c472..005fa1859f 100644
--- a/m4/vsnprintf-posix.m4
+++ b/m4/vsnprintf-posix.m4
@@ -1,4 +1,4 @@
-# vsnprintf-posix.m4 serial 19
+# vsnprintf-posix.m4 serial 20
 dnl Copyright (C) 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,
@@ -33,6 +33,7 @@ AC_DEFUN([gl_FUNC_VSNPRINTF_IS_POSIX]
   AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
   AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
+  AC_REQUIRE([gl_PRINTF_FLAG_ALT_PRECISION_ZERO])
   AC_REQUIRE([gl_PRINTF_PRECISION])
   AC_REQUIRE([gl_PRINTF_ENOMEM])
   gl_cv_func_vsnprintf_posix=no
@@ -74,23 +75,27 @@ AC_DEFUN([gl_FUNC_VSNPRINTF_IS_POSIX]
                                                           *yes)
                                                             case 
"$gl_cv_func_printf_flag_zero" in
                                                               *yes)
-                                                                case 
"$gl_cv_func_printf_precision" in
+                                                                case 
"$gl_cv_func_printf_flag_alt_precision_zero" in
                                                                   *yes)
-                                                                    case 
"$gl_cv_func_printf_enomem" in
+                                                                    case 
"$gl_cv_func_printf_precision" in
                                                                       *yes)
-                                                                        case 
"$gl_cv_func_snprintf_truncation_c99" in
+                                                                        case 
"$gl_cv_func_printf_enomem" in
                                                                           *yes)
-                                                                            
case "$gl_cv_func_snprintf_retval_c99" in
+                                                                            
case "$gl_cv_func_snprintf_truncation_c99" in
                                                                               
*yes)
-                                                                               
 case "$gl_cv_func_snprintf_directive_n" in
+                                                                               
 case "$gl_cv_func_snprintf_retval_c99" in
                                                                                
   *yes)
-                                                                               
     case "$gl_cv_func_snprintf_size1" in
+                                                                               
     case "$gl_cv_func_snprintf_directive_n" in
                                                                                
       *yes)
-                                                                               
         case "$gl_cv_func_vsnprintf_zerosize_c99" in
+                                                                               
         case "$gl_cv_func_snprintf_size1" in
                                                                                
           *yes)
-                                                                               
             # vsnprintf exists and is
-                                                                               
             # already POSIX compliant.
-                                                                               
             gl_cv_func_vsnprintf_posix=yes
+                                                                               
             case "$gl_cv_func_vsnprintf_zerosize_c99" in
+                                                                               
               *yes)
+                                                                               
                 # vsnprintf exists and is
+                                                                               
                 # already POSIX compliant.
+                                                                               
                 gl_cv_func_vsnprintf_posix=yes
+                                                                               
                 ;;
+                                                                               
             esac
                                                                                
             ;;
                                                                                
         esac
                                                                                
         ;;
diff --git a/m4/vsprintf-posix.m4 b/m4/vsprintf-posix.m4
index 57c3dd98f8..0e131a2afa 100644
--- a/m4/vsprintf-posix.m4
+++ b/m4/vsprintf-posix.m4
@@ -1,4 +1,4 @@
-# vsprintf-posix.m4 serial 16
+# vsprintf-posix.m4 serial 17
 dnl Copyright (C) 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,
@@ -33,6 +33,7 @@ AC_DEFUN([gl_FUNC_VSPRINTF_IS_POSIX]
   AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
   AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
+  AC_REQUIRE([gl_PRINTF_FLAG_ALT_PRECISION_ZERO])
   AC_REQUIRE([gl_PRINTF_PRECISION])
   AC_REQUIRE([gl_PRINTF_ENOMEM])
   gl_cv_func_vsprintf_posix=no
@@ -66,13 +67,17 @@ AC_DEFUN([gl_FUNC_VSPRINTF_IS_POSIX]
                                                         *yes)
                                                           case 
"$gl_cv_func_printf_flag_zero" in
                                                             *yes)
-                                                              case 
"$gl_cv_func_printf_precision" in
+                                                              case 
"$gl_cv_func_printf_flag_alt_precision_zero" in
                                                                 *yes)
-                                                                  case 
"$gl_cv_func_printf_enomem" in
+                                                                  case 
"$gl_cv_func_printf_precision" in
                                                                     *yes)
-                                                                      # 
vsprintf exists and is
-                                                                      # 
already POSIX compliant.
-                                                                      
gl_cv_func_vsprintf_posix=yes
+                                                                      case 
"$gl_cv_func_printf_enomem" in
+                                                                        *yes)
+                                                                          # 
vsprintf exists and is
+                                                                          # 
already POSIX compliant.
+                                                                          
gl_cv_func_vsprintf_posix=yes
+                                                                          ;;
+                                                                      esac
                                                                       ;;
                                                                   esac
                                                                   ;;




Reply via email to