summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qlocale_tools.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/text/qlocale_tools.cpp')
-rw-r--r--src/corelib/text/qlocale_tools.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/corelib/text/qlocale_tools.cpp b/src/corelib/text/qlocale_tools.cpp
index a123714f7f..b6639bcb71 100644
--- a/src/corelib/text/qlocale_tools.cpp
+++ b/src/corelib/text/qlocale_tools.cpp
@@ -7,6 +7,7 @@
#include "qlocale_p.h"
#include "qstring.h"
+#include <private/qtools_p.h>
#include <private/qnumeric_p.h>
#include <ctype.h>
@@ -37,6 +38,8 @@
QT_BEGIN_NAMESPACE
+using namespace QtMiscUtils;
+
QT_CLOCALE_HOLDER
void qt_doubleToAscii(double d, QLocaleData::DoubleForm form, int precision,
@@ -304,11 +307,11 @@ QSimpleParsedNumber<double> qt_asciiToDouble(const char *num, qsizetype numLen,
// a number over 2 GB in length is silly, just assume it isn't valid
return {};
} else {
- d = conv.StringToDouble(num, numLen, &processed);
+ d = conv.StringToDouble(num, int(numLen), &processed);
}
- if (!qIsFinite(d)) {
- if (qIsNaN(d)) {
+ if (!qt_is_finite(d)) {
+ if (qt_is_nan(d)) {
// Garbage found. We don't accept it and return 0.
return {};
} else {
@@ -326,12 +329,12 @@ QSimpleParsedNumber<double> qt_asciiToDouble(const char *num, qsizetype numLen,
if (qDoubleSscanf(num, QT_CLOCALE, fmt, &d, &processed) < 1)
processed = 0;
- if ((strayCharMode == TrailingJunkProhibited && processed != numLen) || qIsNaN(d)) {
+ if ((strayCharMode == TrailingJunkProhibited && processed != numLen) || qt_is_nan(d)) {
// Implementation defined nan symbol or garbage found. We don't accept it.
return {};
}
- if (!qIsFinite(d)) {
+ if (!qt_is_finite(d)) {
// Overflow. Check for implementation-defined infinity symbols and reject them.
// We assume that any infinity symbol has to contain a character that cannot be part of a
// "normal" number (that is 0-9, ., -, +, e).
@@ -371,7 +374,7 @@ static auto scanPrefix(const char *p, const char *stop, int base)
const char *next;
int base;
};
- if (p < stop && *p >= '0' && *p <= '9') {
+ if (p < stop && isAsciiDigit(*p)) {
if (*p == '0') {
const char *x_or_b = p + 1;
if (x_or_b < stop) {
@@ -552,7 +555,9 @@ QString qulltoa(qulonglong number, int base, const QStringView zero)
/*!
\internal
- Converts the initial portion of the string pointed to by \a s00 to a double, using the 'C' locale.
+ Converts the initial portion of the string pointed to by \a s00 to a double,
+ using the 'C' locale. The function sets the pointer pointed to by \a se to
+ point to the character past the last character converted.
*/
double qstrntod(const char *s00, qsizetype len, const char **se, bool *ok)
{
@@ -646,7 +651,7 @@ static T dtoString(double d, QLocaleData::DoubleForm form, int precision, bool u
int bufSize = 1;
if (precision == QLocale::FloatingPointShortest)
bufSize += D::max_digits10;
- else if (form == QLocaleData::DFDecimal && qIsFinite(d))
+ else if (form == QLocaleData::DFDecimal && qt_is_finite(d))
bufSize += wholePartSpace(qAbs(d)) + precision;
else // Add extra digit due to different interpretations of precision.
bufSize += qMax(2, precision) + 1; // Must also be big enough for "nan" or "inf"
@@ -661,7 +666,7 @@ static T dtoString(double d, QLocaleData::DoubleForm form, int precision, bool u
QLatin1StringView view(buffer.data(), length);
const bool succinct = form == QLocaleData::DFSignificantDigits;
qsizetype total = (negative ? 1 : 0) + length;
- if (qIsFinite(d)) {
+ if (qt_is_finite(d)) {
if (succinct)
form = resolveFormat(precision, decpt, view.size());
@@ -703,7 +708,7 @@ static T dtoString(double d, QLocaleData::DoubleForm form, int precision, bool u
if (negative && !isZero(d)) // We don't return "-0"
result.append(Char('-'));
- if (!qIsFinite(d)) {
+ if (!qt_is_finite(d)) {
result.append(view);
if (uppercase)
result = std::move(result).toUpper();
@@ -724,7 +729,7 @@ static T dtoString(double d, QLocaleData::DoubleForm form, int precision, bool u
result.append(Char(uppercase ? 'E' : 'e'));
result.append(Char(exponent < 0 ? '-' : '+'));
exponent = std::abs(exponent);
- Q_ASSUME(exponent <= D::max_exponent10 + D::max_digits10);
+ Q_ASSERT(exponent <= D::max_exponent10 + D::max_digits10);
int exponentDigits = digits(exponent);
// C's printf guarantees a two-digit exponent, and so do we:
if (exponentDigits == 1)