diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2004-07-12 17:50:11 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2004-07-12 17:50:11 +0000 |
commit | 955aa2dc77774fadef9549321f5473e41eb78b53 (patch) | |
tree | 759b0956a0bd1973c9156e37497f2348c18859cb /lib | |
parent | 70c9129e14867d39df5d078def0f48af597571d1 (diff) | |
download | coreutils-955aa2dc77774fadef9549321f5473e41eb78b53.tar.xz |
(STRTOD_L): New macro.
(C_STRTOD) [defined LC_ALL_MASK]: Use it, so that the
code is reentrant on platforms that have strtod_l.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/c-strtod.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/c-strtod.c b/lib/c-strtod.c index 25d895107..ae0511034 100644 --- a/lib/c-strtod.c +++ b/lib/c-strtod.c @@ -32,9 +32,11 @@ #if LONG # define C_STRTOD c_strtold # define DOUBLE long double +# define STRTOD_L strtold_l #else # define C_STRTOD c_strtod # define DOUBLE double +# define STRTOD_L strtod_l #endif /* c_strtold falls back on strtod if strtold isn't declared. */ @@ -48,6 +50,15 @@ DOUBLE C_STRTOD (char const *nptr, char **endptr) { DOUBLE r; + +#ifdef LC_ALL_MASK + + locale_t c_locale = newlocale (LC_ALL_MASK, "C", 0); + r = STRTOD_L (nptr, endptr, c_locale); + freelocale (c_locale); + +#else + char *saved_locale = setlocale (LC_NUMERIC, NULL); if (saved_locale) @@ -64,5 +75,7 @@ C_STRTOD (char const *nptr, char **endptr) free (saved_locale); } +#endif + return r; } |