From 349718d4d7841df46bcc36df9bc2baef4c40d6f5 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Wed, 7 Mar 2018 14:31:58 -0500 Subject: 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. --- stdio-common/iovfwscanf.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 stdio-common/iovfwscanf.c (limited to 'stdio-common/iovfwscanf.c') diff --git a/stdio-common/iovfwscanf.c b/stdio-common/iovfwscanf.c new file mode 100644 index 0000000000..26a57788cb --- /dev/null +++ b/stdio-common/iovfwscanf.c @@ -0,0 +1,38 @@ +/* Implementation and symbols for _IO_vfwscanf. + Copyright (C) 1991-2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +/* This function is provided for ports older than GLIBC 2.29 because + external callers could theoretically exist. Newer ports do not need, + since it is not part of the API. */ +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_29) + +int +attribute_compat_text_section +__IO_vfwscanf (FILE *fp, const wchar_t *format, va_list ap, int *errp) +{ + int rv = __vfwscanf_internal (fp, format, ap, 0); + if (__glibc_unlikely (errp != 0)) + *errp = (rv == -1); + return rv; +} +compat_symbol (libc, __IO_vfwscanf, _IO_vfwscanf, GLIBC_2_0); + +#endif -- cgit v1.2.3