glibc/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
Zack Weinberg 03992356e6
Use C99-compliant scanf under _GNU_SOURCE with modern compilers.
The only difference between noncompliant and C99-compliant scanf is
that the former accepts the archaic GNU extension '%as' (also %aS and
%a[...]) meaning to allocate space for the input string with malloc.
This extension conflicts with C99's use of %a as a format _type_
meaning to read a floating-point number; POSIX.1-2008 standardized
equivalent functionality using the modifier letter 'm' instead (%ms,
%mS, %m[...]).

The extension was already disabled in most conformance modes:
specifically, any mode that doesn't involve _GNU_SOURCE and _does_
involve either strict conformance to C99 or loose conformance to both
C99 and POSIX.1-2001 would get the C99-compliant scanf.  With
compilers new enough to use -std=gnu11 instead of -std=gnu89, or
equivalent, that includes the default mode.

With this patch, we now provide C99-compliant scanf in all
configurations except when _GNU_SOURCE is defined *and*
__STDC_VERSION__ or __cplusplus (whichever is relevant) indicates
C89/C++98.  This leaves the old scanf available under e.g. -std=c89
-D_GNU_SOURCE, but removes it from e.g. -std=gnu11 -D_GNU_SOURCE (it
was already not present under -std=gnu11 without -D_GNU_SOURCE) and
from -std=gnu89 without -D_GNU_SOURCE.

There needs to be an internal override so we can compile the
noncompliant scanf itself.  This is the same problem we had when we
removed 'gets' from _GNU_SOURCE and it's dealt with the same way:
there's a new __GLIBC_USE symbol, DEPRECATED_SCANF, which defaults to
off under the appropriate conditions for external code, but can be
overridden by individual files within stdio.

We also run into problems with PLT bypass for internal uses of sscanf,
because libc_hidden_proto uses __REDIRECT and so does the logic in
stdio.h for choosing which implementation of scanf to use; __REDIRECT
isn't transitive, so include/stdio.h needs to bridge the gap with a
macro.  As far as I can tell, sscanf is the only function in this
family that's internally called by unrelated code.

