diff options
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 17 | ||||
-rw-r--r-- | src/corelib/tools/qlocale_p.h | 8 | ||||
-rw-r--r-- | src/gui/util/qvalidator.cpp | 12 |
3 files changed, 12 insertions, 25 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index d5a024177d..0a573e77dc 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -3564,7 +3564,7 @@ qulonglong QLocaleData::stringToUnsLongLong(QStringView str, int base, bool *ok, return bytearrayToUnsLongLong(buff.constData(), base, ok); } -double QLocaleData::bytearrayToDouble(const char *num, bool *ok, bool *overflow) +double QLocaleData::bytearrayToDouble(const char *num, bool *ok) { bool nonNullOk = false; int len = static_cast<int>(strlen(num)); @@ -3573,12 +3573,10 @@ double QLocaleData::bytearrayToDouble(const char *num, bool *ok, bool *overflow) double d = asciiToDouble(num, len, nonNullOk, processed); if (ok) *ok = nonNullOk; - if (overflow) - *overflow = processed < len; return d; } -qlonglong QLocaleData::bytearrayToLongLong(const char *num, int base, bool *ok, bool *overflow) +qlonglong QLocaleData::bytearrayToLongLong(const char *num, int base, bool *ok) { bool _ok; const char *endptr; @@ -3586,8 +3584,6 @@ qlonglong QLocaleData::bytearrayToLongLong(const char *num, int base, bool *ok, if (*num == '\0') { if (ok != 0) *ok = false; - if (overflow != 0) - *overflow = false; return 0; } @@ -3596,11 +3592,6 @@ qlonglong QLocaleData::bytearrayToLongLong(const char *num, int base, bool *ok, if (!_ok) { if (ok != 0) *ok = false; - if (overflow != 0) { - // the only way qstrtoll can fail with *endptr != '\0' on a non-empty - // input string is overflow - *overflow = *endptr != '\0'; - } return 0; } @@ -3608,15 +3599,11 @@ qlonglong QLocaleData::bytearrayToLongLong(const char *num, int base, bool *ok, // we stopped at a non-digit character after converting some digits if (ok != 0) *ok = false; - if (overflow != 0) - *overflow = false; return 0; } if (ok != 0) *ok = true; - if (overflow != 0) - *overflow = false; return l; } diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 12d5c60324..e77b73c089 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -258,10 +258,10 @@ public: qint64 stringToLongLong(QStringView str, int base, bool *ok, QLocale::NumberOptions options) const; quint64 stringToUnsLongLong(QStringView str, int base, bool *ok, QLocale::NumberOptions options) const; - // these functions are used in QIntValidator (QtGui) - Q_CORE_EXPORT static double bytearrayToDouble(const char *num, bool *ok, bool *overflow = 0); - Q_CORE_EXPORT static qint64 bytearrayToLongLong(const char *num, int base, bool *ok, bool *overflow = 0); - Q_CORE_EXPORT static quint64 bytearrayToUnsLongLong(const char *num, int base, bool *ok); + static double bytearrayToDouble(const char *num, bool *ok); + // this function is used in QIntValidator (QtGui) + Q_CORE_EXPORT static qint64 bytearrayToLongLong(const char *num, int base, bool *ok); + static quint64 bytearrayToUnsLongLong(const char *num, int base, bool *ok); bool numberToCLocale(QStringView s, QLocale::NumberOptions number_options, CharBuff *result) const; diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index fb9dfc9f69..1709012291 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -420,9 +420,9 @@ QValidator::State QIntValidator::validate(QString & input, int&) const if (buff.size() == 1 && (buff.at(0) == '+' || buff.at(0) == '-')) return Intermediate; - bool ok, overflow; - qlonglong entered = QLocaleData::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow); - if (overflow || !ok) + bool ok; + qlonglong entered = QLocaleData::bytearrayToLongLong(buff.constData(), 10, &ok); + if (!ok) return Invalid; if (entered >= b && entered <= t) { @@ -447,9 +447,9 @@ void QIntValidator::fixup(QString &input) const locale().numberOptions())) { return; } - bool ok, overflow; - qlonglong entered = QLocaleData::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow); - if (ok && !overflow) + bool ok; + qlonglong entered = QLocaleData::bytearrayToLongLong(buff.constData(), 10, &ok); + if (ok) input = locale().toString(entered); } |