summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-02-02 15:57:44 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2016-02-02 15:57:44 +0100
commitd3e6e732c70ebc2340d6376d727b3c623be23810 (patch)
tree18d469f02ac36edd04b87a9bfa4886ceef0490f0 /src/corelib/tools
parentfdfd63053ae6b10af06553be3c1b15de274bebf7 (diff)
parentba8d3430029d8c4342e9a47c110ee8c9879818f4 (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: config.tests/unix/compile.test src/plugins/platforms/cocoa/qcocoahelpers.mm src/tools/qlalr/cppgenerator.cpp Change-Id: I0103ca076a9aca7118b2fd99f0fdaf81055998c3
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qdatetimeparser.cpp37
-rw-r--r--src/corelib/tools/qdatetimeparser_p.h2
-rw-r--r--src/corelib/tools/qstringbuilder.h6
3 files changed, 19 insertions, 26 deletions
diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp
index ace663ae30..853903619f 100644
--- a/src/corelib/tools/qdatetimeparser.cpp
+++ b/src/corelib/tools/qdatetimeparser.cpp
@@ -131,14 +131,13 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const
}
const SectionNode &node = sectionNodes.at(index);
- int year, month, day, hour, minute, second, msec;
- year = v.date().year();
- month = v.date().month();
- day = v.date().day();
- hour = v.time().hour();
- minute = v.time().minute();
- second = v.time().second();
- msec = v.time().msec();
+ int year = v.date().year();
+ int month = v.date().month();
+ int day = v.date().day();
+ int hour = v.time().hour();
+ int minute = v.time().minute();
+ int second = v.time().second();
+ int msec = v.time().msec();
switch (node.type) {
case Hour24Section: case Hour12Section: hour = newVal; break;
@@ -676,15 +675,7 @@ QString QDateTimeParser::sectionText(const QString &text, int sectionIndex, int
QString QDateTimeParser::sectionText(int sectionIndex) const
{
const SectionNode &sn = sectionNode(sectionIndex);
- switch (sn.type) {
- case NoSectionIndex:
- case FirstSectionIndex:
- case LastSectionIndex:
- return QString();
- default: break;
- }
-
- return displayText().mid(sn.pos, sectionSize(sectionIndex));
+ return sectionText(displayText(), sectionIndex, sn.pos);
}
@@ -1012,8 +1003,10 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos
const QDate date(year, month, day);
const int diff = dayofweek - date.dayOfWeek();
- if (diff != 0 && state == Acceptable && isSet & (DayOfWeekSectionShort|DayOfWeekSectionLong)) {
- conflicts = isSet & DaySection;
+ if (diff != 0 && state == Acceptable
+ && isSet & (DayOfWeekSectionShort | DayOfWeekSectionLong)) {
+ if (isSet & DaySection)
+ conflicts = true;
const SectionNode &sn = sectionNode(currentSectionIndex);
if (sn.type & (DayOfWeekSectionShort|DayOfWeekSectionLong) || currentSectionIndex == -1) {
// dayofweek should be preferred
@@ -1377,9 +1370,9 @@ int QDateTimeParser::findDay(const QString &str1, int startDay, int sectionIndex
*/
-int QDateTimeParser::findAmPm(QString &str, int index, int *used) const
+int QDateTimeParser::findAmPm(QString &str, int sectionIndex, int *used) const
{
- const SectionNode &s = sectionNode(index);
+ const SectionNode &s = sectionNode(sectionIndex);
if (s.type != AmPmSection) {
qWarning("QDateTimeParser::findAmPm Internal error");
return -1;
@@ -1390,7 +1383,7 @@ int QDateTimeParser::findAmPm(QString &str, int index, int *used) const
return PossibleBoth;
}
const QLatin1Char space(' ');
- int size = sectionMaxSize(index);
+ int size = sectionMaxSize(sectionIndex);
enum {
amindex = 0,
diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h
index 2c1c14f05a..64e73346f2 100644
--- a/src/corelib/tools/qdatetimeparser_p.h
+++ b/src/corelib/tools/qdatetimeparser_p.h
@@ -93,7 +93,7 @@ public:
first.pos = -1;
first.count = -1;
first.zeroesAdded = 0;
- last.type = FirstSection;
+ last.type = LastSection;
last.pos = -1;
last.count = -1;
last.zeroesAdded = 0;
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index 524c9a14ae..faf9eb4b4d 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -242,9 +242,9 @@ template <> struct QConcatenable<QLatin1String> : private QAbstractConcatenable
}
static inline void appendTo(const QLatin1String a, char *&out)
{
- if (a.data()) {
- for (const char *s = a.data(); *s; )
- *out++ = *s++;
+ if (const char *data = a.data()) {
+ memcpy(out, data, a.size());
+ out += a.size();
}
}
};