Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qdatetimeparser.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||||||||
3 | int QDateTimeParser::getDigit(const QDateTime &t, int index) const | - | ||||||||||||||||||||||||||||||
4 | { | - | ||||||||||||||||||||||||||||||
5 | if (index < 0 || index >= sectionNodes.size()) { | - | ||||||||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||||||||
7 | QMessageLogger(__FILE__, 7076, __PRETTY_FUNCTION__).warning("QDateTimeParser::getDigit() Internal error (%s %d)", | - | ||||||||||||||||||||||||||||||
8 | QString(t.toString()).toLocal8Bit().constData(), index); | - | ||||||||||||||||||||||||||||||
9 | - | |||||||||||||||||||||||||||||||
10 | - | |||||||||||||||||||||||||||||||
11 | - | |||||||||||||||||||||||||||||||
12 | return -1; | - | ||||||||||||||||||||||||||||||
13 | } | - | ||||||||||||||||||||||||||||||
14 | const SectionNode &node = sectionNodes.at(index); | - | ||||||||||||||||||||||||||||||
15 | switch (node.type) { | - | ||||||||||||||||||||||||||||||
16 | case Hour24Section: case Hour12Section: return t.time().hour(); | - | ||||||||||||||||||||||||||||||
17 | case MinuteSection: return t.time().minute(); | - | ||||||||||||||||||||||||||||||
18 | case SecondSection: return t.time().second(); | - | ||||||||||||||||||||||||||||||
19 | case MSecSection: return t.time().msec(); | - | ||||||||||||||||||||||||||||||
20 | case YearSection2Digits: | - | ||||||||||||||||||||||||||||||
21 | case YearSection: return t.date().year(); | - | ||||||||||||||||||||||||||||||
22 | case MonthSection: return t.date().month(); | - | ||||||||||||||||||||||||||||||
23 | case DaySection: return t.date().day(); | - | ||||||||||||||||||||||||||||||
24 | case DayOfWeekSectionShort: | - | ||||||||||||||||||||||||||||||
25 | case DayOfWeekSectionLong: return t.date().day(); | - | ||||||||||||||||||||||||||||||
26 | case AmPmSection: return t.time().hour() > 11 ? 1 : 0; | - | ||||||||||||||||||||||||||||||
27 | - | |||||||||||||||||||||||||||||||
28 | default: break; | - | ||||||||||||||||||||||||||||||
29 | } | - | ||||||||||||||||||||||||||||||
30 | - | |||||||||||||||||||||||||||||||
31 | - | |||||||||||||||||||||||||||||||
32 | QMessageLogger(__FILE__, 95101, __PRETTY_FUNCTION__).warning("QDateTimeParser::getDigit() Internal error 2 (%s %d)", | - | ||||||||||||||||||||||||||||||
33 | QString(t.toString()).toLocal8Bit().constData(), index); | - | ||||||||||||||||||||||||||||||
34 | - | |||||||||||||||||||||||||||||||
35 | - | |||||||||||||||||||||||||||||||
36 | - | |||||||||||||||||||||||||||||||
37 | return -1; | - | ||||||||||||||||||||||||||||||
38 | } | - | ||||||||||||||||||||||||||||||
39 | bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const | - | ||||||||||||||||||||||||||||||
40 | { | - | ||||||||||||||||||||||||||||||
41 | if (index < 0
| 0-4310 | ||||||||||||||||||||||||||||||
42 | - | |||||||||||||||||||||||||||||||
43 | QMessageLogger(__FILE__, 119125, __PRETTY_FUNCTION__).warning("QDateTimeParser::setDigit() Internal error (%s %d %d)", | - | ||||||||||||||||||||||||||||||
44 | QString(v.toString()).toLocal8Bit().constData(), index, newVal); | - | ||||||||||||||||||||||||||||||
45 | - | |||||||||||||||||||||||||||||||
46 | - | |||||||||||||||||||||||||||||||
47 | - | |||||||||||||||||||||||||||||||
48 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
49 | } | - | ||||||||||||||||||||||||||||||
50 | const SectionNode &node = sectionNodes.at(index); | - | ||||||||||||||||||||||||||||||
51 | - | |||||||||||||||||||||||||||||||
52 | int yearconst QDate date = v.date().(); | - | ||||||||||||||||||||||||||||||
53 | const QTime time = v.time(); | - | ||||||||||||||||||||||||||||||
54 | int year = date.year(); | - | ||||||||||||||||||||||||||||||
55 | int month = v.date()..month(); | - | ||||||||||||||||||||||||||||||
56 | int day = v.date()..day(); | - | ||||||||||||||||||||||||||||||
57 | int hour = v.time()..hour(); | - | ||||||||||||||||||||||||||||||
58 | int minute = v.time()..minute(); | - | ||||||||||||||||||||||||||||||
59 | int second = v.time()..second(); | - | ||||||||||||||||||||||||||||||
60 | int msec = v.time()..msec(); | - | ||||||||||||||||||||||||||||||
61 | - | |||||||||||||||||||||||||||||||
62 | switch (node.type) { | - | ||||||||||||||||||||||||||||||
63 | case executed 478 times by 2 tests: Hour24Section:case Hour24Section: Executed by:
executed 478 times by 2 tests: casecase Hour24Section: Executed by:
executed 378 times by 2 tests: Hour12Section:case Hour12Section: Executed by:
executed 378 times by 2 tests: hour = newVal; break;case Hour12Section: Executed by:
executed 856 times by 3 tests: break; Executed by:
| 378-856 | ||||||||||||||||||||||||||||||
64 | case executed 470 times by 1 test: MinuteSection:case MinuteSection: Executed by:
executed 470 times by 1 test: minute = newVal; break;case MinuteSection: Executed by:
executed 470 times by 1 test: break; Executed by:
| 470 | ||||||||||||||||||||||||||||||
65 | case executed 434 times by 1 test: SecondSection:case SecondSection: Executed by:
executed 434 times by 1 test: second = newVal; break;case SecondSection: Executed by:
executed 434 times by 1 test: break; Executed by:
| 434 | ||||||||||||||||||||||||||||||
66 | case executed 36 times by 1 test: MSecSection:case MSecSection: Executed by:
executed 36 times by 1 test: msec = newVal; break;case MSecSection: Executed by:
executed 36 times by 1 test: break; Executed by:
| 36 | ||||||||||||||||||||||||||||||
67 | case executed 565 times by 2 tests: YearSection2Digits:case YearSection2Digits: Executed by:
executed 565 times by 2 tests: case YearSection2Digits: Executed by:
| 565 | ||||||||||||||||||||||||||||||
68 | case executed 154 times by 1 test: YearSection:case YearSection: Executed by:
executed 154 times by 1 test: year = newVal; break;case YearSection: Executed by:
executed 719 times by 2 tests: break; Executed by:
| 154-719 | ||||||||||||||||||||||||||||||
69 | case executed 241 times by 4 tests: MonthSection:case MonthSection: Executed by:
executed 241 times by 4 tests: month = newVal; break;case MonthSection: Executed by:
executed 241 times by 4 tests: break; Executed by:
| 241 | ||||||||||||||||||||||||||||||
70 | case executed 445 times by 2 tests: DaySection:case DaySection: Executed by:
executed 445 times by 2 tests: case DaySection: Executed by:
| 445 | ||||||||||||||||||||||||||||||
71 | case executed 90 times by 1 test: DayOfWeekSectionShort:case DayOfWeekSectionShort: Executed by:
executed 90 times by 1 test: case DayOfWeekSectionShort: Executed by:
| 90 | ||||||||||||||||||||||||||||||
72 | case executed 1013 times by 1 test: DayOfWeekSectionLong:case DayOfWeekSectionLong: Executed by:
executed 1013 times by 1 test: case DayOfWeekSectionLong: Executed by:
| 1013 | ||||||||||||||||||||||||||||||
73 | if (newVal > 31
| 0-1548 | ||||||||||||||||||||||||||||||
74 | - | |||||||||||||||||||||||||||||||
75 | - | |||||||||||||||||||||||||||||||
76 | - | |||||||||||||||||||||||||||||||
77 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
78 | } | - | ||||||||||||||||||||||||||||||
79 | day = newVal; | - | ||||||||||||||||||||||||||||||
80 | break; executed 1548 times by 2 tests: break; Executed by:
| 1548 | ||||||||||||||||||||||||||||||
81 | case executed 6 times by 1 test: AmPmSection:case AmPmSection: Executed by:
executed 6 times by 1 test: hour = (newVal == 0case AmPmSection: Executed by:
executed 6 times by 1 test: break; Executed by:
| 2-6 | ||||||||||||||||||||||||||||||
82 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
83 | QMessageLogger(__FILE__, 157165, __PRETTY_FUNCTION__).warning("QDateTimeParser::setDigit() Internal error (%s)", | - | ||||||||||||||||||||||||||||||
84 | QString(node.name()).toLocal8Bit().constData()); | - | ||||||||||||||||||||||||||||||
85 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
86 | } | - | ||||||||||||||||||||||||||||||
87 | - | |||||||||||||||||||||||||||||||
88 | if (!(node.type & DaySectionMask)
| 1548-2762 | ||||||||||||||||||||||||||||||
89 | if (day < cachedDay
| 21-2741 | ||||||||||||||||||||||||||||||
90 | day = cachedDay; executed 21 times by 1 test: day = cachedDay; Executed by:
| 21 | ||||||||||||||||||||||||||||||
91 | const int max = QDate(year, month, 1).daysInMonth(); | - | ||||||||||||||||||||||||||||||
92 | if (day > max
| 76-2686 | ||||||||||||||||||||||||||||||
93 | day = max; | - | ||||||||||||||||||||||||||||||
94 | } executed 76 times by 3 tests: end of block Executed by:
| 76 | ||||||||||||||||||||||||||||||
95 | } executed 2762 times by 6 tests: end of block Executed by:
| 2762 | ||||||||||||||||||||||||||||||
96 | if (QDate::isValid(year, month, day)
| 0-4271 | ||||||||||||||||||||||||||||||
97 | v = QDateTime(QDate(year, month, day), QTime(hour, minute, second, msec), spec); | - | ||||||||||||||||||||||||||||||
98 | return executed 4271 times by 7 tests: true;return true; Executed by:
executed 4271 times by 7 tests: return true; Executed by:
| 4271 | ||||||||||||||||||||||||||||||
99 | } | - | ||||||||||||||||||||||||||||||
100 | return executed 39 times by 2 tests: false;return false; Executed by:
executed 39 times by 2 tests: return false; Executed by:
| 39 | ||||||||||||||||||||||||||||||
101 | } | - | ||||||||||||||||||||||||||||||
102 | int QDateTimeParser::absoluteMax(int s, const QDateTime &cur) const | - | ||||||||||||||||||||||||||||||
103 | { | - | ||||||||||||||||||||||||||||||
104 | const SectionNode &sn = sectionNode(s); | - | ||||||||||||||||||||||||||||||
105 | switch (sn.type) { | - | ||||||||||||||||||||||||||||||
106 | case Hour24Section: | - | ||||||||||||||||||||||||||||||
107 | case Hour12Section: return 23; | - | ||||||||||||||||||||||||||||||
108 | - | |||||||||||||||||||||||||||||||
109 | - | |||||||||||||||||||||||||||||||
110 | case MinuteSection: | - | ||||||||||||||||||||||||||||||
111 | case SecondSection: return 59; | - | ||||||||||||||||||||||||||||||
112 | case MSecSection: return 999; | - | ||||||||||||||||||||||||||||||
113 | case YearSection2Digits: | - | ||||||||||||||||||||||||||||||
114 | case YearSection: return 9999; | - | ||||||||||||||||||||||||||||||
115 | - | |||||||||||||||||||||||||||||||
116 | - | |||||||||||||||||||||||||||||||
117 | - | |||||||||||||||||||||||||||||||
118 | case MonthSection: return 12; | - | ||||||||||||||||||||||||||||||
119 | case DaySection: | - | ||||||||||||||||||||||||||||||
120 | case DayOfWeekSectionShort: | - | ||||||||||||||||||||||||||||||
121 | case DayOfWeekSectionLong: return cur.isValid() ? cur.date().daysInMonth() : 31; | - | ||||||||||||||||||||||||||||||
122 | case AmPmSection: return 1; | - | ||||||||||||||||||||||||||||||
123 | default: break; | - | ||||||||||||||||||||||||||||||
124 | } | - | ||||||||||||||||||||||||||||||
125 | QMessageLogger(__FILE__, 208216, __PRETTY_FUNCTION__).warning("QDateTimeParser::absoluteMax() Internal error (%s)", | - | ||||||||||||||||||||||||||||||
126 | QString(sn.name()).toLocal8Bit().constData()); | - | ||||||||||||||||||||||||||||||
127 | return -1; | - | ||||||||||||||||||||||||||||||
128 | } | - | ||||||||||||||||||||||||||||||
129 | - | |||||||||||||||||||||||||||||||
130 | - | |||||||||||||||||||||||||||||||
131 | - | |||||||||||||||||||||||||||||||
132 | - | |||||||||||||||||||||||||||||||
133 | - | |||||||||||||||||||||||||||||||
134 | - | |||||||||||||||||||||||||||||||
135 | - | |||||||||||||||||||||||||||||||
136 | int QDateTimeParser::absoluteMin(int s) const | - | ||||||||||||||||||||||||||||||
137 | { | - | ||||||||||||||||||||||||||||||
138 | const SectionNode &sn = sectionNode(s); | - | ||||||||||||||||||||||||||||||
139 | switch (sn.type) { | - | ||||||||||||||||||||||||||||||
140 | case Hour24Section: | - | ||||||||||||||||||||||||||||||
141 | case Hour12Section: | - | ||||||||||||||||||||||||||||||
142 | case MinuteSection: | - | ||||||||||||||||||||||||||||||
143 | case SecondSection: | - | ||||||||||||||||||||||||||||||
144 | case MSecSection: | - | ||||||||||||||||||||||||||||||
145 | case YearSection2Digits: | - | ||||||||||||||||||||||||||||||
146 | case YearSection: return 0; | - | ||||||||||||||||||||||||||||||
147 | case MonthSection: | - | ||||||||||||||||||||||||||||||
148 | case DaySection: | - | ||||||||||||||||||||||||||||||
149 | case DayOfWeekSectionShort: | - | ||||||||||||||||||||||||||||||
150 | case DayOfWeekSectionLong: return 1; | - | ||||||||||||||||||||||||||||||
151 | case AmPmSection: return 0; | - | ||||||||||||||||||||||||||||||
152 | default: break; | - | ||||||||||||||||||||||||||||||
153 | } | - | ||||||||||||||||||||||||||||||
154 | QMessageLogger(__FILE__, 237245, __PRETTY_FUNCTION__).warning("QDateTimeParser::absoluteMin() Internal error (%s, %0x)", | - | ||||||||||||||||||||||||||||||
155 | QString(sn.name()).toLocal8Bit().constData(), sn.type); | - | ||||||||||||||||||||||||||||||
156 | return -1; | - | ||||||||||||||||||||||||||||||
157 | } | - | ||||||||||||||||||||||||||||||
158 | - | |||||||||||||||||||||||||||||||
159 | - | |||||||||||||||||||||||||||||||
160 | - | |||||||||||||||||||||||||||||||
161 | - | |||||||||||||||||||||||||||||||
162 | - | |||||||||||||||||||||||||||||||
163 | - | |||||||||||||||||||||||||||||||
164 | - | |||||||||||||||||||||||||||||||
165 | const QDateTimeParser::SectionNode &QDateTimeParser::sectionNode(int sectionIndex) const | - | ||||||||||||||||||||||||||||||
166 | { | - | ||||||||||||||||||||||||||||||
167 | if (sectionIndex < 0) { | - | ||||||||||||||||||||||||||||||
168 | switch (sectionIndex) { | - | ||||||||||||||||||||||||||||||
169 | case FirstSectionIndex: | - | ||||||||||||||||||||||||||||||
170 | return first; | - | ||||||||||||||||||||||||||||||
171 | case LastSectionIndex: | - | ||||||||||||||||||||||||||||||
172 | return last; | - | ||||||||||||||||||||||||||||||
173 | case NoSectionIndex: | - | ||||||||||||||||||||||||||||||
174 | return none; | - | ||||||||||||||||||||||||||||||
175 | } | - | ||||||||||||||||||||||||||||||
176 | } else if (sectionIndex < sectionNodes.size()) { | - | ||||||||||||||||||||||||||||||
177 | return sectionNodes.at(sectionIndex); | - | ||||||||||||||||||||||||||||||
178 | } | - | ||||||||||||||||||||||||||||||
179 | - | |||||||||||||||||||||||||||||||
180 | QMessageLogger(__FILE__, 263271, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionNode() Internal error (%d)", | - | ||||||||||||||||||||||||||||||
181 | sectionIndex); | - | ||||||||||||||||||||||||||||||
182 | return none; | - | ||||||||||||||||||||||||||||||
183 | } | - | ||||||||||||||||||||||||||||||
184 | - | |||||||||||||||||||||||||||||||
185 | QDateTimeParser::Section QDateTimeParser::sectionType(int sectionIndex) const | - | ||||||||||||||||||||||||||||||
186 | { | - | ||||||||||||||||||||||||||||||
187 | return sectionNode(sectionIndex).type; | - | ||||||||||||||||||||||||||||||
188 | } | - | ||||||||||||||||||||||||||||||
189 | int QDateTimeParser::sectionPos(int sectionIndex) const | - | ||||||||||||||||||||||||||||||
190 | { | - | ||||||||||||||||||||||||||||||
191 | return sectionPos(sectionNode(sectionIndex)); | - | ||||||||||||||||||||||||||||||
192 | } | - | ||||||||||||||||||||||||||||||
193 | - | |||||||||||||||||||||||||||||||
194 | int QDateTimeParser::sectionPos(const SectionNode &sn) const | - | ||||||||||||||||||||||||||||||
195 | { | - | ||||||||||||||||||||||||||||||
196 | switch (sn.type) { | - | ||||||||||||||||||||||||||||||
197 | case FirstSection: return 0; | - | ||||||||||||||||||||||||||||||
198 | case LastSection: return displayText().size() - 1; | - | ||||||||||||||||||||||||||||||
199 | default: break; | - | ||||||||||||||||||||||||||||||
200 | } | - | ||||||||||||||||||||||||||||||
201 | if (sn.pos == -1) { | - | ||||||||||||||||||||||||||||||
202 | QMessageLogger(__FILE__, 293301, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionPos Internal error (%s)", QString(sn.name()).toLocal8Bit().constData()); | - | ||||||||||||||||||||||||||||||
203 | return -1; | - | ||||||||||||||||||||||||||||||
204 | } | - | ||||||||||||||||||||||||||||||
205 | return sn.pos; | - | ||||||||||||||||||||||||||||||
206 | } | - | ||||||||||||||||||||||||||||||
207 | static QString unquote(const QStringQStringRef &str) | - | ||||||||||||||||||||||||||||||
208 | { | - | ||||||||||||||||||||||||||||||
209 | const QChar quote(QLatin1Char('\'')); | - | ||||||||||||||||||||||||||||||
210 | const QChar slash(QLatin1Char('\\')); | - | ||||||||||||||||||||||||||||||
211 | const QChar zero(QLatin1Char('0')); | - | ||||||||||||||||||||||||||||||
212 | QString ret; | - | ||||||||||||||||||||||||||||||
213 | QChar status(zero); | - | ||||||||||||||||||||||||||||||
214 | const int max = str.size(); | - | ||||||||||||||||||||||||||||||
215 | for (int i=0; i<max
| 476-991 | ||||||||||||||||||||||||||||||
216 | if (str.at(i) == quote
| 21-455 | ||||||||||||||||||||||||||||||
217 | if (status != quote
| 10-11 | ||||||||||||||||||||||||||||||
218 | status = quote; | - | ||||||||||||||||||||||||||||||
219 | } executed 11 times by 4 tests: else if (!ret.isEmpty()end of block Executed by:
| 0-11 | ||||||||||||||||||||||||||||||
220 | ret[ret.size() - 1] = quote; | - | ||||||||||||||||||||||||||||||
221 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
222 | status = zero; | - | ||||||||||||||||||||||||||||||
223 | } executed 10 times by 4 tests: end of block Executed by:
| 10 | ||||||||||||||||||||||||||||||
224 | } else { | - | ||||||||||||||||||||||||||||||
225 | ret += str.at(i); | - | ||||||||||||||||||||||||||||||
226 | } executed 455 times by 5 tests: end of block Executed by:
| 455 | ||||||||||||||||||||||||||||||
227 | } | - | ||||||||||||||||||||||||||||||
228 | return executed 991 times by 10 tests: ret;return ret; Executed by:
executed 991 times by 10 tests: return ret; Executed by:
| 991 | ||||||||||||||||||||||||||||||
229 | } | - | ||||||||||||||||||||||||||||||
230 | static inline int countRepeat(const QString &str, int index, int maxCount) | - | ||||||||||||||||||||||||||||||
231 | { | - | ||||||||||||||||||||||||||||||
232 | int count = 1; | - | ||||||||||||||||||||||||||||||
233 | const QChar ch(str.at(index)); | - | ||||||||||||||||||||||||||||||
234 | const int max = qMin(index + maxCount, str.size()); | - | ||||||||||||||||||||||||||||||
235 | while (index + count < max && str.at(index + count) == ch) { | - | ||||||||||||||||||||||||||||||
236 | ++count; | - | ||||||||||||||||||||||||||||||
237 | } | - | ||||||||||||||||||||||||||||||
238 | return count; | - | ||||||||||||||||||||||||||||||
239 | } | - | ||||||||||||||||||||||||||||||
240 | - | |||||||||||||||||||||||||||||||
241 | static inline void appendSeparator(QStringList *list, const QString &string, int from, int size, int lastQuote) | - | ||||||||||||||||||||||||||||||
242 | { | - | ||||||||||||||||||||||||||||||
243 | QString str(const QStringRef separator = string.midmidRef(from, size)); | - | ||||||||||||||||||||||||||||||
if); | ||||||||||||||||||||||||||||||||
244 | list->append(lastQuote >= from ) | - | ||||||||||||||||||||||||||||||
str =? unquote(str); | ||||||||||||||||||||||||||||||||
list->append(str);separator) : separator.toString()); | ||||||||||||||||||||||||||||||||
245 | } executed 3025 times by 11 tests: end of block Executed by:
| 3025 | ||||||||||||||||||||||||||||||
246 | - | |||||||||||||||||||||||||||||||
247 | - | |||||||||||||||||||||||||||||||
248 | bool QDateTimeParser::parseFormat(const QString &newFormat) | - | ||||||||||||||||||||||||||||||
249 | { | - | ||||||||||||||||||||||||||||||
250 | const QLatin1Char quote('\''); | - | ||||||||||||||||||||||||||||||
251 | const QLatin1Char slash('\\'); | - | ||||||||||||||||||||||||||||||
252 | const QLatin1Char zero('0'); | - | ||||||||||||||||||||||||||||||
253 | if (newFormat == displayFormat
| 2-1149 | ||||||||||||||||||||||||||||||
254 | return executed 173 times by 1 test: true;return true; Executed by:
executed 173 times by 1 test: return true; Executed by:
| 173 | ||||||||||||||||||||||||||||||
255 | } | - | ||||||||||||||||||||||||||||||
256 | - | |||||||||||||||||||||||||||||||
257 | if (false) QMessageLogger(__FILE__, 368374, __PRETTY_FUNCTION__).debug("parseFormat: %s", newFormat.toLatin1().constData()); dead code: QMessageLogger(__FILE__, 374, __PRETTY_FUNCTION__).debug("parseFormat: %s", newFormat.toLatin1().constData()); | - | ||||||||||||||||||||||||||||||
258 | - | |||||||||||||||||||||||||||||||
259 | QVector<SectionNode> newSectionNodes; | - | ||||||||||||||||||||||||||||||
260 | Sections newDisplay = 0; | - | ||||||||||||||||||||||||||||||
261 | QStringList newSeparators; | - | ||||||||||||||||||||||||||||||
262 | int i, index = 0; | - | ||||||||||||||||||||||||||||||
263 | int add = 0; | - | ||||||||||||||||||||||||||||||
264 | QChar status(zero); | - | ||||||||||||||||||||||||||||||
265 | const int max = newFormat.size(); | - | ||||||||||||||||||||||||||||||
266 | int lastQuote = -1; | - | ||||||||||||||||||||||||||||||
267 | for (i = 0; i<max
| 1151-7177 | ||||||||||||||||||||||||||||||
268 | if (newFormat.at(i) == quote
| 21-7156 | ||||||||||||||||||||||||||||||
269 | lastQuote = i; | - | ||||||||||||||||||||||||||||||
270 | ++add; | - | ||||||||||||||||||||||||||||||
271 | if (status != quote
| 10-11 | ||||||||||||||||||||||||||||||
272 | status = quote; | - | ||||||||||||||||||||||||||||||
273 | } executed 11 times by 4 tests: else if (i > 0end of block Executed by:
| 0-11 | ||||||||||||||||||||||||||||||
274 | status = zero; | - | ||||||||||||||||||||||||||||||
275 | } executed 10 times by 4 tests: end of block Executed by:
| 10 | ||||||||||||||||||||||||||||||
276 | } executed 21 times by 4 tests: else if (status != quoteend of block Executed by:
| 21-7117 | ||||||||||||||||||||||||||||||
277 | const char sect = newFormat.at(i).toLatin1(); | - | ||||||||||||||||||||||||||||||
278 | switch (sect) { | - | ||||||||||||||||||||||||||||||
279 | case executed 81 times by 4 tests: 'H':case 'H': Executed by:
executed 81 times by 4 tests: case 'H': Executed by:
| 81 | ||||||||||||||||||||||||||||||
280 | case executed 319 times by 8 tests: 'h':case 'h': Executed by:
executed 319 times by 8 tests: case 'h': Executed by:
| 319 | ||||||||||||||||||||||||||||||
281 | if (parserType != QVariant::Date
| 3-397 | ||||||||||||||||||||||||||||||
282 | const Section hour = (
| 81-316 | ||||||||||||||||||||||||||||||
283 | const SectionNode sn = { hour, i - add, countRepeat(newFormat, i, 2), 0 }; | - | ||||||||||||||||||||||||||||||
284 | newSectionNodes.append(sn); | - | ||||||||||||||||||||||||||||||
285 | appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); | - | ||||||||||||||||||||||||||||||
286 | i += sn.count - 1; | - | ||||||||||||||||||||||||||||||
287 | index = i + 1; | - | ||||||||||||||||||||||||||||||
288 | newDisplay |= hour; | - | ||||||||||||||||||||||||||||||
289 | } executed 397 times by 8 tests: end of block Executed by:
| 397 | ||||||||||||||||||||||||||||||
290 | break; executed 400 times by 9 tests: break; Executed by:
| 400 | ||||||||||||||||||||||||||||||
291 | case executed 379 times by 8 tests: 'm':case 'm': Executed by:
executed 379 times by 8 tests: case 'm': Executed by:
| 379 | ||||||||||||||||||||||||||||||
292 | if (parserType != QVariant::Date
| 0-379 | ||||||||||||||||||||||||||||||
293 | const SectionNode sn = { MinuteSection, i - add, countRepeat(newFormat, i, 2), 0 }; | - | ||||||||||||||||||||||||||||||
294 | newSectionNodes.append(sn); | - | ||||||||||||||||||||||||||||||
295 | appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); | - | ||||||||||||||||||||||||||||||
296 | i += sn.count - 1; | - | ||||||||||||||||||||||||||||||
297 | index = i + 1; | - | ||||||||||||||||||||||||||||||
298 | newDisplay |= MinuteSection; | - | ||||||||||||||||||||||||||||||
299 | } executed 379 times by 8 tests: end of block Executed by:
| 379 | ||||||||||||||||||||||||||||||
300 | break; executed 379 times by 8 tests: break; Executed by:
| 379 | ||||||||||||||||||||||||||||||
301 | case executed 236 times by 4 tests: 's':case 's': Executed by:
executed 236 times by 4 tests: case 's': Executed by:
| 236 | ||||||||||||||||||||||||||||||
302 | if (parserType != QVariant::Date
| 0-236 | ||||||||||||||||||||||||||||||
303 | const SectionNode sn = { SecondSection, i - add, countRepeat(newFormat, i, 2), 0 }; | - | ||||||||||||||||||||||||||||||
304 | newSectionNodes.append(sn); | - | ||||||||||||||||||||||||||||||
305 | appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); | - | ||||||||||||||||||||||||||||||
306 | i += sn.count - 1; | - | ||||||||||||||||||||||||||||||
307 | index = i + 1; | - | ||||||||||||||||||||||||||||||
308 | newDisplay |= SecondSection; | - | ||||||||||||||||||||||||||||||
309 | } executed 236 times by 4 tests: end of block Executed by:
| 236 | ||||||||||||||||||||||||||||||
310 | break; executed 236 times by 4 tests: break; Executed by:
| 236 | ||||||||||||||||||||||||||||||
311 | - | |||||||||||||||||||||||||||||||
312 | case executed 47 times by 2 tests: 'z':case 'z': Executed by:
executed 47 times by 2 tests: case 'z': Executed by:
| 47 | ||||||||||||||||||||||||||||||
313 | if (parserType != QVariant::Date
| 0-47 | ||||||||||||||||||||||||||||||
314 | const SectionNode sn = { MSecSection, i - add, countRepeat(newFormat, i, 3) < 3 ? 1 : 3, 0 }; | - | ||||||||||||||||||||||||||||||
315 | newSectionNodes.append(sn); | - | ||||||||||||||||||||||||||||||
316 | appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); | - | ||||||||||||||||||||||||||||||
317 | i += sn.count - 1; | - | ||||||||||||||||||||||||||||||
318 | index = i + 1; | - | ||||||||||||||||||||||||||||||
319 | newDisplay |= MSecSection; | - | ||||||||||||||||||||||||||||||
320 | } executed 47 times by 2 tests: end of block Executed by:
| 47 | ||||||||||||||||||||||||||||||
321 | break; executed 47 times by 2 tests: break; Executed by:
| 47 | ||||||||||||||||||||||||||||||
322 | case executed 16 times by 5 tests: 'A':case 'A': Executed by:
executed 16 times by 5 tests: case 'A': Executed by:
| 16 | ||||||||||||||||||||||||||||||
323 | case executed 79 times by 4 tests: 'a':case 'a': Executed by:
executed 79 times by 4 tests: case 'a': Executed by:
| 79 | ||||||||||||||||||||||||||||||
324 | if (parserType != QVariant::Date
| 2-93 | ||||||||||||||||||||||||||||||
325 | const bool cap = (sect == 'A'); | - | ||||||||||||||||||||||||||||||
326 | const SectionNode sn = { AmPmSection, i - add, (cap ? 1 : 0), 0 }; | - | ||||||||||||||||||||||||||||||
327 | newSectionNodes.append(sn); | - | ||||||||||||||||||||||||||||||
328 | appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); | - | ||||||||||||||||||||||||||||||
329 | newDisplay |= AmPmSection; | - | ||||||||||||||||||||||||||||||
330 | if (i + 1 < newFormat.size()
| 1-92 | ||||||||||||||||||||||||||||||
331 | && newFormat.at(i+1) == (cap
| 0-92 | ||||||||||||||||||||||||||||||
332 | ++i; | - | ||||||||||||||||||||||||||||||
333 | } executed 92 times by 5 tests: end of block Executed by:
| 92 | ||||||||||||||||||||||||||||||
334 | index = i + 1; | - | ||||||||||||||||||||||||||||||
335 | } executed 93 times by 5 tests: end of block Executed by:
| 93 | ||||||||||||||||||||||||||||||
336 | break; executed 95 times by 6 tests: break; Executed by:
| 95 | ||||||||||||||||||||||||||||||
337 | case executed 863 times by 10 tests: 'y':case 'y': Executed by:
executed 863 times by 10 tests: case 'y': Executed by:
| 863 | ||||||||||||||||||||||||||||||
338 | if (parserType != QVariant::Time
| 4-859 | ||||||||||||||||||||||||||||||
339 | const int repeat = countRepeat(newFormat, i, 4); | - | ||||||||||||||||||||||||||||||
340 | if (repeat >= 2
| 1-858 | ||||||||||||||||||||||||||||||
341 | const SectionNode sn = { repeat == 4 ? YearSection : YearSection2Digits, | - | ||||||||||||||||||||||||||||||
342 | i - add, repeat == 4 ? 4 : 2, 0 }; | - | ||||||||||||||||||||||||||||||
343 | newSectionNodes.append(sn); | - | ||||||||||||||||||||||||||||||
344 | appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); | - | ||||||||||||||||||||||||||||||
345 | i += sn.count - 1; | - | ||||||||||||||||||||||||||||||
346 | index = i + 1; | - | ||||||||||||||||||||||||||||||
347 | newDisplay |= sn.type; | - | ||||||||||||||||||||||||||||||
348 | } executed 858 times by 10 tests: end of block Executed by:
| 858 | ||||||||||||||||||||||||||||||
349 | } executed 859 times by 10 tests: end of block Executed by:
| 859 | ||||||||||||||||||||||||||||||
350 | break; executed 863 times by 10 tests: break; Executed by:
| 863 | ||||||||||||||||||||||||||||||
351 | case executed 981 times by 10 tests: 'M':case 'M': Executed by:
executed 981 times by 10 tests: case 'M': Executed by:
| 981 | ||||||||||||||||||||||||||||||
352 | if (parserType != QVariant::Time
| 0-981 | ||||||||||||||||||||||||||||||
353 | const SectionNode sn = { MonthSection, i - add, countRepeat(newFormat, i, 4), 0 }; | - | ||||||||||||||||||||||||||||||
354 | newSectionNodes.append(sn); | - | ||||||||||||||||||||||||||||||
355 | newSeparators.append(unquote(newFormat.midmidRef(index, i - index))); | - | ||||||||||||||||||||||||||||||
356 | i += sn.count - 1; | - | ||||||||||||||||||||||||||||||
357 | index = i + 1; | - | ||||||||||||||||||||||||||||||
358 | newDisplay |= MonthSection; | - | ||||||||||||||||||||||||||||||
359 | } executed 981 times by 10 tests: end of block Executed by:
| 981 | ||||||||||||||||||||||||||||||
360 | break; executed 981 times by 10 tests: break; Executed by:
| 981 | ||||||||||||||||||||||||||||||
361 | case executed 999 times by 10 tests: 'd':case 'd': Executed by:
executed 999 times by 10 tests: case 'd': Executed by:
| 999 | ||||||||||||||||||||||||||||||
362 | if (parserType != QVariant::Time
| 0-999 | ||||||||||||||||||||||||||||||
363 | const int repeat = countRepeat(newFormat, i, 4); | - | ||||||||||||||||||||||||||||||
364 | const Section sectionType = (repeat == 4
| 31-968 | ||||||||||||||||||||||||||||||
365 | : (repeat == 3
| 6-962 | ||||||||||||||||||||||||||||||
366 | const SectionNode sn = { sectionType, i - add, repeat, 0 }; | - | ||||||||||||||||||||||||||||||
367 | newSectionNodes.append(sn); | - | ||||||||||||||||||||||||||||||
368 | appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); | - | ||||||||||||||||||||||||||||||
369 | i += sn.count - 1; | - | ||||||||||||||||||||||||||||||
370 | index = i + 1; | - | ||||||||||||||||||||||||||||||
371 | newDisplay |= sn.type; | - | ||||||||||||||||||||||||||||||
372 | } executed 999 times by 10 tests: end of block Executed by:
| 999 | ||||||||||||||||||||||||||||||
373 | break; executed 999 times by 10 tests: break; Executed by:
| 999 | ||||||||||||||||||||||||||||||
374 | - | |||||||||||||||||||||||||||||||
375 | default executed 3117 times by 10 tests: :default: Executed by:
executed 3117 times by 10 tests: default: Executed by:
| 3117 | ||||||||||||||||||||||||||||||
376 | break; executed 3117 times by 10 tests: break; Executed by:
| 3117 | ||||||||||||||||||||||||||||||
377 | } | - | ||||||||||||||||||||||||||||||
378 | } | - | ||||||||||||||||||||||||||||||
379 | } executed 7177 times by 11 tests: end of block Executed by:
| 7177 | ||||||||||||||||||||||||||||||
380 | if (newSectionNodes.isEmpty()
| 2-1140 | ||||||||||||||||||||||||||||||
381 | return executed 2 times by 1 test: false;return false; Executed by:
executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||||||||||||||
382 | } | - | ||||||||||||||||||||||||||||||
383 | - | |||||||||||||||||||||||||||||||
384 | if ((
| 218-931 | ||||||||||||||||||||||||||||||
385 | const int count = newSectionNodes.size(); | - | ||||||||||||||||||||||||||||||
386 | for (int i = 0; i < count
| 218-878 | ||||||||||||||||||||||||||||||
387 | SectionNode &node = newSectionNodes[i]; | - | ||||||||||||||||||||||||||||||
388 | if (node.type == Hour12Section
| 229-649 | ||||||||||||||||||||||||||||||
389 | node.type = Hour24Section; executed 229 times by 5 tests: node.type = Hour24Section; Executed by:
| 229 | ||||||||||||||||||||||||||||||
390 | } executed 878 times by 5 tests: end of block Executed by:
| 878 | ||||||||||||||||||||||||||||||
391 | } executed 218 times by 5 tests: end of block Executed by:
| 218 | ||||||||||||||||||||||||||||||
392 | - | |||||||||||||||||||||||||||||||
393 | if (index < max
| 16-1133 | ||||||||||||||||||||||||||||||
394 | appendSeparator(&newSeparators, newFormat, index, index - max, lastQuote); | - | ||||||||||||||||||||||||||||||
395 | } executed 16 times by 4 tests: else {end of block Executed by:
| 16 | ||||||||||||||||||||||||||||||
396 | newSeparators.append(QString()); | - | ||||||||||||||||||||||||||||||
397 | } executed 1133 times by 10 tests: end of block Executed by:
| 1133 | ||||||||||||||||||||||||||||||
398 | - | |||||||||||||||||||||||||||||||
399 | displayFormat = newFormat; | - | ||||||||||||||||||||||||||||||
400 | separators = newSeparators; | - | ||||||||||||||||||||||||||||||
401 | sectionNodes = newSectionNodes; | - | ||||||||||||||||||||||||||||||
402 | display = newDisplay; | - | ||||||||||||||||||||||||||||||
403 | last.pos = -1; | - | ||||||||||||||||||||||||||||||
404 | - | |||||||||||||||||||||||||||||||
405 | - | |||||||||||||||||||||||||||||||
406 | - | |||||||||||||||||||||||||||||||
407 | - | |||||||||||||||||||||||||||||||
408 | - | |||||||||||||||||||||||||||||||
409 | if (false) QMessageLogger(__FILE__, 520526, __PRETTY_FUNCTION__).debug() << newFormat << displayFormat; dead code: QMessageLogger(__FILE__, 526, __PRETTY_FUNCTION__).debug() << newFormat << displayFormat; | - | ||||||||||||||||||||||||||||||
410 | if (false) QMessageLogger(__FILE__, 521527, __PRETTY_FUNCTION__).debug("separators:\n'%s'", separators.join(QLatin1String("\n")).toLatin1().constData()); dead code: QMessageLogger(__FILE__, 527, __PRETTY_FUNCTION__).debug("separators:\n'%s'", separators.join(QLatin1String("\n")).toLatin1().constData()); | - | ||||||||||||||||||||||||||||||
411 | - | |||||||||||||||||||||||||||||||
412 | return executed 1149 times by 11 tests: true;return true; Executed by:
executed 1149 times by 11 tests: return true; Executed by:
| 1149 | ||||||||||||||||||||||||||||||
413 | } | - | ||||||||||||||||||||||||||||||
414 | - | |||||||||||||||||||||||||||||||
415 | - | |||||||||||||||||||||||||||||||
416 | - | |||||||||||||||||||||||||||||||
417 | - | |||||||||||||||||||||||||||||||
418 | - | |||||||||||||||||||||||||||||||
419 | - | |||||||||||||||||||||||||||||||
420 | - | |||||||||||||||||||||||||||||||
421 | int QDateTimeParser::sectionSize(int sectionIndex) const | - | ||||||||||||||||||||||||||||||
422 | { | - | ||||||||||||||||||||||||||||||
423 | if (sectionIndex < 0
| 0-18759 | ||||||||||||||||||||||||||||||
424 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
425 | - | |||||||||||||||||||||||||||||||
426 | if (sectionIndex >= sectionNodes.size()
| 0-18759 | ||||||||||||||||||||||||||||||
427 | QMessageLogger(__FILE__, 538544, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionSize Internal error (%d)", sectionIndex); | - | ||||||||||||||||||||||||||||||
428 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
429 | } | - | ||||||||||||||||||||||||||||||
430 | - | |||||||||||||||||||||||||||||||
431 | if (sectionIndex == sectionNodes.size() - 1
| 4554-14205 | ||||||||||||||||||||||||||||||
432 | - | |||||||||||||||||||||||||||||||
433 | - | |||||||||||||||||||||||||||||||
434 | - | |||||||||||||||||||||||||||||||
435 | - | |||||||||||||||||||||||||||||||
436 | int sizeAdjustment = 0; | - | ||||||||||||||||||||||||||||||
437 | if (const int displayTextSize = displayText().size()(); | - | ||||||||||||||||||||||||||||||
438 | if (displayTextSize
| 23-4531 | ||||||||||||||||||||||||||||||
439 | - | |||||||||||||||||||||||||||||||
440 | int preceedingZeroesAdded = 0; | - | ||||||||||||||||||||||||||||||
441 | if (sectionNodes.size() > 1
| 0-23 | ||||||||||||||||||||||||||||||
442 | for (QVector<SectionNode>::ConstIterator sectionItconst auto begin = sectionNodes.constBegincbegin(); | - | ||||||||||||||||||||||||||||||
443 | sectionIt != sectionNodes.constBegin()const auto end = begin + sectionIndex; | - | ||||||||||||||||||||||||||||||
444 | for (auto sectionIt = begin; sectionIt != end
| 23-40 | ||||||||||||||||||||||||||||||
445 | {preceedingZeroesAdded += sectionIt->zeroesAdded; executed 40 times by 1 test: preceedingZeroesAdded += sectionIt->zeroesAdded; Executed by:
| 40 | ||||||||||||||||||||||||||||||
446 | }} executed 23 times by 1 test: end of block Executed by:
| 23 | ||||||||||||||||||||||||||||||
447 | sizeAdjustment = preceedingZeroesAdded; | - | ||||||||||||||||||||||||||||||
448 | } executed 23 times by 1 test: end of block Executed by:
| 23 | ||||||||||||||||||||||||||||||
449 | - | |||||||||||||||||||||||||||||||
450 | return executed 4554 times by 1 test: displayText().size()displayTextSize + sizeAdjustment - sectionPos(sectionIndex) - separators.last().size();return displayTextSize + sizeAdjustment - sectionPos(sectionIndex) - separators.last().size(); Executed by:
executed 4554 times by 1 test: return displayTextSize + sizeAdjustment - sectionPos(sectionIndex) - separators.last().size(); Executed by:
| 4554 | ||||||||||||||||||||||||||||||
451 | } else { | - | ||||||||||||||||||||||||||||||
452 | return executed 14205 times by 4 tests: sectionPos(sectionIndex + 1) - sectionPos(sectionIndex)return sectionPos(sectionIndex + 1) - sectionPos(sectionIndex) - separators.at(sectionIndex + 1).size(); Executed by:
executed 14205 times by 4 tests: return sectionPos(sectionIndex + 1) - sectionPos(sectionIndex) - separators.at(sectionIndex + 1).size(); Executed by:
| 14205 | ||||||||||||||||||||||||||||||
453 | - separators.at(sectionIndex + 1).size(); executed 14205 times by 4 tests: return sectionPos(sectionIndex + 1) - sectionPos(sectionIndex) - separators.at(sectionIndex + 1).size(); Executed by:
| 14205 | ||||||||||||||||||||||||||||||
454 | } | - | ||||||||||||||||||||||||||||||
455 | } | - | ||||||||||||||||||||||||||||||
456 | - | |||||||||||||||||||||||||||||||
457 | - | |||||||||||||||||||||||||||||||
458 | int QDateTimeParser::sectionMaxSize(Section s, int count) const | - | ||||||||||||||||||||||||||||||
459 | { | - | ||||||||||||||||||||||||||||||
460 | - | |||||||||||||||||||||||||||||||
461 | int mcount = 12; | - | ||||||||||||||||||||||||||||||
462 | - | |||||||||||||||||||||||||||||||
463 | - | |||||||||||||||||||||||||||||||
464 | switch (s) { | - | ||||||||||||||||||||||||||||||
465 | case FirstSection: | - | ||||||||||||||||||||||||||||||
466 | case NoSection: | - | ||||||||||||||||||||||||||||||
467 | case LastSection: return 0; | - | ||||||||||||||||||||||||||||||
468 | - | |||||||||||||||||||||||||||||||
469 | case AmPmSection: { | - | ||||||||||||||||||||||||||||||
470 | const int lowerMax = qMin(getAmPmText(AmText, LowerCase).size(), | - | ||||||||||||||||||||||||||||||
471 | getAmPmText(PmText, LowerCase).size()); | - | ||||||||||||||||||||||||||||||
472 | const int upperMax = qMin(getAmPmText(AmText, UpperCase).size(), | - | ||||||||||||||||||||||||||||||
473 | getAmPmText(PmText, UpperCase).size()); | - | ||||||||||||||||||||||||||||||
474 | return qMin(4, qMin(lowerMax, upperMax)); | - | ||||||||||||||||||||||||||||||
475 | } | - | ||||||||||||||||||||||||||||||
476 | - | |||||||||||||||||||||||||||||||
477 | case Hour24Section: | - | ||||||||||||||||||||||||||||||
478 | case Hour12Section: | - | ||||||||||||||||||||||||||||||
479 | case MinuteSection: | - | ||||||||||||||||||||||||||||||
480 | case SecondSection: | - | ||||||||||||||||||||||||||||||
481 | case DaySection: return 2; | - | ||||||||||||||||||||||||||||||
482 | case DayOfWeekSectionShort: | - | ||||||||||||||||||||||||||||||
483 | case DayOfWeekSectionLong: | - | ||||||||||||||||||||||||||||||
484 | - | |||||||||||||||||||||||||||||||
485 | - | |||||||||||||||||||||||||||||||
486 | - | |||||||||||||||||||||||||||||||
487 | mcount = 7; | - | ||||||||||||||||||||||||||||||
488 | - | |||||||||||||||||||||||||||||||
489 | - | |||||||||||||||||||||||||||||||
490 | case MonthSection: | - | ||||||||||||||||||||||||||||||
491 | - | |||||||||||||||||||||||||||||||
492 | - | |||||||||||||||||||||||||||||||
493 | - | |||||||||||||||||||||||||||||||
494 | if (count <= 2) | - | ||||||||||||||||||||||||||||||
495 | return 2; | - | ||||||||||||||||||||||||||||||
496 | - | |||||||||||||||||||||||||||||||
497 | { | - | ||||||||||||||||||||||||||||||
498 | int ret = 0; | - | ||||||||||||||||||||||||||||||
499 | const QLocale l = locale(); | - | ||||||||||||||||||||||||||||||
500 | const QLocale::FormatType format = count == 4 ? QLocale::LongFormat : QLocale::ShortFormat; | - | ||||||||||||||||||||||||||||||
501 | for (int i=1; i<=mcount; ++i) { | - | ||||||||||||||||||||||||||||||
502 | const QString str = (s == MonthSection | - | ||||||||||||||||||||||||||||||
503 | ? l.monthName(i, format) | - | ||||||||||||||||||||||||||||||
504 | : l.dayName(i, format)); | - | ||||||||||||||||||||||||||||||
505 | ret = qMax(str.size(), ret); | - | ||||||||||||||||||||||||||||||
506 | } | - | ||||||||||||||||||||||||||||||
507 | return ret; | - | ||||||||||||||||||||||||||||||
508 | } | - | ||||||||||||||||||||||||||||||
509 | - | |||||||||||||||||||||||||||||||
510 | case MSecSection: return 3; | - | ||||||||||||||||||||||||||||||
511 | case YearSection: return 4; | - | ||||||||||||||||||||||||||||||
512 | case YearSection2Digits: return 2; | - | ||||||||||||||||||||||||||||||
513 | - | |||||||||||||||||||||||||||||||
514 | case CalendarPopupSection: | - | ||||||||||||||||||||||||||||||
515 | case Internal: | - | ||||||||||||||||||||||||||||||
516 | case TimeSectionMask: | - | ||||||||||||||||||||||||||||||
517 | case DateSectionMask: | - | ||||||||||||||||||||||||||||||
518 | case HourSectionMask: | - | ||||||||||||||||||||||||||||||
519 | case YearSectionMask: | - | ||||||||||||||||||||||||||||||
520 | case DayOfWeekSectionMask: | - | ||||||||||||||||||||||||||||||
521 | case DaySectionMask: | - | ||||||||||||||||||||||||||||||
522 | QMessageLogger(__FILE__, 632639, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionMaxSize: Invalid section %s", | - | ||||||||||||||||||||||||||||||
523 | SectionNode::name(s).toLatin1().constData()); | - | ||||||||||||||||||||||||||||||
524 | - | |||||||||||||||||||||||||||||||
525 | case NoSectionIndex: | - | ||||||||||||||||||||||||||||||
526 | case FirstSectionIndex: | - | ||||||||||||||||||||||||||||||
527 | case LastSectionIndex: | - | ||||||||||||||||||||||||||||||
528 | case CalendarPopupIndex: | - | ||||||||||||||||||||||||||||||
529 | - | |||||||||||||||||||||||||||||||
530 | break; | - | ||||||||||||||||||||||||||||||
531 | } | - | ||||||||||||||||||||||||||||||
532 | return -1; | - | ||||||||||||||||||||||||||||||
533 | } | - | ||||||||||||||||||||||||||||||
534 | - | |||||||||||||||||||||||||||||||
535 | - | |||||||||||||||||||||||||||||||
536 | int QDateTimeParser::sectionMaxSize(int index) const | - | ||||||||||||||||||||||||||||||
537 | { | - | ||||||||||||||||||||||||||||||
538 | const SectionNode &sn = sectionNode(index); | - | ||||||||||||||||||||||||||||||
539 | return sectionMaxSize(sn.type, sn.count); | - | ||||||||||||||||||||||||||||||
540 | } | - | ||||||||||||||||||||||||||||||
541 | QString QDateTimeParser::sectionText(const QString &text, int sectionIndex, int index) const | - | ||||||||||||||||||||||||||||||
542 | { | - | ||||||||||||||||||||||||||||||
543 | const SectionNode &sn = sectionNode(sectionIndex); | - | ||||||||||||||||||||||||||||||
544 | switch (sn.type) { | - | ||||||||||||||||||||||||||||||
545 | case NoSectionIndex: | - | ||||||||||||||||||||||||||||||
546 | case FirstSectionIndex: | - | ||||||||||||||||||||||||||||||
547 | case LastSectionIndex: | - | ||||||||||||||||||||||||||||||
548 | return QString(); | - | ||||||||||||||||||||||||||||||
549 | default: break; | - | ||||||||||||||||||||||||||||||
550 | } | - | ||||||||||||||||||||||||||||||
551 | - | |||||||||||||||||||||||||||||||
552 | return text.mid(index, sectionSize(sectionIndex)); | - | ||||||||||||||||||||||||||||||
553 | } | - | ||||||||||||||||||||||||||||||
554 | - | |||||||||||||||||||||||||||||||
555 | QString QDateTimeParser::sectionText(int sectionIndex) const | - | ||||||||||||||||||||||||||||||
556 | { | - | ||||||||||||||||||||||||||||||
557 | const SectionNode &sn = sectionNode(sectionIndex); | - | ||||||||||||||||||||||||||||||
558 | return sectionText(displayText(), sectionIndex, sn.pos); | - | ||||||||||||||||||||||||||||||
559 | } | - | ||||||||||||||||||||||||||||||
560 | int QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionIndex, | - | ||||||||||||||||||||||||||||||
561 | QString &text, int &cursorPosition, int index, | - | ||||||||||||||||||||||||||||||
562 | State &state, int *usedptr) const | - | ||||||||||||||||||||||||||||||
563 | { | - | ||||||||||||||||||||||||||||||
564 | state = Invalid; | - | ||||||||||||||||||||||||||||||
565 | int num = 0; | - | ||||||||||||||||||||||||||||||
566 | const SectionNode &sn = sectionNode(sectionIndex); | - | ||||||||||||||||||||||||||||||
567 | if ((
| 0-15899 | ||||||||||||||||||||||||||||||
568 | QMessageLogger(__FILE__, 698705, __PRETTY_FUNCTION__).warning("QDateTimeParser::parseSection Internal error (%s %d)", | - | ||||||||||||||||||||||||||||||
569 | QString(sn.name()).toLocal8Bit().constData(), sectionIndex); | - | ||||||||||||||||||||||||||||||
570 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
571 | } | - | ||||||||||||||||||||||||||||||
572 | - | |||||||||||||||||||||||||||||||
573 | const int sectionmaxsize = sectionMaxSize(sectionIndex); | - | ||||||||||||||||||||||||||||||
574 | QString sectiontextQStringRef sectionTextRef = text.midmidRef(index, sectionmaxsize); | - | ||||||||||||||||||||||||||||||
575 | int sectiontextSize = sectiontextsectionTextRef.size(); | - | ||||||||||||||||||||||||||||||
576 | - | |||||||||||||||||||||||||||||||
577 | if (false) QMessageLogger(__FILE__, 707714, __PRETTY_FUNCTION__).debug() << "sectionValue for" << sn.name() dead code: QMessageLogger(__FILE__, 714, __PRETTY_FUNCTION__).debug() << "sectionValue for" << sn.name() << "with text" << text << "and st" << sectionTextRef << text.midRef(index, sectionmaxsize) << index; | - | ||||||||||||||||||||||||||||||
578 | << "with text" << text << "and st" << sectiontextsectionTextRef dead code: QMessageLogger(__FILE__, 714, __PRETTY_FUNCTION__).debug() << "sectionValue for" << sn.name() << "with text" << text << "and st" << sectionTextRef << text.midRef(index, sectionmaxsize) << index; | - | ||||||||||||||||||||||||||||||
579 | << text.midmidRef(index, sectionmaxsize) dead code: QMessageLogger(__FILE__, 714, __PRETTY_FUNCTION__).debug() << "sectionValue for" << sn.name() << "with text" << text << "and st" << sectionTextRef << text.midRef(index, sectionmaxsize) << index; | - | ||||||||||||||||||||||||||||||
580 | << index; dead code: QMessageLogger(__FILE__, 714, __PRETTY_FUNCTION__).debug() << "sectionValue for" << sn.name() << "with text" << text << "and st" << sectionTextRef << text.midRef(index, sectionmaxsize) << index; | - | ||||||||||||||||||||||||||||||
581 | - | |||||||||||||||||||||||||||||||
582 | int used = 0; | - | ||||||||||||||||||||||||||||||
583 | switch (sn.type) { | - | ||||||||||||||||||||||||||||||
584 | case executed 863 times by 5 tests: AmPmSection:case AmPmSection: Executed by:
executed 863 times by 5 tests: {case AmPmSection: Executed by:
| 863 | ||||||||||||||||||||||||||||||
585 | QString sectiontext = sectionTextRef.toString(); | - | ||||||||||||||||||||||||||||||
586 | const int ampm = findAmPm(sectiontext, sectionIndex, &used); | - | ||||||||||||||||||||||||||||||
587 | switch (ampm) { | - | ||||||||||||||||||||||||||||||
588 | case executed 758 times by 5 tests: AM:case AM: Executed by:
executed 758 times by 5 tests: case AM: Executed by:
| 758 | ||||||||||||||||||||||||||||||
589 | case executed 103 times by 3 tests: PM:case PM: Executed by:
executed 103 times by 3 tests: case PM: Executed by:
| 103 | ||||||||||||||||||||||||||||||
590 | num = ampm; | - | ||||||||||||||||||||||||||||||
591 | state = Acceptable; | - | ||||||||||||||||||||||||||||||
592 | break; executed 861 times by 5 tests: break; Executed by:
| 861 | ||||||||||||||||||||||||||||||
593 | case never executed: PossibleAM:case PossibleAM: never executed: case PossibleAM: | 0 | ||||||||||||||||||||||||||||||
594 | case never executed: PossiblePM:case PossiblePM: never executed: case PossiblePM: | 0 | ||||||||||||||||||||||||||||||
595 | num = ampm - 2; | - | ||||||||||||||||||||||||||||||
596 | state = Intermediate; | - | ||||||||||||||||||||||||||||||
597 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
598 | case never executed: PossibleBoth:case PossibleBoth: never executed: case PossibleBoth: | 0 | ||||||||||||||||||||||||||||||
599 | num = 0; | - | ||||||||||||||||||||||||||||||
600 | state = Intermediate; | - | ||||||||||||||||||||||||||||||
601 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
602 | case executed 2 times by 2 tests: Neither:case Neither: Executed by:
executed 2 times by 2 tests: case Neither: Executed by:
| 2 | ||||||||||||||||||||||||||||||
603 | state = Invalid; | - | ||||||||||||||||||||||||||||||
604 | if (false) QMessageLogger(__FILE__, 733741, __PRETTY_FUNCTION__).debug() << "invalid because findAmPm(" << sectiontext << ") returned -1"; dead code: QMessageLogger(__FILE__, 741, __PRETTY_FUNCTION__).debug() << "invalid because findAmPm(" << sectiontext << ") returned -1"; | - | ||||||||||||||||||||||||||||||
605 | break; executed 2 times by 2 tests: break; Executed by:
| 2 | ||||||||||||||||||||||||||||||
606 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
607 | if (false) QMessageLogger(__FILE__, 736744, __PRETTY_FUNCTION__).debug("This should never happen (findAmPm returned %d)", ampm); dead code: QMessageLogger(__FILE__, 744, __PRETTY_FUNCTION__).debug("This should never happen (findAmPm returned %d)", ampm); | - | ||||||||||||||||||||||||||||||
608 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
609 | } | - | ||||||||||||||||||||||||||||||
610 | if (state != Invalid
| 2-861 | ||||||||||||||||||||||||||||||
611 | {text.replace(index, used, sectiontext.left(constData(), used)); executed 861 times by 5 tests: text.replace(index, used, sectiontext.constData(), used); Executed by:
| 861 | ||||||||||||||||||||||||||||||
} executed 861 times by 5 tests: text.replace(index, used, sectiontext.constData(), used); Executed by:
executed 861 times by 5 tests: );text.replace(index, used, sectiontext.constData(), used); Executed by:
executed 861 times by 5 tests: text.replace(index, used, sectiontext.constData(), used); Executed by:
| ||||||||||||||||||||||||||||||||
612 | break; executed 863 times by 5 tests: }break; Executed by:
| 863 | ||||||||||||||||||||||||||||||
613 | case executed 3195 times by 10 tests: MonthSection:case MonthSection: Executed by:
executed 3195 times by 10 tests: case MonthSection: Executed by:
| 3195 | ||||||||||||||||||||||||||||||
614 | case executed 40 times by 3 tests: DayOfWeekSectionShort:case DayOfWeekSectionShort: Executed by:
executed 40 times by 3 tests: case DayOfWeekSectionShort: Executed by:
| 40 | ||||||||||||||||||||||||||||||
615 | case executed 424 times by 3 tests: DayOfWeekSectionLong:case DayOfWeekSectionLong: Executed by:
executed 424 times by 3 tests: case DayOfWeekSectionLong: Executed by:
| 424 | ||||||||||||||||||||||||||||||
616 | if (sn.count >= 3
| 1733-1926 | ||||||||||||||||||||||||||||||
617 | QString sectiontext = sectionTextRef.toString(); | - | ||||||||||||||||||||||||||||||
618 | if (sn.type == MonthSection
| 464-1462 | ||||||||||||||||||||||||||||||
619 | int min = 1; | - | ||||||||||||||||||||||||||||||
620 | const QDate minDate = getMinimum().date(); | - | ||||||||||||||||||||||||||||||
621 | if (currentValue.date().year() == minDate.year()
| 17-1445 | ||||||||||||||||||||||||||||||
622 | min = minDate.month(); | - | ||||||||||||||||||||||||||||||
623 | } executed 17 times by 1 test: end of block Executed by:
| 17 | ||||||||||||||||||||||||||||||
624 | num = findMonth(sectiontext.toLower(), min, sectionIndex, §iontext, &used); | - | ||||||||||||||||||||||||||||||
625 | } executed 1462 times by 6 tests: else {end of block Executed by:
| 1462 | ||||||||||||||||||||||||||||||
626 | num = findDay(sectiontext.toLower(), 1, sectionIndex, §iontext, &used); | - | ||||||||||||||||||||||||||||||
627 | } executed 464 times by 3 tests: end of block Executed by:
| 464 | ||||||||||||||||||||||||||||||
628 | - | |||||||||||||||||||||||||||||||
629 | if (num != -1
| 5-1921 | ||||||||||||||||||||||||||||||
630 | state = (used == sectiontext.size()
| 107-1814 | ||||||||||||||||||||||||||||||
631 | text.replace(index, used, sectiontext.left(constData(), used));); | - | ||||||||||||||||||||||||||||||
632 | } executed 1921 times by 6 tests: else {end of block Executed by:
| 1921 | ||||||||||||||||||||||||||||||
633 | state = Intermediate; | - | ||||||||||||||||||||||||||||||
634 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||||||||||||||
635 | break; executed 1926 times by 6 tests: break; Executed by:
| 1926 | ||||||||||||||||||||||||||||||
636 | } | - | ||||||||||||||||||||||||||||||
637 | case executed 2691 times by 10 tests: DaySection:case DaySection: Executed by:
executed 2691 times by 10 tests: case DaySection: Executed by:
code before this statement executed 1733 times by 7 tests: case DaySection: Executed by:
| 1733-2691 | ||||||||||||||||||||||||||||||
638 | case executed 1932 times by 6 tests: YearSection:case YearSection: Executed by:
executed 1932 times by 6 tests: case YearSection: Executed by:
| 1932 | ||||||||||||||||||||||||||||||
639 | case executed 880 times by 7 tests: YearSection2Digits:case YearSection2Digits: Executed by:
executed 880 times by 7 tests: case YearSection2Digits: Executed by:
| 880 | ||||||||||||||||||||||||||||||
640 | case executed 820 times by 5 tests: Hour12Section:case Hour12Section: Executed by:
executed 820 times by 5 tests: case Hour12Section: Executed by:
| 820 | ||||||||||||||||||||||||||||||
641 | case executed 1246 times by 6 tests: Hour24Section:case Hour24Section: Executed by:
executed 1246 times by 6 tests: case Hour24Section: Executed by:
| 1246 | ||||||||||||||||||||||||||||||
642 | case executed 1886 times by 8 tests: MinuteSection:case MinuteSection: Executed by:
executed 1886 times by 8 tests: case MinuteSection: Executed by:
| 1886 | ||||||||||||||||||||||||||||||
643 | case executed 1703 times by 4 tests: SecondSection:case SecondSection: Executed by:
executed 1703 times by 4 tests: case SecondSection: Executed by:
| 1703 | ||||||||||||||||||||||||||||||
644 | case executed 219 times by 2 tests: MSecSection:case MSecSection: Executed by:
executed 219 times by 2 tests: {case MSecSection: Executed by:
| 219 | ||||||||||||||||||||||||||||||
645 | if (sectiontextSize == 0
| 17-13093 | ||||||||||||||||||||||||||||||
646 | num = 0; | - | ||||||||||||||||||||||||||||||
647 | used = 0; | - | ||||||||||||||||||||||||||||||
648 | state = Intermediate; | - | ||||||||||||||||||||||||||||||
649 | } executed 17 times by 2 tests: else {end of block Executed by:
| 17 | ||||||||||||||||||||||||||||||
650 | const int absMax = absoluteMax(sectionIndex); | - | ||||||||||||||||||||||||||||||
651 | QLocale loc; | - | ||||||||||||||||||||||||||||||
652 | bool ok = true; | - | ||||||||||||||||||||||||||||||
653 | int last = -1; | - | ||||||||||||||||||||||||||||||
654 | used = -1; | - | ||||||||||||||||||||||||||||||
655 | - | |||||||||||||||||||||||||||||||
656 | QStringQStringRef digitsStr (sectiontext);= sectionTextRef; | - | ||||||||||||||||||||||||||||||
657 | for (int i = 0; i < sectiontextSize
| 12847-29808 | ||||||||||||||||||||||||||||||
658 | if (digitsStr.at(i).isSpace()
| 246-29562 | ||||||||||||||||||||||||||||||
659 | sectiontextSize = i; | - | ||||||||||||||||||||||||||||||
660 | break; executed 246 times by 4 tests: break; Executed by:
| 246 | ||||||||||||||||||||||||||||||
661 | } | - | ||||||||||||||||||||||||||||||
662 | } executed 29562 times by 11 tests: end of block Executed by:
| 29562 | ||||||||||||||||||||||||||||||
663 | - | |||||||||||||||||||||||||||||||
664 | const int max = qMin(sectionmaxsize, sectiontextSize); | - | ||||||||||||||||||||||||||||||
665 | for (int digits = max; digits >= 1
| 48-14065 | ||||||||||||||||||||||||||||||
666 | digitsStr.truncate(digits); | - | ||||||||||||||||||||||||||||||
667 | int tmp = (int)loc.toUInt(digitsStr, &ok); | - | ||||||||||||||||||||||||||||||
668 | if (ok
| 822-13053 | ||||||||||||||||||||||||||||||
669 | if (tmp > 12
| 2-820 | ||||||||||||||||||||||||||||||
670 | tmp = -1; | - | ||||||||||||||||||||||||||||||
671 | ok = false; | - | ||||||||||||||||||||||||||||||
672 | } executed 2 times by 1 test: else if (tmp == 12end of block Executed by:
| 2-720 | ||||||||||||||||||||||||||||||
673 | tmp = 0; | - | ||||||||||||||||||||||||||||||
674 | } executed 100 times by 3 tests: end of block Executed by:
| 100 | ||||||||||||||||||||||||||||||
675 | } executed 822 times by 5 tests: end of block Executed by:
| 822 | ||||||||||||||||||||||||||||||
676 | if (ok
| 6-13051 | ||||||||||||||||||||||||||||||
677 | if (false) QMessageLogger(__FILE__, 806814, __PRETTY_FUNCTION__).debug() << sectiontextsectionTextRef.left(digits) << tmp << digits; dead code: QMessageLogger(__FILE__, 814, __PRETTY_FUNCTION__).debug() << sectionTextRef.left(digits) << tmp << digits; | - | ||||||||||||||||||||||||||||||
678 | last = tmp; | - | ||||||||||||||||||||||||||||||
679 | used = digits; | - | ||||||||||||||||||||||||||||||
680 | break; executed 13045 times by 11 tests: break; Executed by:
| 13045 | ||||||||||||||||||||||||||||||
681 | } | - | ||||||||||||||||||||||||||||||
682 | } executed 1020 times by 7 tests: end of block Executed by:
| 1020 | ||||||||||||||||||||||||||||||
683 | - | |||||||||||||||||||||||||||||||
684 | if (last == -1
| 48-13045 | ||||||||||||||||||||||||||||||
685 | QChar first(sectiontextsectionTextRef.at(0)); | - | ||||||||||||||||||||||||||||||
686 | if (separators.at(sectionIndex + 1).startsWith(first)
| 2-46 | ||||||||||||||||||||||||||||||
687 | used = 0; | - | ||||||||||||||||||||||||||||||
688 | state = Intermediate; | - | ||||||||||||||||||||||||||||||
689 | } executed 46 times by 2 tests: else {end of block Executed by:
| 46 | ||||||||||||||||||||||||||||||
690 | state = Invalid; | - | ||||||||||||||||||||||||||||||
691 | if (false) QMessageLogger(__FILE__, 820828, __PRETTY_FUNCTION__).debug() << "invalid because" << sectiontextsectionTextRef << "can't become a uint" << last << ok; dead code: QMessageLogger(__FILE__, 828, __PRETTY_FUNCTION__).debug() << "invalid because" << sectionTextRef << "can't become a uint" << last << ok; | - | ||||||||||||||||||||||||||||||
692 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||
693 | } else { | - | ||||||||||||||||||||||||||||||
694 | num += last; | - | ||||||||||||||||||||||||||||||
695 | const FieldInfo fi = fieldInfo(sectionIndex); | - | ||||||||||||||||||||||||||||||
696 | const bool done = (used == sectionmaxsize); | - | ||||||||||||||||||||||||||||||
697 | if (!done
| 1515-11530 | ||||||||||||||||||||||||||||||
698 | for (int i=used; i<sectionmaxsize
| 78-148 | ||||||||||||||||||||||||||||||
699 | num *= 10; | - | ||||||||||||||||||||||||||||||
700 | } executed 148 times by 1 test: end of block Executed by:
| 148 | ||||||||||||||||||||||||||||||
701 | } executed 78 times by 1 test: end of block Executed by:
| 78 | ||||||||||||||||||||||||||||||
702 | const int absMin = absoluteMin(sectionIndex); | - | ||||||||||||||||||||||||||||||
703 | if (num < absMin
| 25-13020 | ||||||||||||||||||||||||||||||
704 | state = done
| 3-22 | ||||||||||||||||||||||||||||||
705 | if (done
| 3-22 | ||||||||||||||||||||||||||||||
706 | if (false) QMessageLogger(__FILE__, 835843, __PRETTY_FUNCTION__).debug() << "invalid because" << num << "is less than absoluteMin" << absMin; dead code: QMessageLogger(__FILE__, 843, __PRETTY_FUNCTION__).debug() << "invalid because" << num << "is less than absoluteMin" << absMin; | - | ||||||||||||||||||||||||||||||
707 | } executed 25 times by 1 test: else if (num > absMaxend of block Executed by:
| 0-13020 | ||||||||||||||||||||||||||||||
708 | state = Intermediate; | - | ||||||||||||||||||||||||||||||
709 | } never executed: else if (!doneend of block
| 0-11527 | ||||||||||||||||||||||||||||||
710 | if (skipToNextSection(sectionIndex, currentValue, digitsStr)
| 27-438 | ||||||||||||||||||||||||||||||
711 | state = Acceptable; | - | ||||||||||||||||||||||||||||||
712 | const int missingZeroes = sectionmaxsize - digitsStr.size(); | - | ||||||||||||||||||||||||||||||
713 | text.insert(index, QString().fill(missingZeroes, QLatin1Char('0'), missingZeroes));))); | - | ||||||||||||||||||||||||||||||
714 | used = sectionmaxsize; | - | ||||||||||||||||||||||||||||||
715 | cursorPosition += missingZeroes; | - | ||||||||||||||||||||||||||||||
716 | ++(const_cast<QDateTimeParser*>(this)->sectionNodes[sectionIndex].zeroesAdded); | - | ||||||||||||||||||||||||||||||
717 | } executed 27 times by 1 test: else {end of block Executed by:
| 27 | ||||||||||||||||||||||||||||||
718 | state = Intermediate;; | - | ||||||||||||||||||||||||||||||
719 | } executed 438 times by 4 tests: end of block Executed by:
| 438 | ||||||||||||||||||||||||||||||
720 | } else { | - | ||||||||||||||||||||||||||||||
721 | state = Acceptable; | - | ||||||||||||||||||||||||||||||
722 | } executed 12555 times by 11 tests: end of block Executed by:
| 12555 | ||||||||||||||||||||||||||||||
723 | } | - | ||||||||||||||||||||||||||||||
724 | } | - | ||||||||||||||||||||||||||||||
725 | break; executed 13110 times by 11 tests: }break; Executed by:
| 13110 | ||||||||||||||||||||||||||||||
726 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
727 | QMessageLogger(__FILE__, 856864, __PRETTY_FUNCTION__).warning("QDateTimeParser::parseSection Internal error (%s %d)", | - | ||||||||||||||||||||||||||||||
728 | QString(sn.name()).toLocal8Bit().constData(), sectionIndex); | - | ||||||||||||||||||||||||||||||
729 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
730 | } | - | ||||||||||||||||||||||||||||||
731 | - | |||||||||||||||||||||||||||||||
732 | if (usedptr
| 0-15899 | ||||||||||||||||||||||||||||||
733 | * executed 15899 times by 11 tests: usedptr = used;*usedptr = used; Executed by:
executed 15899 times by 11 tests: *usedptr = used; Executed by:
| 15899 | ||||||||||||||||||||||||||||||
734 | - | |||||||||||||||||||||||||||||||
735 | return executed 15899 times by 11 tests: (state != Invalid ? num : -1);return (state != Invalid ? num : -1); Executed by:
executed 15899 times by 11 tests: return (state != Invalid ? num : -1); Executed by:
| 15899 | ||||||||||||||||||||||||||||||
736 | } | - | ||||||||||||||||||||||||||||||
737 | - | |||||||||||||||||||||||||||||||
738 | - | |||||||||||||||||||||||||||||||
739 | - | |||||||||||||||||||||||||||||||
740 | - | |||||||||||||||||||||||||||||||
741 | - | |||||||||||||||||||||||||||||||
742 | - | |||||||||||||||||||||||||||||||
743 | - | |||||||||||||||||||||||||||||||
744 | QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPosition, | - | ||||||||||||||||||||||||||||||
745 | const QDateTime ¤tValue, bool fixup) const | - | ||||||||||||||||||||||||||||||
746 | { | - | ||||||||||||||||||||||||||||||
747 | const QDateTime minimum = getMinimum(); | - | ||||||||||||||||||||||||||||||
748 | const QDateTime maximum = getMaximum(); | - | ||||||||||||||||||||||||||||||
749 | - | |||||||||||||||||||||||||||||||
750 | State state = Acceptable; | - | ||||||||||||||||||||||||||||||
751 | - | |||||||||||||||||||||||||||||||
752 | QDateTime newCurrentValue; | - | ||||||||||||||||||||||||||||||
753 | bool conflicts = false; | - | ||||||||||||||||||||||||||||||
754 | const int sectionNodesCount = sectionNodes.size(); | - | ||||||||||||||||||||||||||||||
755 | - | |||||||||||||||||||||||||||||||
756 | if (false) QMessageLogger(__FILE__, 885893, __PRETTY_FUNCTION__).debug() << "parse" << input; dead code: QMessageLogger(__FILE__, 893, __PRETTY_FUNCTION__).debug() << "parse" << input; | - | ||||||||||||||||||||||||||||||
757 | { | - | ||||||||||||||||||||||||||||||
758 | int pos = 0; | - | ||||||||||||||||||||||||||||||
759 | int year, month, day; | - | ||||||||||||||||||||||||||||||
760 | const QDate currentDate = currentValue.date().(); | - | ||||||||||||||||||||||||||||||
761 | const QTime currentTime = currentValue.time(); | - | ||||||||||||||||||||||||||||||
762 | currentDate.getDate(&year, &month, &day); | - | ||||||||||||||||||||||||||||||
763 | int year2digits = year % 100; | - | ||||||||||||||||||||||||||||||
764 | int hour = currentValuecurrentTime.time().hour(); | - | ||||||||||||||||||||||||||||||
765 | int hour12 = -1; | - | ||||||||||||||||||||||||||||||
766 | int minute = currentValuecurrentTime.time().minute(); | - | ||||||||||||||||||||||||||||||
767 | int second = currentValuecurrentTime.time().second(); | - | ||||||||||||||||||||||||||||||
768 | int msec = currentValuecurrentTime.time().msec(); | - | ||||||||||||||||||||||||||||||
769 | int dayofweek = currentValuecurrentDate.date().dayOfWeek(); | - | ||||||||||||||||||||||||||||||
770 | - | |||||||||||||||||||||||||||||||
771 | int ampm = -1; | - | ||||||||||||||||||||||||||||||
772 | Sections isSet = NoSection; | - | ||||||||||||||||||||||||||||||
773 | int num; | - | ||||||||||||||||||||||||||||||
774 | State tmpstate; | - | ||||||||||||||||||||||||||||||
775 | - | |||||||||||||||||||||||||||||||
776 | for (int index=0; state != Invalid
| 7-20637 | ||||||||||||||||||||||||||||||
777 | if (QStringRef(&input, pos, separators.at(index).size()) != separators.at(index)
| 122-15899 | ||||||||||||||||||||||||||||||
778 | if (false) QMessageLogger(__FILE__, 905915, __PRETTY_FUNCTION__).debug() << "invalid because" << input.midmidRef(pos, separators.at(index).size()) dead code: QMessageLogger(__FILE__, 915, __PRETTY_FUNCTION__).debug() << "invalid because" << input.midRef(pos, separators.at(index).size()) << "!=" << separators.at(index) << index << pos << currentSectionIndex; | - | ||||||||||||||||||||||||||||||
779 | << "!=" << separators.at(index) dead code: QMessageLogger(__FILE__, 915, __PRETTY_FUNCTION__).debug() << "invalid because" << input.midRef(pos, separators.at(index).size()) << "!=" << separators.at(index) << index << pos << currentSectionIndex; | - | ||||||||||||||||||||||||||||||
780 | << index << pos << currentSectionIndex; dead code: QMessageLogger(__FILE__, 915, __PRETTY_FUNCTION__).debug() << "invalid because" << input.midRef(pos, separators.at(index).size()) << "!=" << separators.at(index) << index << pos << currentSectionIndex; | - | ||||||||||||||||||||||||||||||
781 | state = Invalid; | - | ||||||||||||||||||||||||||||||
782 | goto executed 122 times by 2 tests: end;goto end; Executed by:
executed 122 times by 2 tests: goto end; Executed by:
| 122 | ||||||||||||||||||||||||||||||
783 | } | - | ||||||||||||||||||||||||||||||
784 | pos += separators.at(index).size(); | - | ||||||||||||||||||||||||||||||
785 | sectionNodes[index].pos = pos; | - | ||||||||||||||||||||||||||||||
786 | int *current = 0; | - | ||||||||||||||||||||||||||||||
787 | const SectionNode sn = sectionNodes.at(index); | - | ||||||||||||||||||||||||||||||
788 | int used; | - | ||||||||||||||||||||||||||||||
789 | - | |||||||||||||||||||||||||||||||
790 | num = parseSection(currentValue, index, input, cursorPosition, pos, tmpstate, &used); | - | ||||||||||||||||||||||||||||||
791 | if (false) QMessageLogger(__FILE__, 918928, __PRETTY_FUNCTION__).debug() << "sectionValue" << sn.name() << input dead code: QMessageLogger(__FILE__, 928, __PRETTY_FUNCTION__).debug() << "sectionValue" << sn.name() << input << "pos" << pos << "used" << used << stateName(tmpstate); | - | ||||||||||||||||||||||||||||||
792 | << "pos" << pos << "used" << used << stateName(tmpstate); dead code: QMessageLogger(__FILE__, 928, __PRETTY_FUNCTION__).debug() << "sectionValue" << sn.name() << input << "pos" << pos << "used" << used << stateName(tmpstate); | - | ||||||||||||||||||||||||||||||
793 | if (fixup
| 1-15826 | ||||||||||||||||||||||||||||||
794 | const FieldInfo fi = fieldInfo(index); | - | ||||||||||||||||||||||||||||||
795 | if ((
| 3-17 | ||||||||||||||||||||||||||||||
796 | const QString newText = QString::fromLatin1("%1").arg(num, sn.count, 10, QLatin1Char('0')); | - | ||||||||||||||||||||||||||||||
797 | input.replace(pos, used, newText); | - | ||||||||||||||||||||||||||||||
798 | used = sn.count; | - | ||||||||||||||||||||||||||||||
799 | } executed 17 times by 1 test: end of block Executed by:
| 17 | ||||||||||||||||||||||||||||||
800 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||||||||||||||
801 | pos += qMax(0, used); | - | ||||||||||||||||||||||||||||||
802 | - | |||||||||||||||||||||||||||||||
803 | state = qMin<State>(state, tmpstate); | - | ||||||||||||||||||||||||||||||
804 | if (state == Intermediate
| 12-14546 | ||||||||||||||||||||||||||||||
805 | state = Invalid; | - | ||||||||||||||||||||||||||||||
806 | break; executed 12 times by 4 tests: break; Executed by:
| 12 | ||||||||||||||||||||||||||||||
807 | } | - | ||||||||||||||||||||||||||||||
808 | - | |||||||||||||||||||||||||||||||
809 | if (false) QMessageLogger(__FILE__, 936946, __PRETTY_FUNCTION__).debug() << index << sn.name() << "is set to" dead code: QMessageLogger(__FILE__, 946, __PRETTY_FUNCTION__).debug() << index << sn.name() << "is set to" << pos << "state is" << stateName(state); | - | ||||||||||||||||||||||||||||||
810 | << pos << "state is" << stateName(state); dead code: QMessageLogger(__FILE__, 946, __PRETTY_FUNCTION__).debug() << index << sn.name() << "is set to" << pos << "state is" << stateName(state); | - | ||||||||||||||||||||||||||||||
811 | - | |||||||||||||||||||||||||||||||
812 | - | |||||||||||||||||||||||||||||||
813 | if (state != Invalid
| 7-15880 | ||||||||||||||||||||||||||||||
814 | switch (sn.type) { | - | ||||||||||||||||||||||||||||||
815 | case executed 1245 times by 6 tests: Hour24Section:case Hour24Section: Executed by:
executed 1245 times by 6 tests: current = &hour; break;case Hour24Section: Executed by:
executed 1245 times by 6 tests: break; Executed by:
| 1245 | ||||||||||||||||||||||||||||||
816 | case executed 820 times by 5 tests: Hour12Section:case Hour12Section: Executed by:
executed 820 times by 5 tests: current = &hour12; break;case Hour12Section: Executed by:
executed 820 times by 5 tests: break; Executed by:
| 820 | ||||||||||||||||||||||||||||||
817 | case executed 1885 times by 8 tests: MinuteSection:case MinuteSection: Executed by:
executed 1885 times by 8 tests: current = &minute; break;case MinuteSection: Executed by:
executed 1885 times by 8 tests: break; Executed by:
| 1885 | ||||||||||||||||||||||||||||||
818 | case executed 1703 times by 4 tests: SecondSection:case SecondSection: Executed by:
executed 1703 times by 4 tests: current = &second; break;case SecondSection: Executed by:
executed 1703 times by 4 tests: break; Executed by:
| 1703 | ||||||||||||||||||||||||||||||
819 | case executed 219 times by 2 tests: MSecSection:case MSecSection: Executed by:
executed 219 times by 2 tests: current = &msec; break;case MSecSection: Executed by:
executed 219 times by 2 tests: break; Executed by:
| 219 | ||||||||||||||||||||||||||||||
820 | case executed 1932 times by 6 tests: YearSection:case YearSection: Executed by:
executed 1932 times by 6 tests: current = &year; break;case YearSection: Executed by:
executed 1932 times by 6 tests: break; Executed by:
| 1932 | ||||||||||||||||||||||||||||||
821 | case executed 879 times by 7 tests: YearSection2Digits:case YearSection2Digits: Executed by:
executed 879 times by 7 tests: current = &year2digits; break;case YearSection2Digits: Executed by:
executed 879 times by 7 tests: break; Executed by:
| 879 | ||||||||||||||||||||||||||||||
822 | case executed 3192 times by 10 tests: MonthSection:case MonthSection: Executed by:
executed 3192 times by 10 tests: current = &month; break;case MonthSection: Executed by:
executed 3192 times by 10 tests: break; Executed by:
| 3192 | ||||||||||||||||||||||||||||||
823 | case executed 40 times by 3 tests: DayOfWeekSectionShort:case DayOfWeekSectionShort: Executed by:
executed 40 times by 3 tests: case DayOfWeekSectionShort: Executed by:
| 40 | ||||||||||||||||||||||||||||||
824 | case executed 424 times by 3 tests: DayOfWeekSectionLong:case DayOfWeekSectionLong: Executed by:
executed 424 times by 3 tests: current = &dayofweek; break;case DayOfWeekSectionLong: Executed by:
executed 464 times by 3 tests: break; Executed by:
| 424-464 | ||||||||||||||||||||||||||||||
825 | case executed 2680 times by 10 tests: DaySection:case DaySection: Executed by:
executed 2680 times by 10 tests: current = &day; num = qMax<int>(1, num); break;case DaySection: Executed by:
executed 2680 times by 10 tests: break; Executed by:
| 2680 | ||||||||||||||||||||||||||||||
826 | case executed 861 times by 5 tests: AmPmSection:case AmPmSection: Executed by:
executed 861 times by 5 tests: current = &m; break;case AmPmSection: Executed by:
executed 861 times by 5 tests: break; Executed by:
| 861 | ||||||||||||||||||||||||||||||
827 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
828 | QMessageLogger(__FILE__, 955965, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error (%s)", | - | ||||||||||||||||||||||||||||||
829 | QString(sn.name()).toLocal8Bit().constData()); | - | ||||||||||||||||||||||||||||||
830 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
831 | } | - | ||||||||||||||||||||||||||||||
832 | if (!current
| 0-15880 | ||||||||||||||||||||||||||||||
833 | QMessageLogger(__FILE__, 960970, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 2"); | - | ||||||||||||||||||||||||||||||
834 | return never executed: StateNode();return StateNode(); never executed: return StateNode(); | 0 | ||||||||||||||||||||||||||||||
835 | } | - | ||||||||||||||||||||||||||||||
836 | if (isSet & sn.type && *
| 101-416 | ||||||||||||||||||||||||||||||
837 | if (false) QMessageLogger(__FILE__, 964974, __PRETTY_FUNCTION__).debug() << "CONFLICT " << sn.name() << *current << num; dead code: QMessageLogger(__FILE__, 974, __PRETTY_FUNCTION__).debug() << "CONFLICT " << sn.name() << *current << num; | - | ||||||||||||||||||||||||||||||
838 | conflicts = true; | - | ||||||||||||||||||||||||||||||
839 | if (index != currentSectionIndex
| 0-96 | ||||||||||||||||||||||||||||||
840 | continue; executed 96 times by 3 tests: continue; Executed by:
| 96 | ||||||||||||||||||||||||||||||
841 | } | - | ||||||||||||||||||||||||||||||
842 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||||||||||||||
843 | if (num != -1
| 5-15779 | ||||||||||||||||||||||||||||||
844 | * executed 15779 times by 11 tests: current = num;*current = num; Executed by:
executed 15779 times by 11 tests: *current = num; Executed by:
| 15779 | ||||||||||||||||||||||||||||||
845 | isSet |= sn.type; | - | ||||||||||||||||||||||||||||||
846 | } executed 15784 times by 11 tests: end of block Executed by:
| 15784 | ||||||||||||||||||||||||||||||
847 | } executed 15791 times by 11 tests: end of block Executed by:
| 15791 | ||||||||||||||||||||||||||||||
848 | - | |||||||||||||||||||||||||||||||
849 | if (state != Invalid
| 15-4616 | ||||||||||||||||||||||||||||||
850 | if (false) QMessageLogger(__FILE__, 977987, __PRETTY_FUNCTION__).debug() << "invalid because" << input.midmidRef(pos) dead code: QMessageLogger(__FILE__, 987, __PRETTY_FUNCTION__).debug() << "invalid because" << input.midRef(pos) << "!=" << separators.last() << pos; | - | ||||||||||||||||||||||||||||||
851 | << "!=" << separators.last() << pos; dead code: QMessageLogger(__FILE__, 987, __PRETTY_FUNCTION__).debug() << "invalid because" << input.midRef(pos) << "!=" << separators.last() << pos; | - | ||||||||||||||||||||||||||||||
852 | state = Invalid; | - | ||||||||||||||||||||||||||||||
853 | } executed 15 times by 4 tests: end of block Executed by:
| 15 | ||||||||||||||||||||||||||||||
854 | - | |||||||||||||||||||||||||||||||
855 | if (state != Invalid
| 34-4601 | ||||||||||||||||||||||||||||||
856 | if (parserType != QVariant::Time
| 23-4578 | ||||||||||||||||||||||||||||||
857 | if (year % 100 != year2digits
| 359-4219 | ||||||||||||||||||||||||||||||
858 | if (!(isSet & YearSection)
| 1-16 | ||||||||||||||||||||||||||||||
859 | year = (year / 100) * 100; | - | ||||||||||||||||||||||||||||||
860 | year += year2digits; | - | ||||||||||||||||||||||||||||||
861 | } executed 16 times by 4 tests: else {end of block Executed by:
| 16 | ||||||||||||||||||||||||||||||
862 | conflicts = true; | - | ||||||||||||||||||||||||||||||
863 | const SectionNode &sn = sectionNode(currentSectionIndex); | - | ||||||||||||||||||||||||||||||
864 | if (sn.type == YearSection2Digits
| 0-1 | ||||||||||||||||||||||||||||||
865 | year = (year / 100) * 100; | - | ||||||||||||||||||||||||||||||
866 | year += year2digits; | - | ||||||||||||||||||||||||||||||
867 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
868 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||||||||
869 | } | - | ||||||||||||||||||||||||||||||
870 | - | |||||||||||||||||||||||||||||||
871 | const QDate date(year, month, day); | - | ||||||||||||||||||||||||||||||
872 | const int diff = dayofweek - date.dayOfWeek(); | - | ||||||||||||||||||||||||||||||
873 | if (diff != 0
| 209-4054 | ||||||||||||||||||||||||||||||
874 | if (isSet & DaySection
| 2-26 | ||||||||||||||||||||||||||||||
875 | conflicts = true; executed 2 times by 1 test: conflicts = true; Executed by:
| 2 | ||||||||||||||||||||||||||||||
876 | const SectionNode &sn = sectionNode(currentSectionIndex); | - | ||||||||||||||||||||||||||||||
877 | if (sn.type & DayOfWeekSectionMask
| 0-28 | ||||||||||||||||||||||||||||||
878 | - | |||||||||||||||||||||||||||||||
879 | day += diff; | - | ||||||||||||||||||||||||||||||
880 | if (day <= 0
| 6-8 | ||||||||||||||||||||||||||||||
881 | day += 7; | - | ||||||||||||||||||||||||||||||
882 | } executed 8 times by 2 tests: else if (day > date.daysInMonth()end of block Executed by:
| 0-8 | ||||||||||||||||||||||||||||||
883 | day -= 7; | - | ||||||||||||||||||||||||||||||
884 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
885 | if (false) QMessageLogger(__FILE__, 10121022, __PRETTY_FUNCTION__).debug() << year << month << day << dayofweek dead code: QMessageLogger(__FILE__, 1022, __PRETTY_FUNCTION__).debug() << year << month << day << dayofweek << diff << QDate(year, month, day).dayOfWeek(); | - | ||||||||||||||||||||||||||||||
886 | << diff << QDate(year, month, day).dayOfWeek(); dead code: QMessageLogger(__FILE__, 1022, __PRETTY_FUNCTION__).debug() << year << month << day << dayofweek << diff << QDate(year, month, day).dayOfWeek(); | - | ||||||||||||||||||||||||||||||
887 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||||||||||||||||||||
888 | } executed 28 times by 3 tests: end of block Executed by:
| 28 | ||||||||||||||||||||||||||||||
889 | - | |||||||||||||||||||||||||||||||
890 | bool needfixday = false; | - | ||||||||||||||||||||||||||||||
891 | if (sectionType(currentSectionIndex) & DaySectionMask
| 1257-3321 | ||||||||||||||||||||||||||||||
892 | cachedDay = day; | - | ||||||||||||||||||||||||||||||
893 | } executed 1257 times by 1 test: else if (cachedDay > dayend of block Executed by:
| 12-3309 | ||||||||||||||||||||||||||||||
894 | day = cachedDay; | - | ||||||||||||||||||||||||||||||
895 | needfixday = true; | - | ||||||||||||||||||||||||||||||
896 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||||||||
897 | - | |||||||||||||||||||||||||||||||
898 | if (!QDate::isValid(year, month, day)
| 88-4490 | ||||||||||||||||||||||||||||||
899 | if (day < 32
| 0-88 | ||||||||||||||||||||||||||||||
900 | cachedDay = day; | - | ||||||||||||||||||||||||||||||
901 | } executed 88 times by 2 tests: end of block Executed by:
| 88 | ||||||||||||||||||||||||||||||
902 | if (day > 28
| 0-51 | ||||||||||||||||||||||||||||||
903 | needfixday = true; | - | ||||||||||||||||||||||||||||||
904 | } executed 51 times by 2 tests: end of block Executed by:
| 51 | ||||||||||||||||||||||||||||||
905 | } executed 88 times by 2 tests: end of block Executed by:
| 88 | ||||||||||||||||||||||||||||||
906 | if (needfixday
| 51-4527 | ||||||||||||||||||||||||||||||
907 | if (context == FromString
| 1-50 | ||||||||||||||||||||||||||||||
908 | state = Invalid; | - | ||||||||||||||||||||||||||||||
909 | goto executed 1 time by 1 test: end;goto end; Executed by:
executed 1 time by 1 test: goto end; Executed by:
| 1 | ||||||||||||||||||||||||||||||
910 | } | - | ||||||||||||||||||||||||||||||
911 | if (state == Acceptable
| 0-50 | ||||||||||||||||||||||||||||||
912 | day = qMin<int>(day, QDate(year, month, 1).daysInMonth()); | - | ||||||||||||||||||||||||||||||
913 | - | |||||||||||||||||||||||||||||||
914 | const QLocale loc = locale(); | - | ||||||||||||||||||||||||||||||
915 | for (int i=0; i<sectionNodesCount
| 50-149 | ||||||||||||||||||||||||||||||
916 | const SectionNode sn = sectionNode(i); | - | ||||||||||||||||||||||||||||||
917 | if (sn.type & DaySection
| 38-111 | ||||||||||||||||||||||||||||||
918 | input.replace(sectionPos(sn), sectionSize(i), loc.toString(day)); | - | ||||||||||||||||||||||||||||||
919 | } executed 38 times by 1 test: else if (sn.type & DayOfWeekSectionMaskend of block Executed by:
| 14-97 | ||||||||||||||||||||||||||||||
920 | const int dayOfWeek = QDate(year, month, day).dayOfWeek(); | - | ||||||||||||||||||||||||||||||
921 | const QLocale::FormatType dayFormat = | - | ||||||||||||||||||||||||||||||
922 | (sn.type == DayOfWeekSectionShort
| 1-13 | ||||||||||||||||||||||||||||||
923 | ? QLocale::ShortFormat : QLocale::LongFormat); | - | ||||||||||||||||||||||||||||||
924 | const QString dayName(loc.dayName(dayOfWeek, dayFormat)); | - | ||||||||||||||||||||||||||||||
925 | input.replace(sectionPos(sn), sectionSize(i), dayName); | - | ||||||||||||||||||||||||||||||
926 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||||||||
927 | } executed 149 times by 1 test: end of block Executed by:
| 149 | ||||||||||||||||||||||||||||||
928 | } executed 50 times by 1 test: else {end of block Executed by:
| 50 | ||||||||||||||||||||||||||||||
929 | state = qMin(Intermediate, state); | - | ||||||||||||||||||||||||||||||
930 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
931 | } | - | ||||||||||||||||||||||||||||||
932 | } executed 4577 times by 10 tests: end of block Executed by:
| 4577 | ||||||||||||||||||||||||||||||
933 | - | |||||||||||||||||||||||||||||||
934 | if (parserType != QVariant::Date
| 919-3681 | ||||||||||||||||||||||||||||||
935 | if (isSet & Hour12Section
| 808-2873 | ||||||||||||||||||||||||||||||
936 | const bool hasHour = isSet & Hour24Section; | - | ||||||||||||||||||||||||||||||
937 | if (ampm == -1
| 0-808 | ||||||||||||||||||||||||||||||
938 | if (hasHour
| 0 | ||||||||||||||||||||||||||||||
939 | ampm = (hour < 12
| 0 | ||||||||||||||||||||||||||||||
940 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
941 | ampm = 0; | - | ||||||||||||||||||||||||||||||
942 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
943 | } | - | ||||||||||||||||||||||||||||||
944 | hour12 = (ampm == 0
| 78-730 | ||||||||||||||||||||||||||||||
945 | if (!hasHour
| 2-806 | ||||||||||||||||||||||||||||||
946 | hour = hour12; | - | ||||||||||||||||||||||||||||||
947 | } executed 806 times by 5 tests: else if (hour != hour12end of block Executed by:
| 0-806 | ||||||||||||||||||||||||||||||
948 | conflicts = true; | - | ||||||||||||||||||||||||||||||
949 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
950 | } executed 808 times by 5 tests: else if (ampm != -1end of block Executed by:
| 51-2822 | ||||||||||||||||||||||||||||||
951 | if (!(isSet & (Hour24Section))
| 3-48 | ||||||||||||||||||||||||||||||
952 | hour = (12 * ampm); | - | ||||||||||||||||||||||||||||||
953 | } executed 3 times by 2 tests: else if ((end of block Executed by:
| 0-48 | ||||||||||||||||||||||||||||||
954 | conflicts = true; | - | ||||||||||||||||||||||||||||||
955 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
956 | } executed 51 times by 3 tests: end of block Executed by:
| 51 | ||||||||||||||||||||||||||||||
957 | - | |||||||||||||||||||||||||||||||
958 | } executed 3681 times by 9 tests: end of block Executed by:
| 3681 | ||||||||||||||||||||||||||||||
959 | - | |||||||||||||||||||||||||||||||
960 | newCurrentValue = QDateTime(QDate(year, month, day), QTime(hour, minute, second, msec), spec); | - | ||||||||||||||||||||||||||||||
961 | if (false) QMessageLogger(__FILE__, 10881098, __PRETTY_FUNCTION__).debug() << year << month << day << hour << minute << second << msec; dead code: QMessageLogger(__FILE__, 1098, __PRETTY_FUNCTION__).debug() << year << month << day << hour << minute << second << msec; | - | ||||||||||||||||||||||||||||||
962 | } executed 4600 times by 11 tests: end of block Executed by:
| 4600 | ||||||||||||||||||||||||||||||
963 | if (false) QMessageLogger(__FILE__, 10901100, __PRETTY_FUNCTION__).debug("'%s' => '%s'(%s)", input.toLatin1().constData(), dead code: QMessageLogger(__FILE__, 1100, __PRETTY_FUNCTION__).debug("'%s' => '%s'(%s)", input.toLatin1().constData(), newCurrentValue.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")).toLatin1().constData(), stateName(state).toLatin1().constData()); | - | ||||||||||||||||||||||||||||||
964 | newCurrentValue.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")).toLatin1().constData(), dead code: QMessageLogger(__FILE__, 1100, __PRETTY_FUNCTION__).debug("'%s' => '%s'(%s)", input.toLatin1().constData(), newCurrentValue.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")).toLatin1().constData(), stateName(state).toLatin1().constData()); | - | ||||||||||||||||||||||||||||||
965 | stateName(state).toLatin1().constData()); dead code: QMessageLogger(__FILE__, 1100, __PRETTY_FUNCTION__).debug("'%s' => '%s'(%s)", input.toLatin1().constData(), newCurrentValue.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")).toLatin1().constData(), stateName(state).toLatin1().constData()); | - | ||||||||||||||||||||||||||||||
966 | } | - | ||||||||||||||||||||||||||||||
967 | end: code before this statement executed 4634 times by 11 tests: end: Executed by:
| 4634 | ||||||||||||||||||||||||||||||
968 | if (newCurrentValue.isValid()
| 194-4563 | ||||||||||||||||||||||||||||||
969 | if (context != FromString
| 0-4098 | ||||||||||||||||||||||||||||||
970 | const QLatin1Char space(' '); | - | ||||||||||||||||||||||||||||||
971 | if (newCurrentValue >= minimum
| 0-53 | ||||||||||||||||||||||||||||||
972 | QMessageLogger(__FILE__, 10991109, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 3 (%s %s)", never executed: QMessageLogger(__FILE__, 1109, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 3 (%s %s)", QString(newCurrentValue.toString()).toLocal8Bit().constData(), QString(minimum.toString()).toLocal8Bit().constData()); | 0 | ||||||||||||||||||||||||||||||
973 | QString(newCurrentValue.toString()).toLocal8Bit().constData(), QString(minimum.toString()).toLocal8Bit().constData()); never executed: QMessageLogger(__FILE__, 1109, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 3 (%s %s)", QString(newCurrentValue.toString()).toLocal8Bit().constData(), QString(minimum.toString()).toLocal8Bit().constData()); | 0 | ||||||||||||||||||||||||||||||
974 | - | |||||||||||||||||||||||||||||||
975 | bool done = false; | - | ||||||||||||||||||||||||||||||
976 | state = Invalid; | - | ||||||||||||||||||||||||||||||
977 | for (int i=0; i<sectionNodesCount
| 9-138 | ||||||||||||||||||||||||||||||
978 | const SectionNode &sn = sectionNodes.at(i); | - | ||||||||||||||||||||||||||||||
979 | QString t = sectionText(input, i, sn.pos).toLower(); | - | ||||||||||||||||||||||||||||||
980 | if ((t.size() < sectionMaxSize(i)
| 0-74 | ||||||||||||||||||||||||||||||
981 | || t.contains(space)
| 0-74 | ||||||||||||||||||||||||||||||
982 | switch (sn.type) { | - | ||||||||||||||||||||||||||||||
983 | case never executed: AmPmSection:case AmPmSection: never executed: case AmPmSection: | 0 | ||||||||||||||||||||||||||||||
984 | switch (findAmPm(t, i)) { | - | ||||||||||||||||||||||||||||||
985 | case never executed: AM:case AM: never executed: case AM: | 0 | ||||||||||||||||||||||||||||||
986 | case never executed: PM:case PM: never executed: case PM: | 0 | ||||||||||||||||||||||||||||||
987 | state = Acceptable; | - | ||||||||||||||||||||||||||||||
988 | done = true; | - | ||||||||||||||||||||||||||||||
989 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
990 | case never executed: Neither:case Neither: never executed: case Neither: | 0 | ||||||||||||||||||||||||||||||
991 | state = Invalid; | - | ||||||||||||||||||||||||||||||
992 | done = true; | - | ||||||||||||||||||||||||||||||
993 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
994 | case never executed: PossibleAM:case PossibleAM: never executed: case PossibleAM: | 0 | ||||||||||||||||||||||||||||||
995 | case never executed: PossiblePM:case PossiblePM: never executed: case PossiblePM: | 0 | ||||||||||||||||||||||||||||||
996 | case never executed: PossibleBoth:case PossibleBoth: never executed: {case PossibleBoth: | 0 | ||||||||||||||||||||||||||||||
997 | const QDateTime copy(newCurrentValue.addSecs(12 * 60 * 60)); | - | ||||||||||||||||||||||||||||||
998 | if (copy >= minimum
| 0 | ||||||||||||||||||||||||||||||
999 | state = Intermediate; | - | ||||||||||||||||||||||||||||||
1000 | done = true; | - | ||||||||||||||||||||||||||||||
1001 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1002 | break; never executed: }break; | 0 | ||||||||||||||||||||||||||||||
1003 | } | - | ||||||||||||||||||||||||||||||
1004 | case executed 3 times by 1 test: case MonthSection: Executed by:
code before this statement never executed: case MonthSection: executed 3 times by 1 test: MonthSection:case MonthSection: Executed by:
code before this statement never executed: case MonthSection: executed 3 times by 1 test: case MonthSection: Executed by:
| 0-3 | ||||||||||||||||||||||||||||||
1005 | if (sn.count >= 3
| 0-3 | ||||||||||||||||||||||||||||||
1006 | const int tmpcurrentMonth = newCurrentValue.date().month(); | - | ||||||||||||||||||||||||||||||
1007 | int tmp = currentMonth; | - | ||||||||||||||||||||||||||||||
1008 | - | |||||||||||||||||||||||||||||||
1009 | while ((
| 3-6 | ||||||||||||||||||||||||||||||
1010 | const QDateTime copy(newCurrentValue.addMonths(tmp - newCurrentValue.date().month()));currentMonth)); | - | ||||||||||||||||||||||||||||||
1011 | if (copy >= minimum
| 0-6 | ||||||||||||||||||||||||||||||
1012 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
1013 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||||||||
1014 | if (tmp == -1
| 0-3 | ||||||||||||||||||||||||||||||
1015 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||||||||||||||
1016 | } | - | ||||||||||||||||||||||||||||||
1017 | state = Intermediate; | - | ||||||||||||||||||||||||||||||
1018 | done = true; | - | ||||||||||||||||||||||||||||||
1019 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
1020 | } | - | ||||||||||||||||||||||||||||||
1021 | - | |||||||||||||||||||||||||||||||
1022 | default executed 52 times by 1 test: default: Executed by:
code before this statement never executed: default: executed 52 times by 1 test: :default: Executed by:
code before this statement never executed: default: executed 52 times by 1 test: {default: Executed by:
| 0-52 | ||||||||||||||||||||||||||||||
1023 | int toMin; | - | ||||||||||||||||||||||||||||||
1024 | int toMax; | - | ||||||||||||||||||||||||||||||
1025 | - | |||||||||||||||||||||||||||||||
1026 | if (sn.type & TimeSectionMask
| 20-32 | ||||||||||||||||||||||||||||||
1027 | if (newCurrentValue.daysTo(minimum) != 0
| 0-20 | ||||||||||||||||||||||||||||||
1028 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
1029 | } | - | ||||||||||||||||||||||||||||||
1030 | toMinconst QTime time = newCurrentValue.time().(); | - | ||||||||||||||||||||||||||||||
1031 | toMin = time.msecsTo(minimum.time()); | - | ||||||||||||||||||||||||||||||
1032 | if (newCurrentValue.daysTo(maximum) > 0
| 0-20 | ||||||||||||||||||||||||||||||
1033 | toMax = -1; | - | ||||||||||||||||||||||||||||||
1034 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
1035 | toMax = newCurrentValue.time()..msecsTo(maximum.time()); | - | ||||||||||||||||||||||||||||||
1036 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||||||||||||||
1037 | } else { | - | ||||||||||||||||||||||||||||||
1038 | toMin = newCurrentValue.daysTo(minimum); | - | ||||||||||||||||||||||||||||||
1039 | toMax = newCurrentValue.daysTo(maximum); | - | ||||||||||||||||||||||||||||||
1040 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||||||||||||||||||||
1041 | const int maxChange = sn.maxChange(); | - | ||||||||||||||||||||||||||||||
1042 | if (toMin > maxChange
| 0-52 | ||||||||||||||||||||||||||||||
1043 | if (false) QMessageLogger(__FILE__, 11681180, __PRETTY_FUNCTION__).debug() << "invalid because toMin > maxChange" << toMin dead code: QMessageLogger(__FILE__, 1180, __PRETTY_FUNCTION__).debug() << "invalid because toMin > maxChange" << toMin << maxChange << t << newCurrentValue << minimum; | - | ||||||||||||||||||||||||||||||
1044 | << maxChange << t << newCurrentValue << minimum; dead code: QMessageLogger(__FILE__, 1180, __PRETTY_FUNCTION__).debug() << "invalid because toMin > maxChange" << toMin << maxChange << t << newCurrentValue << minimum; | - | ||||||||||||||||||||||||||||||
1045 | state = Invalid; | - | ||||||||||||||||||||||||||||||
1046 | done = true; | - | ||||||||||||||||||||||||||||||
1047 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
1048 | } else if (toMax > maxChange
| 14-38 | ||||||||||||||||||||||||||||||
1049 | toMax = -1; | - | ||||||||||||||||||||||||||||||
1050 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||||||||
1051 | - | |||||||||||||||||||||||||||||||
1052 | const int min = getDigit(minimum, i); | - | ||||||||||||||||||||||||||||||
1053 | if (min == -1
| 0-52 | ||||||||||||||||||||||||||||||
1054 | QMessageLogger(__FILE__, 11791191, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 4 (%s)", | - | ||||||||||||||||||||||||||||||
1055 | QString(sn.name()).toLocal8Bit().constData()); | - | ||||||||||||||||||||||||||||||
1056 | state = Invalid; | - | ||||||||||||||||||||||||||||||
1057 | done = true; | - | ||||||||||||||||||||||||||||||
1058 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
1059 | } | - | ||||||||||||||||||||||||||||||
1060 | - | |||||||||||||||||||||||||||||||
1061 | int max = toMax != -1
| 14-38 | ||||||||||||||||||||||||||||||
1062 | int pos = cursorPosition - sn.pos; | - | ||||||||||||||||||||||||||||||
1063 | if (pos < 0
| 4-48 | ||||||||||||||||||||||||||||||
1064 | pos = -1; executed 45 times by 1 test: pos = -1; Executed by:
| 45 | ||||||||||||||||||||||||||||||
1065 | if (!potentialValue(t.simplified(), min, max, i, newCurrentValue, pos)
| 2-50 | ||||||||||||||||||||||||||||||
1066 | if (false) QMessageLogger(__FILE__, 11911203, __PRETTY_FUNCTION__).debug() << "invalid because potentialValue(" << t.simplified() << min << max dead code: QMessageLogger(__FILE__, 1203, __PRETTY_FUNCTION__).debug() << "invalid because potentialValue(" << t.simplified() << min << max << sn.name() << "returned" << toMax << toMin << pos; | - | ||||||||||||||||||||||||||||||
1067 | << sn.name() << "returned" << toMax << toMin << pos; dead code: QMessageLogger(__FILE__, 1203, __PRETTY_FUNCTION__).debug() << "invalid because potentialValue(" << t.simplified() << min << max << sn.name() << "returned" << toMax << toMin << pos; | - | ||||||||||||||||||||||||||||||
1068 | state = Invalid; | - | ||||||||||||||||||||||||||||||
1069 | done = true; | - | ||||||||||||||||||||||||||||||
1070 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||||||||
1071 | } | - | ||||||||||||||||||||||||||||||
1072 | state = Intermediate; | - | ||||||||||||||||||||||||||||||
1073 | done = true; | - | ||||||||||||||||||||||||||||||
1074 | break; executed 50 times by 1 test: }break; Executed by:
| 50 | ||||||||||||||||||||||||||||||
1075 | } | - | ||||||||||||||||||||||||||||||
1076 | } | - | ||||||||||||||||||||||||||||||
1077 | } executed 129 times by 1 test: end of block Executed by:
| 129 | ||||||||||||||||||||||||||||||
1078 | } executed 53 times by 1 test: else {end of block Executed by:
| 53 | ||||||||||||||||||||||||||||||
1079 | if (context == FromString
| 465-4045 | ||||||||||||||||||||||||||||||
1080 | - | |||||||||||||||||||||||||||||||
1081 | ((!(getMaximum().date().toJulianDay() == 4642999)) ? qt_assert("getMaximum().date().toJulianDay() == 4642999",__FILE__,12061218) : qt_noop()); | - | ||||||||||||||||||||||||||||||
1082 | if (newCurrentValue.date().toJulianDay() > 4642999
| 0-465 | ||||||||||||||||||||||||||||||
1083 | state = Invalid; never executed: state = Invalid; | 0 | ||||||||||||||||||||||||||||||
1084 | } executed 465 times by 8 tests: else {end of block Executed by:
| 465 | ||||||||||||||||||||||||||||||
1085 | if (newCurrentValue > getMaximum()
| 1-4044 | ||||||||||||||||||||||||||||||
1086 | state = Invalid; executed 1 time by 1 test: state = Invalid; Executed by:
| 1 | ||||||||||||||||||||||||||||||
1087 | } executed 4045 times by 4 tests: end of block Executed by:
| 4045 | ||||||||||||||||||||||||||||||
1088 | - | |||||||||||||||||||||||||||||||
1089 | if (false) QMessageLogger(__FILE__, 12141226, __PRETTY_FUNCTION__).debug() << "not checking intermediate because newCurrentValue is" << newCurrentValue << getMinimum() << getMaximum(); dead code: QMessageLogger(__FILE__, 1226, __PRETTY_FUNCTION__).debug() << "not checking intermediate because newCurrentValue is" << newCurrentValue << getMinimum() << getMaximum(); | - | ||||||||||||||||||||||||||||||
1090 | } executed 4510 times by 11 tests: end of block Executed by:
| 4510 | ||||||||||||||||||||||||||||||
1091 | } | - | ||||||||||||||||||||||||||||||
1092 | StateNode node; | - | ||||||||||||||||||||||||||||||
1093 | node.input = input; | - | ||||||||||||||||||||||||||||||
1094 | node.state = state; | - | ||||||||||||||||||||||||||||||
1095 | node.conflicts = conflicts; | - | ||||||||||||||||||||||||||||||
1096 | node.value = newCurrentValue.toTimeSpec(spec); | - | ||||||||||||||||||||||||||||||
1097 | text = input; | - | ||||||||||||||||||||||||||||||
1098 | return executed 4757 times by 11 tests: node;return node; Executed by:
executed 4757 times by 11 tests: return node; Executed by:
| 4757 | ||||||||||||||||||||||||||||||
1099 | } | - | ||||||||||||||||||||||||||||||
1100 | int QDateTimeParser::findMonth(const QString &str1, int startMonth, int sectionIndex, | - | ||||||||||||||||||||||||||||||
1101 | QString *usedMonth, int *used) const | - | ||||||||||||||||||||||||||||||
1102 | { | - | ||||||||||||||||||||||||||||||
1103 | int bestMatch = -1; | - | ||||||||||||||||||||||||||||||
1104 | int bestCount = 0; | - | ||||||||||||||||||||||||||||||
1105 | if (!str1.isEmpty()
| 0-1471 | ||||||||||||||||||||||||||||||
1106 | const SectionNode &sn = sectionNode(sectionIndex); | - | ||||||||||||||||||||||||||||||
1107 | if (sn.type != MonthSection
| 0-1471 | ||||||||||||||||||||||||||||||
1108 | QMessageLogger(__FILE__, 12421254, __PRETTY_FUNCTION__).warning("QDateTimeParser::findMonth Internal error"); | - | ||||||||||||||||||||||||||||||
1109 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
1110 | } | - | ||||||||||||||||||||||||||||||
1111 | - | |||||||||||||||||||||||||||||||
1112 | QLocale::FormatType type = sn.count == 3
| 201-1270 | ||||||||||||||||||||||||||||||
1113 | QLocale l = locale(); | - | ||||||||||||||||||||||||||||||
1114 | - | |||||||||||||||||||||||||||||||
1115 | for (int month=startMonth; month<=12
| 118-6035 | ||||||||||||||||||||||||||||||
1116 | const QString str2monthName = l.monthName(month, type).); | - | ||||||||||||||||||||||||||||||
1117 | QString str2 = monthName.toLower(); | - | ||||||||||||||||||||||||||||||
1118 | - | |||||||||||||||||||||||||||||||
1119 | if (str1.startsWith(str2)
| 1350-4685 | ||||||||||||||||||||||||||||||
1120 | if (used
| 0-1350 | ||||||||||||||||||||||||||||||
1121 | if (false) QMessageLogger(__FILE__, 12541267, __PRETTY_FUNCTION__).debug() << "used is set to" << str2.size(); dead code: QMessageLogger(__FILE__, 1267, __PRETTY_FUNCTION__).debug() << "used is set to" << str2.size(); | - | ||||||||||||||||||||||||||||||
1122 | *used = str2.size(); | - | ||||||||||||||||||||||||||||||
1123 | } executed 1350 times by 6 tests: end of block Executed by:
| 1350 | ||||||||||||||||||||||||||||||
1124 | if (usedMonth
| 0-1350 | ||||||||||||||||||||||||||||||
1125 | * executed 1350 times by 6 tests: usedMonth = l.monthName(month, type);;*usedMonth = monthName; Executed by:
executed 1350 times by 6 tests: *usedMonth = monthName; Executed by:
| 1350 | ||||||||||||||||||||||||||||||
1126 | - | |||||||||||||||||||||||||||||||
1127 | return executed 1350 times by 6 tests: month;return month; Executed by:
executed 1350 times by 6 tests: return month; Executed by:
| 1350 | ||||||||||||||||||||||||||||||
1128 | } | - | ||||||||||||||||||||||||||||||
1129 | if (context == FromString
| 1599-3086 | ||||||||||||||||||||||||||||||
1130 | continue; executed 3086 times by 5 tests: continue; Executed by:
| 3086 | ||||||||||||||||||||||||||||||
1131 | - | |||||||||||||||||||||||||||||||
1132 | const int limit = qMin(str1.size(), str2.size()); | - | ||||||||||||||||||||||||||||||
1133 | - | |||||||||||||||||||||||||||||||
1134 | if (false) QMessageLogger(__FILE__, 12671280, __PRETTY_FUNCTION__).debug() << "limit is" << limit << str1 << str2; dead code: QMessageLogger(__FILE__, 1280, __PRETTY_FUNCTION__).debug() << "limit is" << limit << str1 << str2; | - | ||||||||||||||||||||||||||||||
1135 | bool equal = true; | - | ||||||||||||||||||||||||||||||
1136 | for (int i=0; i<limit
| 3-2263 | ||||||||||||||||||||||||||||||
1137 | if (str1.at(i) != str2.at(i)
| 667-1596 | ||||||||||||||||||||||||||||||
1138 | equal = false; | - | ||||||||||||||||||||||||||||||
1139 | if (i > bestCount
| 177-1419 | ||||||||||||||||||||||||||||||
1140 | bestCount = i; | - | ||||||||||||||||||||||||||||||
1141 | bestMatch = month; | - | ||||||||||||||||||||||||||||||
1142 | } executed 177 times by 1 test: end of block Executed by:
| 177 | ||||||||||||||||||||||||||||||
1143 | break; executed 1596 times by 1 test: break; Executed by:
| 1596 | ||||||||||||||||||||||||||||||
1144 | } | - | ||||||||||||||||||||||||||||||
1145 | } executed 667 times by 1 test: end of block Executed by:
| 667 | ||||||||||||||||||||||||||||||
1146 | if (equal
| 3-1596 | ||||||||||||||||||||||||||||||
1147 | if (used
| 0-3 | ||||||||||||||||||||||||||||||
1148 | * executed 3 times by 1 test: used = limit;*used = limit; Executed by:
executed 3 times by 1 test: *used = limit; Executed by:
| 3 | ||||||||||||||||||||||||||||||
1149 | if (usedMonth
| 0-3 | ||||||||||||||||||||||||||||||
1150 | * executed 3 times by 1 test: usedMonth = l.monthName(month, type);;*usedMonth = monthName; Executed by:
executed 3 times by 1 test: *usedMonth = monthName; Executed by:
| 3 | ||||||||||||||||||||||||||||||
1151 | return executed 3 times by 1 test: month;return month; Executed by:
executed 3 times by 1 test: return month; Executed by:
| 3 | ||||||||||||||||||||||||||||||
1152 | } | - | ||||||||||||||||||||||||||||||
1153 | } executed 1596 times by 1 test: end of block Executed by:
| 1596 | ||||||||||||||||||||||||||||||
1154 | if (usedMonth
| 5-109 | ||||||||||||||||||||||||||||||
1155 | * executed 104 times by 1 test: usedMonth = l.monthName(bestMatch, type);*usedMonth = l.monthName(bestMatch, type); Executed by:
executed 104 times by 1 test: *usedMonth = l.monthName(bestMatch, type); Executed by:
| 104 | ||||||||||||||||||||||||||||||
1156 | } executed 118 times by 1 test: end of block Executed by:
| 118 | ||||||||||||||||||||||||||||||
1157 | if (used
| 9-109 | ||||||||||||||||||||||||||||||
1158 | if (false) QMessageLogger(__FILE__, 12911304, __PRETTY_FUNCTION__).debug() << "used is set to" << bestCount; dead code: QMessageLogger(__FILE__, 1304, __PRETTY_FUNCTION__).debug() << "used is set to" << bestCount; | - | ||||||||||||||||||||||||||||||
1159 | *used = bestCount; | - | ||||||||||||||||||||||||||||||
1160 | } executed 109 times by 1 test: end of block Executed by:
| 109 | ||||||||||||||||||||||||||||||
1161 | return executed 118 times by 1 test: bestMatch;return bestMatch; Executed by:
executed 118 times by 1 test: return bestMatch; Executed by:
| 118 | ||||||||||||||||||||||||||||||
1162 | } | - | ||||||||||||||||||||||||||||||
1163 | - | |||||||||||||||||||||||||||||||
1164 | int QDateTimeParser::findDay(const QString &str1, int startDay, int sectionIndex, QString *usedDay, int *used) const | - | ||||||||||||||||||||||||||||||
1165 | { | - | ||||||||||||||||||||||||||||||
1166 | int bestMatch = -1; | - | ||||||||||||||||||||||||||||||
1167 | int bestCount = 0; | - | ||||||||||||||||||||||||||||||
1168 | if (!str1.isEmpty()
| 0-464 | ||||||||||||||||||||||||||||||
1169 | const SectionNode &sn = sectionNode(sectionIndex); | - | ||||||||||||||||||||||||||||||
1170 | if (!(sn.type & DaySectionMask)
| 0-464 | ||||||||||||||||||||||||||||||
1171 | QMessageLogger(__FILE__, 13041317, __PRETTY_FUNCTION__).warning("QDateTimeParser::findDay Internal error"); | - | ||||||||||||||||||||||||||||||
1172 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
1173 | } | - | ||||||||||||||||||||||||||||||
1174 | const QLocale l = locale(); | - | ||||||||||||||||||||||||||||||
1175 | for (int day=startDay; day<=7
| 0-1838 | ||||||||||||||||||||||||||||||
1176 | const QString dayNamestr2 = l.dayName(day, sn.count == 4 ? QLocale::LongFormat : QLocale::ShortFormat); | - | ||||||||||||||||||||||||||||||
1177 | - | |||||||||||||||||||||||||||||||
1178 | const QStringif (str1.startsWith(
| 464-1374 | ||||||||||||||||||||||||||||||
1179 | if (used
| 0-464 | ||||||||||||||||||||||||||||||
1180 | * executed 464 times by 3 tests: used = str2.size*used = str2.size(); Executed by:
executed 464 times by 3 tests: *used = str2.size(); Executed by:
executed 464 times by 3 tests: ();*used = str2.size(); Executed by:
executed 464 times by 3 tests: *used = str2.size(); Executed by:
| 464 | ||||||||||||||||||||||||||||||
1181 | if (usedDay
| 0-464 | ||||||||||||||||||||||||||||||
1182 | *usedDay = str2; | - | ||||||||||||||||||||||||||||||
1183 | } executed 464 times by 3 tests: end of block Executed by:
| 464 | ||||||||||||||||||||||||||||||
1184 | return executed 464 times by 3 tests: day;return day; Executed by:
executed 464 times by 3 tests: return day; Executed by:
| 464 | ||||||||||||||||||||||||||||||
1185 | } | - | ||||||||||||||||||||||||||||||
1186 | if (context == FromString
| 53-1321 | ||||||||||||||||||||||||||||||
1187 | continue; executed 53 times by 2 tests: continue; Executed by:
| 53 | ||||||||||||||||||||||||||||||
1188 | - | |||||||||||||||||||||||||||||||
1189 | const int limit = qMin(str1.size(), str2.size()); | - | ||||||||||||||||||||||||||||||
1190 | bool found = true; | - | ||||||||||||||||||||||||||||||
1191 | for (int i=0; while (i<limit&&
| 0-1321 | ||||||||||||||||||||||||||||||
1192 | if (str1.at(i) ==!= str2.at(i))
| 0-1321 | ||||||||||||||||||||||||||||||
++
| ||||||||||||||||||||||||||||||||
1193 | if (i > bestCount
| 0-1321 | ||||||||||||||||||||||||||||||
1194 | bestCount = i; | - | ||||||||||||||||||||||||||||||
1195 | bestMatch = day; | - | ||||||||||||||||||||||||||||||
1196 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1197 | found = false; | - | ||||||||||||||||||||||||||||||
1198 | break; executed 1321 times by 1 test: break; Executed by:
| 1321 | ||||||||||||||||||||||||||||||
1199 | } | - | ||||||||||||||||||||||||||||||
1200 | - | |||||||||||||||||||||||||||||||
1201 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1202 | if (found
| 0-1321 | ||||||||||||||||||||||||||||||
1203 | if (used
| 0 | ||||||||||||||||||||||||||||||
1204 | * never executed: used = limit;*used = limit; never executed: *used = limit; | 0 | ||||||||||||||||||||||||||||||
1205 | if (usedDay
| 0 | ||||||||||||||||||||||||||||||
1206 | * never executed: usedDay*usedDay = str2; never executed: *usedDay = str2; never executed: = str2;*usedDay = str2; never executed: *usedDay = str2; | 0 | ||||||||||||||||||||||||||||||
1207 | - | |||||||||||||||||||||||||||||||
1208 | return never executed: return day; never executed: return day; never executed: day;return day; never executed: return day; | 0 | ||||||||||||||||||||||||||||||
1209 | } | - | ||||||||||||||||||||||||||||||
1210 | } executed 1321 times by 1 test: end of block Executed by:
| 1321 | ||||||||||||||||||||||||||||||
1211 | if (usedDay
| 0 | ||||||||||||||||||||||||||||||
1212 | *usedDay = l.dayName(bestMatch, sn.count == 4 ? QLocale::LongFormat : QLocale::ShortFormat); | - | ||||||||||||||||||||||||||||||
1213 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1214 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1215 | if (used
| 0 | ||||||||||||||||||||||||||||||
1216 | * never executed: used = bestCount;*used = bestCount; never executed: *used = bestCount; | 0 | ||||||||||||||||||||||||||||||
1217 | - | |||||||||||||||||||||||||||||||
1218 | return never executed: bestMatch;return bestMatch; never executed: return bestMatch; | 0 | ||||||||||||||||||||||||||||||
1219 | } | - | ||||||||||||||||||||||||||||||
1220 | QDateTimeParser::AmPmFinder QDateTimeParser::findAmPm(QString &str, int sectionIndex, int *used) const | - | ||||||||||||||||||||||||||||||
1221 | { | - | ||||||||||||||||||||||||||||||
1222 | const SectionNode &s = sectionNode(sectionIndex); | - | ||||||||||||||||||||||||||||||
1223 | if (s.type != AmPmSection
| 0-863 | ||||||||||||||||||||||||||||||
1224 | QMessageLogger(__FILE__, 13471383, __PRETTY_FUNCTION__).warning("QDateTimeParser::findAmPm Internal error"); | - | ||||||||||||||||||||||||||||||
1225 | return never executed: Neither;return Neither; never executed: return Neither; | 0 | ||||||||||||||||||||||||||||||
1226 | } | - | ||||||||||||||||||||||||||||||
1227 | if (used
| 0-863 | ||||||||||||||||||||||||||||||
1228 | * executed 863 times by 5 tests: used = str.size();*used = str.size(); Executed by:
executed 863 times by 5 tests: *used = str.size(); Executed by:
| 863 | ||||||||||||||||||||||||||||||
1229 | if (str.QStringRef(&str).
| 0-863 | ||||||||||||||||||||||||||||||
1230 | return never executed: PossibleBoth;return PossibleBoth; never executed: return PossibleBoth; | 0 | ||||||||||||||||||||||||||||||
1231 | } | - | ||||||||||||||||||||||||||||||
1232 | const QLatin1Char space(' '); | - | ||||||||||||||||||||||||||||||
1233 | int size = sectionMaxSize(sectionIndex); | - | ||||||||||||||||||||||||||||||
1234 | - | |||||||||||||||||||||||||||||||
1235 | enum { | - | ||||||||||||||||||||||||||||||
1236 | amindex = 0, | - | ||||||||||||||||||||||||||||||
1237 | pmindex = 1 | - | ||||||||||||||||||||||||||||||
1238 | }; | - | ||||||||||||||||||||||||||||||
1239 | QString ampm[2]; | - | ||||||||||||||||||||||||||||||
1240 | ampm[amindex] = getAmPmText(AmText, s.count == 1 ? UpperCase : LowerCase); | - | ||||||||||||||||||||||||||||||
1241 | ampm[pmindex] = getAmPmText(PmText, s.count == 1 ? UpperCase : LowerCase); | - | ||||||||||||||||||||||||||||||
1242 | for (int i=0; i<2
| 863-1726 | ||||||||||||||||||||||||||||||
1243 | ampm[i].truncate(size); executed 1726 times by 5 tests: ampm[i].truncate(size); Executed by:
| 1726 | ||||||||||||||||||||||||||||||
1244 | - | |||||||||||||||||||||||||||||||
1245 | if (false) QMessageLogger(__FILE__, 13681404, __PRETTY_FUNCTION__).debug() << "findAmPm" << str << ampm[0] << ampm[1]; dead code: QMessageLogger(__FILE__, 1404, __PRETTY_FUNCTION__).debug() << "findAmPm" << str << ampm[0] << ampm[1]; | - | ||||||||||||||||||||||||||||||
1246 | - | |||||||||||||||||||||||||||||||
1247 | if (str.indexOf(ampm[amindex], 0, Qt::CaseInsensitive) == 0
| 105-758 | ||||||||||||||||||||||||||||||
1248 | str = ampm[amindex]; | - | ||||||||||||||||||||||||||||||
1249 | return executed 758 times by 5 tests: AM;return AM; Executed by:
executed 758 times by 5 tests: return AM; Executed by:
| 758 | ||||||||||||||||||||||||||||||
1250 | } else if (str.indexOf(ampm[pmindex], 0, Qt::CaseInsensitive) == 0
| 2-103 | ||||||||||||||||||||||||||||||
1251 | str = ampm[pmindex]; | - | ||||||||||||||||||||||||||||||
1252 | return executed 103 times by 3 tests: PM;return PM; Executed by:
executed 103 times by 3 tests: return PM; Executed by:
| 103 | ||||||||||||||||||||||||||||||
1253 | } else if (context == FromString
| 0-1 | ||||||||||||||||||||||||||||||
1254 | return executed 1 time by 1 test: Neither;return Neither; Executed by:
executed 1 time by 1 test: return Neither; Executed by:
| 1 | ||||||||||||||||||||||||||||||
1255 | } | - | ||||||||||||||||||||||||||||||
1256 | size = qMin(size, str.size()); | - | ||||||||||||||||||||||||||||||
1257 | - | |||||||||||||||||||||||||||||||
1258 | bool broken[2] = {false, false}; | - | ||||||||||||||||||||||||||||||
1259 | for (int i=0; i<size
| 0-1 | ||||||||||||||||||||||||||||||
1260 | if (str.at(i) != space
| 0-1 | ||||||||||||||||||||||||||||||
1261 | for (int j=0; j<2
| 0-2 | ||||||||||||||||||||||||||||||
1262 | if (!broken[j]
| 0-2 | ||||||||||||||||||||||||||||||
1263 | int index = ampm[j].indexOf(str.at(i)); | - | ||||||||||||||||||||||||||||||
1264 | if (false) QMessageLogger(__FILE__, 13871423, __PRETTY_FUNCTION__).debug() << "looking for" << str.at(i) dead code: QMessageLogger(__FILE__, 1423, __PRETTY_FUNCTION__).debug() << "looking for" << str.at(i) << "in" << ampm[j] << "and got" << index; | - | ||||||||||||||||||||||||||||||
1265 | << "in" << ampm[j] << "and got" << index; dead code: QMessageLogger(__FILE__, 1423, __PRETTY_FUNCTION__).debug() << "looking for" << str.at(i) << "in" << ampm[j] << "and got" << index; | - | ||||||||||||||||||||||||||||||
1266 | if (index == -1
| 0-2 | ||||||||||||||||||||||||||||||
1267 | if (str.at(i).category() == QChar::Letter_Uppercase
| 0-2 | ||||||||||||||||||||||||||||||
1268 | index = ampm[j].indexOf(str.at(i).toLower()); | - | ||||||||||||||||||||||||||||||
1269 | if (false) QMessageLogger(__FILE__, 13921428, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toLower() dead code: QMessageLogger(__FILE__, 1428, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toLower() << "in" << ampm[j] << "and got" << index; | - | ||||||||||||||||||||||||||||||
1270 | << "in" << ampm[j] << "and got" << index; dead code: QMessageLogger(__FILE__, 1428, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toLower() << "in" << ampm[j] << "and got" << index; | - | ||||||||||||||||||||||||||||||
1271 | } never executed: else if (str.at(i).category() == QChar::Letter_Lowercaseend of block
| 0-2 | ||||||||||||||||||||||||||||||
1272 | index = ampm[j].indexOf(str.at(i).toUpper()); | - | ||||||||||||||||||||||||||||||
1273 | if (false) QMessageLogger(__FILE__, 13961432, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toUpper() dead code: QMessageLogger(__FILE__, 1432, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toUpper() << "in" << ampm[j] << "and got" << index; | - | ||||||||||||||||||||||||||||||
1274 | << "in" << ampm[j] << "and got" << index; dead code: QMessageLogger(__FILE__, 1432, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toUpper() << "in" << ampm[j] << "and got" << index; | - | ||||||||||||||||||||||||||||||
1275 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1276 | if (index == -1
| 0-2 | ||||||||||||||||||||||||||||||
1277 | broken[j] = true; | - | ||||||||||||||||||||||||||||||
1278 | if (broken[amindex]
| 0-2 | ||||||||||||||||||||||||||||||
1279 | if (false) QMessageLogger(__FILE__, 14021438, __PRETTY_FUNCTION__).debug() << str << "didn't make it"; dead code: QMessageLogger(__FILE__, 1438, __PRETTY_FUNCTION__).debug() << str << "didn't make it"; | - | ||||||||||||||||||||||||||||||
1280 | return executed 1 time by 1 test: Neither;return Neither; Executed by:
executed 1 time by 1 test: return Neither; Executed by:
| 1 | ||||||||||||||||||||||||||||||
1281 | } | - | ||||||||||||||||||||||||||||||
1282 | continue; executed 1 time by 1 test: continue; Executed by:
| 1 | ||||||||||||||||||||||||||||||
1283 | } else { | - | ||||||||||||||||||||||||||||||
1284 | str[i] = ampm[j].at(index); | - | ||||||||||||||||||||||||||||||
1285 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1286 | } | - | ||||||||||||||||||||||||||||||
1287 | ampm[j].remove(index, 1); | - | ||||||||||||||||||||||||||||||
1288 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1289 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1290 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1291 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
1292 | if (!broken[pmindex]
| 0 | ||||||||||||||||||||||||||||||
1293 | return never executed: PossibleBoth;return PossibleBoth; never executed: return PossibleBoth; | 0 | ||||||||||||||||||||||||||||||
1294 | return never executed: (!broken[amindex] ? PossibleAM : PossiblePM);return (!broken[amindex] ? PossibleAM : PossiblePM); never executed: return (!broken[amindex] ? PossibleAM : PossiblePM); | 0 | ||||||||||||||||||||||||||||||
1295 | } | - | ||||||||||||||||||||||||||||||
1296 | - | |||||||||||||||||||||||||||||||
1297 | - | |||||||||||||||||||||||||||||||
1298 | - | |||||||||||||||||||||||||||||||
1299 | - | |||||||||||||||||||||||||||||||
1300 | - | |||||||||||||||||||||||||||||||
1301 | - | |||||||||||||||||||||||||||||||
1302 | int QDateTimeParser::SectionNode::maxChange() const | - | ||||||||||||||||||||||||||||||
1303 | { | - | ||||||||||||||||||||||||||||||
1304 | switch (type) { | - | ||||||||||||||||||||||||||||||
1305 | - | |||||||||||||||||||||||||||||||
1306 | case MSecSection: return 999; | - | ||||||||||||||||||||||||||||||
1307 | case SecondSection: return 59 * 1000; | - | ||||||||||||||||||||||||||||||
1308 | case MinuteSection: return 59 * 60 * 1000; | - | ||||||||||||||||||||||||||||||
1309 | case Hour24Section: case Hour12Section: return 59 * 60 * 60 * 1000; | - | ||||||||||||||||||||||||||||||
1310 | - | |||||||||||||||||||||||||||||||
1311 | - | |||||||||||||||||||||||||||||||
1312 | case DayOfWeekSectionShort: | - | ||||||||||||||||||||||||||||||
1313 | case DayOfWeekSectionLong: return 7; | - | ||||||||||||||||||||||||||||||
1314 | case DaySection: return 30; | - | ||||||||||||||||||||||||||||||
1315 | case MonthSection: return 365 - 31; | - | ||||||||||||||||||||||||||||||
1316 | case YearSection: return 9999 * 365; | - | ||||||||||||||||||||||||||||||
1317 | case YearSection2Digits: return 100 * 365; | - | ||||||||||||||||||||||||||||||
1318 | default: | - | ||||||||||||||||||||||||||||||
1319 | QMessageLogger(__FILE__, 14421478, __PRETTY_FUNCTION__).warning("QDateTimeParser::maxChange() Internal error (%s)", | - | ||||||||||||||||||||||||||||||
1320 | QString(name()).toLocal8Bit().constData()); | - | ||||||||||||||||||||||||||||||
1321 | } | - | ||||||||||||||||||||||||||||||
1322 | - | |||||||||||||||||||||||||||||||
1323 | return -1; | - | ||||||||||||||||||||||||||||||
1324 | } | - | ||||||||||||||||||||||||||||||
1325 | - | |||||||||||||||||||||||||||||||
1326 | QDateTimeParser::FieldInfo QDateTimeParser::fieldInfo(int index) const | - | ||||||||||||||||||||||||||||||
1327 | { | - | ||||||||||||||||||||||||||||||
1328 | FieldInfo ret = 0; | - | ||||||||||||||||||||||||||||||
1329 | const SectionNode &sn = sectionNode(index); | - | ||||||||||||||||||||||||||||||
1330 | switch (sn.type) { | - | ||||||||||||||||||||||||||||||
1331 | case MSecSection: | - | ||||||||||||||||||||||||||||||
1332 | ret |= Fraction; | - | ||||||||||||||||||||||||||||||
1333 | - | |||||||||||||||||||||||||||||||
1334 | case SecondSection: | - | ||||||||||||||||||||||||||||||
1335 | case MinuteSection: | - | ||||||||||||||||||||||||||||||
1336 | case Hour24Section: | - | ||||||||||||||||||||||||||||||
1337 | case Hour12Section: | - | ||||||||||||||||||||||||||||||
1338 | case YearSection: | - | ||||||||||||||||||||||||||||||
1339 | case YearSection2Digits: | - | ||||||||||||||||||||||||||||||
1340 | ret |= Numeric; | - | ||||||||||||||||||||||||||||||
1341 | if (sn.type != YearSection) { | - | ||||||||||||||||||||||||||||||
1342 | ret |= AllowPartial; | - | ||||||||||||||||||||||||||||||
1343 | } | - | ||||||||||||||||||||||||||||||
1344 | if (sn.count != 1) { | - | ||||||||||||||||||||||||||||||
1345 | ret |= FixedWidth; | - | ||||||||||||||||||||||||||||||
1346 | } | - | ||||||||||||||||||||||||||||||
1347 | break; | - | ||||||||||||||||||||||||||||||
1348 | case MonthSection: | - | ||||||||||||||||||||||||||||||
1349 | case DaySection: | - | ||||||||||||||||||||||||||||||
1350 | switch (sn.count) { | - | ||||||||||||||||||||||||||||||
1351 | case 2: | - | ||||||||||||||||||||||||||||||
1352 | ret |= FixedWidth; | - | ||||||||||||||||||||||||||||||
1353 | - | |||||||||||||||||||||||||||||||
1354 | case 1: | - | ||||||||||||||||||||||||||||||
1355 | ret |= (Numeric|AllowPartial); | - | ||||||||||||||||||||||||||||||
1356 | break; | - | ||||||||||||||||||||||||||||||
1357 | } | - | ||||||||||||||||||||||||||||||
1358 | break; | - | ||||||||||||||||||||||||||||||
1359 | case DayOfWeekSectionShort: | - | ||||||||||||||||||||||||||||||
1360 | case DayOfWeekSectionLong: | - | ||||||||||||||||||||||||||||||
1361 | if (sn.count == 3) | - | ||||||||||||||||||||||||||||||
1362 | ret |= FixedWidth; | - | ||||||||||||||||||||||||||||||
1363 | break; | - | ||||||||||||||||||||||||||||||
1364 | case AmPmSection: | - | ||||||||||||||||||||||||||||||
1365 | ret |= FixedWidth; | - | ||||||||||||||||||||||||||||||
1366 | break; | - | ||||||||||||||||||||||||||||||
1367 | default: | - | ||||||||||||||||||||||||||||||
1368 | QMessageLogger(__FILE__, 14911527, __PRETTY_FUNCTION__).warning("QDateTimeParser::fieldInfo Internal error 2 (%d %s %d)", | - | ||||||||||||||||||||||||||||||
1369 | index, QString(sn.name()).toLocal8Bit().constData(), sn.count); | - | ||||||||||||||||||||||||||||||
1370 | break; | - | ||||||||||||||||||||||||||||||
1371 | } | - | ||||||||||||||||||||||||||||||
1372 | return ret; | - | ||||||||||||||||||||||||||||||
1373 | } | - | ||||||||||||||||||||||||||||||
1374 | - | |||||||||||||||||||||||||||||||
1375 | QString QDateTimeParser::SectionNode::format() const | - | ||||||||||||||||||||||||||||||
1376 | { | - | ||||||||||||||||||||||||||||||
1377 | QChar fillChar; | - | ||||||||||||||||||||||||||||||
1378 | switch (type) { | - | ||||||||||||||||||||||||||||||
1379 | case never executed: AmPmSection:case AmPmSection: never executed: returncase AmPmSection: never executed: count == 1 ? QLatin1String("AP") : QLatin1String("ap");return count == 1 ? QLatin1String("AP") : QLatin1String("ap"); never executed: return count == 1 ? QLatin1String("AP") : QLatin1String("ap"); | 0 | ||||||||||||||||||||||||||||||
1380 | case never executed: MSecSection:case MSecSection: never executed: fillChar = QLatin1Char('z'); break;case MSecSection: never executed: break; | 0 | ||||||||||||||||||||||||||||||
1381 | case never executed: SecondSection:case SecondSection: never executed: fillChar = QLatin1Char('s'); break;case SecondSection: never executed: break; | 0 | ||||||||||||||||||||||||||||||
1382 | case never executed: MinuteSection:case MinuteSection: never executed: fillChar = QLatin1Char('m'); break;case MinuteSection: never executed: break; | 0 | ||||||||||||||||||||||||||||||
1383 | case never executed: Hour24Section:case Hour24Section: never executed: fillChar = QLatin1Char('H'); break;case Hour24Section: never executed: break; | 0 | ||||||||||||||||||||||||||||||
1384 | case never executed: Hour12Section:case Hour12Section: never executed: fillChar = QLatin1Char('h'); break;case Hour12Section: never executed: break; | 0 | ||||||||||||||||||||||||||||||
1385 | case never executed: DayOfWeekSectionShort:case DayOfWeekSectionShort: never executed: case DayOfWeekSectionShort: | 0 | ||||||||||||||||||||||||||||||
1386 | case never executed: DayOfWeekSectionLong:case DayOfWeekSectionLong: never executed: case DayOfWeekSectionLong: | 0 | ||||||||||||||||||||||||||||||
1387 | case executed 2 times by 1 test: DaySection:case DaySection: Executed by:
executed 2 times by 1 test: fillChar = QLatin1Char('d'); break;case DaySection: Executed by:
executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||||||||
1388 | case executed 2 times by 1 test: MonthSection:case MonthSection: Executed by:
executed 2 times by 1 test: fillChar = QLatin1Char('M'); break;case MonthSection: Executed by:
executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||||||||
1389 | case never executed: YearSection2Digits:case YearSection2Digits: never executed: case YearSection2Digits: | 0 | ||||||||||||||||||||||||||||||
1390 | case executed 2 times by 1 test: YearSection:case YearSection: Executed by:
executed 2 times by 1 test: fillChar = QLatin1Char('y'); break;case YearSection: Executed by:
executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||||||||
1391 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
1392 | QMessageLogger(__FILE__, 15151551, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionFormat Internal error (%s)", | - | ||||||||||||||||||||||||||||||
1393 | QString(name(type)).toLocal8Bit().constData()); | - | ||||||||||||||||||||||||||||||
1394 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||||||||
1395 | } | - | ||||||||||||||||||||||||||||||
1396 | if (fillChar.isNull()
| 0-6 | ||||||||||||||||||||||||||||||
1397 | QMessageLogger(__FILE__, 15201556, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionFormat Internal error 2"); | - | ||||||||||||||||||||||||||||||
1398 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||||||||
1399 | } | - | ||||||||||||||||||||||||||||||
1400 | return executed 6 times by 1 test: return QString(count, fillChar); Executed by:
executed 6 times by 1 test: QStringstr;return QString(count, fillChar); Executed by:
executed 6 times by 1 test: return QString(count, fillChar); Executed by:
| 6 | ||||||||||||||||||||||||||||||
str.fill executed 6 times by 1 test: return QString(count, fillChar); Executed by:
executed 6 times by 1 test: (fillChar,count, fillChar);return QString(count, fillChar); Executed by:
executed 6 times by 1 test: return QString(count, fillChar); Executed by:
| ||||||||||||||||||||||||||||||||
return str;} | ||||||||||||||||||||||||||||||||
1402 | bool QDateTimeParser::potentialValue(const QStringQStringRef &str, int min, int max, int index, | - | ||||||||||||||||||||||||||||||
1403 | const QDateTime ¤tValue, int insert) const | - | ||||||||||||||||||||||||||||||
1404 | { | - | ||||||||||||||||||||||||||||||
1405 | if (str.isEmpty()
| 3-1610 | ||||||||||||||||||||||||||||||
1406 | return executed 3 times by 1 test: true;return true; Executed by:
executed 3 times by 1 test: return true; Executed by:
| 3 | ||||||||||||||||||||||||||||||
1407 | } | - | ||||||||||||||||||||||||||||||
1408 | const int size = sectionMaxSize(index); | - | ||||||||||||||||||||||||||||||
1409 | int val = (int)locale().toUInt(str); | - | ||||||||||||||||||||||||||||||
1410 | const SectionNode &sn = sectionNode(index); | - | ||||||||||||||||||||||||||||||
1411 | if (sn.type == YearSection2Digits
| 20-1590 | ||||||||||||||||||||||||||||||
1412 | val +=const int year = currentValue.date().year()(); | - | ||||||||||||||||||||||||||||||
1413 | val += year - (currentValue.date().year ()% 100); | - | ||||||||||||||||||||||||||||||
1414 | } executed 20 times by 2 tests: end of block Executed by:
| 20 | ||||||||||||||||||||||||||||||
1415 | if (val >= min
| 201-1409 | ||||||||||||||||||||||||||||||
1416 | return executed 495 times by 4 tests: true;return true; Executed by:
executed 495 times by 4 tests: return true; Executed by:
| 495 | ||||||||||||||||||||||||||||||
1417 | } else if (val > max
| 410-705 | ||||||||||||||||||||||||||||||
1418 | return executed 410 times by 1 test: false;return false; Executed by:
executed 410 times by 1 test: return false; Executed by:
| 410 | ||||||||||||||||||||||||||||||
1419 | } else if (str.size() == size
| 0-590 | ||||||||||||||||||||||||||||||
1420 | return executed 115 times by 1 test: false;return false; Executed by:
executed 115 times by 1 test: return false; Executed by:
| 115 | ||||||||||||||||||||||||||||||
1421 | } | - | ||||||||||||||||||||||||||||||
1422 | - | |||||||||||||||||||||||||||||||
1423 | const int len = size - str.size(); | - | ||||||||||||||||||||||||||||||
1424 | for (int i=0; i<len
| 45-590 | ||||||||||||||||||||||||||||||
1425 | for (int j=0; j<10
| 45-1061 | ||||||||||||||||||||||||||||||
1426 | if (potentialValue(str + QLatin1Char('0' + j), min, max, index, currentValue, insert)
| 519-542 | ||||||||||||||||||||||||||||||
1427 | return executed 542 times by 4 tests: true;return true; Executed by:
executed 542 times by 4 tests: return true; Executed by:
| 542 | ||||||||||||||||||||||||||||||
1428 | } else if (insert >= 0
| 9-510 | ||||||||||||||||||||||||||||||
1429 | const QString tmp = str; | - | ||||||||||||||||||||||||||||||
tmp.insertleft(insert,) + QLatin1Char('0' + j));) + str.mid(insert); | ||||||||||||||||||||||||||||||||
1430 | if (potentialValue(tmp, min, max, index, currentValue, insert)
| 3-6 | ||||||||||||||||||||||||||||||
1431 | return executed 3 times by 1 test: true;return true; Executed by:
executed 3 times by 1 test: return true; Executed by:
| 3 | ||||||||||||||||||||||||||||||
1432 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||||||||
1433 | } executed 516 times by 1 test: end of block Executed by:
| 516 | ||||||||||||||||||||||||||||||
1434 | } executed 45 times by 1 test: end of block Executed by:
| 45 | ||||||||||||||||||||||||||||||
1435 | - | |||||||||||||||||||||||||||||||
1436 | return executed 45 times by 1 test: false;return false; Executed by:
executed 45 times by 1 test: return false; Executed by:
| 45 | ||||||||||||||||||||||||||||||
1437 | } | - | ||||||||||||||||||||||||||||||
1438 | - | |||||||||||||||||||||||||||||||
1439 | bool QDateTimeParser::skipToNextSection(int index, const QDateTime ¤t, const QStringQStringRef &text) const | - | ||||||||||||||||||||||||||||||
1440 | { | - | ||||||||||||||||||||||||||||||
1441 | ((!(current >= getMinimum() && current <= getMaximum())) ? qt_assert("current >= getMinimum() && current <= getMaximum()",__FILE__,15761609) : qt_noop()); | - | ||||||||||||||||||||||||||||||
1442 | - | |||||||||||||||||||||||||||||||
1443 | const SectionNode &node = sectionNode(index); | - | ||||||||||||||||||||||||||||||
1444 | ((!(text.size() < sectionMaxSize(index))) ? qt_assert("text.size() < sectionMaxSize(index)",__FILE__,15791612) : qt_noop()); | - | ||||||||||||||||||||||||||||||
1445 | - | |||||||||||||||||||||||||||||||
1446 | const QDateTime maximum = getMaximum(); | - | ||||||||||||||||||||||||||||||
1447 | const QDateTime minimum = getMinimum(); | - | ||||||||||||||||||||||||||||||
1448 | QDateTime tmp = current; | - | ||||||||||||||||||||||||||||||
1449 | int min = absoluteMin(index); | - | ||||||||||||||||||||||||||||||
1450 | setDigit(tmp, index, min); | - | ||||||||||||||||||||||||||||||
1451 | if (tmp < minimum
| 17-474 | ||||||||||||||||||||||||||||||
1452 | min = getDigit(minimum, index); | - | ||||||||||||||||||||||||||||||
1453 | } executed 17 times by 1 test: end of block Executed by:
| 17 | ||||||||||||||||||||||||||||||
1454 | - | |||||||||||||||||||||||||||||||
1455 | int max = absoluteMax(index, current); | - | ||||||||||||||||||||||||||||||
1456 | setDigit(tmp, index, max); | - | ||||||||||||||||||||||||||||||
1457 | if (tmp > maximum
| 33-458 | ||||||||||||||||||||||||||||||
1458 | max = getDigit(maximum, index); | - | ||||||||||||||||||||||||||||||
1459 | } executed 33 times by 2 tests: end of block Executed by:
| 33 | ||||||||||||||||||||||||||||||
1460 | int pos = cursorPosition() - node.pos; | - | ||||||||||||||||||||||||||||||
1461 | if (pos < 0
| 7-479 | ||||||||||||||||||||||||||||||
1462 | pos = -1; executed 484 times by 4 tests: pos = -1; Executed by:
| 484 | ||||||||||||||||||||||||||||||
1463 | - | |||||||||||||||||||||||||||||||
1464 | const bool potential = potentialValue(text, min, max, index, current, pos); | - | ||||||||||||||||||||||||||||||
1465 | return executed 491 times by 4 tests: !potential;return !potential; Executed by:
executed 491 times by 4 tests: return !potential; Executed by:
| 491 | ||||||||||||||||||||||||||||||
1466 | - | |||||||||||||||||||||||||||||||
1467 | - | |||||||||||||||||||||||||||||||
1468 | - | |||||||||||||||||||||||||||||||
1469 | - | |||||||||||||||||||||||||||||||
1470 | - | |||||||||||||||||||||||||||||||
1471 | - | |||||||||||||||||||||||||||||||
1472 | } | - | ||||||||||||||||||||||||||||||
1473 | - | |||||||||||||||||||||||||||||||
1474 | - | |||||||||||||||||||||||||||||||
1475 | - | |||||||||||||||||||||||||||||||
1476 | - | |||||||||||||||||||||||||||||||
1477 | - | |||||||||||||||||||||||||||||||
1478 | - | |||||||||||||||||||||||||||||||
1479 | QString QDateTimeParser::SectionNode::name(QDateTimeParser::Section s) | - | ||||||||||||||||||||||||||||||
1480 | { | - | ||||||||||||||||||||||||||||||
1481 | switch (s) { | - | ||||||||||||||||||||||||||||||
1482 | case QDateTimeParser::AmPmSection: return QLatin1String("AmPmSection"); | - | ||||||||||||||||||||||||||||||
1483 | case QDateTimeParser::DaySection: return QLatin1String("DaySection"); | - | ||||||||||||||||||||||||||||||
1484 | case QDateTimeParser::DayOfWeekSectionShort: return QLatin1String("DayOfWeekSectionShort"); | - | ||||||||||||||||||||||||||||||
1485 | case QDateTimeParser::DayOfWeekSectionLong: return QLatin1String("DayOfWeekSectionLong"); | - | ||||||||||||||||||||||||||||||
1486 | case QDateTimeParser::Hour24Section: return QLatin1String("Hour24Section"); | - | ||||||||||||||||||||||||||||||
1487 | case QDateTimeParser::Hour12Section: return QLatin1String("Hour12Section"); | - | ||||||||||||||||||||||||||||||
1488 | case QDateTimeParser::MSecSection: return QLatin1String("MSecSection"); | - | ||||||||||||||||||||||||||||||
1489 | case QDateTimeParser::MinuteSection: return QLatin1String("MinuteSection"); | - | ||||||||||||||||||||||||||||||
1490 | case QDateTimeParser::MonthSection: return QLatin1String("MonthSection"); | - | ||||||||||||||||||||||||||||||
1491 | case QDateTimeParser::SecondSection: return QLatin1String("SecondSection"); | - | ||||||||||||||||||||||||||||||
1492 | case QDateTimeParser::YearSection: return QLatin1String("YearSection"); | - | ||||||||||||||||||||||||||||||
1493 | case QDateTimeParser::YearSection2Digits: return QLatin1String("YearSection2Digits"); | - | ||||||||||||||||||||||||||||||
1494 | case QDateTimeParser::NoSection: return QLatin1String("NoSection"); | - | ||||||||||||||||||||||||||||||
1495 | case QDateTimeParser::FirstSection: return QLatin1String("FirstSection"); | - | ||||||||||||||||||||||||||||||
1496 | case QDateTimeParser::LastSection: return QLatin1String("LastSection"); | - | ||||||||||||||||||||||||||||||
1497 | default: return QLatin1String("Unknown section ") + QString::number(int(s)); | - | ||||||||||||||||||||||||||||||
1498 | } | - | ||||||||||||||||||||||||||||||
1499 | } | - | ||||||||||||||||||||||||||||||
1500 | - | |||||||||||||||||||||||||||||||
1501 | - | |||||||||||||||||||||||||||||||
1502 | - | |||||||||||||||||||||||||||||||
1503 | - | |||||||||||||||||||||||||||||||
1504 | - | |||||||||||||||||||||||||||||||
1505 | - | |||||||||||||||||||||||||||||||
1506 | QString QDateTimeParser::stateName(State s) const | - | ||||||||||||||||||||||||||||||
1507 | { | - | ||||||||||||||||||||||||||||||
1508 | switch (s) { | - | ||||||||||||||||||||||||||||||
1509 | case Invalid: return QLatin1String("Invalid"); | - | ||||||||||||||||||||||||||||||
1510 | case Intermediate: return QLatin1String("Intermediate"); | - | ||||||||||||||||||||||||||||||
1511 | case Acceptable: return QLatin1String("Acceptable"); | - | ||||||||||||||||||||||||||||||
1512 | default: return QLatin1String("Unknown state ") + QString::number(s); | - | ||||||||||||||||||||||||||||||
1513 | } | - | ||||||||||||||||||||||||||||||
1514 | } | - | ||||||||||||||||||||||||||||||
1515 | - | |||||||||||||||||||||||||||||||
1516 | - | |||||||||||||||||||||||||||||||
1517 | bool QDateTimeParser::fromString(const QString &t, QDate *date, QTime *time) const | - | ||||||||||||||||||||||||||||||
1518 | { | - | ||||||||||||||||||||||||||||||
1519 | QDateTime val(QDate(1900, 1, 1), QTime(0, 0, 0, 0)); | - | ||||||||||||||||||||||||||||||
1520 | QString text = t; | - | ||||||||||||||||||||||||||||||
1521 | int copy = -1; | - | ||||||||||||||||||||||||||||||
1522 | const StateNode tmp = parse(text, copy, val, false); | - | ||||||||||||||||||||||||||||||
1523 | if (tmp.state != Acceptable || tmp.conflicts) { | - | ||||||||||||||||||||||||||||||
1524 | return false; | - | ||||||||||||||||||||||||||||||
1525 | } | - | ||||||||||||||||||||||||||||||
1526 | if (time) { | - | ||||||||||||||||||||||||||||||
1527 | const QTime t = tmp.value.time(); | - | ||||||||||||||||||||||||||||||
1528 | if (!t.isValid()) { | - | ||||||||||||||||||||||||||||||
1529 | return false; | - | ||||||||||||||||||||||||||||||
1530 | } | - | ||||||||||||||||||||||||||||||
1531 | *time = t; | - | ||||||||||||||||||||||||||||||
1532 | } | - | ||||||||||||||||||||||||||||||
1533 | - | |||||||||||||||||||||||||||||||
1534 | if (date) { | - | ||||||||||||||||||||||||||||||
1535 | const QDate d = tmp.value.date(); | - | ||||||||||||||||||||||||||||||
1536 | if (!d.isValid()) { | - | ||||||||||||||||||||||||||||||
1537 | return false; | - | ||||||||||||||||||||||||||||||
1538 | } | - | ||||||||||||||||||||||||||||||
1539 | *date = d; | - | ||||||||||||||||||||||||||||||
1540 | } | - | ||||||||||||||||||||||||||||||
1541 | return true; | - | ||||||||||||||||||||||||||||||
1542 | } | - | ||||||||||||||||||||||||||||||
1543 | - | |||||||||||||||||||||||||||||||
1544 | - | |||||||||||||||||||||||||||||||
1545 | QDateTime QDateTimeParser::getMinimum() const | - | ||||||||||||||||||||||||||||||
1546 | { | - | ||||||||||||||||||||||||||||||
1547 | return QDateTime(QDate(100, 1, 1), QTime(0, 0, 0, 0), spec); | - | ||||||||||||||||||||||||||||||
1548 | } | - | ||||||||||||||||||||||||||||||
1549 | - | |||||||||||||||||||||||||||||||
1550 | QDateTime QDateTimeParser::getMaximum() const | - | ||||||||||||||||||||||||||||||
1551 | { | - | ||||||||||||||||||||||||||||||
1552 | return QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999), spec); | - | ||||||||||||||||||||||||||||||
1553 | } | - | ||||||||||||||||||||||||||||||
1554 | - | |||||||||||||||||||||||||||||||
1555 | QString QDateTimeParser::getAmPmText(AmPm ap, Case cs) const | - | ||||||||||||||||||||||||||||||
1556 | { | - | ||||||||||||||||||||||||||||||
1557 | const QLocale loc = locale(); | - | ||||||||||||||||||||||||||||||
1558 | QString raw = ap == AmText ? loc.amText() : loc.pmText(); | - | ||||||||||||||||||||||||||||||
1559 | return cs == UpperCase ? raw.toUpper() : raw.toLower(); | - | ||||||||||||||||||||||||||||||
1560 | } | - | ||||||||||||||||||||||||||||||
1561 | - | |||||||||||||||||||||||||||||||
1562 | - | |||||||||||||||||||||||||||||||
1563 | - | |||||||||||||||||||||||||||||||
1564 | - | |||||||||||||||||||||||||||||||
1565 | - | |||||||||||||||||||||||||||||||
1566 | - | |||||||||||||||||||||||||||||||
1567 | - | |||||||||||||||||||||||||||||||
1568 | bool operator==(const QDateTimeParser::SectionNode &s1, const QDateTimeParser::SectionNode &s2) | - | ||||||||||||||||||||||||||||||
1569 | { | - | ||||||||||||||||||||||||||||||
1570 | return (s1.type == s2.type) && (s1.pos == s2.pos) && (s1.count == s2.count); | - | ||||||||||||||||||||||||||||||
1571 | } | - | ||||||||||||||||||||||||||||||
1572 | - | |||||||||||||||||||||||||||||||
1573 | - | |||||||||||||||||||||||||||||||
1574 | - | |||||||||||||||||||||||||||||||
1575 | - | |||||||||||||||||||||||||||||||
Switch to Source code | Preprocessed file |