Line | Source Code | Coverage |
---|
1 | | - |
2 | static const int nestingLimit = 1024; | - |
3 | | - |
4 | | - |
5 | QString QJsonParseError::errorString() const | - |
6 | { | - |
7 | const char *sz = ""; | - |
8 | switch (error) { | - |
9 | case NoError: | - |
10 | sz = "no error occurred"; | - |
11 | break; | 0 |
12 | case UnterminatedObject: | - |
13 | sz = "unterminated object"; | - |
14 | break; | 0 |
15 | case MissingNameSeparator: | - |
16 | sz = "missing name separator"; | - |
17 | break; | 0 |
18 | case UnterminatedArray: | - |
19 | sz = "unterminated array"; | - |
20 | break; | 0 |
21 | case MissingValueSeparator: | - |
22 | sz = "missing value separator"; | - |
23 | break; | 0 |
24 | case IllegalValue: | - |
25 | sz = "illegal value"; | - |
26 | break; | 0 |
27 | case TerminationByNumber: | - |
28 | sz = "invalid termination by number"; | - |
29 | break; | 0 |
30 | case IllegalNumber: | - |
31 | sz = "illegal number"; | - |
32 | break; | 0 |
33 | case IllegalEscapeSequence: | - |
34 | sz = "invalid escape sequence"; | - |
35 | break; | 0 |
36 | case IllegalUTF8String: | - |
37 | sz = "invalid UTF8 string"; | - |
38 | break; | 0 |
39 | case UnterminatedString: | - |
40 | sz = "unterminated string"; | - |
41 | break; | 0 |
42 | case MissingObject: | - |
43 | sz = "object is missing after a comma"; | - |
44 | break; | 0 |
45 | case DeepNesting: | - |
46 | sz = "too deeply nested document"; | - |
47 | break; | 0 |
48 | } | - |
49 | | - |
50 | return QCoreApplication::translate("QJsonParseError", sz); never executed: return QCoreApplication::translate("QJsonParseError", sz); | 0 |
51 | | - |
52 | | - |
53 | | - |
54 | } | - |
55 | | - |
56 | using namespace QJsonPrivate; | - |
57 | | - |
58 | Parser::Parser(const char *json, int length) | - |
59 | : head(json), json(json), data(0), dataLength(0), current(0), nestingLevel(0), lastError(QJsonParseError::NoError) | - |
60 | { | - |
61 | end = json + length; | - |
62 | } executed: } Execution Count:88 | 88 |
63 | enum { | - |
64 | Space = 0x20, | - |
65 | Tab = 0x09, | - |
66 | LineFeed = 0x0a, | - |
67 | Return = 0x0d, | - |
68 | BeginArray = 0x5b, | - |
69 | BeginObject = 0x7b, | - |
70 | EndArray = 0x5d, | - |
71 | EndObject = 0x7d, | - |
72 | NameSeparator = 0x3a, | - |
73 | ValueSeparator = 0x2c, | - |
74 | Quote = 0x22 | - |
75 | }; | - |
76 | | - |
77 | void Parser::eatBOM() | - |
78 | { | - |
79 | | - |
80 | uchar utf8bom[3] = { 0xef, 0xbb, 0xbf }; | - |
81 | if (end - json > 3 && evaluated: end - json > 3 yes Evaluation Count:86 | yes Evaluation Count:2 |
| 2-86 |
82 | (uchar)json[0] == utf8bom[0] && evaluated: (uchar)json[0] == utf8bom[0] yes Evaluation Count:1 | yes Evaluation Count:85 |
| 1-85 |
83 | (uchar)json[1] == utf8bom[1] && partially evaluated: (uchar)json[1] == utf8bom[1] yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
84 | (uchar)json[2] == utf8bom[2]) partially evaluated: (uchar)json[2] == utf8bom[2] yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
85 | json += 3; executed: json += 3; Execution Count:1 | 1 |
86 | } executed: } Execution Count:88 | 88 |
87 | | - |
88 | bool Parser::eatSpace() | - |
89 | { | - |
90 | while (json < end) { evaluated: json < end yes Evaluation Count:67279 | yes Evaluation Count:69 |
| 69-67279 |
91 | if (*json > Space) evaluated: *json > Space yes Evaluation Count:48649 | yes Evaluation Count:18630 |
| 18630-48649 |
92 | break; executed: break; Execution Count:48649 | 48649 |
93 | if (*json != Space && evaluated: *json != Space yes Evaluation Count:2317 | yes Evaluation Count:16313 |
| 2317-16313 |
94 | *json != Tab && partially evaluated: *json != Tab yes Evaluation Count:2317 | no Evaluation Count:0 |
| 0-2317 |
95 | *json != LineFeed && partially evaluated: *json != LineFeed no Evaluation Count:0 | yes Evaluation Count:2317 |
| 0-2317 |
96 | *json != Return) never evaluated: *json != Return | 0 |
97 | break; | 0 |
98 | ++json; | - |
99 | } executed: } Execution Count:18630 | 18630 |
100 | return (json < end); executed: return (json < end); Execution Count:48718 | 48718 |
101 | } | - |
102 | | - |
103 | char Parser::nextToken() | - |
104 | { | - |
105 | if (!eatSpace()) evaluated: !eatSpace() yes Evaluation Count:2 | yes Evaluation Count:27197 |
| 2-27197 |
106 | return 0; executed: return 0; Execution Count:2 | 2 |
107 | char token = *json++; | - |
108 | switch (token) { | - |
109 | case BeginArray: | - |
110 | case BeginObject: | - |
111 | case NameSeparator: | - |
112 | case ValueSeparator: | - |
113 | case EndArray: | - |
114 | case EndObject: | - |
115 | eatSpace(); | - |
116 | case Quote: | - |
117 | break; executed: break; Execution Count:27193 | 27193 |
118 | default: | - |
119 | token = 0; | - |
120 | break; executed: break; Execution Count:4 | 4 |
121 | } | - |
122 | return token; executed: return token; Execution Count:27197 | 27197 |
123 | } | - |
124 | | - |
125 | | - |
126 | | - |
127 | | - |
128 | QJsonDocument Parser::parse(QJsonParseError *error) | - |
129 | { | - |
130 | | - |
131 | | - |
132 | | - |
133 | | - |
134 | | - |
135 | dataLength = qMax(end - json, (ptrdiff_t) 256); | - |
136 | data = (char *)malloc(dataLength); | - |
137 | | - |
138 | | - |
139 | QJsonPrivate::Header *h = (QJsonPrivate::Header *)data; | - |
140 | h->tag = QJsonDocument::BinaryFormatTag; | - |
141 | h->version = 1u; | - |
142 | | - |
143 | current = sizeof(QJsonPrivate::Header); | - |
144 | | - |
145 | eatBOM(); | - |
146 | char token = nextToken(); | - |
147 | | - |
148 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 305, __PRETTY_FUNCTION__).debug() << hex << (uint)token; executed: ; Execution Count:88 never executed: QMessageLogger("json/qjsonparser.cpp", 305, __PRETTY_FUNCTION__).debug() << hex << (uint)token; partially evaluated: 1 yes Evaluation Count:88 | no Evaluation Count:0 |
| 0-88 |
149 | if (token == BeginArray) { evaluated: token == BeginArray yes Evaluation Count:73 | yes Evaluation Count:15 |
| 15-73 |
150 | if (!parseArray()) evaluated: !parseArray() yes Evaluation Count:21 | yes Evaluation Count:52 |
| 21-52 |
151 | goto error; executed: goto error; Execution Count:21 | 21 |
152 | } else if (token == BeginObject) { partially evaluated: token == BeginObject yes Evaluation Count:15 | no Evaluation Count:0 |
executed: } Execution Count:52 | 0-52 |
153 | if (!parseObject()) evaluated: !parseObject() yes Evaluation Count:5 | yes Evaluation Count:10 |
| 5-10 |
154 | goto error; executed: goto error; Execution Count:5 | 5 |
155 | } else { executed: } Execution Count:10 | 10 |
156 | lastError = QJsonParseError::IllegalValue; | - |
157 | goto error; never executed: goto error; | 0 |
158 | } | - |
159 | | - |
160 | do {} while (0); partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:62 |
executed: } Execution Count:62 | 0-62 |
161 | { | - |
162 | if (error) { evaluated: error yes Evaluation Count:3 | yes Evaluation Count:59 |
| 3-59 |
163 | error->offset = 0; | - |
164 | error->error = QJsonParseError::NoError; | - |
165 | } executed: } Execution Count:3 | 3 |
166 | QJsonPrivate::Data *d = new QJsonPrivate::Data(data, current); | - |
167 | return QJsonDocument(d); executed: return QJsonDocument(d); Execution Count:62 | 62 |
168 | } | - |
169 | | - |
170 | error: | - |
171 | | - |
172 | | - |
173 | | - |
174 | if (error) { evaluated: error yes Evaluation Count:24 | yes Evaluation Count:2 |
| 2-24 |
175 | error->offset = json - head; | - |
176 | error->error = lastError; | - |
177 | } executed: } Execution Count:24 | 24 |
178 | free(data); | - |
179 | return QJsonDocument(); executed: return QJsonDocument(); Execution Count:26 | 26 |
180 | } | - |
181 | | - |
182 | | - |
183 | void Parser::ParsedObject::insert(uint offset) { | - |
184 | const QJsonPrivate::Entry *newEntry = reinterpret_cast<const QJsonPrivate::Entry *>(parser->data + objectPosition + offset); | - |
185 | int min = 0; | - |
186 | int n = offsets.size(); | - |
187 | while (n > 0) { evaluated: n > 0 yes Evaluation Count:7317 | yes Evaluation Count:7418 |
| 7317-7418 |
188 | int half = n >> 1; | - |
189 | int middle = min + half; | - |
190 | if (*entryAt(middle) >= *newEntry) { evaluated: *entryAt(middle) >= *newEntry yes Evaluation Count:3732 | yes Evaluation Count:3585 |
| 3585-3732 |
191 | n = half; | - |
192 | } else { executed: } Execution Count:3732 | 3732 |
193 | min = middle + 1; | - |
194 | n -= half + 1; | - |
195 | } executed: } Execution Count:3585 | 3585 |
196 | } | - |
197 | if (min < offsets.size() && *entryAt(min) == *newEntry) { evaluated: min < offsets.size() yes Evaluation Count:2442 | yes Evaluation Count:4976 |
evaluated: *entryAt(min) == *newEntry yes Evaluation Count:1 | yes Evaluation Count:2441 |
| 1-4976 |
198 | offsets[min] = offset; | - |
199 | } else { executed: } Execution Count:1 | 1 |
200 | offsets.insert(min, offset); | - |
201 | } executed: } Execution Count:7417 | 7417 |
202 | } | - |
203 | | - |
204 | | - |
205 | | - |
206 | | - |
207 | | - |
208 | | - |
209 | bool Parser::parseObject() | - |
210 | { | - |
211 | if (++nestingLevel > nestingLimit) { evaluated: ++nestingLevel > nestingLimit yes Evaluation Count:1 | yes Evaluation Count:4179 |
| 1-4179 |
212 | lastError = QJsonParseError::DeepNesting; | - |
213 | return false; executed: return false; Execution Count:1 | 1 |
214 | } | - |
215 | | - |
216 | int objectOffset = reserveSpace(sizeof(QJsonPrivate::Object)); | - |
217 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 374, __PRETTY_FUNCTION__).debug() << "parseObject pos=" << objectOffset << current << json; partially evaluated: 1 yes Evaluation Count:4179 | no Evaluation Count:0 |
executed: ; Execution Count:4179 never executed: QMessageLogger("json/qjsonparser.cpp", 374, __PRETTY_FUNCTION__).debug() << "parseObject pos=" << objectOffset << current << json; | 0-4179 |
218 | | - |
219 | ParsedObject parsedObject(this, objectOffset); | - |
220 | | - |
221 | char token = nextToken(); | - |
222 | while (token == Quote) { evaluated: token == Quote yes Evaluation Count:8442 | yes Evaluation Count:14 |
| 14-8442 |
223 | int off = current - objectOffset; | - |
224 | if (!parseMember(objectOffset)) evaluated: !parseMember(objectOffset) yes Evaluation Count:1024 | yes Evaluation Count:7418 |
| 1024-7418 |
225 | return false; executed: return false; Execution Count:1024 | 1024 |
226 | parsedObject.insert(off); | - |
227 | token = nextToken(); | - |
228 | if (token != ValueSeparator) evaluated: token != ValueSeparator yes Evaluation Count:3140 | yes Evaluation Count:4278 |
| 3140-4278 |
229 | break; executed: break; Execution Count:3140 | 3140 |
230 | token = nextToken(); | - |
231 | if (token == EndObject) { evaluated: token == EndObject yes Evaluation Count:1 | yes Evaluation Count:4277 |
| 1-4277 |
232 | lastError = QJsonParseError::MissingObject; | - |
233 | return false; executed: return false; Execution Count:1 | 1 |
234 | } | - |
235 | } executed: } Execution Count:4277 | 4277 |
236 | | - |
237 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 394, __PRETTY_FUNCTION__).debug() << "end token=" << token; partially evaluated: 1 yes Evaluation Count:3154 | no Evaluation Count:0 |
executed: ; Execution Count:3154 never executed: QMessageLogger("json/qjsonparser.cpp", 394, __PRETTY_FUNCTION__).debug() << "end token=" << token; | 0-3154 |
238 | if (token != EndObject) { evaluated: token != EndObject yes Evaluation Count:3 | yes Evaluation Count:3151 |
| 3-3151 |
239 | lastError = QJsonParseError::UnterminatedObject; | - |
240 | return false; executed: return false; Execution Count:3 | 3 |
241 | } | - |
242 | | - |
243 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 400, __PRETTY_FUNCTION__).debug() << "numEntries" << parsedObject.offsets.size(); partially evaluated: 1 yes Evaluation Count:3151 | no Evaluation Count:0 |
executed: ; Execution Count:3151 never executed: QMessageLogger("json/qjsonparser.cpp", 400, __PRETTY_FUNCTION__).debug() << "numEntries" << parsedObject.offsets.size(); | 0-3151 |
244 | int table = objectOffset; | - |
245 | | - |
246 | if (parsedObject.offsets.size()) { evaluated: parsedObject.offsets.size() yes Evaluation Count:3140 | yes Evaluation Count:11 |
| 11-3140 |
247 | int tableSize = parsedObject.offsets.size()*sizeof(uint); | - |
248 | table = reserveSpace(tableSize); | - |
249 | | - |
250 | memcpy(data + table, parsedObject.offsets.constData(), tableSize); | - |
251 | | - |
252 | | - |
253 | | - |
254 | | - |
255 | | - |
256 | | - |
257 | } executed: } Execution Count:3140 | 3140 |
258 | | - |
259 | QJsonPrivate::Object *o = (QJsonPrivate::Object *)(data + objectOffset); | - |
260 | o->tableOffset = table - objectOffset; | - |
261 | o->size = current - objectOffset; | - |
262 | o->is_object = true; | - |
263 | o->length = parsedObject.offsets.size(); | - |
264 | | - |
265 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 422, __PRETTY_FUNCTION__).debug() << "current=" << current; partially evaluated: 1 yes Evaluation Count:3151 | no Evaluation Count:0 |
executed: ; Execution Count:3151 never executed: QMessageLogger("json/qjsonparser.cpp", 422, __PRETTY_FUNCTION__).debug() << "current=" << current; | 0-3151 |
266 | do {} while (0); partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:3151 |
executed: } Execution Count:3151 | 0-3151 |
267 | | - |
268 | --nestingLevel; | - |
269 | return true; executed: return true; Execution Count:3151 | 3151 |
270 | } | - |
271 | | - |
272 | | - |
273 | | - |
274 | | - |
275 | bool Parser::parseMember(int baseOffset) | - |
276 | { | - |
277 | int entryOffset = reserveSpace(sizeof(QJsonPrivate::Entry)); | - |
278 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 435, __PRETTY_FUNCTION__).debug() << "parseMember pos=" << entryOffset; partially evaluated: 1 yes Evaluation Count:8442 | no Evaluation Count:0 |
executed: ; Execution Count:8442 never executed: QMessageLogger("json/qjsonparser.cpp", 435, __PRETTY_FUNCTION__).debug() << "parseMember pos=" << entryOffset; | 0-8442 |
279 | | - |
280 | bool latin1; | - |
281 | if (!parseString(&latin1)) partially evaluated: !parseString(&latin1) no Evaluation Count:0 | yes Evaluation Count:8442 |
| 0-8442 |
282 | return false; never executed: return false; | 0 |
283 | char token = nextToken(); | - |
284 | if (token != NameSeparator) { evaluated: token != NameSeparator yes Evaluation Count:1 | yes Evaluation Count:8441 |
| 1-8441 |
285 | lastError = QJsonParseError::MissingNameSeparator; | - |
286 | return false; executed: return false; Execution Count:1 | 1 |
287 | } | - |
288 | QJsonPrivate::Value val; | - |
289 | if (!parseValue(&val, baseOffset)) evaluated: !parseValue(&val, baseOffset) yes Evaluation Count:1023 | yes Evaluation Count:7418 |
| 1023-7418 |
290 | return false; executed: return false; Execution Count:1023 | 1023 |
291 | | - |
292 | | - |
293 | QJsonPrivate::Entry *e = (QJsonPrivate::Entry *)(data + entryOffset); | - |
294 | e->value = val; | - |
295 | e->value.latinKey = latin1; | - |
296 | | - |
297 | do {} while (0); partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:7418 |
executed: } Execution Count:7418 | 0-7418 |
298 | return true; executed: return true; Execution Count:7418 | 7418 |
299 | } | - |
300 | | - |
301 | | - |
302 | | - |
303 | | - |
304 | bool Parser::parseArray() | - |
305 | { | - |
306 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 463, __PRETTY_FUNCTION__).debug() << "parseArray"; partially evaluated: 1 yes Evaluation Count:2767 | no Evaluation Count:0 |
executed: ; Execution Count:2767 never executed: QMessageLogger("json/qjsonparser.cpp", 463, __PRETTY_FUNCTION__).debug() << "parseArray"; | 0-2767 |
307 | | - |
308 | if (++nestingLevel > nestingLimit) { evaluated: ++nestingLevel > nestingLimit yes Evaluation Count:1 | yes Evaluation Count:2766 |
| 1-2766 |
309 | lastError = QJsonParseError::DeepNesting; | - |
310 | return false; executed: return false; Execution Count:1 | 1 |
311 | } | - |
312 | | - |
313 | int arrayOffset = reserveSpace(sizeof(QJsonPrivate::Array)); | - |
314 | | - |
315 | QVarLengthArray<QJsonPrivate::Value, 64> values; | - |
316 | | - |
317 | if (!eatSpace()) { evaluated: !eatSpace() yes Evaluation Count:1 | yes Evaluation Count:2765 |
| 1-2765 |
318 | lastError = QJsonParseError::UnterminatedArray; | - |
319 | return false; executed: return false; Execution Count:1 | 1 |
320 | } | - |
321 | if (*json == EndArray) { evaluated: *json == EndArray yes Evaluation Count:99 | yes Evaluation Count:2666 |
| 99-2666 |
322 | nextToken(); | - |
323 | } else { executed: } Execution Count:99 | 99 |
324 | while (1) { partially evaluated: 1 yes Evaluation Count:3736 | no Evaluation Count:0 |
| 0-3736 |
325 | QJsonPrivate::Value val; | - |
326 | if (!parseValue(&val, arrayOffset)) evaluated: !parseValue(&val, arrayOffset) yes Evaluation Count:1041 | yes Evaluation Count:2695 |
| 1041-2695 |
327 | return false; executed: return false; Execution Count:1041 | 1041 |
328 | values.append(val); | - |
329 | char token = nextToken(); | - |
330 | if (token == EndArray) evaluated: token == EndArray yes Evaluation Count:1623 | yes Evaluation Count:1072 |
| 1072-1623 |
331 | break; executed: break; Execution Count:1623 | 1623 |
332 | else if (token != ValueSeparator) { evaluated: token != ValueSeparator yes Evaluation Count:2 | yes Evaluation Count:1070 |
| 2-1070 |
333 | if (!eatSpace()) evaluated: !eatSpace() yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
334 | lastError = QJsonParseError::UnterminatedArray; executed: lastError = QJsonParseError::UnterminatedArray; Execution Count:1 | 1 |
335 | else | - |
336 | lastError = QJsonParseError::MissingValueSeparator; executed: lastError = QJsonParseError::MissingValueSeparator; Execution Count:1 | 1 |
337 | return false; executed: return false; Execution Count:2 | 2 |
338 | } | - |
339 | } | - |
340 | } executed: } Execution Count:1623 | 1623 |
341 | | - |
342 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 499, __PRETTY_FUNCTION__).debug() << "size =" << values.size(); partially evaluated: 1 yes Evaluation Count:1722 | no Evaluation Count:0 |
executed: ; Execution Count:1722 never executed: QMessageLogger("json/qjsonparser.cpp", 499, __PRETTY_FUNCTION__).debug() << "size =" << values.size(); | 0-1722 |
343 | int table = arrayOffset; | - |
344 | | - |
345 | if (values.size()) { evaluated: values.size() yes Evaluation Count:1623 | yes Evaluation Count:99 |
| 99-1623 |
346 | int tableSize = values.size()*sizeof(QJsonPrivate::Value); | - |
347 | table = reserveSpace(tableSize); | - |
348 | memcpy(data + table, values.constData(), tableSize); | - |
349 | } executed: } Execution Count:1623 | 1623 |
350 | | - |
351 | QJsonPrivate::Array *a = (QJsonPrivate::Array *)(data + arrayOffset); | - |
352 | a->tableOffset = table - arrayOffset; | - |
353 | a->size = current - arrayOffset; | - |
354 | a->is_object = false; | - |
355 | a->length = values.size(); | - |
356 | | - |
357 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 514, __PRETTY_FUNCTION__).debug() << "current=" << current; partially evaluated: 1 yes Evaluation Count:1722 | no Evaluation Count:0 |
executed: ; Execution Count:1722 never executed: QMessageLogger("json/qjsonparser.cpp", 514, __PRETTY_FUNCTION__).debug() << "current=" << current; | 0-1722 |
358 | do {} while (0); partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:1722 |
executed: } Execution Count:1722 | 0-1722 |
359 | | - |
360 | --nestingLevel; | - |
361 | return true; executed: return true; Execution Count:1722 | 1722 |
362 | } | - |
363 | | - |
364 | | - |
365 | | - |
366 | | - |
367 | | - |
368 | | - |
369 | bool Parser::parseValue(QJsonPrivate::Value *val, int baseOffset) | - |
370 | { | - |
371 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 528, __PRETTY_FUNCTION__).debug() << "parse Value" << json; partially evaluated: 1 yes Evaluation Count:12177 | no Evaluation Count:0 |
executed: ; Execution Count:12177 never executed: QMessageLogger("json/qjsonparser.cpp", 528, __PRETTY_FUNCTION__).debug() << "parse Value" << json; | 0-12177 |
372 | val->_dummy = 0; | - |
373 | | - |
374 | switch (*json++) { | - |
375 | case 'n': | - |
376 | if (end - json < 4) { evaluated: end - json < 4 yes Evaluation Count:1 | yes Evaluation Count:12 |
| 1-12 |
377 | lastError = QJsonParseError::IllegalValue; | - |
378 | return false; executed: return false; Execution Count:1 | 1 |
379 | } | - |
380 | if (*json++ == 'u' && partially evaluated: *json++ == 'u' yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
381 | *json++ == 'l' && partially evaluated: *json++ == 'l' yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
382 | *json++ == 'l') { evaluated: *json++ == 'l' yes Evaluation Count:11 | yes Evaluation Count:1 |
| 1-11 |
383 | val->type = QJsonValue::Null; | - |
384 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 541, __PRETTY_FUNCTION__).debug() << "value: null"; partially evaluated: 1 yes Evaluation Count:11 | no Evaluation Count:0 |
executed: ; Execution Count:11 never executed: QMessageLogger("json/qjsonparser.cpp", 541, __PRETTY_FUNCTION__).debug() << "value: null"; | 0-11 |
385 | do {} while (0); partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:11 |
executed: } Execution Count:11 | 0-11 |
386 | return true; executed: return true; Execution Count:11 | 11 |
387 | } | - |
388 | lastError = QJsonParseError::IllegalValue; | - |
389 | return false; executed: return false; Execution Count:1 | 1 |
390 | case 't': | - |
391 | if (end - json < 4) { evaluated: end - json < 4 yes Evaluation Count:1 | yes Evaluation Count:19 |
| 1-19 |
392 | lastError = QJsonParseError::IllegalValue; | - |
393 | return false; executed: return false; Execution Count:1 | 1 |
394 | } | - |
395 | if (*json++ == 'r' && partially evaluated: *json++ == 'r' yes Evaluation Count:19 | no Evaluation Count:0 |
| 0-19 |
396 | *json++ == 'u' && partially evaluated: *json++ == 'u' yes Evaluation Count:19 | no Evaluation Count:0 |
| 0-19 |
397 | *json++ == 'e') { evaluated: *json++ == 'e' yes Evaluation Count:18 | yes Evaluation Count:1 |
| 1-18 |
398 | val->type = QJsonValue::Bool; | - |
399 | val->value = true; | - |
400 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 557, __PRETTY_FUNCTION__).debug() << "value: true"; partially evaluated: 1 yes Evaluation Count:18 | no Evaluation Count:0 |
executed: ; Execution Count:18 never executed: QMessageLogger("json/qjsonparser.cpp", 557, __PRETTY_FUNCTION__).debug() << "value: true"; | 0-18 |
401 | do {} while (0); partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:18 |
executed: } Execution Count:18 | 0-18 |
402 | return true; executed: return true; Execution Count:18 | 18 |
403 | } | - |
404 | lastError = QJsonParseError::IllegalValue; | - |
405 | return false; executed: return false; Execution Count:1 | 1 |
406 | case 'f': | - |
407 | if (end - json < 5) { evaluated: end - json < 5 yes Evaluation Count:1 | yes Evaluation Count:13 |
| 1-13 |
408 | lastError = QJsonParseError::IllegalValue; | - |
409 | return false; executed: return false; Execution Count:1 | 1 |
410 | } | - |
411 | if (*json++ == 'a' && partially evaluated: *json++ == 'a' yes Evaluation Count:13 | no Evaluation Count:0 |
| 0-13 |
412 | *json++ == 'l' && partially evaluated: *json++ == 'l' yes Evaluation Count:13 | no Evaluation Count:0 |
| 0-13 |
413 | *json++ == 's' && partially evaluated: *json++ == 's' yes Evaluation Count:13 | no Evaluation Count:0 |
| 0-13 |
414 | *json++ == 'e') { evaluated: *json++ == 'e' yes Evaluation Count:12 | yes Evaluation Count:1 |
| 1-12 |
415 | val->type = QJsonValue::Bool; | - |
416 | val->value = false; | - |
417 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 574, __PRETTY_FUNCTION__).debug() << "value: false"; partially evaluated: 1 yes Evaluation Count:12 | no Evaluation Count:0 |
executed: ; Execution Count:12 never executed: QMessageLogger("json/qjsonparser.cpp", 574, __PRETTY_FUNCTION__).debug() << "value: false"; | 0-12 |
418 | do {} while (0); executed: } Execution Count:12 partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
419 | return true; executed: return true; Execution Count:12 | 12 |
420 | } | - |
421 | lastError = QJsonParseError::IllegalValue; | - |
422 | return false; executed: return false; Execution Count:1 | 1 |
423 | case Quote: { | - |
424 | val->type = QJsonValue::String; | - |
425 | val->value = current - baseOffset; | - |
426 | bool latin1; | - |
427 | if (!parseString(&latin1)) evaluated: !parseString(&latin1) yes Evaluation Count:6 | yes Evaluation Count:2776 |
| 6-2776 |
428 | return false; executed: return false; Execution Count:6 | 6 |
429 | val->latinOrIntValue = latin1; | - |
430 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 587, __PRETTY_FUNCTION__).debug() << "value: string"; executed: ; Execution Count:2776 never executed: QMessageLogger("json/qjsonparser.cpp", 587, __PRETTY_FUNCTION__).debug() << "value: string"; partially evaluated: 1 yes Evaluation Count:2776 | no Evaluation Count:0 |
| 0-2776 |
431 | do {} while (0); executed: } Execution Count:2776 partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:2776 |
| 0-2776 |
432 | return true; executed: return true; Execution Count:2776 | 2776 |
433 | } | - |
434 | case BeginArray: | - |
435 | val->type = QJsonValue::Array; | - |
436 | val->value = current - baseOffset; | - |
437 | if (!parseArray()) evaluated: !parseArray() yes Evaluation Count:1024 | yes Evaluation Count:1670 |
| 1024-1670 |
438 | return false; executed: return false; Execution Count:1024 | 1024 |
439 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 596, __PRETTY_FUNCTION__).debug() << "value: array"; executed: ; Execution Count:1670 never executed: QMessageLogger("json/qjsonparser.cpp", 596, __PRETTY_FUNCTION__).debug() << "value: array"; partially evaluated: 1 yes Evaluation Count:1670 | no Evaluation Count:0 |
| 0-1670 |
440 | do {} while (0); executed: } Execution Count:1670 partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:1670 |
| 0-1670 |
441 | return true; executed: return true; Execution Count:1670 | 1670 |
442 | case BeginObject: | - |
443 | val->type = QJsonValue::Object; | - |
444 | val->value = current - baseOffset; | - |
445 | if (!parseObject()) evaluated: !parseObject() yes Evaluation Count:1024 | yes Evaluation Count:3141 |
| 1024-3141 |
446 | return false; executed: return false; Execution Count:1024 | 1024 |
447 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 604, __PRETTY_FUNCTION__).debug() << "value: object"; executed: ; Execution Count:3141 never executed: QMessageLogger("json/qjsonparser.cpp", 604, __PRETTY_FUNCTION__).debug() << "value: object"; partially evaluated: 1 yes Evaluation Count:3141 | no Evaluation Count:0 |
| 0-3141 |
448 | do {} while (0); executed: } Execution Count:3141 partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:3141 |
| 0-3141 |
449 | return true; executed: return true; Execution Count:3141 | 3141 |
450 | case EndArray: | - |
451 | lastError = QJsonParseError::MissingObject; | - |
452 | return false; executed: return false; Execution Count:1 | 1 |
453 | default: | - |
454 | --json; | - |
455 | if (!parseNumber(val, baseOffset)) evaluated: !parseNumber(val, baseOffset) yes Evaluation Count:3 | yes Evaluation Count:2485 |
| 3-2485 |
456 | return false; executed: return false; Execution Count:3 | 3 |
457 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 614, __PRETTY_FUNCTION__).debug() << "value: number"; executed: ; Execution Count:2485 never executed: QMessageLogger("json/qjsonparser.cpp", 614, __PRETTY_FUNCTION__).debug() << "value: number"; partially evaluated: 1 yes Evaluation Count:2485 | no Evaluation Count:0 |
| 0-2485 |
458 | do {} while (0); executed: } Execution Count:2485 partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:2485 |
| 0-2485 |
459 | } executed: } Execution Count:2485 | 2485 |
460 | | - |
461 | return true; executed: return true; Execution Count:2485 | 2485 |
462 | } | - |
463 | bool Parser::parseNumber(QJsonPrivate::Value *val, int baseOffset) | - |
464 | { | - |
465 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 641, __PRETTY_FUNCTION__).debug() << "parseNumber" << json; executed: ; Execution Count:2488 never executed: QMessageLogger("json/qjsonparser.cpp", 641, __PRETTY_FUNCTION__).debug() << "parseNumber" << json; partially evaluated: 1 yes Evaluation Count:2488 | no Evaluation Count:0 |
| 0-2488 |
466 | val->type = QJsonValue::Double; | - |
467 | | - |
468 | const char *start = json; | - |
469 | bool isInt = true; | - |
470 | | - |
471 | | - |
472 | if (json < end && *json == '-') partially evaluated: json < end yes Evaluation Count:2488 | no Evaluation Count:0 |
evaluated: *json == '-' yes Evaluation Count:21 | yes Evaluation Count:2467 |
| 0-2488 |
473 | ++json; executed: ++json; Execution Count:21 | 21 |
474 | | - |
475 | | - |
476 | if (json < end && *json == '0') { partially evaluated: json < end yes Evaluation Count:2488 | no Evaluation Count:0 |
evaluated: *json == '0' yes Evaluation Count:18 | yes Evaluation Count:2470 |
| 0-2488 |
477 | ++json; | - |
478 | } else { executed: } Execution Count:18 | 18 |
479 | while (json < end && *json >= '0' && *json <= '9') evaluated: json < end yes Evaluation Count:12496 | yes Evaluation Count:1 |
evaluated: *json >= '0' yes Evaluation Count:11388 | yes Evaluation Count:1108 |
evaluated: *json <= '9' yes Evaluation Count:10027 | yes Evaluation Count:1361 |
| 1-12496 |
480 | ++json; executed: ++json; Execution Count:10027 | 10027 |
481 | } executed: } Execution Count:2470 | 2470 |
482 | | - |
483 | | - |
484 | if (json < end && *json == '.') { evaluated: json < end yes Evaluation Count:2487 | yes Evaluation Count:1 |
evaluated: *json == '.' yes Evaluation Count:199 | yes Evaluation Count:2288 |
| 1-2487 |
485 | isInt = false; | - |
486 | ++json; | - |
487 | while (json < end && *json >= '0' && *json <= '9') partially evaluated: json < end yes Evaluation Count:1284 | no Evaluation Count:0 |
evaluated: *json >= '0' yes Evaluation Count:1106 | yes Evaluation Count:178 |
evaluated: *json <= '9' yes Evaluation Count:1085 | yes Evaluation Count:21 |
| 0-1284 |
488 | ++json; executed: ++json; Execution Count:1085 | 1085 |
489 | } executed: } Execution Count:199 | 199 |
490 | | - |
491 | | - |
492 | if (json < end && (*json == 'e' || *json == 'E')) { evaluated: json < end yes Evaluation Count:2487 | yes Evaluation Count:1 |
evaluated: *json == 'e' yes Evaluation Count:40 | yes Evaluation Count:2447 |
evaluated: *json == 'E' yes Evaluation Count:10 | yes Evaluation Count:2437 |
| 1-2487 |
493 | isInt = false; | - |
494 | ++json; | - |
495 | if (json < end && (*json == '-' || *json == '+')) partially evaluated: json < end yes Evaluation Count:50 | no Evaluation Count:0 |
evaluated: *json == '-' yes Evaluation Count:15 | yes Evaluation Count:35 |
evaluated: *json == '+' yes Evaluation Count:12 | yes Evaluation Count:23 |
| 0-50 |
496 | ++json; executed: ++json; Execution Count:27 | 27 |
497 | while (json < end && *json >= '0' && *json <= '9') partially evaluated: json < end yes Evaluation Count:152 | no Evaluation Count:0 |
evaluated: *json >= '0' yes Evaluation Count:104 | yes Evaluation Count:48 |
evaluated: *json <= '9' yes Evaluation Count:102 | yes Evaluation Count:2 |
| 0-152 |
498 | ++json; executed: ++json; Execution Count:102 | 102 |
499 | } executed: } Execution Count:50 | 50 |
500 | | - |
501 | if (json >= end) { evaluated: json >= end yes Evaluation Count:1 | yes Evaluation Count:2487 |
| 1-2487 |
502 | lastError = QJsonParseError::TerminationByNumber; | - |
503 | return false; executed: return false; Execution Count:1 | 1 |
504 | } | - |
505 | | - |
506 | QByteArray number(start, json - start); | - |
507 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 683, __PRETTY_FUNCTION__).debug() << "numberstring" << number; executed: ; Execution Count:2487 never executed: QMessageLogger("json/qjsonparser.cpp", 683, __PRETTY_FUNCTION__).debug() << "numberstring" << number; partially evaluated: 1 yes Evaluation Count:2487 | no Evaluation Count:0 |
| 0-2487 |
508 | | - |
509 | if (isInt) { evaluated: isInt yes Evaluation Count:2259 | yes Evaluation Count:228 |
| 228-2259 |
510 | bool ok; | - |
511 | int n = number.toInt(&ok); | - |
512 | if (ok && n < (1<<25) && n > -(1<<25)) { evaluated: ok yes Evaluation Count:2163 | yes Evaluation Count:96 |
evaluated: n < (1<<25) yes Evaluation Count:2095 | yes Evaluation Count:68 |
partially evaluated: n > -(1<<25) yes Evaluation Count:2095 | no Evaluation Count:0 |
| 0-2163 |
513 | val->int_value = n; | - |
514 | val->latinOrIntValue = true; | - |
515 | do {} while (0); executed: } Execution Count:2095 partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:2095 |
| 0-2095 |
516 | return true; executed: return true; Execution Count:2095 | 2095 |
517 | } | - |
518 | } executed: } Execution Count:164 | 164 |
519 | | - |
520 | bool ok; | - |
521 | union { | - |
522 | quint64 ui; | - |
523 | double d; | - |
524 | }; | - |
525 | d = number.toDouble(&ok); | - |
526 | | - |
527 | if (!ok) { evaluated: !ok yes Evaluation Count:2 | yes Evaluation Count:390 |
| 2-390 |
528 | lastError = QJsonParseError::IllegalNumber; | - |
529 | return false; executed: return false; Execution Count:2 | 2 |
530 | } | - |
531 | | - |
532 | int pos = reserveSpace(sizeof(double)); | - |
533 | *(quint64 *)(data + pos) = qToLittleEndian(ui); | - |
534 | val->value = pos - baseOffset; | - |
535 | val->latinOrIntValue = false; | - |
536 | | - |
537 | do {} while (0); executed: } Execution Count:390 partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:390 |
| 0-390 |
538 | return true; executed: return true; Execution Count:390 | 390 |
539 | } | - |
540 | static inline bool addHexDigit(char digit, uint *result) | - |
541 | { | - |
542 | *result <<= 4; | - |
543 | if (digit >= '0' && digit <= '9') evaluated: digit >= '0' yes Evaluation Count:680 | yes Evaluation Count:2 |
evaluated: digit <= '9' yes Evaluation Count:414 | yes Evaluation Count:266 |
| 2-680 |
544 | *result |= (digit - '0'); executed: *result |= (digit - '0'); Execution Count:414 | 414 |
545 | else if (digit >= 'a' && digit <= 'f') evaluated: digit >= 'a' yes Evaluation Count:49 | yes Evaluation Count:219 |
partially evaluated: digit <= 'f' yes Evaluation Count:49 | no Evaluation Count:0 |
| 0-219 |
546 | *result |= (digit - 'a') + 10; executed: *result |= (digit - 'a') + 10; Execution Count:49 | 49 |
547 | else if (digit >= 'A' && digit <= 'F') evaluated: digit >= 'A' yes Evaluation Count:217 | yes Evaluation Count:2 |
partially evaluated: digit <= 'F' yes Evaluation Count:217 | no Evaluation Count:0 |
| 0-217 |
548 | *result |= (digit - 'A') + 10; executed: *result |= (digit - 'A') + 10; Execution Count:217 | 217 |
549 | else | - |
550 | return false; executed: return false; Execution Count:2 | 2 |
551 | return true; executed: return true; Execution Count:680 | 680 |
552 | } | - |
553 | | - |
554 | static inline bool scanEscapeSequence(const char *&json, const char *end, uint *ch) | - |
555 | { | - |
556 | ++json; | - |
557 | if (json >= end) partially evaluated: json >= end no Evaluation Count:0 | yes Evaluation Count:374 |
| 0-374 |
558 | return false; never executed: return false; | 0 |
559 | | - |
560 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 759, __PRETTY_FUNCTION__).debug() << "scan escape" << (char)*json; executed: ; Execution Count:374 never executed: QMessageLogger("json/qjsonparser.cpp", 759, __PRETTY_FUNCTION__).debug() << "scan escape" << (char)*json; partially evaluated: 1 yes Evaluation Count:374 | no Evaluation Count:0 |
| 0-374 |
561 | uint escaped = *json++; | - |
562 | switch (escaped) { | - |
563 | case '"': | - |
564 | *ch = '"'; break; executed: break; Execution Count:127 | 127 |
565 | case '\\': | - |
566 | *ch = '\\'; break; executed: break; Execution Count:9 | 9 |
567 | case '/': | - |
568 | *ch = '/'; break; executed: break; Execution Count:13 | 13 |
569 | case 'b': | - |
570 | *ch = 0x8; break; executed: break; Execution Count:9 | 9 |
571 | case 'f': | - |
572 | *ch = 0xc; break; executed: break; Execution Count:9 | 9 |
573 | case 'n': | - |
574 | *ch = 0xa; break; executed: break; Execution Count:9 | 9 |
575 | case 'r': | - |
576 | *ch = 0xd; break; executed: break; Execution Count:10 | 10 |
577 | case 't': | - |
578 | *ch = 0x9; break; executed: break; Execution Count:9 | 9 |
579 | case 'u': { | - |
580 | *ch = 0; | - |
581 | if (json > end - 4) partially evaluated: json > end - 4 no Evaluation Count:0 | yes Evaluation Count:171 |
| 0-171 |
582 | return false; never executed: return false; | 0 |
583 | for (int i = 0; i < 4; ++i) { evaluated: i < 4 yes Evaluation Count:682 | yes Evaluation Count:169 |
| 169-682 |
584 | if (!addHexDigit(*json, ch)) evaluated: !addHexDigit(*json, ch) yes Evaluation Count:2 | yes Evaluation Count:680 |
| 2-680 |
585 | return false; executed: return false; Execution Count:2 | 2 |
586 | ++json; | - |
587 | } executed: } Execution Count:680 | 680 |
588 | return true; executed: return true; Execution Count:169 | 169 |
589 | } | - |
590 | default: | - |
591 | | - |
592 | | - |
593 | *ch = escaped; | - |
594 | return true; executed: return true; Execution Count:8 | 8 |
595 | } | - |
596 | return true; executed: return true; Execution Count:195 | 195 |
597 | } | - |
598 | | - |
599 | static inline bool scanUtf8Char(const char *&json, const char *end, uint *result) | - |
600 | { | - |
601 | int need; | - |
602 | uint min_uc; | - |
603 | uint uc; | - |
604 | uchar ch = *json++; | - |
605 | if (ch < 128) { evaluated: ch < 128 yes Evaluation Count:184476 | yes Evaluation Count:42 |
| 42-184476 |
606 | *result = ch; | - |
607 | return true; executed: return true; Execution Count:184476 | 184476 |
608 | } else if ((ch & 0xe0) == 0xc0) { evaluated: (ch & 0xe0) == 0xc0 yes Evaluation Count:40 | yes Evaluation Count:2 |
| 2-40 |
609 | uc = ch & 0x1f; | - |
610 | need = 1; | - |
611 | min_uc = 0x80; | - |
612 | } else if ((ch & 0xf0) == 0xe0) { executed: } Execution Count:40 partially evaluated: (ch & 0xf0) == 0xe0 yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-40 |
613 | uc = ch & 0x0f; | - |
614 | need = 2; | - |
615 | min_uc = 0x800; | - |
616 | } else if ((ch&0xf8) == 0xf0) { executed: } Execution Count:2 never evaluated: (ch&0xf8) == 0xf0 | 0-2 |
617 | uc = ch & 0x07; | - |
618 | need = 3; | - |
619 | min_uc = 0x10000; | - |
620 | } else { | 0 |
621 | return false; never executed: return false; | 0 |
622 | } | - |
623 | | - |
624 | if (json >= end - need) partially evaluated: json >= end - need no Evaluation Count:0 | yes Evaluation Count:42 |
| 0-42 |
625 | return false; never executed: return false; | 0 |
626 | | - |
627 | for (int i = 0; i < need; ++i) { evaluated: i < need yes Evaluation Count:44 | yes Evaluation Count:42 |
| 42-44 |
628 | ch = *json++; | - |
629 | if ((ch&0xc0) != 0x80) partially evaluated: (ch&0xc0) != 0x80 no Evaluation Count:0 | yes Evaluation Count:44 |
| 0-44 |
630 | return false; never executed: return false; | 0 |
631 | uc = (uc << 6) | (ch & 0x3f); | - |
632 | } executed: } Execution Count:44 | 44 |
633 | | - |
634 | if (uc < min_uc || QChar::isNonCharacter(uc) || partially evaluated: uc < min_uc no Evaluation Count:0 | yes Evaluation Count:42 |
evaluated: QChar::isNonCharacter(uc) yes Evaluation Count:2 | yes Evaluation Count:40 |
| 0-42 |
635 | QChar::isSurrogate(uc) || uc > QChar::LastValidCodePoint) { partially evaluated: QChar::isSurrogate(uc) no Evaluation Count:0 | yes Evaluation Count:40 |
partially evaluated: uc > QChar::LastValidCodePoint no Evaluation Count:0 | yes Evaluation Count:40 |
| 0-40 |
636 | return false; executed: return false; Execution Count:2 | 2 |
637 | } | - |
638 | | - |
639 | *result = uc; | - |
640 | return true; executed: return true; Execution Count:40 | 40 |
641 | } | - |
642 | | - |
643 | bool Parser::parseString(bool *latin1) | - |
644 | { | - |
645 | *latin1 = true; | - |
646 | | - |
647 | const char *start = json; | - |
648 | int outStart = current; | - |
649 | | - |
650 | | - |
651 | | - |
652 | int stringPos = reserveSpace(2); | - |
653 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 852, __PRETTY_FUNCTION__).debug() << "parse string stringPos=" << stringPos << json; executed: ; Execution Count:11224 never executed: QMessageLogger("json/qjsonparser.cpp", 852, __PRETTY_FUNCTION__).debug() << "parse string stringPos=" << stringPos << json; partially evaluated: 1 yes Evaluation Count:11224 | no Evaluation Count:0 |
| 0-11224 |
654 | while (json < end) { evaluated: json < end yes Evaluation Count:195755 | yes Evaluation Count:1 |
| 1-195755 |
655 | uint ch = 0; | - |
656 | if (*json == '"') evaluated: *json == '"' yes Evaluation Count:11198 | yes Evaluation Count:184557 |
| 11198-184557 |
657 | break; executed: break; Execution Count:11198 | 11198 |
658 | else if (*json == '\\') { evaluated: *json == '\\' yes Evaluation Count:196 | yes Evaluation Count:184361 |
| 196-184361 |
659 | if (!scanEscapeSequence(json, end, &ch)) { evaluated: !scanEscapeSequence(json, end, &ch) yes Evaluation Count:1 | yes Evaluation Count:195 |
| 1-195 |
660 | lastError = QJsonParseError::IllegalEscapeSequence; | - |
661 | return false; executed: return false; Execution Count:1 | 1 |
662 | } | - |
663 | } else { executed: } Execution Count:195 | 195 |
664 | if (!scanUtf8Char(json, end, &ch)) { evaluated: !scanUtf8Char(json, end, &ch) yes Evaluation Count:1 | yes Evaluation Count:184360 |
| 1-184360 |
665 | lastError = QJsonParseError::IllegalUTF8String; | - |
666 | return false; executed: return false; Execution Count:1 | 1 |
667 | } | - |
668 | } executed: } Execution Count:184360 | 184360 |
669 | if (ch > 0xff) { evaluated: ch > 0xff yes Evaluation Count:23 | yes Evaluation Count:184532 |
| 23-184532 |
670 | *latin1 = false; | - |
671 | break; executed: break; Execution Count:23 | 23 |
672 | } | - |
673 | int pos = reserveSpace(1); | - |
674 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 873, __PRETTY_FUNCTION__).debug() << " " << ch << (char)ch; executed: ; Execution Count:184532 never executed: QMessageLogger("json/qjsonparser.cpp", 873, __PRETTY_FUNCTION__).debug() << " " << ch << (char)ch; partially evaluated: 1 yes Evaluation Count:184532 | no Evaluation Count:0 |
| 0-184532 |
675 | data[pos] = (uchar)ch; | - |
676 | } executed: } Execution Count:184532 | 184532 |
677 | ++json; | - |
678 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 877, __PRETTY_FUNCTION__).debug() << "end of string"; executed: ; Execution Count:11222 never executed: QMessageLogger("json/qjsonparser.cpp", 877, __PRETTY_FUNCTION__).debug() << "end of string"; partially evaluated: 1 yes Evaluation Count:11222 | no Evaluation Count:0 |
| 0-11222 |
679 | if (json >= end) { evaluated: json >= end yes Evaluation Count:1 | yes Evaluation Count:11221 |
| 1-11221 |
680 | lastError = QJsonParseError::UnterminatedString; | - |
681 | return false; executed: return false; Execution Count:1 | 1 |
682 | } | - |
683 | | - |
684 | | - |
685 | if (*latin1) { evaluated: *latin1 yes Evaluation Count:11198 | yes Evaluation Count:23 |
| 23-11198 |
686 | | - |
687 | *(QJsonPrivate::qle_ushort *)(data + stringPos) = ushort(current - outStart - sizeof(ushort)); | - |
688 | int pos = reserveSpace((4 - current) & 3); | - |
689 | while (pos & 3) evaluated: pos & 3 yes Evaluation Count:18526 | yes Evaluation Count:11198 |
| 11198-18526 |
690 | data[pos++] = 0; executed: data[pos++] = 0; Execution Count:18526 | 18526 |
691 | do {} while (0); executed: } Execution Count:11198 partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:11198 |
| 0-11198 |
692 | return true; executed: return true; Execution Count:11198 | 11198 |
693 | } | - |
694 | | - |
695 | *latin1 = false; | - |
696 | if (1) ; else QMessageLogger("json/qjsonparser.cpp", 895, __PRETTY_FUNCTION__).debug() << "not latin"; executed: ; Execution Count:23 never executed: QMessageLogger("json/qjsonparser.cpp", 895, __PRETTY_FUNCTION__).debug() << "not latin"; partially evaluated: 1 yes Evaluation Count:23 | no Evaluation Count:0 |
| 0-23 |
697 | | - |
698 | json = start; | - |
699 | current = outStart + sizeof(int); | - |
700 | | - |
701 | while (json < end) { evaluated: json < end yes Evaluation Count:355 | yes Evaluation Count:1 |
| 1-355 |
702 | uint ch = 0; | - |
703 | if (*json == '"') evaluated: *json == '"' yes Evaluation Count:20 | yes Evaluation Count:335 |
| 20-335 |
704 | break; executed: break; Execution Count:20 | 20 |
705 | else if (*json == '\\') { evaluated: *json == '\\' yes Evaluation Count:178 | yes Evaluation Count:157 |
| 157-178 |
706 | if (!scanEscapeSequence(json, end, &ch)) { evaluated: !scanEscapeSequence(json, end, &ch) yes Evaluation Count:1 | yes Evaluation Count:177 |
| 1-177 |
707 | lastError = QJsonParseError::IllegalEscapeSequence; | - |
708 | return false; executed: return false; Execution Count:1 | 1 |
709 | } | - |
710 | } else { executed: } Execution Count:177 | 177 |
711 | if (!scanUtf8Char(json, end, &ch)) { evaluated: !scanUtf8Char(json, end, &ch) yes Evaluation Count:1 | yes Evaluation Count:156 |
| 1-156 |
712 | lastError = QJsonParseError::IllegalUTF8String; | - |
713 | return false; executed: return false; Execution Count:1 | 1 |
714 | } | - |
715 | } executed: } Execution Count:156 | 156 |
716 | if (QChar::requiresSurrogates(ch)) { partially evaluated: QChar::requiresSurrogates(ch) no Evaluation Count:0 | yes Evaluation Count:333 |
| 0-333 |
717 | int pos = reserveSpace(4); | - |
718 | *(QJsonPrivate::qle_ushort *)(data + pos) = QChar::highSurrogate(ch); | - |
719 | *(QJsonPrivate::qle_ushort *)(data + pos + 2) = QChar::lowSurrogate(ch); | - |
720 | } else { | 0 |
721 | int pos = reserveSpace(2); | - |
722 | *(QJsonPrivate::qle_ushort *)(data + pos) = (ushort)ch; | - |
723 | } executed: } Execution Count:333 | 333 |
724 | } | - |
725 | ++json; | - |
726 | | - |
727 | if (json >= end) { evaluated: json >= end yes Evaluation Count:1 | yes Evaluation Count:20 |
| 1-20 |
728 | lastError = QJsonParseError::UnterminatedString; | - |
729 | return false; executed: return false; Execution Count:1 | 1 |
730 | } | - |
731 | | - |
732 | | - |
733 | *(QJsonPrivate::qle_int *)(data + stringPos) = (current - outStart - sizeof(int))/2; | - |
734 | int pos = reserveSpace((4 - current) & 3); | - |
735 | while (pos & 3) evaluated: pos & 3 yes Evaluation Count:16 | yes Evaluation Count:20 |
| 16-20 |
736 | data[pos++] = 0; executed: data[pos++] = 0; Execution Count:16 | 16 |
737 | do {} while (0); executed: } Execution Count:20 partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
738 | return true; executed: return true; Execution Count:20 | 20 |
739 | } | - |
740 | | - |
741 | | - |
742 | | - |
| | |