summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/vfprintf.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2001-02-10 06:25:33 +0000
committerache <ache@FreeBSD.org>2001-02-10 06:25:33 +0000
commit6679201fe71154d3f4325a3e5e663ed67e6dc459 (patch)
treeb646c5b008bd980c05005776834742c5a311db8e /lib/libc/stdio/vfprintf.c
parentdbf0a463e4dd4ec5d6554ff5e15c70d74cecacf2 (diff)
downloadFreeBSD-src-6679201fe71154d3f4325a3e5e663ed67e6dc459.zip
FreeBSD-src-6679201fe71154d3f4325a3e5e663ed67e6dc459.tar.gz
Take decimal point from locale instead of hardcoded '.' (SUSv2)
Diffstat (limited to 'lib/libc/stdio/vfprintf.c')
-rw-r--r--lib/libc/stdio/vfprintf.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c
index fff9aa8..ffdf522 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -261,6 +261,7 @@ vfprintf(FILE *fp, const char *fmt0, va_list ap)
}
#ifdef FLOATING_POINT
+#include <locale.h>
#include <math.h>
#include "floatio.h"
@@ -307,6 +308,7 @@ __vfprintf(FILE *fp, const char *fmt0, va_list ap)
int prec; /* precision from format (%.3d), or -1 */
char sign; /* sign prefix (' ', '+', '-', or \0) */
#ifdef FLOATING_POINT
+ char *decimal_point = localeconv()->decimal_point;
char softsign; /* temporary negative sign for floats */
double _double; /* double precision arguments %[eEfgG] */
int expt; /* integer value of exponent */
@@ -811,32 +813,31 @@ number: if ((dprec = prec) >= 0)
if (ch >= 'f') { /* 'f' or 'g' */
if (_double == 0) {
/* kludge for __dtoa irregularity */
- if (expt >= ndig &&
- (flags & ALT) == 0) {
- PRINT("0", 1);
- } else {
- PRINT("0.", 2);
+ PRINT("0", 1);
+ if (expt < ndig || (flags & ALT) != 0) {
+ PRINT(decimal_point, 1);
PAD(ndig - 1, zeroes);
}
} else if (expt <= 0) {
- PRINT("0.", 2);
+ PRINT("0", 1);
+ PRINT(decimal_point, 1);
PAD(-expt, zeroes);
PRINT(cp, ndig);
} else if (expt >= ndig) {
PRINT(cp, ndig);
PAD(expt - ndig, zeroes);
if (flags & ALT)
- PRINT(".", 1);
+ PRINT(decimal_point, 1);
} else {
PRINT(cp, expt);
cp += expt;
- PRINT(".", 1);
+ PRINT(decimal_point, 1);
PRINT(cp, ndig-expt);
}
} else { /* 'e' or 'E' */
if (ndig > 1 || flags & ALT) {
ox[0] = *cp++;
- ox[1] = '.';
+ ox[1] = *decimal_point;
PRINT(ox, 2);
if (_double) {
PRINT(cp, ndig-1);
OpenPOWER on IntegriCloud