Remove support for QT_QLOCALE_USES_FCVT.
We expect floating-point math to be IEEE754 compliant. Change-Id: I2b257177f2ef5fce38ac4d8fd76f746dc7b9fc15 Reviewed-by: Lars Knoll <lars.knoll@digia.com>bb10
parent
e1cdfc5529
commit
467c2bc9c3
|
|
@ -2744,30 +2744,6 @@ QString QLocaleData::doubleToString(const QChar _zero, const QChar plus, const Q
|
|||
int decpt, sign;
|
||||
QString digits;
|
||||
|
||||
#ifdef QT_QLOCALE_USES_FCVT
|
||||
// NOT thread safe!
|
||||
if (form == DFDecimal) {
|
||||
digits = QLatin1String(fcvt(d, precision, &decpt, &sign));
|
||||
} else {
|
||||
int pr = precision;
|
||||
if (form == DFExponent)
|
||||
++pr;
|
||||
else if (form == DFSignificantDigits && pr == 0)
|
||||
pr = 1;
|
||||
digits = QLatin1String(ecvt(d, pr, &decpt, &sign));
|
||||
|
||||
// Chop trailing zeros
|
||||
if (digits.length() > 0) {
|
||||
int last_nonzero_idx = digits.length() - 1;
|
||||
while (last_nonzero_idx > 0
|
||||
&& digits.unicode()[last_nonzero_idx] == QLatin1Char('0'))
|
||||
--last_nonzero_idx;
|
||||
digits.truncate(last_nonzero_idx + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
int mode;
|
||||
if (form == DFDecimal)
|
||||
mode = 3;
|
||||
|
|
@ -2795,7 +2771,6 @@ QString QLocaleData::doubleToString(const QChar _zero, const QChar plus, const Q
|
|||
}
|
||||
if (buff != 0)
|
||||
free(buff);
|
||||
#endif // QT_QLOCALE_USES_FCVT
|
||||
|
||||
if (_zero.unicode() != '0') {
|
||||
ushort z = _zero.unicode() - '0';
|
||||
|
|
|
|||
|
|
@ -63,10 +63,8 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_QLOCALE_USES_FCVT
|
||||
static char *_qdtoa( NEEDS_VOLATILE double d, int mode, int ndigits, int *decpt,
|
||||
int *sign, char **rve, char **digits_str);
|
||||
#endif
|
||||
|
||||
QString qulltoa(qulonglong l, int base, const QChar _zero)
|
||||
{
|
||||
|
|
@ -390,8 +388,6 @@ qlonglong qstrtoll(const char *nptr, const char **endptr, int base, bool *ok)
|
|||
return acc;
|
||||
}
|
||||
|
||||
#ifndef QT_QLOCALE_USES_FCVT
|
||||
|
||||
/* From: NetBSD: strtod.c,v 1.26 1998/02/03 18:44:21 perry Exp */
|
||||
/* $FreeBSD: src/lib/libc/stdlib/netbsd_strtod.c,v 1.2.2.2 2001/03/02 17:14:15 tegge Exp $ */
|
||||
|
||||
|
|
@ -2780,54 +2776,5 @@ static char *_qdtoa( NEEDS_VOLATILE double d, int mode, int ndigits, int *decpt,
|
|||
*rve = s;
|
||||
return s0;
|
||||
}
|
||||
#else
|
||||
// NOT thread safe!
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
Q_CORE_EXPORT char *qdtoa( double d, int mode, int ndigits, int *decpt, int *sign, char **rve, char **resultp)
|
||||
{
|
||||
if(rve)
|
||||
*rve = 0;
|
||||
|
||||
char *res;
|
||||
if (mode == 0)
|
||||
ndigits = 80;
|
||||
|
||||
if (mode == 3)
|
||||
res = fcvt(d, ndigits, decpt, sign);
|
||||
else
|
||||
res = ecvt(d, ndigits, decpt, sign);
|
||||
|
||||
int n = qstrlen(res);
|
||||
if (mode == 0) { // remove trailing 0's
|
||||
const int stop = qMax(1, *decpt);
|
||||
int i;
|
||||
for (i = n-1; i >= stop; --i) {
|
||||
if (res[i] != '0')
|
||||
break;
|
||||
}
|
||||
n = i + 1;
|
||||
}
|
||||
*resultp = static_cast<char*>(malloc(n + 1));
|
||||
Q_CHECK_PTR(resultp);
|
||||
qstrncpy(*resultp, res, n + 1);
|
||||
return *resultp;
|
||||
}
|
||||
|
||||
Q_CORE_EXPORT double qstrtod(const char *s00, const char **se, bool *ok)
|
||||
{
|
||||
double ret = strtod((char*)s00, (char**)se);
|
||||
if (ok) {
|
||||
if((ret == 0.0l && errno == ERANGE)
|
||||
|| ret == HUGE_VAL || ret == -HUGE_VAL)
|
||||
*ok = false;
|
||||
else
|
||||
*ok = true; // the result will be that we don't report underflow in this case
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif // QT_QLOCALE_USES_FCVT
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -5302,10 +5302,8 @@ void tst_QString::nanAndInf()
|
|||
CHECK_NAN("nan ", true, true)
|
||||
CHECK_NAN("\t NAN", true, true)
|
||||
CHECK_NAN("\t NAN ", true, true)
|
||||
#ifndef QT_QLOCALE_USES_FCVT //In case we use glibc this tests will fail
|
||||
CHECK_NAN("-nan", false, false)
|
||||
CHECK_NAN("+NAN", false, false)
|
||||
#endif
|
||||
CHECK_NAN("NaN", true, true)
|
||||
CHECK_NAN("nAn", true, true)
|
||||
CHECK_NAN("NANe-10", false, false)
|
||||
|
|
|
|||
Loading…
Reference in New Issue