diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2012-05-23 03:57:19 +0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-01 03:16:17 +0200 |
commit | f19fbcf4e3c531cdbaf82ea32da2210bea64cb1c (patch) | |
tree | 7c7e6a7f0e8d1334387d60d35740f7729159c4c8 /src/corelib/tools/qstring.h | |
parent | 72bd1c3228c8c816be74ab0432028424c688b979 (diff) |
Add missing QT_NO_CAST_FROM_ASCII
to QLatin1String's compare operators that takes const char *s or QByteArray.
Such comparison leads to a potential misuse since QByteArray could contain any arbitrary data
in any arbitrary encoding and QLatin1String is used to only contain strings in UTF-8 -
they are just a different beasts aimed for different purposes, and since QT_NO_CAST_*_ASCII
disallow indirect conversions and require the user to know what he's doing,
let's be consistent here too.
Change-Id: I9bf5f326495157db8a6af064d6154961b7861a7e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qstring.h')
-rw-r--r-- | src/corelib/tools/qstring.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 47ac45ac06..b5633834eb 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -96,6 +96,7 @@ public: inline bool operator>=(const QString &s) const; inline bool operator<=(const QString &s) const; +#ifndef QT_NO_CAST_FROM_ASCII inline QT_ASCII_CAST_WARN bool operator==(const char *s) const; inline QT_ASCII_CAST_WARN bool operator!=(const char *s) const; inline QT_ASCII_CAST_WARN bool operator<(const char *s) const; @@ -109,6 +110,7 @@ public: inline QT_ASCII_CAST_WARN bool operator>(const QByteArray &s) const; inline QT_ASCII_CAST_WARN bool operator<=(const QByteArray &s) const; inline QT_ASCII_CAST_WARN bool operator>=(const QByteArray &s) const; +#endif // QT_NO_CAST_FROM_ASCII private: int m_size; @@ -1049,7 +1051,6 @@ inline bool operator>(QLatin1String s1, QLatin1String s2) inline bool operator>=(QLatin1String s1, QLatin1String s2) { int r = memcmp(s1.latin1(), s2.latin1(), qMin(s1.size(), s2.size())); return (r > 0) || (r == 0 && s1.size() >= s2.size()); } -#endif // QT_NO_CAST_FROM_ASCII inline QT_ASCII_CAST_WARN bool QLatin1String::operator==(const char *s) const { return QString::fromUtf8(s) == *this; } @@ -1077,7 +1078,6 @@ inline QT_ASCII_CAST_WARN bool QLatin1String::operator<=(const QByteArray &s) co inline QT_ASCII_CAST_WARN bool QLatin1String::operator>=(const QByteArray &s) const { return QString::fromUtf8(s) <= *this; } -#ifndef QT_NO_CAST_FROM_ASCII inline QT_ASCII_CAST_WARN bool QString::operator==(const QByteArray &s) const { return QString::compare_helper(constData(), size(), s.constData(), qstrnlen(s.constData(), s.size())) == 0; } inline QT_ASCII_CAST_WARN bool QString::operator!=(const QByteArray &s) const |