diff options
author | Paul R. Eggert <eggert@cs.ucla.edu> | 2010-07-12 09:14:10 -0700 |
---|---|---|
committer | Paul R. Eggert <eggert@lnxsrv01.seas.ucla.edu> | 2010-07-12 09:15:42 -0700 |
commit | 3458f09caac5234831a315d073344fc898dde077 (patch) | |
tree | 41f9f8348b29fe3c44f3bf18bdbff3fed6e02370 /m4 | |
parent | 4482085b415661578d0dff98b4c99314d12b308b (diff) | |
download | gnulib-3458f09caac5234831a315d073344fc898dde077.tar.gz |
strtod: make it more-accurate typically, and don't require libm
* lib/strtod.c (_GL_ARG_NONNULL): Remove; no longer needed.
Include limits.h. Don't include string.h.
(HAVE_LDEXP_IN_LIBC, HAVE_RAW_DECL_STRTOD): Define to 0 if not defined.
(locale_isspace): New function, so that no casts are needed to
check whether *s is a space.
(ldexp): Provide an unused dummy if not available.
(scale_radix_exp, parse_number, underlying_strtod): New functions.
(strtod): Use them. This implementation prefers to use the
underlying strtod if available, falling back on our own code
only to fix known bugs. This is more likely to produce an
accurate result. Also, it avoids the use of libm functions.
* m4/strtod.m4 (gl_FUNC_STRTOD): Don't invoke _AC_LIBOBJ_STRTOD;
no longer needed. Invoke AC_LIBOBJ([strtod]); don't know why this
was absent, but it caused a test failure with coreutils.
(gl_PREREQ_STRTOD): Check wither ldexp can be used without linking
with libm.
* modules/strtod (Makefile.am, Link): libm is no longer needed.
* modules/strtod-tests (Makefile.am): Likewise.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/strtod.m4 | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/m4/strtod.m4 b/m4/strtod.m4 index aa6a1c53d5..05d36bd4b3 100644 --- a/m4/strtod.m4 +++ b/m4/strtod.m4 @@ -11,7 +11,7 @@ AC_DEFUN([gl_FUNC_STRTOD], dnl Don't call AC_FUNC_STRTOD, because it does not have the right guess dnl when cross-compiling. dnl Don't call AC_CHECK_FUNCS([strtod]) because it would collide with the - dnl ac_cv_func_strtod variable set by the AC_FUNC_STRTOD macro, + dnl ac_cv_func_strtod variable set by the AC_FUNC_STRTOD macro. AC_CHECK_DECLS_ONCE([strtod]) if test $ac_cv_have_decl_strtod != yes; then HAVE_STRTOD=0 @@ -113,12 +113,26 @@ numeric_equal (double x, double y) fi fi if test $HAVE_STRTOD = 0 || test $REPLACE_STRTOD = 1; then + AC_LIBOBJ([strtod]) gl_PREREQ_STRTOD - dnl Use undocumented macro to set POW_LIB correctly. - _AC_LIBOBJ_STRTOD fi ]) # Prerequisites of lib/strtod.c. -# The need for pow() is already handled by AC_FUNC_STRTOD. -AC_DEFUN([gl_PREREQ_STRTOD], [:]) +# FIXME: This implementation is a copy of printf-frexp.m4 and should be shared. +AC_DEFUN([gl_PREREQ_STRTOD], [ + AC_CACHE_CHECK([whether ldexp can be used without linking with libm], + [gl_cv_func_ldexp_no_libm], + [ + AC_TRY_LINK([#include <math.h> + double x; + int y;], + [return ldexp (x, y) < 1;], + [gl_cv_func_ldexp_no_libm=yes], + [gl_cv_func_ldexp_no_libm=no]) + ]) + if test $gl_cv_func_ldexp_no_libm = yes; then + AC_DEFINE([HAVE_LDEXP_IN_LIBC], [1], + [Define if the ldexp function is available in libc.]) + fi +]) |