]> git.ipfire.org Git - thirdparty/glibc.git/commit - manual/stdio.texi
C2x scanf binary constant handling
authorJoseph Myers <joseph@codesourcery.com>
Thu, 2 Mar 2023 19:10:37 +0000 (19:10 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Thu, 2 Mar 2023 19:10:37 +0000 (19:10 +0000)
commitdee2bea048b688b643a9a3b44b26ca9f7a706fe8
tree3e7cd1057154850968d13023bc2e082cfc7940ad
parent51aeab9a363a0d000d0912aa3d6490463a26fba2
C2x scanf binary constant handling

C2x adds binary integer constants starting with 0b or 0B, and supports
those constants for the %i scanf format (in addition to the %b format,
which isn't yet implemented for scanf in glibc).  Implement that scanf
support for glibc.

As with the strtol support, this is incompatible with previous C
standard versions, in that such an input string starting with 0b or 0B
was previously required to be parsed as 0 (with the rest of the input
potentially matching subsequent parts of the scanf format string).
Thus this patch adds 12 new __isoc23_* functions per long double
format (12, 24 or 36 depending on how many long double formats the
glibc configuration supports), with appropriate header redirection
support (generally very closely following that for the __isoc99_*
scanf functions - note that __GLIBC_USE (DEPRECATED_SCANF) takes
precedence over __GLIBC_USE (C2X_STRTOL), so the case of GNU
extensions to C89 continues to get old-style GNU %a and does not get
this new feature).  The function names would remain as __isoc23_* even
if C2x ends up published in 2024 rather than 2023.

When scanf %b support is added, I think it will be appropriate for all
versions of scanf to follow C2x rules for inputs to the %b format
(given that there are no compatibility concerns for a new format).

Tested for x86_64 (full glibc testsuite).  The first version was also
tested for powerpc (32-bit) and powerpc64le (stdio-common/ and wcsmbs/
tests), and with build-many-glibcs.py.
127 files changed:
NEWS
include/stdio.h
include/wchar.h
libio/bits/stdio-ldbl.h
libio/libioP.h
libio/stdio.h
manual/stdio.texi
stdio-common/Makefile
stdio-common/Versions
stdio-common/isoc23_fscanf.c [new file with mode: 0644]
stdio-common/isoc23_scanf.c [new file with mode: 0644]
stdio-common/isoc23_sscanf.c [new file with mode: 0644]
stdio-common/isoc23_vfscanf.c [new file with mode: 0644]
stdio-common/isoc23_vscanf.c [new file with mode: 0644]
stdio-common/isoc23_vsscanf.c [new file with mode: 0644]
stdio-common/tst-scanf-binary-c11.c [new file with mode: 0644]
stdio-common/tst-scanf-binary-c2x.c [new file with mode: 0644]
stdio-common/tst-scanf-binary-gnu11.c [new file with mode: 0644]
stdio-common/tst-scanf-binary-gnu89.c [new file with mode: 0644]
stdio-common/tst-scanf-binary-main.c [new file with mode: 0644]
stdio-common/vfscanf-internal.c
support/Makefile
support/xfreopen.c [new file with mode: 0644]
support/xstdio.h
sysdeps/ieee754/ldbl-128ibm-compat/Makefile
sysdeps/ieee754/ldbl-128ibm-compat/Versions
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc23_fscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc23_fwscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc23_scanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc23_sscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc23_swscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc23_vfscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc23_vfwscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc23_vscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc23_vsscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc23_vswscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc23_vwscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc23_wscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/tst-ibm128-scanf-binary-c11.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/tst-ibm128-scanf-binary-c2x.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/tst-ibm128-scanf-binary-gnu11.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/tst-ibm128-scanf-binary-gnu89.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/tst-ibm128-wscanf-binary-c11.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/tst-ibm128-wscanf-binary-c2x.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/tst-ibm128-wscanf-binary-gnu11.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/tst-ibm128-wscanf-binary-gnu89.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/tst-ieee128-scanf-binary-c11.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/tst-ieee128-scanf-binary-c2x.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/tst-ieee128-scanf-binary-gnu11.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/tst-ieee128-scanf-binary-gnu89.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/tst-ieee128-wscanf-binary-c11.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/tst-ieee128-wscanf-binary-c2x.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/tst-ieee128-wscanf-binary-gnu11.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm-compat/tst-ieee128-wscanf-binary-gnu89.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/Makefile
sysdeps/ieee754/ldbl-opt/Versions
sysdeps/ieee754/ldbl-opt/nldbl-compat.c
sysdeps/ieee754/ldbl-opt/nldbl-compat.h
sysdeps/ieee754/ldbl-opt/nldbl-isoc23_fscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/nldbl-isoc23_fwscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/nldbl-isoc23_scanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/nldbl-isoc23_sscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/nldbl-isoc23_swscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/nldbl-isoc23_vfscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/nldbl-isoc23_vfwscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/nldbl-isoc23_vscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/nldbl-isoc23_vsscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/nldbl-isoc23_vswscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/nldbl-isoc23_vwscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/nldbl-isoc23_wscanf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/tst-nldbl-scanf-binary-c11.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/tst-nldbl-scanf-binary-c2x.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/tst-nldbl-scanf-binary-gnu11.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/tst-nldbl-scanf-binary-gnu89.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/tst-nldbl-wscanf-binary-c11.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/tst-nldbl-wscanf-binary-c2x.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/tst-nldbl-wscanf-binary-gnu11.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-opt/tst-nldbl-wscanf-binary-gnu89.c [new file with mode: 0644]
sysdeps/mach/hurd/i386/libc.abilist
sysdeps/unix/sysv/linux/aarch64/libc.abilist
sysdeps/unix/sysv/linux/alpha/libc.abilist
sysdeps/unix/sysv/linux/arc/libc.abilist
sysdeps/unix/sysv/linux/arm/be/libc.abilist
sysdeps/unix/sysv/linux/arm/le/libc.abilist
sysdeps/unix/sysv/linux/csky/libc.abilist
sysdeps/unix/sysv/linux/hppa/libc.abilist
sysdeps/unix/sysv/linux/i386/libc.abilist
sysdeps/unix/sysv/linux/ia64/libc.abilist
sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist
sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
sysdeps/unix/sysv/linux/nios2/libc.abilist
sysdeps/unix/sysv/linux/or1k/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
sysdeps/unix/sysv/linux/sh/be/libc.abilist
sysdeps/unix/sysv/linux/sh/le/libc.abilist
sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
wcsmbs/Makefile
wcsmbs/Versions
wcsmbs/bits/wchar-ldbl.h
wcsmbs/isoc23_fwscanf.c [new file with mode: 0644]
wcsmbs/isoc23_swscanf.c [new file with mode: 0644]
wcsmbs/isoc23_vfwscanf.c [new file with mode: 0644]
wcsmbs/isoc23_vswscanf.c [new file with mode: 0644]
wcsmbs/isoc23_vwscanf.c [new file with mode: 0644]
wcsmbs/isoc23_wscanf.c [new file with mode: 0644]
wcsmbs/tst-wscanf-binary-c11.c [new file with mode: 0644]
wcsmbs/tst-wscanf-binary-c2x.c [new file with mode: 0644]
wcsmbs/tst-wscanf-binary-gnu11.c [new file with mode: 0644]
wcsmbs/tst-wscanf-binary-gnu89.c [new file with mode: 0644]
wcsmbs/wchar.h