bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*printf-posix: ISO C 23: Add %b directive for binary output of integers


From: Bruno Haible
Subject: *printf-posix: ISO C 23: Add %b directive for binary output of integers
Date: Fri, 17 Mar 2023 22:51:12 +0100

This set of patches adds support for the %b format string directive, required
by ISO C 23, to the *printf family of functions.

So far, only glibc implements it (since version 2.35). For portability to the
other platforms, use the *printf-posix modules.


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.
        * lib/vasnprintf.c (MAX_ROOM_NEEDED): Remove dead code: The directives
        'o', 'x', 'X' always take an unsigned integer argument.

Attachment: 0001-vasnprintf-vasnwprintf-Simplify-code.patch
Description: Text Data

Attachment: 0002-printf-posix-ISO-C-23-Add-b-directive-for-binary-out.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]