From: Bruno Haible Date: Sat, 10 Mar 2007 00:20:53 +0000 (+0000) Subject: The decimal point must be locale dependent. X-Git-Tag: cvs-readonly~818 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=794283a4bb176e313b3a7a7fc5d320e37881a0be;p=gnulib.git The decimal point must be locale dependent. --- diff --git a/ChangeLog b/ChangeLog index fc237af4e..c305aa5cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-03-09 Bruno Haible + + * lib/vasnprintf.c (VASNPRINTF): For the 'a' and 'A' directives, use + a locale dependent decimal point, rather than always '.'. + 2007-03-09 Eric Blake * lib/stdlib_.h (EXIT_FAILURE): GNU code expects this to be 1, in diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index aff0b172e..a0523ec1f 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -34,6 +34,7 @@ # include "vasnprintf.h" #endif +#include /* localeconv() */ #include /* snprintf(), sprintf() */ #include /* abort(), malloc(), realloc(), free() */ #include /* 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)