# HG changeset patch # User Bruno Haible # Date 1173486053 0 # Node ID 655fca11a0e64b390660bd9ba48e5d88a3548369 # Parent b6e248728b1a6da139aea93fca73a08763064b83 The decimal point must be locale dependent. diff --git a/ChangeLog b/ChangeLog --- 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 --- 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 @@ 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 @@ 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)