mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Merge from gnulib
This incorporates: 2017-02-25 maintainer-makefile: Fix AC_PROG_SED with autoconf cache. 2017-02-24 ftoastr: port to -Wdouble-promotion * lib/ftoastr.c, m4/gnulib-common.m4: Copy from gnulib.
This commit is contained in:
parent
aaf86f30f7
commit
f1fe3fcfc5
2 changed files with 12 additions and 5 deletions
|
|
@ -39,6 +39,7 @@
|
||||||
# define FLOAT_MIN LDBL_MIN
|
# define FLOAT_MIN LDBL_MIN
|
||||||
# define FLOAT_PREC_BOUND _GL_LDBL_PREC_BOUND
|
# define FLOAT_PREC_BOUND _GL_LDBL_PREC_BOUND
|
||||||
# define FTOASTR ldtoastr
|
# define FTOASTR ldtoastr
|
||||||
|
# define PROMOTED_FLOAT long double
|
||||||
# if HAVE_C99_STRTOLD
|
# if HAVE_C99_STRTOLD
|
||||||
# define STRTOF strtold
|
# define STRTOF strtold
|
||||||
# endif
|
# endif
|
||||||
|
|
@ -48,6 +49,7 @@
|
||||||
# define FLOAT_MIN DBL_MIN
|
# define FLOAT_MIN DBL_MIN
|
||||||
# define FLOAT_PREC_BOUND _GL_DBL_PREC_BOUND
|
# define FLOAT_PREC_BOUND _GL_DBL_PREC_BOUND
|
||||||
# define FTOASTR dtoastr
|
# define FTOASTR dtoastr
|
||||||
|
# define PROMOTED_FLOAT double
|
||||||
#else
|
#else
|
||||||
# define LENGTH 1
|
# define LENGTH 1
|
||||||
# define FLOAT float
|
# define FLOAT float
|
||||||
|
|
@ -55,6 +57,7 @@
|
||||||
# define FLOAT_MIN FLT_MIN
|
# define FLOAT_MIN FLT_MIN
|
||||||
# define FLOAT_PREC_BOUND _GL_FLT_PREC_BOUND
|
# define FLOAT_PREC_BOUND _GL_FLT_PREC_BOUND
|
||||||
# define FTOASTR ftoastr
|
# define FTOASTR ftoastr
|
||||||
|
# define PROMOTED_FLOAT double
|
||||||
# if HAVE_STRTOF
|
# if HAVE_STRTOF
|
||||||
# define STRTOF strtof
|
# define STRTOF strtof
|
||||||
# endif
|
# endif
|
||||||
|
|
@ -77,20 +80,21 @@ static int
|
||||||
ftoastr_snprintf (char *buf, size_t bufsize, char const *format,
|
ftoastr_snprintf (char *buf, size_t bufsize, char const *format,
|
||||||
int width, int prec, FLOAT x)
|
int width, int prec, FLOAT x)
|
||||||
{
|
{
|
||||||
|
PROMOTED_FLOAT promoted_x = x;
|
||||||
char width_0_buffer[LENGTH == 1 ? FLT_BUFSIZE_BOUND
|
char width_0_buffer[LENGTH == 1 ? FLT_BUFSIZE_BOUND
|
||||||
: LENGTH == 2 ? DBL_BUFSIZE_BOUND
|
: LENGTH == 2 ? DBL_BUFSIZE_BOUND
|
||||||
: LDBL_BUFSIZE_BOUND];
|
: LDBL_BUFSIZE_BOUND];
|
||||||
int n = width;
|
int n = width;
|
||||||
if (bufsize < sizeof width_0_buffer)
|
if (bufsize < sizeof width_0_buffer)
|
||||||
{
|
{
|
||||||
n = sprintf (width_0_buffer, format, 0, prec, x);
|
n = sprintf (width_0_buffer, format, 0, prec, promoted_x);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return n;
|
return n;
|
||||||
if (n < width)
|
if (n < width)
|
||||||
n = width;
|
n = width;
|
||||||
}
|
}
|
||||||
if (n < bufsize)
|
if (n < bufsize)
|
||||||
n = sprintf (buf, format, width, prec, x);
|
n = sprintf (buf, format, width, prec, promoted_x);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -106,6 +110,7 @@ FTOASTR (char *buf, size_t bufsize, int flags, int width, FLOAT x)
|
||||||
<http://dx.doi.org/10.1145/1809028.1806623>; also see the
|
<http://dx.doi.org/10.1145/1809028.1806623>; also see the
|
||||||
2010-03-21 draft <http://florian.loitsch.com/tmp/article.pdf>. */
|
2010-03-21 draft <http://florian.loitsch.com/tmp/article.pdf>. */
|
||||||
|
|
||||||
|
PROMOTED_FLOAT promoted_x = x;
|
||||||
char format[sizeof "%-+ 0*.*Lg"];
|
char format[sizeof "%-+ 0*.*Lg"];
|
||||||
FLOAT abs_x = x < 0 ? -x : x;
|
FLOAT abs_x = x < 0 ? -x : x;
|
||||||
int prec;
|
int prec;
|
||||||
|
|
@ -128,7 +133,7 @@ FTOASTR (char *buf, size_t bufsize, int flags, int width, FLOAT x)
|
||||||
|
|
||||||
for (prec = abs_x < FLOAT_MIN ? 1 : FLOAT_DIG; ; prec++)
|
for (prec = abs_x < FLOAT_MIN ? 1 : FLOAT_DIG; ; prec++)
|
||||||
{
|
{
|
||||||
int n = snprintf (buf, bufsize, format, width, prec, x);
|
int n = snprintf (buf, bufsize, format, width, prec, promoted_x);
|
||||||
if (n < 0
|
if (n < 0
|
||||||
|| FLOAT_PREC_BOUND <= prec
|
|| FLOAT_PREC_BOUND <= prec
|
||||||
|| (n < bufsize && STRTOF (buf, NULL) == x))
|
|| (n < bufsize && STRTOF (buf, NULL) == x))
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# gnulib-common.m4 serial 36
|
# gnulib-common.m4 serial 37
|
||||||
dnl Copyright (C) 2007-2017 Free Software Foundation, Inc.
|
dnl Copyright (C) 2007-2017 Free Software Foundation, Inc.
|
||||||
dnl This file is free software; the Free Software Foundation
|
dnl This file is free software; the Free Software Foundation
|
||||||
dnl gives unlimited permission to copy and/or distribute it,
|
dnl gives unlimited permission to copy and/or distribute it,
|
||||||
|
|
@ -456,7 +456,9 @@ m4_ifndef([AC_PROG_SED],
|
||||||
else
|
else
|
||||||
ac_cv_path_SED=$SED
|
ac_cv_path_SED=$SED
|
||||||
fi
|
fi
|
||||||
|
])
|
||||||
SED="$ac_cv_path_SED"
|
SED="$ac_cv_path_SED"
|
||||||
AC_SUBST([SED])dnl
|
AC_SUBST([SED])dnl
|
||||||
rm -f conftest.sed
|
rm -f conftest.sed
|
||||||
])])])
|
])
|
||||||
|
])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue