about summary refs log tree commit diff
path: root/stdio-common/vfscanf-internal.c
Commit message (Collapse)AuthorAgeFilesLines
* Prepare vfscanf to use __strtof128_internalGabriel F. T. Gomes2018-12-071-0/+14
| | | | | | | | | | | | | | | | | | | | | On powerpc64le, long double can currently take two formats: the same as double (-mlong-double-64) or IBM Extended Precision (default with -mlong-double-128 or explicitly with -mabi=ibmlongdouble). The internal implementation of scanf-like functions is aware of these possibilites and, based on the format in use, properly calls __strtold_internal or __strtod_internal, saving the return to a variable of type double or long double. When library support for TS 18661-3 was added to glibc, a new function, __strtof128_internal, was added to enable reading of floating-point values with IEEE binary128 format into the _Float128 type. Now that powerpc64le is getting support for its third long double format, and taking into account that this format is the same as the format of _Float128, this patch extends __vfscanf_internal and __vfwscanf_internal to call __strtof128_internal or __wcstof128_internal when appropriate. The result gets saved into a variable of _Float128 type. Tested for powerpc64le.
* Use SCANF_LDBL_IS_DBL instead of __ldbl_is_dbl.Zack Weinberg2018-12-051-4/+0
| | | | | | | | | | Change the callers of __vfscanf_internal and __vfwscanf_internal that want to treat 'long double' as another name for 'double' (all of which happen to be in sysdeps/ieee754/ldbl-opt/nldbl-compat.c) to communicate this via the new flags argument, instead of the per-thread variable __no_long_double and its __ldbl_is_dbl wrapper macro. Tested for powerpc and powerpc64le.
* Use SCANF_ISOC99_A instead of _IO_FLAGS2_SCANF_STD.Zack Weinberg2018-12-051-2/+0
| | | | | | | | | Change the callers of __vfscanf_internal and __vfwscanf_internal that want C99-compliant behavior to communicate this via the new flags argument, rather than setting bits on the FILE object. This also means these functions do not need to do their own locking. Tested for powerpc and powerpc64le.
* Add __vfscanf_internal and __vfwscanf_internal with flags arguments.Zack Weinberg2018-12-051-0/+3049
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.