From 80aba027af3ff41f344bd5a03245900899a1f22a Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 1 Nov 2022 16:00:04 +0100 Subject: [PATCH] QLocaleData::numberToCLocale(): make discarding of grouping overt If grouping isn't allowed, return early on hitting any. Make the elision of grouping from the converted string easier to see. Change-Id: I452d1e2b64612cd3ce534907a4b9aac652669ba5 Reviewed-by: Thiago Macieira --- src/corelib/text/qlocale.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 7dea0e05c7..0755cd8354 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -3969,10 +3969,6 @@ bool QLocaleData::numberToCLocale(QStringView s, QLocale::NumberOptions number_o last_separator_idx = idx; digitsInGroup = 0; - - // don't add the group separator - idx += in.size(); - continue; } else if (out == '.' || idx == exponent_idx) { // Were there enough digits since the last separator? if (last_separator_idx != -1 && digitsInGroup != m_grouping_least) @@ -3985,9 +3981,12 @@ bool QLocaleData::numberToCLocale(QStringView s, QLocale::NumberOptions number_o } else if (out >= '0' && out <= '9') { digitsInGroup++; } + } else if (out == ',') { + return false; } - result->append(out); + if (out != ',') // Leave group separators out of the result. + result->append(out); idx += in.size(); }