Mercurial > hg > octave-shane > gnulib-hg
annotate m4/strtod.m4 @ 11219:aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Thu, 26 Feb 2009 12:54:20 +0100 |
parents | 8233c503d99e |
children | 963fbd66201a |
rev | line source |
---|---|
11212
8233c503d99e
strtod: avoid C99 decl-after-statement
Gary V. Vaughan <gary@gnu.org>
parents:
11210
diff
changeset
|
1 # strtod.m4 serial 12 |
11007
f6cba5a556ce
many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents:
9929
diff
changeset
|
2 dnl Copyright (C) 2002-2003, 2006-2009 Free Software Foundation, Inc. |
5611
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4691
diff
changeset
|
3 dnl This file is free software; the Free Software Foundation |
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4691
diff
changeset
|
4 dnl gives unlimited permission to copy and/or distribute it, |
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4691
diff
changeset
|
5 dnl with or without modifications, as long as this notice is preserved. |
4107
7c1a6b73f48e
An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 |
7c1a6b73f48e
An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 AC_DEFUN([gl_FUNC_STRTOD], |
7c1a6b73f48e
An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 [ |
9821
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) |
7942
9b53e406b401
2007-01-24 Bruno Haible <bruno@clisp.org>
Bruno Haible <bruno@clisp.org>
parents:
6927
diff
changeset
|
10 AC_FUNC_STRTOD |
11007
f6cba5a556ce
many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents:
9929
diff
changeset
|
11 dnl Note: AC_FUNC_STRTOD does AC_LIBOBJ([strtod]). |
4107
7c1a6b73f48e
An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 if test $ac_cv_func_strtod = no; then |
9821
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
13 HAVE_STRTOD=0 |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
14 REPLACE_STRTOD=1 |
4107
7c1a6b73f48e
An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
15 gl_PREREQ_STRTOD |
9821
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
16 else |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
17 AC_CACHE_CHECK([whether strtod obeys C99], [gl_cv_func_strtod_works], |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
18 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
19 #include <stdlib.h> |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
20 #include <math.h> |
11210 | 21 #include <errno.h> |
9929
357b15084942
Adjust strtod detection to catch glibc 2.7 bug.
Eric Blake <ebb9@byu.net>
parents:
9898
diff
changeset
|
22 /* Compare two numbers with ==. |
357b15084942
Adjust strtod detection to catch glibc 2.7 bug.
Eric Blake <ebb9@byu.net>
parents:
9898
diff
changeset
|
23 This is a separate function because IRIX 6.5 "cc -O" miscompiles an |
357b15084942
Adjust strtod detection to catch glibc 2.7 bug.
Eric Blake <ebb9@byu.net>
parents:
9898
diff
changeset
|
24 'x == x' test. */ |
357b15084942
Adjust strtod detection to catch glibc 2.7 bug.
Eric Blake <ebb9@byu.net>
parents:
9898
diff
changeset
|
25 static int |
357b15084942
Adjust strtod detection to catch glibc 2.7 bug.
Eric Blake <ebb9@byu.net>
parents:
9898
diff
changeset
|
26 numeric_equal (double x, double y) |
357b15084942
Adjust strtod detection to catch glibc 2.7 bug.
Eric Blake <ebb9@byu.net>
parents:
9898
diff
changeset
|
27 { |
357b15084942
Adjust strtod detection to catch glibc 2.7 bug.
Eric Blake <ebb9@byu.net>
parents:
9898
diff
changeset
|
28 return x == y; |
357b15084942
Adjust strtod detection to catch glibc 2.7 bug.
Eric Blake <ebb9@byu.net>
parents:
9898
diff
changeset
|
29 } |
9821
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
30 ]], [[ |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
31 { |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
32 /* Older glibc and Cygwin mis-parse "-0x". */ |
9871
faf4392efa56
Improve strtod bug detection check.
Eric Blake <ebb9@byu.net>
parents:
9821
diff
changeset
|
33 const char *string = "-0x"; |
9821
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
34 char *term; |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
35 double value = strtod (string, &term); |
9898
02bfc9acab82
Work around Solaris 10 math.h bug.
Eric Blake <ebb9@byu.net>
parents:
9871
diff
changeset
|
36 double zero = 0.0; |
02bfc9acab82
Work around Solaris 10 math.h bug.
Eric Blake <ebb9@byu.net>
parents:
9871
diff
changeset
|
37 if (1.0 / value != -1.0 / zero || term != (string + 2)) |
9821
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
38 return 1; |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
39 } |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
40 { |
9871
faf4392efa56
Improve strtod bug detection check.
Eric Blake <ebb9@byu.net>
parents:
9821
diff
changeset
|
41 /* Many platforms do not parse hex floats. */ |
faf4392efa56
Improve strtod bug detection check.
Eric Blake <ebb9@byu.net>
parents:
9821
diff
changeset
|
42 const char *string = "0XaP+1"; |
faf4392efa56
Improve strtod bug detection check.
Eric Blake <ebb9@byu.net>
parents:
9821
diff
changeset
|
43 char *term; |
faf4392efa56
Improve strtod bug detection check.
Eric Blake <ebb9@byu.net>
parents:
9821
diff
changeset
|
44 double value = strtod (string, &term); |
faf4392efa56
Improve strtod bug detection check.
Eric Blake <ebb9@byu.net>
parents:
9821
diff
changeset
|
45 if (value != 20.0 || term != (string + 6)) |
faf4392efa56
Improve strtod bug detection check.
Eric Blake <ebb9@byu.net>
parents:
9821
diff
changeset
|
46 return 1; |
faf4392efa56
Improve strtod bug detection check.
Eric Blake <ebb9@byu.net>
parents:
9821
diff
changeset
|
47 } |
faf4392efa56
Improve strtod bug detection check.
Eric Blake <ebb9@byu.net>
parents:
9821
diff
changeset
|
48 { |
11210 | 49 /* Many platforms do not parse infinities. HP-UX 11.31 parses inf, |
50 but mistakenly sets errno. */ | |
9871
faf4392efa56
Improve strtod bug detection check.
Eric Blake <ebb9@byu.net>
parents:
9821
diff
changeset
|
51 const char *string = "inf"; |
9821
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
52 char *term; |
11212
8233c503d99e
strtod: avoid C99 decl-after-statement
Gary V. Vaughan <gary@gnu.org>
parents:
11210
diff
changeset
|
53 double value; |
11210 | 54 errno = 0; |
11212
8233c503d99e
strtod: avoid C99 decl-after-statement
Gary V. Vaughan <gary@gnu.org>
parents:
11210
diff
changeset
|
55 value = strtod (string, &term); |
11210 | 56 if (value != HUGE_VAL || term != (string + 3) || errno) |
9821
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
57 return 1; |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
58 } |
9929
357b15084942
Adjust strtod detection to catch glibc 2.7 bug.
Eric Blake <ebb9@byu.net>
parents:
9898
diff
changeset
|
59 { |
357b15084942
Adjust strtod detection to catch glibc 2.7 bug.
Eric Blake <ebb9@byu.net>
parents:
9898
diff
changeset
|
60 /* glibc 2.7 and cygwin 1.5.24 misparse "nan()". */ |
357b15084942
Adjust strtod detection to catch glibc 2.7 bug.
Eric Blake <ebb9@byu.net>
parents:
9898
diff
changeset
|
61 const char *string = "nan()"; |
357b15084942
Adjust strtod detection to catch glibc 2.7 bug.
Eric Blake <ebb9@byu.net>
parents:
9898
diff
changeset
|
62 char *term; |
357b15084942
Adjust strtod detection to catch glibc 2.7 bug.
Eric Blake <ebb9@byu.net>
parents:
9898
diff
changeset
|
63 double value = strtod (string, &term); |
357b15084942
Adjust strtod detection to catch glibc 2.7 bug.
Eric Blake <ebb9@byu.net>
parents:
9898
diff
changeset
|
64 if (numeric_equal (value, value) || term != (string + 5)) |
357b15084942
Adjust strtod detection to catch glibc 2.7 bug.
Eric Blake <ebb9@byu.net>
parents:
9898
diff
changeset
|
65 return 1; |
357b15084942
Adjust strtod detection to catch glibc 2.7 bug.
Eric Blake <ebb9@byu.net>
parents:
9898
diff
changeset
|
66 } |
9821
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
67 ]])], |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
68 [gl_cv_func_strtod_works=yes], |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
69 [gl_cv_func_strtod_works=no], |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
70 [gl_cv_func_strtod_works="guessing no"])]) |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
71 if test "$gl_cv_func_strtod_works" != yes; then |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
72 REPLACE_STRTOD=1 |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
73 gl_PREREQ_STRTOD |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
74 dnl Use undocumented macro to set POW_LIB correctly. |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
75 _AC_LIBOBJ_STRTOD |
18bab9955c43
Document various strtod bugs, with some fixes.
Eric Blake <ebb9@byu.net>
parents:
7942
diff
changeset
|
76 fi |
4107
7c1a6b73f48e
An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
77 fi |
7c1a6b73f48e
An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
78 ]) |
7c1a6b73f48e
An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
79 |
7c1a6b73f48e
An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
80 # Prerequisites of lib/strtod.c. |
7c1a6b73f48e
An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
81 # The need for pow() is already handled by AC_FUNC_STRTOD. |
6927
fa896bb33133
* lib/memcasecmp.c: Include <limits.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5611
diff
changeset
|
82 AC_DEFUN([gl_PREREQ_STRTOD], [:]) |