From f0d9eed0649f96e2ea1d289e66d7e1a661a2d982 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 8 Jun 2016 14:16:08 +0200 Subject: QString: fix QChar <> QLatin1String relational operators for non-US-ASCII The implementation used the QString::compare_helper(QChar*, int, char*, int) overload, which, however, interprets the rhs as a UTF-8 sequence, not as Latin-1. Fix by using the (QChar*, int, QLatin1String) overload. Extend the test to cover this case, too. Change-Id: I59b26d63d0caec036b80ef8818c75d0cebe519d2 Reviewed-by: Thiago Macieira --- src/corelib/tools/qstring.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 06287c056d..d2410f83e6 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -1635,11 +1635,11 @@ inline bool operator>=(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return // QChar <> QLatin1String inline bool operator==(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW -{ return QString::compare_helper(&lhs, 1, rhs.latin1(), rhs.size()) == 0; } +{ return QString::compare_helper(&lhs, 1, rhs) == 0; } inline bool operator< (QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW -{ return QString::compare_helper(&lhs, 1, rhs.latin1(), rhs.size()) < 0; } +{ return QString::compare_helper(&lhs, 1, rhs) < 0; } inline bool operator> (QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW -{ return QString::compare_helper(&lhs, 1, rhs.latin1(), rhs.size()) > 0; } +{ return QString::compare_helper(&lhs, 1, rhs) > 0; } inline bool operator!=(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs == rhs); } inline bool operator<=(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs > rhs); } -- cgit v1.2.3