]> Savannah Git Hosting - gnulib.git/commitdiff
*printf-posix: ISO C 23: Add %b directive for binary output of integers.
authorBruno Haible <bruno@clisp.org>
Fri, 17 Mar 2023 21:45:56 +0000 (22:45 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 17 Mar 2023 21:45:56 +0000 (22:45 +0100)
* lib/printf-parse.c (PRINTF_PARSE): Recognize the 'b' directive.
* lib/printf-parse.h: Update comment.
* lib/wprintf-parse.h: Likewise.
* lib/vasnprintf.c (MAX_ROOM_NEEDED, VASNPRINTF): Add support for the
'b' directive.
* m4/printf.m4 (gl_PRINTF_DIRECTIVE_B): New macro.
* m4/vasnprintf.m4 (gl_PREREQ_VASNPRINTF_DIRECTIVE_B): New macro.
(gl_PREREQ_VASNPRINTF_WITH_EXTRAS): Invoke it.
* m4/vasnwprintf-posix.m4 (gl_FUNC_VASNWPRINTF_POSIX): Invoke
gl_PREREQ_VASNPRINTF_DIRECTIVE_B.
* m4/dprintf-posix.m4 (gl_FUNC_DPRINTF_POSIX): Require
gl_PRINTF_DIRECTIVE_B and test its result. Invoke
gl_PREREQ_VASNPRINTF_DIRECTIVE_B.
* m4/fprintf-posix.m4 (gl_FUNC_FPRINTF_POSIX): Likewise.
* m4/obstack-printf-posix.m4 (gl_FUNC_OBSTACK_PRINTF_POSIX): Likewise.
* m4/snprintf-posix.m4 (gl_FUNC_SNPRINTF_POSIX): Likewise.
* m4/sprintf-posix.m4 (gl_FUNC_SPRINTF_POSIX): Likewise.
* m4/vasnprintf-posix.m4 (gl_FUNC_VASNPRINTF_POSIX): Likewise.
* m4/vasprintf-posix.m4 (gl_FUNC_VASPRINTF_POSIX): Likewise.
* m4/vdprintf-posix.m4 (gl_FUNC_VDPRINTF_POSIX): Likewise.
* m4/vfprintf-posix.m4 (gl_FUNC_VFPRINTF_POSIX): Likewise.
* m4/vsnprintf-posix.m4 (gl_FUNC_VSNPRINTF_POSIX): Likewise.
* m4/vsprintf-posix.m4 (gl_FUNC_VSPRINTF_POSIX): Likewise.
* tests/test-snprintf-posix.h (test_function): Add some tests of the %b
directive.
* tests/test-sprintf-posix.h (test_function): Likewise.
* tests/test-vasnprintf-posix.c (test_function): Likewise.
* tests/test-vasnwprintf-posix.c (test_function): Likewise.
* tests/test-vasprintf-posix.c (test_function): Likewise.
* doc/glibc-functions/asprintf.texi: Mention the 'b' directive.
* 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.

44 files changed:
ChangeLog
doc/glibc-functions/asprintf.texi
doc/glibc-functions/obstack_printf.texi
doc/glibc-functions/obstack_vprintf.texi
doc/glibc-functions/vasprintf.texi
doc/posix-functions/dprintf.texi
doc/posix-functions/fprintf.texi
doc/posix-functions/fwprintf.texi
doc/posix-functions/printf.texi
doc/posix-functions/snprintf.texi
doc/posix-functions/sprintf.texi
doc/posix-functions/swprintf.texi
doc/posix-functions/vdprintf.texi
doc/posix-functions/vfprintf.texi
doc/posix-functions/vfwprintf.texi
doc/posix-functions/vprintf.texi
doc/posix-functions/vsnprintf.texi
doc/posix-functions/vsprintf.texi
doc/posix-functions/vswprintf.texi
doc/posix-functions/vwprintf.texi
doc/posix-functions/wprintf.texi
lib/printf-parse.c
lib/printf-parse.h
lib/vasnprintf.c
lib/wprintf-parse.h
m4/dprintf-posix.m4
m4/fprintf-posix.m4
m4/obstack-printf-posix.m4
m4/printf.m4
m4/snprintf-posix.m4
m4/sprintf-posix.m4
m4/vasnprintf-posix.m4
m4/vasnprintf.m4
m4/vasnwprintf-posix.m4
m4/vasprintf-posix.m4
m4/vdprintf-posix.m4
m4/vfprintf-posix.m4
m4/vsnprintf-posix.m4
m4/vsprintf-posix.m4
tests/test-snprintf-posix.h
tests/test-sprintf-posix.h
tests/test-vasnprintf-posix.c
tests/test-vasnwprintf-posix.c
tests/test-vasprintf-posix.c

index 62dd39e17f1367b012997ba963faf40dd00dd852..173cd45bff1288cbd9bfb304f303575f39fe9c52 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,56 @@
+2023-03-17  Bruno Haible  <bruno@clisp.org>
+
+       *printf-posix: ISO C 23: Add %b directive for binary output of integers.
+       * lib/printf-parse.c (PRINTF_PARSE): Recognize the 'b' directive.
+       * lib/printf-parse.h: Update comment.
+       * lib/wprintf-parse.h: Likewise.
+       * lib/vasnprintf.c (MAX_ROOM_NEEDED, VASNPRINTF): Add support for the
+       'b' directive.
+       * m4/printf.m4 (gl_PRINTF_DIRECTIVE_B): New macro.
+       * m4/vasnprintf.m4 (gl_PREREQ_VASNPRINTF_DIRECTIVE_B): New macro.
+       (gl_PREREQ_VASNPRINTF_WITH_EXTRAS): Invoke it.
+       * m4/vasnwprintf-posix.m4 (gl_FUNC_VASNWPRINTF_POSIX): Invoke
+       gl_PREREQ_VASNPRINTF_DIRECTIVE_B.
+       * m4/dprintf-posix.m4 (gl_FUNC_DPRINTF_POSIX): Require
+       gl_PRINTF_DIRECTIVE_B and test its result. Invoke
+       gl_PREREQ_VASNPRINTF_DIRECTIVE_B.
+       * m4/fprintf-posix.m4 (gl_FUNC_FPRINTF_POSIX): Likewise.
+       * m4/obstack-printf-posix.m4 (gl_FUNC_OBSTACK_PRINTF_POSIX): Likewise.
+       * m4/snprintf-posix.m4 (gl_FUNC_SNPRINTF_POSIX): Likewise.
+       * m4/sprintf-posix.m4 (gl_FUNC_SPRINTF_POSIX): Likewise.
+       * m4/vasnprintf-posix.m4 (gl_FUNC_VASNPRINTF_POSIX): Likewise.
+       * m4/vasprintf-posix.m4 (gl_FUNC_VASPRINTF_POSIX): Likewise.
+       * m4/vdprintf-posix.m4 (gl_FUNC_VDPRINTF_POSIX): Likewise.
+       * m4/vfprintf-posix.m4 (gl_FUNC_VFPRINTF_POSIX): Likewise.
+       * m4/vsnprintf-posix.m4 (gl_FUNC_VSNPRINTF_POSIX): Likewise.
+       * m4/vsprintf-posix.m4 (gl_FUNC_VSPRINTF_POSIX): Likewise.
+       * tests/test-snprintf-posix.h (test_function): Add some tests of the %b
+       directive.
+       * tests/test-sprintf-posix.h (test_function): Likewise.
+       * tests/test-vasnprintf-posix.c (test_function): Likewise.
+       * tests/test-vasnwprintf-posix.c (test_function): Likewise.
+       * tests/test-vasprintf-posix.c (test_function): Likewise.
+       * doc/glibc-functions/asprintf.texi: Mention the 'b' directive.
+       * 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.
+
 2023-03-17  Bruno Haible  <bruno@clisp.org>
 
        vasnprintf, vasnwprintf: Simplify code.
index 93d092d795b608a4ddc81ad0e53d5fe83ceb155b..47708c40fb853f9ac7defb7f6905f2b1fe7ab771 100644 (file)
@@ -41,6 +41,11 @@ This function does not support the @samp{a} and @samp{A} directives on some
 platforms:
 glibc-2.3.6, Mac OS X 10.5, NetBSD 9.0, OpenBSD 4.0, Solaris 11.4, Cygwin 1.5.x.
 @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,
+AIX 7.2, Solaris 11.4, Cygwin 2.9.0.
+@item
 This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, Cygwin 1.5.x.
 @item
index b417486e7f542ec9510e91d13554ed1e21facea5..7feae78b36dce5a28381e5aa5594f0ddc435fc34 100644 (file)
@@ -39,6 +39,11 @@ platforms:
 glibc-2.3.6, NetBSD 9.0, OpenBSD 4.0, AIX 5.2, HP-UX 11,
 IRIX 6.5, Solaris 11.4, Cygwin 1.5.x, mingw, MSVC 14.
 @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,
+AIX 7.2, HP-UX 11, IRIX 6.5, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
+@item
 This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
index a4d6242704381a6ca3c8700bb22c8d310e59546f..cdded1022185d7fc21174312c8a59cd4cb27d34c 100644 (file)
@@ -39,6 +39,11 @@ platforms:
 glibc-2.3.6, NetBSD 9.0, OpenBSD 4.0, AIX 5.2, HP-UX 11,
 IRIX 6.5, Solaris 11.4, Cygwin 1.5.x, mingw, MSVC 14.
 @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,
+AIX 7.2, HP-UX 11, IRIX 6.5, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
+@item
 This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
index 2ba5405558bb416a6e139ddbc3e4dc6865913a8a..2f69df8e789e4340b51a7eabe172d7a315dccc0b 100644 (file)
@@ -41,6 +41,11 @@ This function does not support the @samp{a} and @samp{A} directives on some
 platforms:
 glibc-2.3.6, Mac OS X 10.5, NetBSD 9.0, OpenBSD 4.0, Solaris 11.4, Cygwin 1.5.x.
 @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,
+AIX 7.2, Solaris 11.4, Cygwin 2.9.0.
+@item
 This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, Cygwin 1.5.x.
 @item
index 51428d036fdd7633b8ad1c4bca76b19278e9e069..7d5aeb9051f86f470d2bcc2d28526f28bfc58fb7 100644 (file)
@@ -24,6 +24,11 @@ This function does not support the @samp{a} and @samp{A} directives on some
 platforms:
 glibc-2.3.6, Solaris 11.4.
 @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,
+AIX 7.2, Solaris 11.4, Cygwin 2.9.0.
+@item
 This function does not support the @samp{n} directive on some platforms:
 glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
 macOS 11.1.
index 18c4e0549d0a229eb098cf16be72bfebd9dc1297..eedd9babbfb741c596ec9bf9fc1d2b114430bcb1 100644 (file)
@@ -25,6 +25,11 @@ platforms:
 glibc-2.3.6, Mac OS X 10.5, NetBSD 9.0, OpenBSD 4.0, AIX 5.2, HP-UX 11,
 IRIX 6.5, Solaris 11.4, Cygwin 1.5.x, mingw, MSVC 14.
 @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,
+AIX 7.2, HP-UX 11, IRIX 6.5, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
+@item
 This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
index 1bd4f3d4b838c725be11a9981c14e9b96fa2a476..b9ce2eb024e6f4a54de25338c45a3efe44e241e3 100644 (file)
@@ -13,16 +13,21 @@ Portability problems fixed by Gnulib:
 Portability problems not fixed by Gnulib:
 @itemize
 @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.
-@item
 This function is missing on some platforms:
 NetBSD 3.0, OpenBSD 3.8, Minix 3.1.8, HP-UX 11.00, IRIX 6.5, Cygwin 1.5.x.
 @item
 On Windows and 32-bit AIX platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @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,
+AIX 7.2, HP-UX 11, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
+@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.
+@item
 When formatting an integer with grouping flag, this function inserts thousands
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
index 6fab46033eab14dfb0572020f2427c2852df095a..c32881c2ccb6f4efa83170c78feaef47aa471d5d 100644 (file)
@@ -25,6 +25,11 @@ platforms:
 glibc-2.3.6, Mac OS X 10.5, NetBSD 9.0, OpenBSD 4.0, AIX 5.2, HP-UX 11,
 IRIX 6.5, Solaris 11.4, Cygwin 1.5.x, mingw, MSVC 14.
 @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,
+AIX 7.2, HP-UX 11, IRIX 6.5, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
+@item
 This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
index 13d63acac726805af52057e0502f27209c2bb9c3..6d8453b9fe48f467002f525f278eec4059409f0b 100644 (file)
@@ -40,6 +40,11 @@ platforms:
 glibc-2.3.6, Mac OS X 10.5, NetBSD 9.0, OpenBSD 4.0, AIX 5.2, HP-UX 11,
 IRIX 6.5, Solaris 11.4, Cygwin 1.5.x, mingw, MSVC 14.
 @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,
+AIX 7.2, HP-UX 11, IRIX 6.5, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
+@item
 This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
index 0ced69dc57dbc72c32a6ba8df8acd06a1a055910..8974498ebf7ede6c1e87ff7c7a9c844dac65a4cb 100644 (file)
@@ -25,6 +25,11 @@ platforms:
 glibc-2.3.6, Mac OS X 10.5, NetBSD 9.0, OpenBSD 4.0, AIX 5.2, HP-UX 11,
 IRIX 6.5, Solaris 11.4, Cygwin 1.5.x, mingw, MSVC 14.
 @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,
+AIX 7.2, HP-UX 11, IRIX 6.5, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
+@item
 This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
index a076eb32cfd2c44385057b5b166a572ea59fa191..906ee521aa365960779cabbba7b8ee7233c0fec8 100644 (file)
@@ -13,10 +13,6 @@ Portability problems fixed by Gnulib:
 Portability problems not fixed by Gnulib:
 @itemize
 @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.
-@item
 This function is missing on some platforms:
 NetBSD 3.0, OpenBSD 3.8, Minix 3.1.8, HP-UX 11.00, IRIX 6.5, Cygwin 1.5.x.
 @item
@@ -35,6 +31,15 @@ accommodate all Unicode characters.
 @item
 On Windows, this function does not take a buffer size as second argument.
 @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,
+AIX 7.2, HP-UX 11, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
+@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.
+@item
 When formatting an integer with grouping flag, this function inserts thousands
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
index ca84b011bb1b5a4ca5e2634c10334d38a325c357..d4de64ee2558b6d3d1f1df4a035b874fe4bcf415 100644 (file)
@@ -24,6 +24,11 @@ This function does not support the @samp{a} and @samp{A} directives on some
 platforms:
 glibc-2.3.6, Solaris 11.4.
 @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,
+AIX 7.2, Solaris 11.4, Cygwin 2.9.0.
+@item
 This function does not support the @samp{n} directive on some platforms:
 glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
 macOS 11.1.
index 8441649d0325d0d9b0a86ebeb94dddffffeffd03..f3ec56b5a6e2d1a4ea4bc26bfd4d31914b1c1c63 100644 (file)
@@ -25,6 +25,11 @@ platforms:
 glibc-2.3.6, Mac OS X 10.5, NetBSD 9.0, OpenBSD 4.0, AIX 5.2, HP-UX 11,
 IRIX 6.5, Solaris 11.4, Cygwin 1.5.x, mingw, MSVC 14.
 @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,
+AIX 7.2, HP-UX 11, IRIX 6.5, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
+@item
 This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
index 56cd3851f8897323b86f775026f0c4806557f9e0..f6e136b0b1553dd30bb6d69fdade29b9d2df0c33 100644 (file)
@@ -13,16 +13,21 @@ Portability problems fixed by Gnulib:
 Portability problems not fixed by Gnulib:
 @itemize
 @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.
-@item
 This function is missing on some platforms:
 NetBSD 3.0, OpenBSD 3.8, Minix 3.1.8, HP-UX 11.00, IRIX 6.5, Cygwin 1.5.x.
 @item
 On Windows and 32-bit AIX platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @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,
+AIX 7.2, HP-UX 11, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
+@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.
+@item
 When formatting an integer with grouping flag, this function inserts thousands
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
index a43942fbd23e586836b9347e82979acd29aff511..6e05d41002847246f678f35fbfb5fdbbb67b20a5 100644 (file)
@@ -25,6 +25,11 @@ platforms:
 glibc-2.3.6, Mac OS X 10.5, NetBSD 9.0, OpenBSD 4.0, AIX 5.2, HP-UX 11,
 IRIX 6.5, Solaris 11.4, Cygwin 1.5.x, mingw, MSVC 14.
 @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,
+AIX 7.2, HP-UX 11, IRIX 6.5, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
+@item
 This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
index 2f3406ec4c8fb392d73def034e7dda1c35516137..660ccfb1c36c2872e6a23e4530b01cff899dcd4e 100644 (file)
@@ -37,6 +37,11 @@ platforms:
 glibc-2.3.6, Mac OS X 10.5, NetBSD 9.0, OpenBSD 4.0, AIX 5.2, HP-UX 11,
 IRIX 6.5, Solaris 11.4, Cygwin 1.5.x, mingw, MSVC 14.
 @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,
+AIX 7.2, HP-UX 11, IRIX 6.5, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
+@item
 This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
index 0ddcdfca12ddf39ce68d9910428101606801db45..8af4bdf279f8c0d85a783eec98ee1e382286e602 100644 (file)
@@ -25,6 +25,11 @@ platforms:
 glibc-2.3.6, Mac OS X 10.5, NetBSD 9.0, OpenBSD 4.0, AIX 5.2, HP-UX 11,
 IRIX 6.5, Solaris 11.4, Cygwin 1.5.x, mingw, MSVC 14.
 @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,
+AIX 7.2, HP-UX 11, IRIX 6.5, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
+@item
 This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
index 2f771216ab8044f13a96582d242eaaad373fdb32..62a644fb6d85ddd822fed06e41c347daee581c27 100644 (file)
@@ -13,10 +13,6 @@ Portability problems fixed by Gnulib:
 Portability problems not fixed by Gnulib:
 @itemize
 @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.
-@item
 This function is missing on some platforms:
 NetBSD 3.0, OpenBSD 3.8, Minix 3.1.8, HP-UX 11.00, IRIX 6.5, Cygwin 1.5.x.
 @item
@@ -25,6 +21,15 @@ accommodate all Unicode characters.
 @item
 On Windows, this function does not take a buffer size as second argument.
 @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,
+AIX 7.2, HP-UX 11, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
+@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.
+@item
 When formatting an integer with grouping flag, this function inserts thousands
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
index f2d839bdbca61e36852599a5db7361c67a70c744..80c86466630e25f2691ac9aa4f7f28d9e7ce327f 100644 (file)
@@ -13,10 +13,6 @@ Portability problems fixed by Gnulib:
 Portability problems not fixed by Gnulib:
 @itemize
 @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.
-@item
 This function is missing on some platforms:
 NetBSD 3.0, OpenBSD 3.8, Minix 3.1.8, HP-UX 11.00, IRIX 6.5, Cygwin 1.7.
 @item
@@ -26,6 +22,15 @@ platforms: Cygwin 1.5.x.
 On Windows and 32-bit AIX platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @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,
+AIX 7.2, HP-UX 11, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
+@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.
+@item
 When formatting an integer with grouping flag, this function inserts thousands
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
index 48ac729e0194750f1a7f4906137322a84dc25dd1..1c3b99b281504d0bdd003e1785ca55e6ddbe84aa 100644 (file)
@@ -13,10 +13,6 @@ Portability problems fixed by Gnulib:
 Portability problems not fixed by Gnulib:
 @itemize
 @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.
-@item
 This function is missing on some platforms:
 NetBSD 3.0, OpenBSD 3.8, Minix 3.1.8, HP-UX 11.00, IRIX 6.5.
 @item
@@ -26,6 +22,15 @@ platforms: Cygwin 1.5.x.
 On Windows and 32-bit AIX platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @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,
+AIX 7.2, HP-UX 11, Solaris 11.4, Cygwin 2.9.0, mingw, MSVC 14.
+@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.
+@item
 When formatting an integer with grouping flag, this function inserts thousands
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
index 3040749abdf2927a4c4e44ba0ea1c42aa57a527e..6273dd773fac757dd98f0836e6d9c9b58ee005f1 100644 (file)
@@ -453,7 +453,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
                   else
                     type = TYPE_INT;
                   break;
-                case 'o': case 'u': case 'x': case 'X':
+                case 'b': case 'o': case 'u': case 'x': case 'X':
                   /* If 'unsigned long long' is larger than 'unsigned long':  */
                   if (flags >= 16 || (flags & 4))
                     type = TYPE_ULONGLONGINT;
index 1f86e32c99e24f4645ab3c144b4ae0ae59813ae7..fcb3cc462ec700cd24dff5b7700392b8552cbb18 100644 (file)
@@ -61,7 +61,7 @@ typedef struct
   const char* precision_start;
   const char* precision_end;
   size_t precision_arg_index;
-  char conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
+  char conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
   size_t arg_index;
 }
 char_directive;
