2 dnl Copyright (C) 2002-2003, 2006-2010 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
16 AC_CACHE_CHECK([whether strtod obeys C99], [gl_cv_func_strtod_works],
17 [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. HP-UX 11.31 parses inf,
49 but mistakenly sets errno. */
50 const char *string = "inf";
54 value = strtod (string, &term);
55 if (value != HUGE_VAL || term != (string + 3) || errno)
59 /* glibc 2.7 and cygwin 1.5.24 misparse "nan()". */
60 const char *string = "nan()";
62 double value = strtod (string, &term);
63 if (numeric_equal (value, value) || term != (string + 5))
67 /* darwin 10.6.1 misparses "nan(". */
68 const char *string = "nan(";
70 double value = strtod (string, &term);
71 if (numeric_equal (value, value) || term != (string + 3))
75 [gl_cv_func_strtod_works=yes],
76 [gl_cv_func_strtod_works=no],
77 [gl_cv_func_strtod_works="guessing no"])])
78 if test "$gl_cv_func_strtod_works" != yes; then
81 dnl Use undocumented macro to set POW_LIB correctly.
87 # Prerequisites of lib/strtod.c.
88 # The need for pow() is already handled by AC_FUNC_STRTOD.
89 AC_DEFUN([gl_PREREQ_STRTOD], [:])