summaryrefslogtreecommitdiffstats
path: root/src/corelib/text
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2023-02-23 16:48:30 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2023-02-24 13:37:07 +0100
commitd753941817f4c623a4e202234535426708bb6eb6 (patch)
tree0d99e5bea8c3bc6ae5e09e112006564f6232b755 /src/corelib/text
parente0f9671338ce742a3ee168e867481be515dcce46 (diff)
Use isAsciiDigit() in a few more places in qlocale.cpp
Use the function now in qtools_p.h in several more places. (A later commit rewrites the remainder away.) Change-Id: I782f0dceffe0e6e76753643a889011a834bc3ff0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text')
-rw-r--r--src/corelib/text/qlocale.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index 2bb9a1eaf5..c86f995bc0 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -3541,8 +3541,7 @@ QString QLocaleData::doubleToString(double d, int precision, DoubleForm form,
if (zero == u"0") {
// No need to convert digits.
- Q_ASSERT(std::all_of(buf.cbegin(), buf.cbegin() + length, [](char ch)
- { return '0' <= ch && ch <= '9'; }));
+ Q_ASSERT(std::all_of(buf.cbegin(), buf.cbegin() + length, isAsciiDigit));
// That check is taken care of in unicodeForDigits, below.
} else if (zero.size() == 2 && zero.at(0).isHighSurrogate()) {
const char32_t zeroUcs4 = QChar::surrogateToUcs4(zero.at(0), zero.at(1));
@@ -3893,7 +3892,7 @@ bool QLocaleData::numberToCLocale(QStringView s, QLocale::NumberOptions number_o
// After the exponent there can only be '+', '-' or digits.
// If we find a '0' directly after some non-digit, then that is a
// leading zero, acceptable only if it is the whole exponent.
- if (idx < length - 1 && (last < '0' || last > '9'))
+ if (idx < length - 1 && !isAsciiDigit(last))
return false;
}
@@ -3904,7 +3903,7 @@ bool QLocaleData::numberToCLocale(QStringView s, QLocale::NumberOptions number_o
}
if (!number_options.testFlag(QLocale::RejectGroupSeparator)) {
- if (out >= '0' && out <= '9') {
+ if (isAsciiDigit(out)) {
if (start_of_digits_idx == -1)
start_of_digits_idx = idx;
++digitsInGroup;
@@ -3988,7 +3987,7 @@ bool QLocaleData::validateChars(QStringView str, NumberMode numMode, QByteArray
return false;
break;
case Exponent:
- if (last < '0' || last > '9') {
+ if (!isAsciiDigit(last)) {
// This is the first digit in the exponent (there may have beena '+'
// or '-' in before). If it's a zero, the exponent is zero-padded.
if (c == '0' && (number_options & QLocale::RejectLeadingZeroInExponent))
@@ -4020,7 +4019,7 @@ bool QLocaleData::validateChars(QStringView str, NumberMode numMode, QByteArray
case ',':
// Grouping is only allowed after a digit in the whole-number portion:
if ((number_options & QLocale::RejectGroupSeparator) || state != Whole
- || last < '0' || last > '9') {
+ || !isAsciiDigit(last)) {
return false;
}
// We could check grouping sizes are correct, but fixup()s are