summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qdatetime.cpp9
-rw-r--r--src/corelib/tools/qregularexpression.cpp2
-rw-r--r--src/corelib/tools/qstring.cpp48
3 files changed, 30 insertions, 29 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 3750b37580..f784aa13fc 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -1646,9 +1646,11 @@ QString QTime::toString(Qt::DateFormat format) const
\row \li z \li the milliseconds without leading zeroes (0 to 999)
\row \li zzz \li the milliseconds with leading zeroes (000 to 999)
\row \li AP or A
- \li use AM/PM display. \e A/AP will be replaced by either "AM" or "PM".
+ \li use AM/PM display. \e A/AP will be replaced by either
+ QLocale::amText() or QLocale::pmText().
\row \li ap or a
- \li use am/pm display. \e a/ap will be replaced by either "am" or "pm".
+ \li use am/pm display. \e a/ap will be replaced by a lower-case version of
+ QLocale::amText() or QLocale::pmText().
\row \li t \li the timezone (for example "CEST")
\endtable
@@ -1657,7 +1659,8 @@ QString QTime::toString(Qt::DateFormat format) const
expression. Two consecutive single quotes ("''") are replaced by a singlequote
in the output. Formats without separators (e.g. "HHmm") are currently not supported.
- Example format strings (assuming that the QTime is 14:13:09.042)
+ Example format strings (assuming that the QTime is 14:13:09.042 and the system
+ locale is \c{en_US})
\table
\header \li Format \li Result
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index e7f86ddf6b..4a30daa72c 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -548,7 +548,7 @@ QT_BEGIN_NAMESPACE
\inmodule QtCore
\reentrant
- \brief The QRegularExpressionMatch class provides the results of a matching
+ \brief The QRegularExpressionMatch class provides the results of matching
a QRegularExpression against a string.
\since 5.0
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 26bb0de278..8db865cfa6 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -494,48 +494,46 @@ static int ucstrncmp(const QChar *a, const QChar *b, int l)
if (!l)
return 0;
- union {
- const QChar *w;
- const quint32 *d;
- quintptr value;
- } sa, sb;
- sa.w = a;
- sb.w = b;
-
// check alignment
- if ((sa.value & 2) == (sb.value & 2)) {
+ if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) {
// both addresses have the same alignment
- if (sa.value & 2) {
+ if (reinterpret_cast<quintptr>(a) & 2) {
// both addresses are not aligned to 4-bytes boundaries
// compare the first character
- if (*sa.w != *sb.w)
- return sa.w->unicode() - sb.w->unicode();
+ if (*a != *b)
+ return a->unicode() - b->unicode();
--l;
- ++sa.w;
- ++sb.w;
+ ++a;
+ ++b;
// now both addresses are 4-bytes aligned
}
// both addresses are 4-bytes aligned
// do a fast 32-bit comparison
- const quint32 *e = sa.d + (l >> 1);
- for ( ; sa.d != e; ++sa.d, ++sb.d) {
- if (*sa.d != *sb.d) {
- if (*sa.w != *sb.w)
- return sa.w->unicode() - sb.w->unicode();
- return sa.w[1].unicode() - sb.w[1].unicode();
+ const quint32 *da = reinterpret_cast<const quint32 *>(a);
+ const quint32 *db = reinterpret_cast<const quint32 *>(b);
+ const quint32 *e = da + (l >> 1);
+ for ( ; da != e; ++da, ++db) {
+ if (*da != *db) {
+ a = reinterpret_cast<const QChar *>(da);
+ b = reinterpret_cast<const QChar *>(db);
+ if (*a != *b)
+ return a->unicode() - b->unicode();
+ return a[1].unicode() - b[1].unicode();
}
}
// do we have a tail?
- return (l & 1) ? sa.w->unicode() - sb.w->unicode() : 0;
+ a = reinterpret_cast<const QChar *>(da);
+ b = reinterpret_cast<const QChar *>(db);
+ return (l & 1) ? a->unicode() - b->unicode() : 0;
} else {
// one of the addresses isn't 4-byte aligned but the other is
- const QChar *e = sa.w + l;
- for ( ; sa.w != e; ++sa.w, ++sb.w) {
- if (*sa.w != *sb.w)
- return sa.w->unicode() - sb.w->unicode();
+ const QChar *e = a + l;
+ for ( ; a != e; ++a, ++b) {
+ if (*a != *b)
+ return a->unicode() - b->unicode();
}
}
return 0;