diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2004-07-12 06:30:36 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2004-07-12 06:30:36 +0000 |
commit | d06984e2be1fc5e2cf871e9666f21d7ab3760e3f (patch) | |
tree | 88b2d96e72f40b42684cbe704df51d2f0f4115c3 | |
parent | c98f2fb04a7d0faf0c8f12b9365ba6f658b387e6 (diff) | |
download | coreutils-d06984e2be1fc5e2cf871e9666f21d7ab3760e3f.tar.xz |
Include <config.h> first.
(C_STRTOD, DOUBLE, STRTOD): New macros.
(c_strtod): Use them.
-rw-r--r-- | lib/c-strtod.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/c-strtod.c b/lib/c-strtod.c index ed5be49ab..25d895107 100644 --- a/lib/c-strtod.c +++ b/lib/c-strtod.c @@ -1,6 +1,6 @@ /* Convert string to double, using the C locale. - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,6 +18,10 @@ /* Written by Paul Eggert. */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include "c-strtod.h" #include <locale.h> @@ -25,10 +29,25 @@ #include "xalloc.h" -double -c_strtod (char const *nptr, char **endptr) +#if LONG +# define C_STRTOD c_strtold +# define DOUBLE long double +#else +# define C_STRTOD c_strtod +# define DOUBLE double +#endif + +/* c_strtold falls back on strtod if strtold isn't declared. */ +#if LONG && HAVE_DECL_STRTOLD +# define STRTOD strtold +#else +# define STRTOD strtod +#endif + +DOUBLE +C_STRTOD (char const *nptr, char **endptr) { - double r; + DOUBLE r; char *saved_locale = setlocale (LC_NUMERIC, NULL); if (saved_locale) @@ -37,7 +56,7 @@ c_strtod (char const *nptr, char **endptr) setlocale (LC_NUMERIC, "C"); } - r = strtod (nptr, endptr); + r = STRTOD (nptr, endptr); if (saved_locale) { |