The decimal point must be locale dependent.
authorBruno Haible <bruno@clisp.org>
Sat, 10 Mar 2007 00:20:53 +0000 (00:20 +0000)
committerBruno Haible <bruno@clisp.org>
Sat, 10 Mar 2007 00:20:53 +0000 (00:20 +0000)
ChangeLog
lib/vasnprintf.c

index fc237af..c305aa5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-03-09  Bruno Haible  <bruno@clisp.org>
+
+       * lib/vasnprintf.c (VASNPRINTF): For the 'a' and 'A' directives, use
+       a locale dependent decimal point, rather than always '.'.
+
 2007-03-09  Eric Blake  <ebb9@byu.net>
 
        * lib/stdlib_.h (EXIT_FAILURE): GNU code expects this to be 1, in
index aff0b17..a0523ec 100644 (file)
@@ -34,6 +34,7 @@
 # include "vasnprintf.h"
 #endif
 
+#include <locale.h>    /* localeconv() */
 #include <stdio.h>     /* snprintf(), sprintf() */
 #include <stdlib.h>    /* abort(), malloc(), realloc(), free() */
 #include <string.h>    /* memcpy(), strlen() */
@@ -492,7 +493,11 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
                              if ((flags & FLAG_ALT)
                                  || mantissa > 0.0L || precision > 0)
                                {
-                                 *p++ = '.';
+                                 const char *point =
+                                   localeconv () -> decimal_point;
+                                 /* The decimal point is always a single byte:
+                                    either '.' or ','.  */
+                                 *p++ = (point[0] != '\0' ? point[0] : '.');
                                  /* This loop terminates because we assume
                                     that FLT_RADIX is a power of 2.  */
                                  while (mantissa > 0.0L)
@@ -636,7 +641,11 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
                              if ((flags & FLAG_ALT)
                                  || mantissa > 0.0 || precision > 0)
                                {
-                                 *p++ = '.';
+                                 const char *point =
+                                   localeconv () -> decimal_point;
+                                 /* The decimal point is always a single byte:
+                                    either '.' or ','.  */
+                                 *p++ = (point[0] != '\0' ? point[0] : '.');
                                  /* This loop terminates because we assume
                                     that FLT_RADIX is a power of 2.  */
                                  while (mantissa > 0.0)