Finally, there are several tests in stdio-common that use the
extension.  bug21.c is a regression test for a crash; it still
exercises the relevant code when changed to use %ms instead of %as.
scanf14.c through scanf17.c are more complicated since they are
actually testing the subtleties of the extension - under what
circumstances is 'a' treated as a modifier letter, etc.  I changed all
of them to use %ms instead of %as as well, but duplicated scanf14.c
and scanf16.c as scanf14a.c and scanf16a.c.  These still use %as and
are compiled with -std=gnu89 to access the old extension.  A bunch of
diagnostic overrides and manual workarounds for the old stdio.h
behavior become unnecessary.  Yay!

	* include/features.h (__GLIBC_USE_DEPRECATED_SCANF): New __GLIBC_USE
	parameter.  Only use deprecated scanf when __USE_GNU is defined
	and __STDC_VERSION__ is less than 199901L or __cplusplus is less
	than 201103L, whichever is relevant for the language being compiled.

	* libio/stdio.h, libio/bits/stdio-ldbl.h: Decide whether to redirect
	scanf, fscanf, sscanf, vscanf, vfscanf, and vsscanf to their
	__isoc99_ variants based only on __GLIBC_USE (DEPRECATED_SCANF).
	* wcsmbs/wchar.h: wcsmbs/bits/wchar-ldbl.h: Likewise for
	wscanf, fwscanf, swscanf, vwscanf, vfwscanf, and vswscanf.

	* libio/iovsscanf.c
	* libio/fwscanf.c
	* libio/iovswscanf.c
	* libio/swscanf.c
	* libio/vscanf.c
	* libio/vwscanf.c
	* libio/wscanf.c
	* stdio-common/fscanf.c
	* stdio-common/scanf.c
	* stdio-common/vfscanf.c
	* stdio-common/vfwscanf.c
	* sysdeps/ieee754/ldbl-opt/nldbl-compat.c
	* sysdeps/ieee754/ldbl-opt/nldbl-fscanf.c
	* sysdeps/ieee754/ldbl-opt/nldbl-fwscanf.c
	* sysdeps/ieee754/ldbl-opt/nldbl-iovfscanf.c
	* sysdeps/ieee754/ldbl-opt/nldbl-scanf.c
	* sysdeps/ieee754/ldbl-opt/nldbl-sscanf.c
	* sysdeps/ieee754/ldbl-opt/nldbl-swscanf.c
	* sysdeps/ieee754/ldbl-opt/nldbl-vfscanf.c
	* sysdeps/ieee754/ldbl-opt/nldbl-vfwscanf.c
	* sysdeps/ieee754/ldbl-opt/nldbl-vscanf.c
	* sysdeps/ieee754/ldbl-opt/nldbl-vsscanf.c
	* sysdeps/ieee754/ldbl-opt/nldbl-vswscanf.c
	* sysdeps/ieee754/ldbl-opt/nldbl-vwscanf.c
	* sysdeps/ieee754/ldbl-opt/nldbl-wscanf.c:
	Override __GLIBC_USE_DEPRECATED_SCANF to 1.

	* stdio-common/sscanf.c: Likewise.  Remove ldbl_hidden_def for __sscanf.
	* stdio-common/isoc99_sscanf.c: Add libc_hidden_def for __isoc99_sscanf.
	* include/stdio.h: Provide libc_hidden_proto for __isoc99_sscanf,
	not sscanf.
	[!__GLIBC_USE (DEPRECATED_SCANF)]: Define sscanf as __isoc99_scanf
	with a preprocessor macro.

	* stdio-common/bug21.c, stdio-common/scanf14.c:
	Use %ms instead of %as, %mS instead of %aS, %m[] instead of %a[];
	remove DIAG_IGNORE_NEEDS_COMMENT for -Wformat.
	* stdio-common/scanf16.c: Likewise.  Add __attribute__ ((format (scanf)))
	to xscanf, xfscanf, xsscanf.

	* stdio-common/scanf14a.c: New copy of scanf14.c which still uses
	%as, %aS, %a[].  Remove DIAG_IGNORE_NEEDS_COMMENT for -Wformat.
	* stdio-common/scanf16a.c: New copy of scanf16.c which still uses
	%as, %aS, %a[].  Add __attribute__ ((format (scanf))) to xscanf,
	xfscanf, xsscanf.
	* stdio-common/scanf15.c, stdio-common/scanf17.c: No need to
	override feature selection macros or provide definitions of u_char etc.
	* stdio-common/Makefile (tests): Add scanf14a and scanf16a.
	(CFLAGS-scanf15.c, CFLAGS-scanf17.c): Remove.
	(CFLAGS-scanf14a.c, CFLAGS-scanf16a.c): New.  Compile these files
	with -std=gnu89.
2019-01-03 11:12:39 -05:00

1066 lines
25 KiB
C

