summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2012-01-26 11:13:41 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-26 13:28:16 +0100
commite62fe9ed4fd8d33f881dedeeafafc4a0c65e5278 (patch)
treee8148f0ed05f2b1584c483ad87f9f462b78badd1 /src
parent68e5fd9ebc8a3f510e3144e981a0cb358945fb9c (diff)
Fixed QString::operator<(QLatin1String)
QLatin1String now has a constructor that takes explicit length, which makes it possible to create QLatin1String that do not have null-termination character. Fixed QString::operator> and < to be safe in that case. In the same patch fixed qtjson which had operator< implemented in the same way. QString::compare(QLatin1String) is still broken and will be fixed separately. Change-Id: I48ec1183a6f44034129cc17312af854795085408 Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/json/qjson_p.h2
-rw-r--r--src/corelib/tools/qstring.cpp6
2 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/json/qjson_p.h b/src/corelib/json/qjson_p.h
index 304aa9cc5d..b484148074 100644
--- a/src/corelib/json/qjson_p.h
+++ b/src/corelib/json/qjson_p.h
@@ -469,7 +469,7 @@ inline bool String::operator<(const Latin1String &str) const
++uc;
++c;
}
- return (uc == (d->utf16 + d->length) ? *c : (ushort)*uc < *c);
+ return (uc == e ? (int)d->length < (int)str.d->length : (ushort)*uc < *c);
}
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index d6090cc7b2..4d8b18d8c3 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -2232,7 +2232,7 @@ bool QString::operator<(const QLatin1String &other) const
++uc;
++c;
}
- return (uc == (d->data() + d->size) ? *c : *uc < *c);
+ return (uc == e ? d->size < other.size() : *uc < *c);
}
/*! \fn bool QString::operator<(const QByteArray &other) const
@@ -2325,7 +2325,7 @@ bool QString::operator>(const QLatin1String &other) const
if (!c || *c == '\0')
return !isEmpty();
- const ushort *uc = d->data();;
+ const ushort *uc = d->data();
const ushort *e = uc + qMin(d->size, other.size());
while (uc < e) {
@@ -2334,7 +2334,7 @@ bool QString::operator>(const QLatin1String &other) const
++uc;
++c;
}
- return (uc == (d->data() + d->size) ? false : *uc > *c);
+ return (uc == e) ? d->size > other.size() : *uc > *c;
}
/*! \fn bool QString::operator>(const QByteArray &other) const