diff options
author | Bruno Haible <bruno@clisp.org> | 2007-03-26 02:15:46 +0000 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2007-03-26 02:15:46 +0000 |
commit | 5b57d6d54bcc8b9339b6216e0d62e750ab6e2ef3 (patch) | |
tree | 771cc9b3f940ab01a7a283ea17c06af4ebeb4692 /lib | |
parent | c2a27af8e00b5f7d0b6fcdea066daecae3d50d30 (diff) | |
download | gnulib-5b57d6d54bcc8b9339b6216e0d62e750ab6e2ef3.tar.gz |
Prefer nl_langinfo over localeconv.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vasnprintf.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 75d33b347e..ab82b21241 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -41,6 +41,9 @@ #include <errno.h> /* errno */ #include <limits.h> /* CHAR_BIT */ #include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */ +#if HAVE_NL_LANGINFO +# include <langinfo.h> +#endif #if WIDE_CHAR_VERSION # include "wprintf-parse.h" #else @@ -507,8 +510,15 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar if ((flags & FLAG_ALT) || mantissa > 0.0L || precision > 0) { - const char *point = - localeconv () -> decimal_point; + const char *point; + /* Prefer nl_langinfo() over localeconv(), + since the latter is not multithread- + safe. */ +# if HAVE_NL_LANGINFO + point = nl_langinfo (RADIXCHAR); +# else + point = localeconv () -> decimal_point; +# endif /* The decimal point is always a single byte: either '.' or ','. */ *p++ = (point[0] != '\0' ? point[0] : '.'); @@ -657,8 +667,15 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar if ((flags & FLAG_ALT) || mantissa > 0.0 || precision > 0) { - const char *point = - localeconv () -> decimal_point; + const char *point; + /* Prefer nl_langinfo() over localeconv(), + since the latter is not multithread- + safe. */ +# if HAVE_NL_LANGINFO + point = nl_langinfo (RADIXCHAR); +# else + point = localeconv () -> decimal_point; +# endif /* The decimal point is always a single byte: either '.' or ','. */ *p++ = (point[0] != '\0' ? point[0] : '.'); |