index a49eb1dcd7a83046e5612396cff91d139bc9c6c4..c2f10cb0c42df92855c524b8c040509919f19998 100644 (file)
@@ -1653,6 +1653,25 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
       tmp_length = xsum (tmp_length, 1);
       break;
 
+    case 'b':
+      if (type == TYPE_ULONGLONGINT)
+        tmp_length =
+          (unsigned int) (sizeof (unsigned long long) * CHAR_BIT)
+          + 1; /* turn floor into ceil */
+      else if (type == TYPE_ULONGINT)
+        tmp_length =
+          (unsigned int) (sizeof (unsigned long) * CHAR_BIT)
+          + 1; /* turn floor into ceil */
+      else
+        tmp_length =
+          (unsigned int) (sizeof (unsigned int) * CHAR_BIT)
+          + 1; /* turn floor into ceil */
+      if (tmp_length < precision)
+        tmp_length = precision;
+      /* Add 2, to account for a prefix from the alternate form.  */
+      tmp_length = xsum (tmp_length, 2);
+      break;
+
     case 'o':
       if (type == TYPE_ULONGLONGINT)
         tmp_length =
@@ -3043,6 +3062,199 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                 }
               }
 #endif
+#if NEED_PRINTF_DIRECTIVE_B
+            else if (dp->conversion == 'b')
+              {
+                arg_type type = a.arg[dp->arg_index].type;
+                int flags = dp->flags;
+                size_t width;
+                int has_precision;
+                size_t precision;
+                size_t tmp_length;
+                size_t count;
+                DCHAR_T tmpbuf[700];
+                DCHAR_T *tmp;
+                DCHAR_T *tmp_end;
+                DCHAR_T *tmp_start;
+                DCHAR_T *pad_ptr;
+                DCHAR_T *p;
+
+                width = 0;
+                if (dp->width_start != dp->width_end)
+                  {
+                    if (dp->width_arg_index != ARG_NONE)
+                      {
+                        int arg;
+
+                        if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+                          abort ();
+                        arg = a.arg[dp->width_arg_index].a.a_int;
+                        width = arg;
+                        if (arg < 0)
+                          {
+                            /* "A negative field width is taken as a '-' flag
+                                followed by a positive field width."  */
+                            flags |= FLAG_LEFT;
+                            width = -width;
+                          }
+                      }
+                    else
+                      {
+                        const FCHAR_T *digitp = dp->width_start;
+
+                        do
+                          width = xsum (xtimes (width, 10), *digitp++ - '0');
+                        while (digitp != dp->width_end);
+                      }
+                  }
+
+                has_precision = 0;
+                precision = 0;
+                if (dp->precision_start != dp->precision_end)
+                  {
+                    if (dp->precision_arg_index != ARG_NONE)
+                      {
+                        int arg;
+
+                        if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+                          abort ();
+                        arg = a.arg[dp->precision_arg_index].a.a_int;
+                        /* "A negative precision is taken as if the precision
+                            were omitted."  */
+                        if (arg >= 0)
+                          {
+                            precision = arg;
+                            has_precision = 1;
+                          }
+                      }
+                    else
+                      {
+                        const FCHAR_T *digitp = dp->precision_start + 1;
+
+                        precision = 0;
+                        while (digitp != dp->precision_end)
+                          precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+                        has_precision = 1;
+                      }
+                  }
+
+                /* Allocate a temporary buffer of sufficient size.  */
+                if (type == TYPE_ULONGLONGINT)
+                  tmp_length =
+                    (unsigned int) (sizeof (unsigned long long) * CHAR_BIT)
+                    + 1; /* turn floor into ceil */
+                else if (type == TYPE_ULONGINT)
+                  tmp_length =
+                    (unsigned int) (sizeof (unsigned long) * CHAR_BIT)
+                    + 1; /* turn floor into ceil */
+                else
+                  tmp_length =
+                    (unsigned int) (sizeof (unsigned int) * CHAR_BIT)
+                    + 1; /* turn floor into ceil */
+                if (tmp_length < precision)
+                  tmp_length = precision;
+                /* Add 2, to account for a prefix from the alternate form.  */
+                tmp_length = xsum (tmp_length, 2);
+
+                if (tmp_length < width)
+                  tmp_length = width;
+
+                if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T))
+                  tmp = tmpbuf;
+                else
+                  {
+                    size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T));
+
+                    if (size_overflow_p (tmp_memsize))
+                      /* Overflow, would lead to out of memory.  */
+                      goto out_of_memory;
+                    tmp = (DCHAR_T *) malloc (tmp_memsize);
+                    if (tmp == NULL)
+                      /* Out of memory.  */
+                      goto out_of_memory;
+                  }
+
+                tmp_end = tmp + tmp_length;
+
+                unsigned long long arg =
+                  (type == TYPE_ULONGLONGINT ? a.arg[dp->arg_index].a.a_ulonglongint :
+                   type == TYPE_ULONGINT ? a.arg[dp->arg_index].a.a_ulongint :
+                   a.arg[dp->arg_index].a.a_uint);
+                int need_prefix = ((flags & FLAG_ALT) && arg != 0);
+
+                p = tmp_end;
+                do
+                  {
+                    *--p = '0' + (arg & 1);
+                    arg = arg >> 1;
+                  }
+                while (arg != 0);
+
+                pad_ptr = p;
+
+                if (need_prefix)
+                  {
+                    *--p = 'b'; *--p = '0';
+                  }
+                tmp_start = p;
+
+                /* The generated string now extends from tmp_start to tmp_end,
+                   with the zero padding insertion point being at pad_ptr,
+                   tmp_start <= pad_ptr <= tmp_end.  */
+                count = tmp_end - tmp_start;
+
+                if (count < width)
+                  {
+                    size_t pad = width - count;
+
+                    if (flags & FLAG_LEFT)
+                      {
+                        /* Pad with spaces on the right.  */
+                        for (p = tmp_start; p < tmp_end; p++)
+                          *(p - pad) = *p;
+                        for (p = tmp_end - pad; p < tmp_end; p++)
+                          *p = ' ';
+                      }
+                    else if (flags & FLAG_ZERO)
+                      {
+                        /* Pad with zeroes.  */
+                        for (p = tmp_start; p < pad_ptr; p++)
+                          *(p - pad) = *p;
+                        for (p = pad_ptr - pad; p < pad_ptr; p++)
+                          *p = '0';
+                      }
+                    else
+                      {
+                        /* Pad with spaces on the left.  */
+                        for (p = tmp_start - pad; p < tmp_start; p++)
+                          *p = ' ';
+                      }
+
+                    tmp_start = tmp_start - pad;
+                  }
+
+                count = tmp_end - tmp_start;
+
+                if (count > tmp_length)
+                  /* tmp_length was incorrectly calculated - fix the
+                     code above!  */
+                  abort ();
+
+                /* Make room for the result.  */
+                if (count >= allocated - length)
+                  {
+                    size_t n = xsum (length, count);
+
+                    ENSURE_ALLOCATION (n);
+                  }
+
+                /* Append the result.  */
+                memcpy (result + length, tmp_start, count * sizeof (DCHAR_T));
+                if (tmp != tmpbuf)
+                  free (tmp);
+                length += count;
+              }
+#endif
 #if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE
             else if ((dp->conversion == 'a' || dp->conversion == 'A')
 # if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE))
@@ -4826,6 +5038,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                 switch (dp->conversion)
                   {
                   case 'd': case 'i': case 'u':
+                  case 'b':
                   case 'o':
                   case 'x': case 'X': case 'p':
                     prec_ourselves = has_precision && (precision > 0);
index 05799b8f15609e210f1f1300ad3affd15b9593fa..86bdec9a21a55e9069626cc19940c0320f4a53f4 100644 (file)
@@ -55,7 +55,7 @@ typedef struct
   const wchar_t* precision_start;
   const wchar_t* precision_end;
   size_t precision_arg_index;
-  wchar_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
+  wchar_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
   size_t arg_index;
 }
 wchar_t_directive;
index a25ef4164e81be86a9b97e19b8e7b097ac708165..4186ab70fe3284dfc47ded56fe49814a0786fcde 100644 (file)
@@ -1,4 +1,4 @@
-# dprintf-posix.m4 serial 3
+# dprintf-posix.m4 serial 4
 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,
@@ -11,6 +11,7 @@ AC_DEFUN([gl_FUNC_DPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_INFINITE])
   AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
+  AC_REQUIRE([gl_PRINTF_DIRECTIVE_B])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
@@ -33,27 +34,31 @@ AC_DEFUN([gl_FUNC_DPRINTF_POSIX],
                   *yes)
                     case "$gl_cv_func_printf_directive_a" in
                       *yes)
