1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

Use SCANF_LDBL_IS_DBL instead of __ldbl_is_dbl.

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.
This commit is contained in:
Zack Weinberg
2018-03-07 14:32:00 -05:00
committed by Gabriel F. T. Gomes
parent b87eb3f8fe
commit d91798b31a
3 changed files with 144 additions and 134 deletions

View File

@ -1,3 +1,26 @@
2018-12-05 Zack Weinberg <zackw@panix.com>
Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
* stdio-common/vfscanf-internal.c: Don't look at __ldbl_is_dbl.
* sysdeps/ieee754/ldbl-opt/ndlbl-compat.c:
Include libio/strfile.h instead of libioP.h.
(__nldbl_IO_vfscanf, __ndlbl___vfscanf, __nldbl_sscanf)
(__nldbl___vsscanf, __nldbl_vscanf, __nldbl_fscanf)
(__nldbl_scanf, __nldbl_vfwscanf, __nldbl_swscanf)
(__nldbl_vswscanf, __nldbl_vwscanf, __nldbl_fwscanf)
(__nldbl_wscanf): Call __vfscanf_internal / __vfwscanf_internal
directly, passing SCANF_LDBL_IS_DBL. Set up a strfile if
necessary. Do not set __no_long_double. Normalize variable names.
(__nldbl___isoc99_vfscanf, __nldbl___isoc99_sscanf)
(__nldbl___isoc99_vsscanf, __nldbl___isoc99_vscanf)
(__nldbl___isoc99_fscanf, __nldbl___isoc99_scanf)
(__nldbl___isoc99_vfwscanf, __nldbl___isoc99_swscanf)
(__nldbl___isoc99_vswscanf, __nldbl___isoc99_vwscanf)
(__nldbl___isoc99_fwscanf, __nldbl___isoc99_wscanf):
Call __vfscanf_internal / __vfwscanf_internal directly, passing
SCANF_LDBL_IS_DBL | SCANF_ISOC99_A. Set up a strfile if necessary.
Do not set __no_long_double. Normalize variable names.
2018-12-05 Zack Weinberg <zackw@panix.com> 2018-12-05 Zack Weinberg <zackw@panix.com>
Gabriel F. T. Gomes <gabriel@inconstante.eti.br> Gabriel F. T. Gomes <gabriel@inconstante.eti.br>

View File

@ -332,10 +332,6 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
struct char_buffer charbuf; struct char_buffer charbuf;
scratch_buffer_init (&charbuf.scratch); scratch_buffer_init (&charbuf.scratch);
/* Temporarily honor the environmental mode bits. */
if (__ldbl_is_dbl)
mode_flags |= SCANF_LDBL_IS_DBL;
#ifdef __va_copy #ifdef __va_copy
__va_copy (arg, argptr); __va_copy (arg, argptr);
#else #else

View File

