Add __vfscanf_internal and __vfwscanf_internal with flags arguments.
authorZack Weinberg <zackw@panix.com>
Wed, 7 Mar 2018 19:31:58 +0000 (14:31 -0500)
committerGabriel F. T. Gomes <gabriel@inconstante.eti.br>
Wed, 5 Dec 2018 20:15:42 +0000 (18:15 -0200)
commit349718d4d7841df46bcc36df9bc2baef4c40d6f5
tree1c6ae071a4a6d063e551ae6577b04d952262daea
parent72b8692d7e640eb85ea0fb7de6d5e797512691c1
Add __vfscanf_internal and __vfwscanf_internal with flags arguments.

There are two flags currently defined: SCANF_LDBL_IS_DBL is the mode
used by __nldbl_ scanf variants, and SCANF_ISOC99_A is the mode used
by __isoc99_ scanf variants.  In this patch, the new functions honor
these flag bits if they're set, but they still also look at the
corresponding bits of environmental state, and callers all pass zero.

The new functions do *not* have the "errp" argument possessed by
_IO_vfscanf and _IO_vfwscanf.  All internal callers passed NULL for
that argument.  External callers could theoretically exist, so I
preserved wrappers, but they are flagged as compat symbols and they
don't preserve the three-way distinction among types of errors that
was formerly exposed.  These functions probably should have been in
the list of deprecated _IO_ symbols in 2.27 NEWS -- they're not just
aliases for vfscanf and vfwscanf.

(It was necessary to introduce ldbl_compat_symbol for _IO_vfscanf.
Please check that part of the patch very carefully, I am still not
confident I understand all of the details of ldbl-opt.)

This patch also introduces helper inlines in libio/strfile.h that
encapsulate the process of initializing an _IO_strfile object for
reading.  This allows us to call __vfscanf_internal directly from
sscanf, and __vfwscanf_internal directly from swscanf, without
duplicating the initialization code.  (Previously, they called their
v-counterparts, but that won't work if we want to control *both* C99
mode and ldbl-is-dbl mode using the flags argument to__vfscanf_internal.)
It's still a little awkward, especially for wide strfiles, but it's
much better than what we had.

Tested for powerpc and powerpc64le.
35 files changed:
ChangeLog
libio/iovsscanf.c
libio/iovswscanf.c
libio/libio.h
libio/libioP.h
libio/strfile.h
libio/swscanf.c
libio/vscanf.c
libio/vwscanf.c
libio/wscanf.c
stdio-common/Makefile
stdio-common/Versions
stdio-common/iovfscanf.c [new file with mode: 0644]
stdio-common/iovfwscanf.c [new file with mode: 0644]
stdio-common/isoc99_fscanf.c
stdio-common/isoc99_scanf.c
stdio-common/isoc99_sscanf.c
stdio-common/isoc99_vfscanf.c
stdio-common/isoc99_vscanf.c
stdio-common/isoc99_vsscanf.c
stdio-common/scanf.c
stdio-common/sscanf.c
stdio-common/vfscanf-internal.c [new file with mode: 0644]
stdio-common/vfscanf.c
stdio-common/vfwscanf-internal.c [new file with mode: 0644]
stdio-common/vfwscanf.c
sysdeps/generic/math_ldbl_opt.h
sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h
sysdeps/ieee754/ldbl-opt/nldbl-compat.c
wcsmbs/isoc99_fwscanf.c
wcsmbs/isoc99_swscanf.c
wcsmbs/isoc99_vfwscanf.c
wcsmbs/isoc99_vswscanf.c
wcsmbs/isoc99_vwscanf.c
wcsmbs/isoc99_wscanf.c