-                        case "$gl_cv_func_printf_directive_f" in
+                        case "$gl_cv_func_printf_directive_b" in
                           *yes)
-                            case "$gl_cv_func_printf_directive_n" in
+                            case "$gl_cv_func_printf_directive_f" in
                               *yes)
-                                case "$gl_cv_func_printf_directive_ls" in
+                                case "$gl_cv_func_printf_directive_n" in
                                   *yes)
-                                    case "$gl_cv_func_printf_positions" in
+                                    case "$gl_cv_func_printf_directive_ls" in
                                       *yes)
-                                        case "$gl_cv_func_printf_flag_grouping" in
+                                        case "$gl_cv_func_printf_positions" in
                                           *yes)
-                                            case "$gl_cv_func_printf_flag_leftadjust" in
+                                            case "$gl_cv_func_printf_flag_grouping" in
                                               *yes)
-                                                case "$gl_cv_func_printf_flag_zero" in
+                                                case "$gl_cv_func_printf_flag_leftadjust" in
                                                   *yes)
-                                                    case "$gl_cv_func_printf_precision" in
+                                                    case "$gl_cv_func_printf_flag_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
                                                         ;;
@@ -88,6 +93,7 @@ AC_DEFUN([gl_FUNC_DPRINTF_POSIX],
     gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
     gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
+    gl_PREREQ_VASNPRINTF_DIRECTIVE_B
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
     gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
     gl_PREREQ_VASNPRINTF_FLAG_GROUPING
index 3a51bcf4e1157604e64f6f516c4ab5f5160b6314..5602000e4a6dbff9af971f0d3eddbf7f4ec2dcf2 100644 (file)
@@ -1,4 +1,4 @@
-# fprintf-posix.m4 serial 14
+# fprintf-posix.m4 serial 15
 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,
@@ -11,6 +11,7 @@ AC_DEFUN([gl_FUNC_FPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_INFINITE])
   AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
+  AC_REQUIRE([gl_PRINTF_DIRECTIVE_B])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
@@ -31,27 +32,31 @@ AC_DEFUN([gl_FUNC_FPRINTF_POSIX],
                 *yes)
                   case "$gl_cv_func_printf_directive_a" in
                     *yes)
