Take decimal point from locale instead of hardcoded '.' (SUSv2)
This commit is contained in:
parent
36db56802d
commit
9ad80ab51f
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user