summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/vfprintf.c
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>2002-04-17 15:06:47 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>2002-04-17 15:06:47 +0000
commit5cae4e2ddb495f5e7b600814a72ac9a7f871b224 (patch)
tree2686b71b2bc3862f63dfcf6bf5642f28f9e9fcbf /lib/libc/stdio/vfprintf.c
parentd1ebf4b5cda323ef195ad488a36510faf655eee4 (diff)
Notes
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 1e67b1a1a5d9..8cbbaccc120e 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -245,6 +245,7 @@ __uqtoa(u_quad_t val, char *endp, int base, int octzero, char *xdigs)
}
#ifdef FLOATING_POINT
+#include <locale.h>
#include <math.h>
#include "floatio.h"
@@ -288,6 +289,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 */
@@ -805,32 +807,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);