-                      case "$gl_cv_func_printf_directive_f" in
+                      case "$gl_cv_func_printf_directive_b" in
                         *yes)
-                          case "$gl_cv_func_printf_directive_n" in
+                          case "$gl_cv_func_printf_directive_f" in
                             *yes)
-                              case "$gl_cv_func_printf_directive_ls" in
+                              case "$gl_cv_func_printf_directive_n" in
                                 *yes)
-                                  case "$gl_cv_func_printf_positions" in
+                                  case "$gl_cv_func_printf_directive_ls" in
                                     *yes)
-                                      case "$gl_cv_func_printf_flag_grouping" in
+                                      case "$gl_cv_func_printf_positions" in
                                         *yes)
-                                          case "$gl_cv_func_printf_flag_leftadjust" in
+                                          case "$gl_cv_func_printf_flag_grouping" in
                                             *yes)
-                                              case "$gl_cv_func_printf_flag_zero" in
+                                              case "$gl_cv_func_printf_flag_leftadjust" in
                                                 *yes)
-                                                  case "$gl_cv_func_printf_precision" in
+                                                  case "$gl_cv_func_printf_flag_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
                                                       ;;
@@ -85,6 +90,7 @@ AC_DEFUN([gl_FUNC_FPRINTF_POSIX],
     gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
     gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
+    gl_PREREQ_VASNPRINTF_DIRECTIVE_B
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
     gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
     gl_PREREQ_VASNPRINTF_FLAG_GROUPING
index 10f744c5752873c38bf7141116e2cac2040ed615..633b01744274bec7e7e9710d1f28b80334c51b26 100644 (file)
@@ -1,4 +1,4 @@
-# obstack-printf-posix.m4 serial 4
+# obstack-printf-posix.m4 serial 5
 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,
@@ -14,6 +14,7 @@ AC_DEFUN([gl_FUNC_OBSTACK_PRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_INFINITE])
   AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
+  AC_REQUIRE([gl_PRINTF_DIRECTIVE_B])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
@@ -36,27 +37,31 @@ AC_DEFUN([gl_FUNC_OBSTACK_PRINTF_POSIX],
                   *yes)
                     case "$gl_cv_func_printf_directive_a" in
                       *yes)
-                        case "$gl_cv_func_printf_directive_f" in
+                        case "$gl_cv_func_printf_directive_b" in
                           *yes)
-                            case "$gl_cv_func_printf_directive_n" in
+                            case "$gl_cv_func_printf_directive_f" in
                               *yes)
-                                case "$gl_cv_func_printf_directive_ls" in
+                                case "$gl_cv_func_printf_directive_n" in
                                   *yes)
-                                    case "$gl_cv_func_printf_positions" in
+                                    case "$gl_cv_func_printf_directive_ls" in
                                       *yes)
-                                        case "$gl_cv_func_printf_flag_grouping" in
+                                        case "$gl_cv_func_printf_positions" in
                                           *yes)
-                                            case "$gl_cv_func_printf_flag_leftadjust" in
+                                            case "$gl_cv_func_printf_flag_grouping" in
                                               *yes)
-                                                case "$gl_cv_func_printf_flag_zero" in
+                                                case "$gl_cv_func_printf_flag_leftadjust" in
                                                   *yes)
-                                                    case "$gl_cv_func_printf_precision" in
+                                                    case "$gl_cv_func_printf_flag_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
                                                         ;;
@@ -91,6 +96,7 @@ AC_DEFUN([gl_FUNC_OBSTACK_PRINTF_POSIX],
     gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
     gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
+    gl_PREREQ_VASNPRINTF_DIRECTIVE_B
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
     gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
     gl_PREREQ_VASNPRINTF_FLAG_GROUPING
index de98a870e983363fdfef9316611a84d45c3c3578..719679c3625cc939cc3029e0ffddcd26cff97a93 100644 (file)
@@ -1,4 +1,4 @@
-# printf.m4 serial 74
+# printf.m4 serial 75
 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,
@@ -603,6 +603,50 @@ int main ()
     ])
 ])
 
+dnl Test whether the *printf family of functions supports the 'b' conversion
+dnl specifier for binary output of integers.
+dnl (ISO C23)
+dnl Result is gl_cv_func_printf_directive_b.
+
+AC_DEFUN([gl_PRINTF_DIRECTIVE_B],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether printf supports the 'b' directive],
+    [gl_cv_func_printf_directive_b],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+static char buf[100];
+int main ()
+{
+  int result = 0;
+  if (sprintf (buf, "%b %d", 12345, 33, 44, 55) < 0
+      || strcmp (buf, "11000000111001 33") != 0)
+    result |= 1;
+  return result;
+}]])],
+        [gl_cv_func_printf_directive_b=yes],
+        [gl_cv_func_printf_directive_b=no],
+        [
+         case "$host_os" in
+                               # Guess no on glibc systems.
+           *-gnu* | gnu*)      gl_cv_func_printf_directive_b="guessing no";;
+                               # Guess no on musl systems.
+           *-musl* | midipix*) gl_cv_func_printf_directive_b="guessing no";;
+                               # Guess no on Android.
+           linux*-android*)    gl_cv_func_printf_directive_b="guessing no";;
+                               # Guess no on native Windows.
+           mingw*)             gl_cv_func_printf_directive_b="guessing no";;
+                               # If we don't know, obey --enable-cross-guesses.
+           *)                  gl_cv_func_printf_directive_b="$gl_cross_guess_normal";;
+         esac
+        ])
+    ])
+])
+
 dnl Test whether the *printf family of functions supports the %F format
 dnl directive. (ISO C99, POSIX:2001)
 dnl Result is gl_cv_func_printf_directive_f.
@@ -1648,81 +1692,83 @@ dnl 2 = gl_PRINTF_LONG_DOUBLE
 dnl 3 = gl_PRINTF_INFINITE
 dnl 4 = gl_PRINTF_INFINITE_LONG_DOUBLE
 dnl 5 = gl_PRINTF_DIRECTIVE_A