/* *printf* family compatibility routines for IEEE double as long double
Copyright (C) 2006-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@cygnus.com>, 2006.
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
<http://www.gnu.org/licenses/>. */
/* This file may define some of the deprecated scanf variants. */
#include <features.h>
#undef __GLIBC_USE_DEPRECATED_SCANF
#define __GLIBC_USE_DEPRECATED_SCANF 1
#include <stdarg.h>
#include <stdio.h>
#include <libio/strfile.h>
#include <math.h>
#include <wchar.h>
#include <printf.h>
#include <monetary.h>
#include <locale/localeinfo.h>
#include <sys/syslog.h>
#include <libc-lock.h>
#include "nldbl-compat.h"
libc_hidden_proto (__nldbl_vsscanf)
libc_hidden_proto (__nldbl_vfscanf)
libc_hidden_proto (__nldbl_vfwscanf)
libc_hidden_proto (__nldbl_vswscanf)
libc_hidden_proto (__nldbl___isoc99_vsscanf)
libc_hidden_proto (__nldbl___isoc99_vfscanf)
libc_hidden_proto (__nldbl___isoc99_vswscanf)
libc_hidden_proto (__nldbl___isoc99_vfwscanf)
/* Compatibility with IEEE double as long double.
IEEE quad long double is used by default for most programs, so
we don't need to split this into one file per function for the
sake of statically linked programs. */
int
attribute_compat_text_section
__nldbl___asprintf (char **string_ptr, const char *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vasprintf_internal (string_ptr, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (ap);
return ret;
}
weak_alias (__nldbl___asprintf, __nldbl_asprintf)
int
attribute_compat_text_section
__nldbl_dprintf (int d, const char *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vdprintf_internal (d, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl_fprintf (FILE *stream, const char *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vfprintf_internal (stream, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (ap);
return ret;
}
weak_alias (__nldbl_fprintf, __nldbl__IO_fprintf)
int
attribute_compat_text_section weak_function
__nldbl_fwprintf (FILE *stream, const wchar_t *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vfwprintf_internal (stream, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl_printf (const char *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vfprintf_internal (stdout, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (ap);
return ret;
}
strong_alias (__nldbl_printf, __nldbl__IO_printf)
int
attribute_compat_text_section
__nldbl_sprintf (char *s, const char *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vsprintf_internal (s, -1, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (ap);
return ret;
}
strong_alias (__nldbl_sprintf, __nldbl__IO_sprintf)
int
attribute_compat_text_section
__nldbl_vfprintf (FILE *s, const char *fmt, va_list ap)
{
return __vfprintf_internal (s, fmt, ap, PRINTF_LDBL_IS_DBL);
}
strong_alias (__nldbl_vfprintf, __nldbl__IO_vfprintf)
int
attribute_compat_text_section
__nldbl___vsprintf (char *string, const char *fmt, va_list ap)
{
return __vsprintf_internal (string, -1, fmt, ap, PRINTF_LDBL_IS_DBL);
}
strong_alias (__nldbl___vsprintf, __nldbl__IO_vsprintf)
weak_alias (__nldbl___vsprintf, __nldbl_vsprintf)
int
attribute_compat_text_section
__nldbl_obstack_vprintf (struct obstack *obstack, const char *fmt,
va_list ap)
{
return __obstack_vprintf_internal (obstack, fmt, ap, PRINTF_LDBL_IS_DBL);
}
int
attribute_compat_text_section
__nldbl_obstack_printf (struct obstack *obstack, const char *fmt, ...)
{
int ret;
va_list ap;
va_start (ap, fmt);
ret = __obstack_vprintf_internal (obstack, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (ap);
return ret;
}
int
attribute_compat_text_section weak_function
__nldbl_snprintf (char *s, size_t maxlen, const char *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vsnprintf_internal (s, maxlen, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl_swprintf (wchar_t *s, size_t n, const wchar_t *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vswprintf_internal (s, n, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (ap);
return ret;
}
int
attribute_compat_text_section weak_function
__nldbl_vasprintf (char **result_ptr, const char *fmt, va_list ap)
{
return __vasprintf_internal (result_ptr, fmt, ap, PRINTF_LDBL_IS_DBL);
}
int
attribute_compat_text_section
__nldbl_vdprintf (int d, const char *fmt, va_list ap)
{
return __vdprintf_internal (d, fmt, ap, PRINTF_LDBL_IS_DBL);
}
int
attribute_compat_text_section weak_function
__nldbl_vfwprintf (FILE *s, const wchar_t *fmt, va_list ap)
{
return __vfwprintf_internal (s, fmt, ap, PRINTF_LDBL_IS_DBL);
}
int
attribute_compat_text_section
__nldbl_vprintf (const char *fmt, va_list ap)
{
return __vfprintf_internal (stdout, fmt, ap, PRINTF_LDBL_IS_DBL);
}
int
attribute_compat_text_section
__nldbl_vsnprintf (char *string, size_t maxlen, const char *fmt,
va_list ap)
{
return __vsnprintf_internal (string, maxlen, fmt, ap, PRINTF_LDBL_IS_DBL);
}
weak_alias (__nldbl_vsnprintf, __nldbl___vsnprintf)
int
attribute_compat_text_section weak_function
__nldbl_vswprintf (wchar_t *string, size_t maxlen, const wchar_t *fmt,
va_list ap)
{
return __vswprintf_internal (string, maxlen, fmt, ap, PRINTF_LDBL_IS_DBL);
}
int
attribute_compat_text_section
__nldbl_vwprintf (const wchar_t *fmt, va_list ap)
{
return __vfwprintf_internal (stdout, fmt, ap, PRINTF_LDBL_IS_DBL);
}
int
attribute_compat_text_section
__nldbl_wprintf (const wchar_t *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vfwprintf_internal (stdout, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (ap);
return ret;
}
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_29)
int
attribute_compat_text_section
__nldbl__IO_vfscanf (FILE *s, const char *fmt, va_list ap, int *errp)
{
int ret = __vfscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL);
if (__glibc_unlikely (errp != 0))
*errp = (ret == -1);
return ret;
}
#endif
int
attribute_compat_text_section
__nldbl___vfscanf (FILE *s, const char *fmt, va_list ap)
{
return __vfscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL);
}
weak_alias (__nldbl___vfscanf, __nldbl_vfscanf)
libc_hidden_def (__nldbl_vfscanf)
int
attribute_compat_text_section
__nldbl_sscanf (const char *s, const char *fmt, ...)
{
_IO_strfile sf;
FILE *f = _IO_strfile_read (&sf, s);
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vfscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL);
va_end (ap);
return ret;
}
strong_alias (__nldbl_sscanf, __nldbl__IO_sscanf)
int
attribute_compat_text_section
__nldbl___vsscanf (const char *s, const char *fmt, va_list ap)
{
_IO_strfile sf;
FILE *f = _IO_strfile_read (&sf, s);
return __vfscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL);
}
weak_alias (__nldbl___vsscanf, __nldbl_vsscanf)
libc_hidden_def (__nldbl_vsscanf)
int
attribute_compat_text_section weak_function
__nldbl_vscanf (const char *fmt, va_list ap)
{
return __vfscanf_internal (stdin, fmt, ap, SCANF_LDBL_IS_DBL);
}
int
attribute_compat_text_section
__nldbl_fscanf (FILE *stream, const char *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vfscanf_internal (stream, fmt, ap, SCANF_LDBL_IS_DBL);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl_scanf (const char *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vfscanf_internal (stdin, fmt, ap, SCANF_LDBL_IS_DBL);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl_vfwscanf (FILE *s, const wchar_t *fmt, va_list ap)
{
return __vfwscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL);
}
libc_hidden_def (__nldbl_vfwscanf)
int
attribute_compat_text_section
__nldbl_swscanf (const wchar_t *s, const wchar_t *fmt, ...)
{
_IO_strfile sf;
struct _IO_wide_data wd;
FILE *f = _IO_strfile_readw (&sf, &wd, s);
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vfwscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl_vswscanf (const wchar_t *s, const wchar_t *fmt, va_list ap)
{
_IO_strfile sf;
struct _IO_wide_data wd;
FILE *f = _IO_strfile_readw (&sf, &wd, s);
return __vfwscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL);
}
libc_hidden_def (__nldbl_vswscanf)
int
attribute_compat_text_section weak_function
__nldbl_vwscanf (const wchar_t *fmt, va_list ap)
{
return __vfwscanf_internal (stdin, fmt, ap, SCANF_LDBL_IS_DBL);
}
int
attribute_compat_text_section
__nldbl_fwscanf (FILE *stream, const wchar_t *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vfwscanf_internal (stream, fmt, ap, SCANF_LDBL_IS_DBL);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl_wscanf (const wchar_t *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vfwscanf_internal (stdin, fmt, ap, SCANF_LDBL_IS_DBL);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl___fprintf_chk (FILE *stream, int flag, const char *fmt, ...)
{
va_list ap;
int ret;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (ap, fmt);
ret = __vfprintf_internal (stream, fmt, ap, mode);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl___fwprintf_chk (FILE *stream, int flag, const wchar_t *fmt, ...)
{
va_list ap;
int ret;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (ap, fmt);
ret = __vfwprintf_internal (stream, fmt, ap, mode);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl___printf_chk (int flag, const char *fmt, ...)
{
va_list ap;
int ret;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (ap, fmt);
ret = __vfprintf_internal (stdout, fmt, ap, mode);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl___snprintf_chk (char *s, size_t maxlen, int flag, size_t slen,
const char *fmt, ...)
{
if (__glibc_unlikely (slen < maxlen))
__chk_fail ();
va_list ap;
int ret;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (ap, fmt);
ret = __vsnprintf_internal (s, maxlen, fmt, ap, mode);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl___sprintf_chk (char *s, int flag, size_t slen, const char *fmt, ...)
{
if (slen == 0)
__chk_fail ();
va_list ap;
int ret;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (ap, fmt);
ret = __vsprintf_internal (s, slen, fmt, ap, mode);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl___swprintf_chk (wchar_t *s, size_t maxlen, int flag, size_t slen,
const wchar_t *fmt, ...)
{
if (__glibc_unlikely (slen < maxlen))
__chk_fail ();
va_list ap;
int ret;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (ap, fmt);
ret = __vswprintf_internal (s, maxlen, fmt, ap, mode);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl___vfprintf_chk (FILE *s, int flag, const char *fmt, va_list ap)
{
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
return __vfprintf_internal (s, fmt, ap, mode);
}
int
attribute_compat_text_section
__nldbl___vfwprintf_chk (FILE *s, int flag, const wchar_t *fmt, va_list ap)
{
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
return __vfwprintf_internal (s, fmt, ap, mode);
}
int
attribute_compat_text_section
__nldbl___vprintf_chk (int flag, const char *fmt, va_list ap)
{
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
return __vfprintf_internal (stdout, fmt, ap, mode);
}
int
attribute_compat_text_section
__nldbl___vsnprintf_chk (char *string, size_t maxlen, int flag, size_t slen,
const char *fmt, va_list ap)
{
if (__glibc_unlikely (slen < maxlen))
__chk_fail ();
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
return __vsnprintf_internal (string, maxlen, fmt, ap, mode);
}
int
attribute_compat_text_section
__nldbl___vsprintf_chk (char *string, int flag, size_t slen, const char *fmt,
va_list ap)
{
if (slen == 0)
__chk_fail ();
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
return __vsprintf_internal (string, slen, fmt, ap, mode);
}
int
attribute_compat_text_section
__nldbl___vswprintf_chk (wchar_t *string, size_t maxlen, int flag, size_t slen,
const wchar_t *fmt, va_list ap)
{
if (__glibc_unlikely (slen < maxlen))
__chk_fail ();
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
return __vswprintf_internal (string, maxlen, fmt, ap, mode);
}
int
attribute_compat_text_section
__nldbl___vwprintf_chk (int flag, const wchar_t *fmt, va_list ap)
{
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
return __vfwprintf_internal (stdout, fmt, ap, mode);
}
int
attribute_compat_text_section
__nldbl___wprintf_chk (int flag, const wchar_t *fmt, ...)
{
va_list ap;
int ret;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (ap, fmt);
ret = __vfwprintf_internal (stdout, fmt, ap, mode);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl___vasprintf_chk (char **ptr, int flag, const char *fmt, va_list ap)
{
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
return __vasprintf_internal (ptr, fmt, ap, mode);
}
int
attribute_compat_text_section
__nldbl___asprintf_chk (char **ptr, int flag, const char *fmt, ...)
{
va_list ap;
int ret;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (ap, fmt);
ret = __vasprintf_internal (ptr, fmt, ap, mode);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl___vdprintf_chk (int d, int flag, const char *fmt, va_list ap)
{
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
return __vdprintf_internal (d, fmt, ap, mode);
}
int
attribute_compat_text_section
__nldbl___dprintf_chk (int d, int flag, const char *fmt, ...)
{
va_list ap;
int ret;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (ap, fmt);
ret = __vdprintf_internal (d, fmt, ap, mode);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl___obstack_vprintf_chk (struct obstack *obstack, int flag,
const char *fmt, va_list ap)
{
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
return __obstack_vprintf_internal (obstack, fmt, ap, mode);
}
int
attribute_compat_text_section
__nldbl___obstack_printf_chk (struct obstack *obstack, int flag,
const char *fmt, ...)
{
va_list ap;
int ret;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (ap, fmt);
ret = __obstack_vprintf_internal (obstack, fmt, ap, mode);
va_end (ap);
return ret;
}
extern __typeof (printf_size) __printf_size;
int
attribute_compat_text_section
__nldbl_printf_size (FILE *fp, const struct printf_info *info,
const void *const *args)
{
struct printf_info info_no_ldbl = *info;
info_no_ldbl.is_long_double = 0;
return __printf_size (fp, &info_no_ldbl, args);
}
extern __typeof (__printf_fp) ___printf_fp;
int
attribute_compat_text_section
__nldbl___printf_fp (FILE *fp, const struct printf_info *info,
const void *const *args)
{
struct printf_info info_no_ldbl = *info;
info_no_ldbl.is_long_double = 0;
return ___printf_fp (fp, &info_no_ldbl, args);
}
ssize_t
attribute_compat_text_section
__nldbl_strfmon (char *s, size_t maxsize, const char *format, ...)
{
va_list ap;
ssize_t ret;
va_start (ap, format);
ret = __vstrfmon_l_internal (s, maxsize, _NL_CURRENT_LOCALE, format, ap,
STRFMON_LDBL_IS_DBL);
va_end (ap);
return ret;
}
ssize_t
attribute_compat_text_section
__nldbl___strfmon_l (char *s, size_t maxsize, locale_t loc,
const char *format, ...)
{
va_list ap;
ssize_t ret;
va_start (ap, format);
ret = __vstrfmon_l_internal (s, maxsize, loc, format, ap,
STRFMON_LDBL_IS_DBL);
va_end (ap);
return ret;
}
weak_alias (__nldbl___strfmon_l, __nldbl_strfmon_l)
ssize_t
attribute_compat_text_section
__nldbl___vstrfmon (char *s, size_t maxsize, const char *format, va_list ap)
{
return __vstrfmon_l_internal (s, maxsize, _NL_CURRENT_LOCALE, format, ap,
STRFMON_LDBL_IS_DBL);
}
ssize_t
attribute_compat_text_section
__nldbl___vstrfmon_l (char *s, size_t maxsize, locale_t loc,
const char *format, va_list ap)
{
return __vstrfmon_l_internal (s, maxsize, loc, format, ap,
STRFMON_LDBL_IS_DBL);
}
void
attribute_compat_text_section
__nldbl_syslog (int pri, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
__vsyslog_internal (pri, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (ap);
}
void
attribute_compat_text_section
__nldbl_vsyslog (int pri, const char *fmt, va_list ap)
{
__vsyslog_internal (pri, fmt, ap, PRINTF_LDBL_IS_DBL);
}
void
attribute_compat_text_section
__nldbl___syslog_chk (int pri, int flag, const char *fmt, ...)
{
va_list ap;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (ap, fmt);
__vsyslog_internal (pri, fmt, ap, mode);
va_end(ap);
}
void
attribute_compat_text_section
__nldbl___vsyslog_chk (int pri, int flag, const char *fmt, va_list ap)
{
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
__vsyslog_internal (pri, fmt, ap, mode);
}
int
attribute_compat_text_section
__nldbl___isoc99_vfscanf (FILE *s, const char *fmt, va_list ap)
{
return __vfscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
}
libc_hidden_def (__nldbl___isoc99_vfscanf)
int
attribute_compat_text_section
__nldbl___isoc99_sscanf (const char *s, const char *fmt, ...)
{
_IO_strfile sf;
FILE *f = _IO_strfile_read (&sf, s);
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vfscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl___isoc99_vsscanf (const char *s, const char *fmt, va_list ap)
{
_IO_strfile sf;
FILE *f = _IO_strfile_read (&sf, s);
return __vfscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
}
libc_hidden_def (__nldbl___isoc99_vsscanf)
int
attribute_compat_text_section
__nldbl___isoc99_vscanf (const char *fmt, va_list ap)
{
return __vfscanf_internal (stdin, fmt, ap,
SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
}
int
attribute_compat_text_section
__nldbl___isoc99_fscanf (FILE *s, const char *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vfscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl___isoc99_scanf (const char *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vfscanf_internal (stdin, fmt, ap,
SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl___isoc99_vfwscanf (FILE *s, const wchar_t *fmt, va_list ap)
{
return __vfwscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
}
libc_hidden_def (__nldbl___isoc99_vfwscanf)
int
attribute_compat_text_section
__nldbl___isoc99_swscanf (const wchar_t *s, const wchar_t *fmt, ...)
{
_IO_strfile sf;
struct _IO_wide_data wd;
FILE *f = _IO_strfile_readw (&sf, &wd, s);
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vfwscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl___isoc99_vswscanf (const wchar_t *s, const wchar_t *fmt, va_list ap)
{
_IO_strfile sf;
struct _IO_wide_data wd;
FILE *f = _IO_strfile_readw (&sf, &wd, s);
return __vfwscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
}
libc_hidden_def (__nldbl___isoc99_vswscanf)
int
attribute_compat_text_section
__nldbl___isoc99_vwscanf (const wchar_t *fmt, va_list ap)
{
return __vfwscanf_internal (stdin, fmt, ap,
SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
}
int
attribute_compat_text_section
__nldbl___isoc99_fwscanf (FILE *s, const wchar_t *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vfwscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
va_end (ap);
return ret;
}
int
attribute_compat_text_section
__nldbl___isoc99_wscanf (const wchar_t *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = __vfwscanf_internal (stdin, fmt, ap,
SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
va_end (ap);
return ret;
}
#if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
compat_symbol (libc, __nldbl__IO_printf, _IO_printf, GLIBC_2_0);
compat_symbol (libc, __nldbl__IO_sprintf, _IO_sprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl__IO_vfprintf, _IO_vfprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl__IO_vsprintf, _IO_vsprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl_dprintf, dprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl_fprintf, fprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl_printf, printf, GLIBC_2_0);
compat_symbol (libc, __nldbl_sprintf, sprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl_vfprintf, vfprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl_vprintf, vprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl__IO_fprintf, _IO_fprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl___vsnprintf, __vsnprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl_asprintf, asprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl_obstack_printf, obstack_printf, GLIBC_2_0);
compat_symbol (libc, __nldbl_obstack_vprintf, obstack_vprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl_snprintf, snprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl_vasprintf, vasprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl_vdprintf, vdprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl_vsnprintf, vsnprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl_vsprintf, vsprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl__IO_sscanf, _IO_sscanf, GLIBC_2_0);
compat_symbol (libc, __nldbl___vfscanf, __vfscanf, GLIBC_2_0);
compat_symbol (libc, __nldbl___vsscanf, __vsscanf, GLIBC_2_0);
compat_symbol (libc, __nldbl_fscanf, fscanf, GLIBC_2_0);
compat_symbol (libc, __nldbl_scanf, scanf, GLIBC_2_0);
compat_symbol (libc, __nldbl_sscanf, sscanf, GLIBC_2_0);
compat_symbol (libc, __nldbl_vfscanf, vfscanf, GLIBC_2_0);
compat_symbol (libc, __nldbl_vscanf, vscanf, GLIBC_2_0);
compat_symbol (libc, __nldbl_vsscanf, vsscanf, GLIBC_2_0);
compat_symbol (libc, __nldbl___printf_fp, __printf_fp, GLIBC_2_0);
compat_symbol (libc, __nldbl_strfmon, strfmon, GLIBC_2_0);
compat_symbol (libc, __nldbl_syslog, syslog, GLIBC_2_0);
compat_symbol (libc, __nldbl_vsyslog, vsyslog, GLIBC_2_0);
/* This function is not in public headers, but was exported until
version 2.29. For platforms that are newer than that, there's no
need to expose the symbol. */
# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_29)
compat_symbol (libc, __nldbl__IO_vfscanf, _IO_vfscanf, GLIBC_2_0);
# endif
#endif
#if LONG_DOUBLE_COMPAT(libc, GLIBC_2_1)
compat_symbol (libc, __nldbl___asprintf, __asprintf, GLIBC_2_1);
compat_symbol (libc, __nldbl_printf_size, printf_size, GLIBC_2_1);
compat_symbol (libc, __nldbl___strfmon_l, __strfmon_l, GLIBC_2_1);
#endif
#if LONG_DOUBLE_COMPAT(libc, GLIBC_2_2)
compat_symbol (libc, __nldbl_swprintf, swprintf, GLIBC_2_2);
compat_symbol (libc, __nldbl_vwprintf, vwprintf, GLIBC_2_2);
compat_symbol (libc, __nldbl_wprintf, wprintf, GLIBC_2_2);
compat_symbol (libc, __nldbl_fwprintf, fwprintf, GLIBC_2_2);
compat_symbol (libc, __nldbl_vfwprintf, vfwprintf, GLIBC_2_2);
compat_symbol (libc, __nldbl_vswprintf, vswprintf, GLIBC_2_2);
compat_symbol (libc, __nldbl_fwscanf, fwscanf, GLIBC_2_2);
compat_symbol (libc, __nldbl_swscanf, swscanf, GLIBC_2_2);
compat_symbol (libc, __nldbl_vfwscanf, vfwscanf, GLIBC_2_2);
compat_symbol (libc, __nldbl_vswscanf, vswscanf, GLIBC_2_2);
compat_symbol (libc, __nldbl_vwscanf, vwscanf, GLIBC_2_2);
compat_symbol (libc, __nldbl_wscanf, wscanf, GLIBC_2_2);
#endif
#if LONG_DOUBLE_COMPAT(libc, GLIBC_2_3)
compat_symbol (libc, __nldbl_strfmon_l, strfmon_l, GLIBC_2_3);
#endif
#if LONG_DOUBLE_COMPAT(libc, GLIBC_2_3_4)
compat_symbol (libc, __nldbl___sprintf_chk, __sprintf_chk, GLIBC_2_3_4);
compat_symbol (libc, __nldbl___vsprintf_chk, __vsprintf_chk, GLIBC_2_3_4);
compat_symbol (libc, __nldbl___snprintf_chk, __snprintf_chk, GLIBC_2_3_4);
compat_symbol (libc, __nldbl___vsnprintf_chk, __vsnprintf_chk, GLIBC_2_3_4);
compat_symbol (libc, __nldbl___printf_chk, __printf_chk, GLIBC_2_3_4);
compat_symbol (libc, __nldbl___fprintf_chk, __fprintf_chk, GLIBC_2_3_4);
compat_symbol (libc, __nldbl___vprintf_chk, __vprintf_chk, GLIBC_2_3_4);
compat_symbol (libc, __nldbl___vfprintf_chk, __vfprintf_chk, GLIBC_2_3_4);
#endif