Mercurial > hg > octave-kai > gnulib-hg
changeset 8400:655fca11a0e6
The decimal point must be locale dependent.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 10 Mar 2007 00:20:53 +0000 |
parents | b6e248728b1a |
children | 7296f61797cf |
files | ChangeLog lib/vasnprintf.c |
diffstat | 2 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -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 @@ 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)