-dnl 6 = gl_PRINTF_DIRECTIVE_F
-dnl 7 = gl_PRINTF_DIRECTIVE_N
-dnl 8 = gl_PRINTF_DIRECTIVE_LS
-dnl 9 = gl_PRINTF_POSITIONS
-dnl 10 = gl_PRINTF_FLAG_GROUPING
-dnl 11 = gl_PRINTF_FLAG_LEFTADJUST
-dnl 12 = gl_PRINTF_FLAG_ZERO
-dnl 13 = gl_PRINTF_PRECISION
-dnl 14 = gl_PRINTF_ENOMEM
-dnl 15 = gl_SNPRINTF_PRESENCE
-dnl 16 = gl_SNPRINTF_TRUNCATION_C99
-dnl 17 = gl_SNPRINTF_RETVAL_C99
-dnl 18 = gl_SNPRINTF_DIRECTIVE_N
-dnl 19 = gl_SNPRINTF_SIZE1
-dnl 20 = gl_VSNPRINTF_ZEROSIZE_C99
+dnl 6 = gl_PRINTF_DIRECTIVE_B
+dnl 7 = gl_PRINTF_DIRECTIVE_F
+dnl 8 = gl_PRINTF_DIRECTIVE_N
+dnl 9 = gl_PRINTF_DIRECTIVE_LS
+dnl 10 = gl_PRINTF_POSITIONS
+dnl 11 = gl_PRINTF_FLAG_GROUPING
+dnl 12 = gl_PRINTF_FLAG_LEFTADJUST
+dnl 13 = gl_PRINTF_FLAG_ZERO
+dnl 14 = gl_PRINTF_PRECISION
+dnl 15 = gl_PRINTF_ENOMEM
+dnl 16 = gl_SNPRINTF_PRESENCE
+dnl 17 = gl_SNPRINTF_TRUNCATION_C99
+dnl 18 = gl_SNPRINTF_RETVAL_C99
+dnl 19 = gl_SNPRINTF_DIRECTIVE_N
+dnl 20 = gl_SNPRINTF_SIZE1
+dnl 21 = gl_VSNPRINTF_ZEROSIZE_C99
 dnl
 dnl 1 = checking whether printf supports size specifiers as in C99...
 dnl 2 = checking whether printf supports 'long double' arguments...
 dnl 3 = checking whether printf supports infinite 'double' arguments...
 dnl 4 = checking whether printf supports infinite 'long double' arguments...
 dnl 5 = checking whether printf supports the 'a' and 'A' directives...
-dnl 6 = checking whether printf supports the 'F' directive...
-dnl 7 = checking whether printf supports the 'n' directive...
-dnl 8 = checking whether printf supports the 'ls' directive...
-dnl 9 = checking whether printf supports POSIX/XSI format strings with positions...
-dnl 10 = checking whether printf supports the grouping flag...
-dnl 11 = checking whether printf supports the left-adjust flag correctly...
-dnl 12 = checking whether printf supports the zero flag correctly...
-dnl 13 = checking whether printf supports large precisions...
-dnl 14 = checking whether printf survives out-of-memory conditions...
-dnl 15 = checking for snprintf...
-dnl 16 = checking whether snprintf truncates the result as in C99...
-dnl 17 = checking whether snprintf returns a byte count as in C99...
-dnl 18 = checking whether snprintf fully supports the 'n' directive...
-dnl 19 = checking whether snprintf respects a size of 1...
-dnl 20 = checking whether vsnprintf respects a zero size as in C99...
+dnl 6 = checking whether printf supports the 'b' directive...
+dnl 7 = checking whether printf supports the 'F' directive...
+dnl 8 = checking whether printf supports the 'n' directive...
+dnl 9 = checking whether printf supports the 'ls' directive...
+dnl 10 = checking whether printf supports POSIX/XSI format strings with positions...
+dnl 11 = checking whether printf supports the grouping flag...
+dnl 12 = checking whether printf supports the left-adjust flag correctly...
+dnl 13 = checking whether printf supports the zero flag correctly...
+dnl 14 = checking whether printf supports large precisions...
+dnl 15 = checking whether printf survives out-of-memory conditions...
+dnl 16 = checking for snprintf...
+dnl 17 = checking whether snprintf truncates the result as in C99...
+dnl 18 = checking whether snprintf returns a byte count as in C99...
+dnl 19 = checking whether snprintf fully supports the 'n' directive...
+dnl 20 = checking whether snprintf respects a size of 1...
+dnl 21 = checking whether vsnprintf respects a zero size as in C99...
 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
-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
+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                 #  #  #  #  #  #  #  .  .  #  #  .  #  #  ?  .  #  #  #  .  .
index 61a80a8aa8d7c09f99d15902834d2ecdcf496c68..033e1916e5db82fa8157a01acc7f5bdd3770cb53 100644 (file)
@@ -1,4 +1,4 @@
-# snprintf-posix.m4 serial 14
+# snprintf-posix.m4 serial 15
 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,
@@ -11,6 +11,7 @@ AC_DEFUN([gl_FUNC_SNPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_INFINITE])
   AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
+  AC_REQUIRE([gl_PRINTF_DIRECTIVE_B])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
@@ -38,37 +39,41 @@ AC_DEFUN([gl_FUNC_SNPRINTF_POSIX],
                   *yes)
                     case "$gl_cv_func_printf_directive_a" in
                       *yes)
-                        case "$gl_cv_func_printf_directive_f" in
+                        case "$gl_cv_func_printf_directive_b" in
                           *yes)
-                            case "$gl_cv_func_printf_directive_n" in
+                            case "$gl_cv_func_printf_directive_f" in
                               *yes)
-                                case "$gl_cv_func_printf_directive_ls" in
+                                case "$gl_cv_func_printf_directive_n" in
                                   *yes)
-                                    case "$gl_cv_func_printf_positions" in
+                                    case "$gl_cv_func_printf_directive_ls" in
                                       *yes)
-                                        case "$gl_cv_func_printf_flag_grouping" in
+                                        case "$gl_cv_func_printf_positions" in
                                           *yes)
-                                            case "$gl_cv_func_printf_flag_leftadjust" in
+                                            case "$gl_cv_func_printf_flag_grouping" in
                                               *yes)
-                                                case "$gl_cv_func_printf_flag_zero" in
+                                                case "$gl_cv_func_printf_flag_leftadjust" in
                                                   *yes)
-                                                    case "$gl_cv_func_printf_precision" in
+                                                    case "$gl_cv_func_printf_flag_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
                                                                             ;;
@@ -113,6 +118,7 @@ AC_DEFUN([gl_FUNC_SNPRINTF_POSIX],
     gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
     gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
+    gl_PREREQ_VASNPRINTF_DIRECTIVE_B
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
     gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
     gl_PREREQ_VASNPRINTF_FLAG_GROUPING
index 9d9258e17af0d1864e7464f92f403b1e8fb6c51f..cfcbe37ccecb66f906ca6a6af9884d52f0fcd6a1 100644 (file)
@@ -1,4 +1,4 @@
-# sprintf-posix.m4 serial 12
+# sprintf-posix.m4 serial 13
 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,
@@ -11,6 +11,7 @@ AC_DEFUN([gl_FUNC_SPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_INFINITE])
   AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
+  AC_REQUIRE([gl_PRINTF_DIRECTIVE_B])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
@@ -31,27 +32,31 @@ AC_DEFUN([gl_FUNC_SPRINTF_POSIX],
                 *yes)
                   case "$gl_cv_func_printf_directive_a" in
                     *yes)
-                      case "$gl_cv_func_printf_directive_f" in
+                      case "$gl_cv_func_printf_directive_b" in
                         *yes)
-                          case "$gl_cv_func_printf_directive_n" in
+                          case "$gl_cv_func_printf_directive_f" in
                             *yes)
-                              case "$gl_cv_func_printf_directive_ls" in
+                              case "$gl_cv_func_printf_directive_n" in
                                 *yes)
-                                  case "$gl_cv_func_printf_positions" in
+                                  case "$gl_cv_func_printf_directive_ls" in
                                     *yes)
-                                      case "$gl_cv_func_printf_flag_grouping" in
+                                      case "$gl_cv_func_printf_positions" in
                                         *yes)
-                                          case "$gl_cv_func_printf_flag_leftadjust" in
+                                          case "$gl_cv_func_printf_flag_grouping" in
                                             *yes)
-                                              case "$gl_cv_func_printf_flag_zero" in
+                                              case "$gl_cv_func_printf_flag_leftadjust" in
                                                 *yes)
-                                                  case "$gl_cv_func_printf_precision" in
+                                                  case "$gl_cv_func_printf_flag_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
                                                       ;;
@@ -85,6 +90,7 @@ AC_DEFUN([gl_FUNC_SPRINTF_POSIX],
     gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
     gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
+    gl_PREREQ_VASNPRINTF_DIRECTIVE_B
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
     gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
     gl_PREREQ_VASNPRINTF_FLAG_GROUPING
index baf7cb437dd253db53713044294bd103c0b26689..4983dfc50a89ee6e1f8e3cbcf7a768fff68c0b79 100644 (file)
@@ -1,4 +1,4 @@
-# vasnprintf-posix.m4 serial 13
+# vasnprintf-posix.m4 serial 14
 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,
@@ -11,6 +11,7 @@ AC_DEFUN([gl_FUNC_VASNPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_INFINITE])
   AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
+  AC_REQUIRE([gl_PRINTF_DIRECTIVE_B])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
@@ -32,29 +33,33 @@ AC_DEFUN([gl_FUNC_VASNPRINTF_POSIX],
                 *yes)
                   case "$gl_cv_func_printf_directive_a" in
                     *yes)
-                      case "$gl_cv_func_printf_directive_f" in
+                      case "$gl_cv_func_printf_directive_b" in
                         *yes)
-                          case "$gl_cv_func_printf_directive_n" in
+                          case "$gl_cv_func_printf_directive_f" in
                             *yes)
-                              case "$gl_cv_func_printf_directive_ls" in
+                              case "$gl_cv_func_printf_directive_n" in
                                 *yes)
-                                  case "$gl_cv_func_printf_positions" in
+                                  case "$gl_cv_func_printf_directive_ls" in
                                     *yes)
-                                      case "$gl_cv_func_printf_flag_grouping" in
+                                      case "$gl_cv_func_printf_positions" in
                                         *yes)
-                                          case "$gl_cv_func_printf_flag_leftadjust" in
+                                          case "$gl_cv_func_printf_flag_grouping" in
                                             *yes)
-                                              case "$gl_cv_func_printf_flag_zero" in
+                                              case "$gl_cv_func_printf_flag_leftadjust" in
                                                 *yes)
-                                                  case "$gl_cv_func_printf_precision" in
+                                                  case "$gl_cv_func_printf_flag_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
                                                       ;;
