2 dnl Copyright (C) 2002-2003, 2006-2009 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_STRTOD],
9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
11 dnl Note: AC_FUNC_STRTOD does AC_LIBOBJ([strtod]).
12 if test $ac_cv_func_strtod = no; then
17 AC_CACHE_CHECK([whether strtod obeys C99], [gl_cv_func_strtod_works],
18 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
21 /* Compare two numbers with ==.
22 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
25 numeric_equal (double x, double y)
31 /* Older glibc and Cygwin mis-parse "-0x". */
32 const char *string = "-0x";
34 double value = strtod (string, &term);
36 if (1.0 / value != -1.0 / zero || term != (string + 2))
40 /* Many platforms do not parse hex floats. */
41 const char *string = "0XaP+1";
43 double value = strtod (string, &term);
44 if (value != 20.0 || term != (string + 6))
48 /* Many platforms do not parse infinities. */
49 const char *string = "inf";
51 double value = strtod (string, &term);
52 if (value != HUGE_VAL || term != (string + 3))
56 /* glibc 2.7 and cygwin 1.5.24 misparse "nan()". */
57 const char *string = "nan()";
59 double value = strtod (string, &term);
60 if (numeric_equal (value, value) || term != (string + 5))
64 [gl_cv_func_strtod_works=yes],
65 [gl_cv_func_strtod_works=no],
66 [gl_cv_func_strtod_works="guessing no"])])
67 if test "$gl_cv_func_strtod_works" != yes; then
70 dnl Use undocumented macro to set POW_LIB correctly.
76 # Prerequisites of lib/strtod.c.
77 # The need for pow() is already handled by AC_FUNC_STRTOD.
78 AC_DEFUN([gl_PREREQ_STRTOD], [:])