@ -19,7 +19,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <libioP.h> #include <libio/strfile.h>
#include <math.h> #include <math.h>
#include <wchar.h> #include <wchar.h>
#include <printf.h> #include <printf.h>
@ -335,13 +335,10 @@ int
attribute_compat_text_section attribute_compat_text_section
__nldbl__IO_vfscanf (FILE *s, const char *fmt, va_list ap, int *errp) __nldbl__IO_vfscanf (FILE *s, const char *fmt, va_list ap, int *errp)
{ {
int res; int ret = __vfscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL);
set_no_long_double ();
res = __vfscanf_internal (s, fmt, ap, 0);
clear_no_long_double ();
if (__glibc_unlikely (errp != 0)) if (__glibc_unlikely (errp != 0))
*errp = (res == -1); *errp = (ret == -1);
return res; return ret;
} }
#endif #endif
@ -349,11 +346,7 @@ int
attribute_compat_text_section attribute_compat_text_section
__nldbl___vfscanf (FILE *s, const char *fmt, va_list ap) __nldbl___vfscanf (FILE *s, const char *fmt, va_list ap)
{ {
int res; return __vfscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL);
set_no_long_double ();
res = __vfscanf_internal (s, fmt, ap, 0);
clear_no_long_double ();
return res;
} }
weak_alias (__nldbl___vfscanf, __nldbl_vfscanf) weak_alias (__nldbl___vfscanf, __nldbl_vfscanf)
libc_hidden_def (__nldbl_vfscanf) libc_hidden_def (__nldbl_vfscanf)
@ -362,26 +355,26 @@ int
attribute_compat_text_section attribute_compat_text_section
__nldbl_sscanf (const char *s, const char *fmt, ...) __nldbl_sscanf (const char *s, const char *fmt, ...)
{ {
va_list arg; _IO_strfile sf;
int done; FILE *f = _IO_strfile_read (&sf, s);
va_list ap;
int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl_vsscanf (s, fmt, arg); ret = __vfscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL);
va_end (arg); va_end (ap);
return done; return ret;
} }
strong_alias (__nldbl_sscanf, __nldbl__IO_sscanf) strong_alias (__nldbl_sscanf, __nldbl__IO_sscanf)
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___vsscanf (const char *string, const char *fmt, va_list ap) __nldbl___vsscanf (const char *s, const char *fmt, va_list ap)
{ {
int res; _IO_strfile sf;
__no_long_double = 1; FILE *f = _IO_strfile_read (&sf, s);
res = _IO_vsscanf (string, fmt, ap); return __vfscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL);
__no_long_double = 0;
return res;
} }
weak_alias (__nldbl___vsscanf, __nldbl_vsscanf) weak_alias (__nldbl___vsscanf, __nldbl_vsscanf)
libc_hidden_def (__nldbl_vsscanf) libc_hidden_def (__nldbl_vsscanf)
@ -390,46 +383,42 @@ int
attribute_compat_text_section weak_function attribute_compat_text_section weak_function
__nldbl_vscanf (const char *fmt, va_list ap) __nldbl_vscanf (const char *fmt, va_list ap)
{ {
return __nldbl_vfscanf (stdin, fmt, ap); return __vfscanf_internal (stdin, fmt, ap, SCANF_LDBL_IS_DBL);
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl_fscanf (FILE *stream, const char *fmt, ...) __nldbl_fscanf (FILE *stream, const char *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl_vfscanf (stream, fmt, arg); ret = __vfscanf_internal (stream, fmt, ap, SCANF_LDBL_IS_DBL);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl_scanf (const char *fmt, ...) __nldbl_scanf (const char *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl_vfscanf (stdin, fmt, arg); ret = __vfscanf_internal (stdin, fmt, ap, SCANF_LDBL_IS_DBL);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl_vfwscanf (FILE *s, const wchar_t *fmt, va_list ap) __nldbl_vfwscanf (FILE *s, const wchar_t *fmt, va_list ap)
{ {
int res; return __vfwscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL);
set_no_long_double ();
res = __vfwscanf_internal (s, fmt, ap, 0);
clear_no_long_double ();
return res;
} }
libc_hidden_def (__nldbl_vfwscanf) libc_hidden_def (__nldbl_vfwscanf)
@ -437,25 +426,28 @@ int
attribute_compat_text_section attribute_compat_text_section
__nldbl_swscanf (const wchar_t *s, const wchar_t *fmt, ...) __nldbl_swscanf (const wchar_t *s, const wchar_t *fmt, ...)
{ {
va_list arg; _IO_strfile sf;
int done; struct _IO_wide_data wd;
FILE *f = _IO_strfile_readw (&sf, &wd, s);
va_list ap;
int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl_vswscanf (s, fmt, arg); ret = __vfwscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl_vswscanf (const wchar_t *string, const wchar_t *fmt, va_list ap) __nldbl_vswscanf (const wchar_t *s, const wchar_t *fmt, va_list ap)
{ {
int res; _IO_strfile sf;
__no_long_double = 1; struct _IO_wide_data wd;
res = vswscanf (string, fmt, ap); FILE *f = _IO_strfile_readw (&sf, &wd, s);
__no_long_double = 0;
return res; return __vfwscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL);
} }
libc_hidden_def (__nldbl_vswscanf) libc_hidden_def (__nldbl_vswscanf)
@ -463,35 +455,35 @@ int
attribute_compat_text_section weak_function attribute_compat_text_section weak_function
__nldbl_vwscanf (const wchar_t *fmt, va_list ap) __nldbl_vwscanf (const wchar_t *fmt, va_list ap)
{ {
return __nldbl_vfwscanf (stdin, fmt, ap); return __vfwscanf_internal (stdin, fmt, ap, SCANF_LDBL_IS_DBL);
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl_fwscanf (FILE *stream, const wchar_t *fmt, ...) __nldbl_fwscanf (FILE *stream, const wchar_t *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl_vfwscanf (stream, fmt, arg); ret = __vfwscanf_internal (stream, fmt, ap, SCANF_LDBL_IS_DBL);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl_wscanf (const wchar_t *fmt, ...) __nldbl_wscanf (const wchar_t *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl_vfwscanf (stdin, fmt, arg); ret = __vfwscanf_internal (stdin, fmt, ap, SCANF_LDBL_IS_DBL);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
@ -866,11 +858,7 @@ int
attribute_compat_text_section attribute_compat_text_section
__nldbl___isoc99_vfscanf (FILE *s, const char *fmt, va_list ap) __nldbl___isoc99_vfscanf (FILE *s, const char *fmt, va_list ap)
{ {
int res; return __vfscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
set_no_long_double ();
res = __isoc99_vfscanf (s, fmt, ap);
clear_no_long_double ();
return res;
} }
libc_hidden_def (__nldbl___isoc99_vfscanf) libc_hidden_def (__nldbl___isoc99_vfscanf)
@ -878,25 +866,26 @@ int
attribute_compat_text_section attribute_compat_text_section
__nldbl___isoc99_sscanf (const char *s, const char *fmt, ...) __nldbl___isoc99_sscanf (const char *s, const char *fmt, ...)
{ {
va_list arg; _IO_strfile sf;
int done; FILE *f = _IO_strfile_read (&sf, s);
va_list ap;
int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl___isoc99_vsscanf (s, fmt, arg); ret = __vfscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___isoc99_vsscanf (const char *string, const char *fmt, va_list ap) __nldbl___isoc99_vsscanf (const char *s, const char *fmt, va_list ap)
{ {
int res; _IO_strfile sf;
__no_long_double = 1; FILE *f = _IO_strfile_read (&sf, s);
res = __isoc99_vsscanf (string, fmt, ap);
__no_long_double = 0; return __vfscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
return res;
} }
libc_hidden_def (__nldbl___isoc99_vsscanf) libc_hidden_def (__nldbl___isoc99_vsscanf)
@ -904,46 +893,44 @@ int
attribute_compat_text_section attribute_compat_text_section
__nldbl___isoc99_vscanf (const char *fmt, va_list ap) __nldbl___isoc99_vscanf (const char *fmt, va_list ap)
{ {
return __nldbl___isoc99_vfscanf (stdin, fmt, ap); return __vfscanf_internal (stdin, fmt, ap,
SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___isoc99_fscanf (FILE *stream, const char *fmt, ...) __nldbl___isoc99_fscanf (FILE *s, const char *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl___isoc99_vfscanf (stream, fmt, arg); ret = __vfscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___isoc99_scanf (const char *fmt, ...) __nldbl___isoc99_scanf (const char *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl___isoc99_vfscanf (stdin, fmt, arg); ret = __vfscanf_internal (stdin, fmt, ap,
va_end (arg); SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___isoc99_vfwscanf (FILE *s, const wchar_t *fmt, va_list ap) __nldbl___isoc99_vfwscanf (FILE *s, const wchar_t *fmt, va_list ap)
{ {
int res; return __vfwscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
set_no_long_double ();
res = __isoc99_vfwscanf (s, fmt, ap);
clear_no_long_double ();
return res;
} }
libc_hidden_def (__nldbl___isoc99_vfwscanf) libc_hidden_def (__nldbl___isoc99_vfwscanf)
@ -951,26 +938,28 @@ int
attribute_compat_text_section attribute_compat_text_section
__nldbl___isoc99_swscanf (const wchar_t *s, const wchar_t *fmt, ...) __nldbl___isoc99_swscanf (const wchar_t *s, const wchar_t *fmt, ...)
{ {
va_list arg; _IO_strfile sf;
int done; struct _IO_wide_data wd;
FILE *f = _IO_strfile_readw (&sf, &wd, s);
va_list ap;
int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl___isoc99_vswscanf (s, fmt, arg); ret = __vfwscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___isoc99_vswscanf (const wchar_t *string, const wchar_t *fmt, __nldbl___isoc99_vswscanf (const wchar_t *s, const wchar_t *fmt, va_list ap)
va_list ap)
{ {
int res; _IO_strfile sf;
__no_long_double = 1; struct _IO_wide_data wd;
res = __isoc99_vswscanf (string, fmt, ap); FILE *f = _IO_strfile_readw (&sf, &wd, s);
__no_long_double = 0;
return res; return __vfwscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
} }
libc_hidden_def (__nldbl___isoc99_vswscanf) libc_hidden_def (__nldbl___isoc99_vswscanf)
@ -978,35 +967,37 @@ int
attribute_compat_text_section attribute_compat_text_section
__nldbl___isoc99_vwscanf (const wchar_t *fmt, va_list ap) __nldbl___isoc99_vwscanf (const wchar_t *fmt, va_list ap)
{ {
return __nldbl___isoc99_vfwscanf (stdin, fmt, ap); return __vfwscanf_internal (stdin, fmt, ap,
SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___isoc99_fwscanf (FILE *stream, const wchar_t *fmt, ...) __nldbl___isoc99_fwscanf (FILE *s, const wchar_t *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl___isoc99_vfwscanf (stream, fmt, arg); ret = __vfwscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___isoc99_wscanf (const wchar_t *fmt, ...) __nldbl___isoc99_wscanf (const wchar_t *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl___isoc99_vfwscanf (stdin, fmt, arg); ret = __vfwscanf_internal (stdin, fmt, ap,
va_end (arg); SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
va_end (ap);
return done; return ret;
} }
#if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0) #if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)