@@ -88,6 +93,7 @@ AC_DEFUN([gl_FUNC_VASNPRINTF_POSIX],
     gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
     gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
+    gl_PREREQ_VASNPRINTF_DIRECTIVE_B
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
     gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
     gl_PREREQ_VASNPRINTF_FLAG_GROUPING
index cf451f9b030e3941b31f5c6397a36c647d30bb56..b868aed08be8335a95973c4fe433851ac740b0ca 100644 (file)
@@ -1,4 +1,4 @@
-# vasnprintf.m4 serial 40
+# vasnprintf.m4 serial 41
 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,
@@ -182,6 +182,21 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
   esac
 ])
 
+# Extra prerequisites of lib/vasnprintf.c for supporting the 'b' directive.
+AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_B],
+[
+  AC_REQUIRE([gl_PRINTF_DIRECTIVE_B])
+  case "$gl_cv_func_printf_directive_b" in
+    *yes)
+      ;;
+    *)
+      AC_DEFINE([NEED_PRINTF_DIRECTIVE_B], [1],
+        [Define if the vasnprintf implementation needs special code for
+         the 'b' directive.])
+      ;;
+  esac
+])
+
 # Extra prerequisites of lib/vasnprintf.c for supporting the 'F' directive.
 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F],
 [
@@ -308,6 +323,7 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_EXTRAS],
   gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
   gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
   gl_PREREQ_VASNPRINTF_DIRECTIVE_A
+  gl_PREREQ_VASNPRINTF_DIRECTIVE_B
   gl_PREREQ_VASNPRINTF_DIRECTIVE_F
   gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
   gl_PREREQ_VASNPRINTF_FLAG_GROUPING
index 9561bcf2b646ba7767ee86175f37621eb83b981c..d9dc41fa9767aac303aef6cc7b763bfba40d9960 100644 (file)
@@ -1,4 +1,4 @@
-# vasnwprintf-posix.m4 serial 1
+# vasnwprintf-posix.m4 serial 2
 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,
@@ -11,6 +11,7 @@ AC_DEFUN([gl_FUNC_VASNWPRINTF_POSIX],
   gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
   gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
   gl_PREREQ_VASNPRINTF_DIRECTIVE_A
+  gl_PREREQ_VASNPRINTF_DIRECTIVE_B
   gl_PREREQ_VASNPRINTF_DIRECTIVE_F
   gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
   gl_PREREQ_VASNPRINTF_FLAG_GROUPING
index 7c198a641081f0090664c0f0b134423728534922..1537ad52d9e23593a9c027be2eeee309b9748da5 100644 (file)
@@ -1,4 +1,4 @@
-# vasprintf-posix.m4 serial 13
+# vasprintf-posix.m4 serial 14
 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,
@@ -11,6 +11,7 @@ AC_DEFUN([gl_FUNC_VASPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_INFINITE])
   AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
+  AC_REQUIRE([gl_PRINTF_DIRECTIVE_B])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
@@ -32,29 +33,33 @@ AC_DEFUN([gl_FUNC_VASPRINTF_POSIX],
                 *yes)
                   case "$gl_cv_func_printf_directive_a" in
                     *yes)
-                      case "$gl_cv_func_printf_directive_f" in
+                      case "$gl_cv_func_printf_directive_b" in
                         *yes)
-                          case "$gl_cv_func_printf_directive_n" in
+                          case "$gl_cv_func_printf_directive_f" in
                             *yes)
-                              case "$gl_cv_func_printf_directive_ls" in
+                              case "$gl_cv_func_printf_directive_n" in
                                 *yes)
-                                  case "$gl_cv_func_printf_positions" in
+                                  case "$gl_cv_func_printf_directive_ls" in
                                     *yes)
-                                      case "$gl_cv_func_printf_flag_grouping" in
+                                      case "$gl_cv_func_printf_positions" in
                                         *yes)
-                                          case "$gl_cv_func_printf_flag_leftadjust" in
+                                          case "$gl_cv_func_printf_flag_grouping" in
                                             *yes)
-                                              case "$gl_cv_func_printf_flag_zero" in
+                                              case "$gl_cv_func_printf_flag_leftadjust" in
                                                 *yes)
-                                                  case "$gl_cv_func_printf_precision" in
+                                                  case "$gl_cv_func_printf_flag_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
                                                       ;;
@@ -88,6 +93,7 @@ AC_DEFUN([gl_FUNC_VASPRINTF_POSIX],
     gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
     gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
+    gl_PREREQ_VASNPRINTF_DIRECTIVE_B
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
     gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
     gl_PREREQ_VASNPRINTF_FLAG_GROUPING
index 47914cd1770574d797d76956790dc617542fef31..eb9ab8c6798310d95ccfb56f40ad1218c1a4f929 100644 (file)
@@ -1,4 +1,4 @@
-# vdprintf-posix.m4 serial 3
+# vdprintf-posix.m4 serial 4
 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,
@@ -11,6 +11,7 @@ AC_DEFUN([gl_FUNC_VDPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_INFINITE])
   AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
+  AC_REQUIRE([gl_PRINTF_DIRECTIVE_B])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
@@ -33,27 +34,31 @@ AC_DEFUN([gl_FUNC_VDPRINTF_POSIX],
                   *yes)
                     case "$gl_cv_func_printf_directive_a" in
                       *yes)
-                        case "$gl_cv_func_printf_directive_f" in
+                        case "$gl_cv_func_printf_directive_b" in
                           *yes)
-                            case "$gl_cv_func_printf_directive_n" in
+                            case "$gl_cv_func_printf_directive_f" in
                               *yes)
-                                case "$gl_cv_func_printf_directive_ls" in
+                                case "$gl_cv_func_printf_directive_n" in
                                   *yes)
-                                    case "$gl_cv_func_printf_positions" in
+                                    case "$gl_cv_func_printf_directive_ls" in
                                       *yes)
-                                        case "$gl_cv_func_printf_flag_grouping" in
+                                        case "$gl_cv_func_printf_positions" in
                                           *yes)
-                                            case "$gl_cv_func_printf_flag_leftadjust" in
+                                            case "$gl_cv_func_printf_flag_grouping" in
                                               *yes)
-                                                case "$gl_cv_func_printf_flag_zero" in
+                                                case "$gl_cv_func_printf_flag_leftadjust" in
                                                   *yes)
-                                                    case "$gl_cv_func_printf_precision" in
+                                                    case "$gl_cv_func_printf_flag_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
                                                         ;;
@@ -88,6 +93,7 @@ AC_DEFUN([gl_FUNC_VDPRINTF_POSIX],
     gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
     gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
+    gl_PREREQ_VASNPRINTF_DIRECTIVE_B
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
     gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
     gl_PREREQ_VASNPRINTF_FLAG_GROUPING
index ec68052214287c0812b3d362f3dc25a59d974034..17a8bad843999eb3fc346568ecf3011a73f1c8bd 100644 (file)
@@ -1,4 +1,4 @@
-# vfprintf-posix.m4 serial 14
+# vfprintf-posix.m4 serial 15
 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,
@@ -11,6 +11,7 @@ AC_DEFUN([gl_FUNC_VFPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_INFINITE])
   AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
+  AC_REQUIRE([gl_PRINTF_DIRECTIVE_B])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
@@ -31,27 +32,31 @@ AC_DEFUN([gl_FUNC_VFPRINTF_POSIX],
                 *yes)
                   case "$gl_cv_func_printf_directive_a" in
                     *yes)
-                      case "$gl_cv_func_printf_directive_f" in
+                      case "$gl_cv_func_printf_directive_b" in
                         *yes)
-                          case "$gl_cv_func_printf_directive_n" in
+                          case "$gl_cv_func_printf_directive_f" in
                             *yes)
-                              case "$gl_cv_func_printf_directive_ls" in
+                              case "$gl_cv_func_printf_directive_n" in
                                 *yes)
-                                  case "$gl_cv_func_printf_positions" in
+                                  case "$gl_cv_func_printf_directive_ls" in
                                     *yes)
-                                      case "$gl_cv_func_printf_flag_grouping" in
+                                      case "$gl_cv_func_printf_positions" in
                                         *yes)
-                                          case "$gl_cv_func_printf_flag_leftadjust" in
+                                          case "$gl_cv_func_printf_flag_grouping" in
                                             *yes)
-                                              case "$gl_cv_func_printf_flag_zero" in
+                                              case "$gl_cv_func_printf_flag_leftadjust" in
                                                 *yes)
-                                                  case "$gl_cv_func_printf_precision" in
+                                                  case "$gl_cv_func_printf_flag_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
                                                       ;;
@@ -85,6 +90,7 @@ AC_DEFUN([gl_FUNC_VFPRINTF_POSIX],
     gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
     gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
+    gl_PREREQ_VASNPRINTF_DIRECTIVE_B
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
     gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
     gl_PREREQ_VASNPRINTF_FLAG_GROUPING
index 5ea04a05e5c8f96eadde7f6b4e2e1e99135e42c0..65805522d4684952a579920a395dfd4c4c7b74cf 100644 (file)
@@ -1,4 +1,4 @@
-# vsnprintf-posix.m4 serial 15
+# vsnprintf-posix.m4 serial 16
 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,
@@ -11,6 +11,7 @@ AC_DEFUN([gl_FUNC_VSNPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_INFINITE])
   AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
+  AC_REQUIRE([gl_PRINTF_DIRECTIVE_B])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
@@ -39,37 +40,41 @@ AC_DEFUN([gl_FUNC_VSNPRINTF_POSIX],
                   *yes)
                     case "$gl_cv_func_printf_directive_a" in
                       *yes)
-                        case "$gl_cv_func_printf_directive_f" in
+                        case "$gl_cv_func_printf_directive_b" in
                           *yes)
-                            case "$gl_cv_func_printf_directive_n" in
+                            case "$gl_cv_func_printf_directive_f" in
                               *yes)
-                                case "$gl_cv_func_printf_directive_ls" in
+                                case "$gl_cv_func_printf_directive_n" in
                                   *yes)
