summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-03-05 09:11:11 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-03-12 05:32:41 +0000
commit5930a2d314d158f67bf3bf2bd940d7b67731ebde (patch)
tree54ba4bb14fd542ba0ce3d239a71d23b511551424 /src
parent718f87046a8fc2c0fb625dfc8641db0352ae9d92 (diff)
Track modifications of white space in QString::simplified().
The existing check fails to detect the case where white space characters other than the space character are replaced by space characters without the length actually changing and returns the original string. Task-number: QTBUG-44936 Change-Id: Ice6faa975f8b41f185c76f6d0d4ff81603e25eb3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qstringalgorithms_p.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/corelib/tools/qstringalgorithms_p.h b/src/corelib/tools/qstringalgorithms_p.h
index b4be5c7ec7..65901b0286 100644
--- a/src/corelib/tools/qstringalgorithms_p.h
+++ b/src/corelib/tools/qstringalgorithms_p.h
@@ -120,21 +120,23 @@ template <typename StringType> struct QStringAlgorithms
Char *dst = const_cast<Char *>(result.cbegin());
Char *ptr = dst;
+ bool unmodified = true;
forever {
while (src != end && isSpace(*src))
++src;
while (src != end && !isSpace(*src))
*ptr++ = *src++;
- if (src != end)
- *ptr++ = QChar::Space;
- else
+ if (src == end)
break;
+ if (*src != QChar::Space)
+ unmodified = false;
+ *ptr++ = QChar::Space;
}
if (ptr != dst && ptr[-1] == QChar::Space)
--ptr;
int newlen = ptr - dst;
- if (isConst && newlen == str.size()) {
+ if (isConst && newlen == str.size() && unmodified) {
// nothing happened, return the original
return str;
}