summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2007-03-26 02:15:46 +0000
committerBruno Haible <bruno@clisp.org>2007-03-26 02:15:46 +0000
commit5b57d6d54bcc8b9339b6216e0d62e750ab6e2ef3 (patch)
tree771cc9b3f940ab01a7a283ea17c06af4ebeb4692 /lib
parentc2a27af8e00b5f7d0b6fcdea066daecae3d50d30 (diff)
downloadgnulib-5b57d6d54bcc8b9339b6216e0d62e750ab6e2ef3.tar.gz
Prefer nl_langinfo over localeconv.
Diffstat (limited to 'lib')
-rw-r--r--lib/vasnprintf.c25
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] : '.');