-                                    case "$gl_cv_func_printf_positions" in
+                                    case "$gl_cv_func_printf_directive_ls" in
                                       *yes)
-                                        case "$gl_cv_func_printf_flag_grouping" in
+                                        case "$gl_cv_func_printf_positions" in
                                           *yes)
-                                            case "$gl_cv_func_printf_flag_leftadjust" in
+                                            case "$gl_cv_func_printf_flag_grouping" in
                                               *yes)
-                                                case "$gl_cv_func_printf_flag_zero" in
+                                                case "$gl_cv_func_printf_flag_leftadjust" in
                                                   *yes)
-                                                    case "$gl_cv_func_printf_precision" in
+                                                    case "$gl_cv_func_printf_flag_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
                                                                             ;;
@@ -114,6 +119,7 @@ AC_DEFUN([gl_FUNC_VSNPRINTF_POSIX],
     gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
     gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
+    gl_PREREQ_VASNPRINTF_DIRECTIVE_B
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
     gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
     gl_PREREQ_VASNPRINTF_FLAG_GROUPING
index 3ca0178ebdeec11b4bb79eeed91a6cedc23e11b1..716f58f761d3a9697eef2699d6222b1e77fed6c7 100644 (file)
@@ -1,4 +1,4 @@
-# vsprintf-posix.m4 serial 12
+# vsprintf-posix.m4 serial 13
 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,
@@ -11,6 +11,7 @@ AC_DEFUN([gl_FUNC_VSPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_INFINITE])
   AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
+  AC_REQUIRE([gl_PRINTF_DIRECTIVE_B])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
@@ -31,27 +32,31 @@ AC_DEFUN([gl_FUNC_VSPRINTF_POSIX],
                 *yes)
                   case "$gl_cv_func_printf_directive_a" in
                     *yes)
-                      case "$gl_cv_func_printf_directive_f" in
+                      case "$gl_cv_func_printf_directive_b" in
                         *yes)
-                          case "$gl_cv_func_printf_directive_n" in
+                          case "$gl_cv_func_printf_directive_f" in
                             *yes)
-                              case "$gl_cv_func_printf_directive_ls" in
+                              case "$gl_cv_func_printf_directive_n" in
                                 *yes)
-                                  case "$gl_cv_func_printf_positions" in
+                                  case "$gl_cv_func_printf_directive_ls" in
                                     *yes)
-                                      case "$gl_cv_func_printf_flag_grouping" in
+                                      case "$gl_cv_func_printf_positions" in
                                         *yes)
-                                          case "$gl_cv_func_printf_flag_leftadjust" in
+                                          case "$gl_cv_func_printf_flag_grouping" in
                                             *yes)
-                                              case "$gl_cv_func_printf_flag_zero" in
+                                              case "$gl_cv_func_printf_flag_leftadjust" in
                                                 *yes)
-                                                  case "$gl_cv_func_printf_precision" in
+                                                  case "$gl_cv_func_printf_flag_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
                                                       ;;
@@ -85,6 +90,7 @@ AC_DEFUN([gl_FUNC_VSPRINTF_POSIX],
     gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
     gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
+    gl_PREREQ_VASNPRINTF_DIRECTIVE_B
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
     gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
     gl_PREREQ_VASNPRINTF_FLAG_GROUPING
index 4db76deb7576528ba2580e2cc782414c5e7a8561..579d34583dff7954a69a401556c584ad2f414597 100644 (file)
@@ -435,6 +435,8 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* Positive infinity.  */
     int retval =
       my_snprintf (result, sizeof (result), "%La %d", Infinityl (), 33, 44, 55);
+    /* Note: This assertion fails under valgrind.
+       Reported at <https://bugs.kde.org/show_bug.cgi?id=424044>.  */
     ASSERT (strcmp (result, "inf 33") == 0);
     ASSERT (retval == strlen (result));
   }
@@ -3053,4 +3055,70 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
     ASSERT (retval == strlen (result));
   }
 #endif
