From 23a854c3a68900752cf146a9c758eba51fdee3a3 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 1 Nov 2022 17:40:33 +0100 Subject: QLocaleData::validateChars(): exploit last to detect first iteration Checking the value of last, instead of the index, prepares the way for using QStringIterator here. Change-Id: Ided0530413211e918acd406ebdb37f16006ef07d Reviewed-by: Thiago Macieira --- src/corelib/text/qlocale.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index b9aaa5b338..83afa4b5b9 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -4022,7 +4022,7 @@ bool QLocaleData::validateChars(QStringView str, NumberMode numMode, QByteArray enum { Whole, Fractional, Exponent } state = Whole; const bool scientific = numMode == DoubleScientificMode; - char last = 0; + char last = '\0'; for (qsizetype i = 0; i < str.size();) { const QStringView in = str.mid(i, str.at(i).isHighSurrogate() ? 2 : 1); @@ -4064,7 +4064,7 @@ bool QLocaleData::validateChars(QStringView str, NumberMode numMode, QByteArray case '+': case '-': // A sign can only appear at the start or after the e of scientific: - if (i != 0 && !(scientific && last == 'e')) + if (last != '\0' && !(scientific && last == 'e')) return false; break; -- cgit v1.2.3