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([[
22 /* Compare two numbers with ==.
23 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
26 numeric_equal (double x, double y)
32 /* Older glibc and Cygwin mis-parse "-0x". */
33 const char *string = "-0x";
35 double value = strtod (string, &term);
37 if (1.0 / value != -1.0 / zero || term != (string + 2))
41 /* Many platforms do not parse hex floats. */
42 const char *string = "0XaP+1";
44 double value = strtod (string, &term);
45 if (value != 20.0 || term != (string + 6))
49 /* Many platforms do not parse infinities. HP-UX 11.31 parses inf,
50 but mistakenly sets errno. */
51 const char *string = "inf";
55 value = strtod (string, &term);
56 if (value != HUGE_VAL || term != (string + 3) || errno)
60 /* glibc 2.7 and cygwin 1.5.24 misparse "nan()". */
61 const char *string = "nan()";
63 double value = strtod (string, &term);
64 if (numeric_equal (value, value) || term != (string + 5))
68 /* darwin 10.6.1 misparses "nan(". */
69 const char *string = "nan(";
71 double value = strtod (string, &term);
72 if (numeric_equal (value, value) || term != (string + 3))
76 [gl_cv_func_strtod_works=yes],
77 [gl_cv_func_strtod_works=no],
78 [gl_cv_func_strtod_works="guessing no"])])
79 if test "$gl_cv_func_strtod_works" != yes; then
82 dnl Use undocumented macro to set POW_LIB correctly.
88 # Prerequisites of lib/strtod.c.
89 # The need for pow() is already handled by AC_FUNC_STRTOD.
90 AC_DEFUN([gl_PREREQ_STRTOD], [:])