+
+  /* Test the support of the 'b' conversion specifier for binary output of
+     integers.  */
+
+  { /* Zero.  */
+    int retval =
+      my_snprintf (result, sizeof (result), "%b %d", 0, 33, 44, 55);
+    ASSERT (strcmp (result, "0 33") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
+  { /* A positive number.  */
+    int retval =
+      my_snprintf (result, sizeof (result), "%b %d", 12345, 33, 44, 55);
+    ASSERT (strcmp (result, "11000000111001 33") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
+  { /* A large positive number.  */
+    int retval =
+      my_snprintf (result, sizeof (result), "%b %d", 0xFFFFFFFEU, 33, 44, 55);
+    ASSERT (strcmp (result, "11111111111111111111111111111110 33") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
+  { /* Width.  */
+    int retval =
+      my_snprintf (result, sizeof (result), "%20b %d", 12345, 33, 44, 55);
+    ASSERT (strcmp (result, "      11000000111001 33") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
+  { /* Width given as argument.  */
+    int retval =
+      my_snprintf (result, sizeof (result), "%*b %d", 20, 12345, 33, 44, 55);
+    ASSERT (strcmp (result, "      11000000111001 33") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
+  { /* Negative width given as argument (cf. FLAG_LEFT below).  */
+    int retval =
+      my_snprintf (result, sizeof (result), "%*b %d", -20, 12345, 33, 44, 55);
+    ASSERT (strcmp (result, "11000000111001       33") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
+  { /* FLAG_LEFT.  */
+    int retval =
+      my_snprintf (result, sizeof (result), "%-20b %d", 12345, 33, 44, 55);
+    ASSERT (strcmp (result, "11000000111001       33") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
+  { /* FLAG_ALT with zero.  */
+    int retval =
+      my_snprintf (result, sizeof (result), "%#b %d", 0, 33, 44, 55);
+    ASSERT (strcmp (result, "0 33") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
+  { /* FLAG_ALT with a positive number.  */
+    int retval =
+      my_snprintf (result, sizeof (result), "%#b %d", 12345, 33, 44, 55);
+    ASSERT (strcmp (result, "0b11000000111001 33") == 0);
+    ASSERT (retval == strlen (result));
+  }
 }
index 979254acc740194ffedf672a302b20ecc8b5bdc3..863d084b99312f573711b480f4731fb20f190f65 100644 (file)
@@ -421,6 +421,8 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* Positive infinity.  */
     int retval =
       my_sprintf (result, "%La %d", Infinityl (), 33, 44, 55);
+    /* Note: This assertion fails under valgrind.
+       Reported at <https://bugs.kde.org/show_bug.cgi?id=424044>.  */
     ASSERT (strcmp (result, "inf 33") == 0);
     ASSERT (retval == strlen (result));
   }
@@ -3035,4 +3037,70 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
     ASSERT (retval == strlen (result));
   }
 #endif
+
+  /* Test the support of the 'b' conversion specifier for binary output of
+     integers.  */
+
+  { /* Zero.  */
+    int retval =
+      my_sprintf (result, "%b %d", 0, 33, 44, 55);
+    ASSERT (strcmp (result, "0 33") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
+  { /* A positive number.  */
+    int retval =
+      my_sprintf (result, "%b %d", 12345, 33, 44, 55);
+    ASSERT (strcmp (result, "11000000111001 33") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
+  { /* A large positive number.  */
+    int retval =
+      my_sprintf (result, "%b %d", 0xFFFFFFFEU, 33, 44, 55);
+    ASSERT (strcmp (result, "11111111111111111111111111111110 33") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
+  { /* Width.  */
+    int retval =
+      my_sprintf (result, "%20b %d", 12345, 33, 44, 55);
+    ASSERT (strcmp (result, "      11000000111001 33") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
+  { /* Width given as argument.  */
+    int retval =
+      my_sprintf (result, "%*b %d", 20, 12345, 33, 44, 55);
+    ASSERT (strcmp (result, "      11000000111001 33") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
+  { /* Negative width given as argument (cf. FLAG_LEFT below).  */
+    int retval =
+      my_sprintf (result, "%*b %d", -20, 12345, 33, 44, 55);
+    ASSERT (strcmp (result, "11000000111001       33") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
+  { /* FLAG_LEFT.  */
+    int retval =
+      my_sprintf (result, "%-20b %d", 12345, 33, 44, 55);
+    ASSERT (strcmp (result, "11000000111001       33") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
+  { /* FLAG_ALT with zero.  */
+    int retval =
+      my_sprintf (result, "%#b %d", 0, 33, 44, 55);
+    ASSERT (strcmp (result, "0 33") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
+  { /* FLAG_ALT with a positive number.  */
+    int retval =
+      my_sprintf (result, "%#b %d", 12345, 33, 44, 55);
+    ASSERT (strcmp (result, "0b11000000111001 33") == 0);
+    ASSERT (retval == strlen (result));
+  }
 }
index 4a83f6d243339d34aa4d25b288461eea007e49b8..c6e1e2f6505088e40069f6b4973016a34cd6ca23 100644 (file)
@@ -562,6 +562,8 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
     char *result =
       my_asnprintf (NULL, &length, "%La %d", Infinityl (), 33, 44, 55);
     ASSERT (result != NULL);
+    /* Note: This assertion fails under valgrind.
+       Reported at <https://bugs.kde.org/show_bug.cgi?id=424044>.  */
     ASSERT (strcmp (result, "inf 33") == 0);
     ASSERT (length == strlen (result));
     free (result);
@@ -3974,6 +3976,97 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   }
 #endif
 
+  /* Test the support of the 'b' conversion specifier for binary output of
+     integers.  */
+
+  { /* Zero.  */
+    size_t length;
+    char *result =
+      my_asnprintf (NULL, &length, "%b %d", 0, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (strcmp (result, "0 33") == 0);
+    ASSERT (length == strlen (result));
+    free (result);
+  }
+
+  { /* A positive number.  */
+    size_t length;
+    char *result =
+      my_asnprintf (NULL, &length, "%b %d", 12345, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (strcmp (result, "11000000111001 33") == 0);
+    ASSERT (length == strlen (result));
+    free (result);
+  }
+
+  { /* A large positive number.  */
+    size_t length;
+    char *result =
+      my_asnprintf (NULL, &length, "%b %d", 0xFFFFFFFEU, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (strcmp (result, "11111111111111111111111111111110 33") == 0);
+    ASSERT (length == strlen (result));
+    free (result);
+  }
+
+  { /* Width.  */
+    size_t length;
+    char *result =
+      my_asnprintf (NULL, &length, "%20b %d", 12345, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (strcmp (result, "      11000000111001 33") == 0);
+    ASSERT (length == strlen (result));
+    free (result);
+  }
+
+  { /* Width given as argument.  */
+    size_t length;
+    char *result =
+      my_asnprintf (NULL, &length, "%*b %d", 20, 12345, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (strcmp (result, "      11000000111001 33") == 0);
+    ASSERT (length == strlen (result));
+    free (result);
+  }
+
+  { /* Negative width given as argument (cf. FLAG_LEFT below).  */
+    size_t length;
+    char *result =
+      my_asnprintf (NULL, &length, "%*b %d", -20, 12345, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (strcmp (result, "11000000111001       33") == 0);
+    ASSERT (length == strlen (result));
+    free (result);
+  }
+
+  { /* FLAG_LEFT.  */
+    size_t length;
+    char *result =
+      my_asnprintf (NULL, &length, "%-20b %d", 12345, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (strcmp (result, "11000000111001       33") == 0);
+    ASSERT (length == strlen (result));
+    free (result);
+  }
+
+  { /* FLAG_ALT with zero.  */
+    size_t length;
+    char *result =
+      my_asnprintf (NULL, &length, "%#b %d", 0, 33, 44, 55);
+    ASSERT (strcmp (result, "0 33") == 0);
+    ASSERT (length == strlen (result));
+    free (result);
+  }
+
+  { /* FLAG_ALT with a positive number.  */
+    size_t length;
+    char *result =
+      my_asnprintf (NULL, &length, "%#b %d", 12345, 33, 44, 55);
+    ASSERT (strcmp (result, "0b11000000111001 33") == 0);
+    ASSERT (length == strlen (result));
+    free (result);
+  }
+
 #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) && !defined __UCLIBC__
   /* Test that the 'I' flag is supported.  */
   {
index f686bfb9fe440e3d7240ada20f705c34f384531e..c609a104ffa14008d27c243b8bbf0f0e29f8f322 100644 (file)
@@ -562,6 +562,8 @@ test_function (wchar_t * (*my_asnwprintf) (wchar_t *, size_t *, const wchar_t *,
     wchar_t *result =
       my_asnwprintf (NULL, &length, L"%La %d", Infinityl (), 33, 44, 55);
     ASSERT (result != NULL);
+    /* Note: This assertion fails under valgrind.
+       Reported at <https://bugs.kde.org/show_bug.cgi?id=424044>.  */
     ASSERT (wcscmp (result, L"inf 33") == 0);
     ASSERT (length == wcslen (result));
     free (result);
@@ -3982,6 +3984,97 @@ test_function (wchar_t * (*my_asnwprintf) (wchar_t *, size_t *, const wchar_t *,
   }
 #endif
 
+  /* Test the support of the 'b' conversion specifier for binary output of
+     integers.  */
+
+  { /* Zero.  */
+    size_t length;
+    wchar_t *result =
+      my_asnwprintf (NULL, &length, L"%b %d", 0, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (wcscmp (result, L"0 33") == 0);
+    ASSERT (length == wcslen (result));
+    free (result);
+  }
+
+  { /* A positive number.  */
+    size_t length;
+    wchar_t *result =
+      my_asnwprintf (NULL, &length, L"%b %d", 12345, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (wcscmp (result, L"11000000111001 33") == 0);
+    ASSERT (length == wcslen (result));
+    free (result);
+  }
+
+  { /* A large positive number.  */
+    size_t length;
+    wchar_t *result =
+      my_asnwprintf (NULL, &length, L"%b %d", 0xFFFFFFFEU, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (wcscmp (result, L"11111111111111111111111111111110 33") == 0);
+    ASSERT (length == wcslen (result));
+    free (result);
+  }
+
+  { /* Width.  */
+    size_t length;
+    wchar_t *result =
+      my_asnwprintf (NULL, &length, L"%20b %d", 12345, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (wcscmp (result, L"      11000000111001 33") == 0);
+    ASSERT (length == wcslen (result));
+    free (result);
+  }
+
+  { /* Width given as argument.  */
+    size_t length;
+    wchar_t *result =
+      my_asnwprintf (NULL, &length, L"%*b %d", 20, 12345, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (wcscmp (result, L"      11000000111001 33") == 0);
+    ASSERT (length == wcslen (result));
+    free (result);
+  }
+
+  { /* Negative width given as argument (cf. FLAG_LEFT below).  */
+    size_t length;
+    wchar_t *result =
+      my_asnwprintf (NULL, &length, L"%*b %d", -20, 12345, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (wcscmp (result, L"11000000111001       33") == 0);
+    ASSERT (length == wcslen (result));
+    free (result);
+  }
+
+  { /* FLAG_LEFT.  */
+    size_t length;
+    wchar_t *result =
+      my_asnwprintf (NULL, &length, L"%-20b %d", 12345, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (wcscmp (result, L"11000000111001       33") == 0);
+    ASSERT (length == wcslen (result));
+    free (result);
+  }
+
+  { /* FLAG_ALT with zero.  */
+    size_t length;
+    wchar_t *result =
+      my_asnwprintf (NULL, &length, L"%#b %d", 0, 33, 44, 55);
+    ASSERT (wcscmp (result, L"0 33") == 0);
+    ASSERT (length == wcslen (result));
+    free (result);
+  }
+
+  { /* FLAG_ALT with a positive number.  */
+    size_t length;
+    wchar_t *result =
+      my_asnwprintf (NULL, &length, L"%#b %d", 12345, 33, 44, 55);
+    ASSERT (wcscmp (result, L"0b11000000111001 33") == 0);
+    ASSERT (length == wcslen (result));
+    free (result);
+  }
+
 #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) && !defined __UCLIBC__
   /* Test that the 'I' flag is supported.  */
   {
index 8563502c472543c87b06ac6dcaffc8f6ab9b59c8..13b3a1bca9573e2b5bd10de96d08eb26b3548bb6 100644 (file)
@@ -543,6 +543,8 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
     int retval =
       my_asprintf (&result, "%La %d", Infinityl (), 33, 44, 55);
     ASSERT (result != NULL);
+    /* Note: This assertion fails under valgrind.
+       Reported at <https://bugs.kde.org/show_bug.cgi?id=424044>.  */
     ASSERT (strcmp (result, "inf 33") == 0);
     ASSERT (retval == strlen (result));
     free (result);
@@ -3914,6 +3916,97 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
     free (result);
   }
 #endif
+
+  /* Test the support of the 'b' conversion specifier for binary output of
+     integers.  */
+
+  { /* Zero.  */
+    char *result;
+    int retval =
+      my_asprintf (&result, "%b %d", 0, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (strcmp (result, "0 33") == 0);
+    ASSERT (retval == strlen (result));
+    free (result);
+  }
+
+  { /* A positive number.  */
+    char *result;
+    int retval =
+      my_asprintf (&result, "%b %d", 12345, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (strcmp (result, "11000000111001 33") == 0);
+    ASSERT (retval == strlen (result));
+    free (result);
+  }
+
+  { /* A large positive number.  */
+    char *result;
+    int retval =
+      my_asprintf (&result, "%b %d", 0xFFFFFFFEU, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (strcmp (result, "11111111111111111111111111111110 33") == 0);
+    ASSERT (retval == strlen (result));
+    free (result);
+  }
+
+  { /* Width.  */
+    char *result;
+    int retval =
+      my_asprintf (&result, "%20b %d", 12345, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (strcmp (result, "      11000000111001 33") == 0);
+    ASSERT (retval == strlen (result));
+    free (result);
+  }
+
+  { /* Width given as argument.  */
+    char *result;
+    int retval =
+      my_asprintf (&result, "%*b %d", 20, 12345, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (strcmp (result, "      11000000111001 33") == 0);
+    ASSERT (retval == strlen (result));
+    free (result);
+  }
+
+  { /* Negative width given as argument (cf. FLAG_LEFT below).  */
+    char *result;
+    int retval =
+      my_asprintf (&result, "%*b %d", -20, 12345, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (strcmp (result, "11000000111001       33") == 0);
+    ASSERT (retval == strlen (result));
+    free (result);
+  }
+
+  { /* FLAG_LEFT.  */
+    char *result;
+    int retval =
+      my_asprintf (&result, "%-20b %d", 12345, 33, 44, 55);
+    ASSERT (result != NULL);
+    ASSERT (strcmp (result, "11000000111001       33") == 0);
+    ASSERT (retval == strlen (result));
+    free (result);
+  }
+
+  { /* FLAG_ALT with zero.  */
+    char *result;
+    int retval =
+      my_asprintf (&result, "%#b %d", 0, 33, 44, 55);
+    ASSERT (strcmp (result, "0 33") == 0);
+    ASSERT (retval == strlen (result));
+    free (result);
+  }
+
+  { /* FLAG_ALT with a positive number.  */
+    char *result;
+    int retval =
+      my_asprintf (&result, "%#b %d", 12345, 33, 44, 55);
+    ASSERT (strcmp (result, "0b11000000111001 33") == 0);
+    ASSERT (retval == strlen (result));
+    free (result);
+  }
 }
 
 static int