qjsonparser.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/json/qjsonparser.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Copyright (C) 2016 Intel Corporation.-
5** Contact: https://www.qt.io/licensing/-
6**-
7** This file is part of the QtCore module of the Qt Toolkit.-
8**-
9** $QT_BEGIN_LICENSE:LGPL$-
10** Commercial License Usage-
11** Licensees holding valid commercial Qt licenses may use this file in-
12** accordance with the commercial license agreement provided with the-
13** Software or, alternatively, in accordance with the terms contained in-
14** a written agreement between you and The Qt Company. For licensing terms-
15** and conditions see https://www.qt.io/terms-conditions. For further-
16** information use the contact form at https://www.qt.io/contact-us.-
17**-
18** GNU Lesser General Public License Usage-
19** Alternatively, this file may be used under the terms of the GNU Lesser-
20** General Public License version 3 as published by the Free Software-
21** Foundation and appearing in the file LICENSE.LGPL3 included in the-
22** packaging of this file. Please review the following information to-
23** ensure the GNU Lesser General Public License version 3 requirements-
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
25**-
26** GNU General Public License Usage-
27** Alternatively, this file may be used under the terms of the GNU-
28** General Public License version 2.0 or (at your option) the GNU General-
29** Public license version 3 or any later version approved by the KDE Free-
30** Qt Foundation. The licenses are as published by the Free Software-
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
32** included in the packaging of this file. Please review the following-
33** information to ensure the GNU General Public License requirements will-
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
35** https://www.gnu.org/licenses/gpl-3.0.html.-
36**-
37** $QT_END_LICENSE$-
38**-
39****************************************************************************/-
40-
41#ifndef QT_BOOTSTRAPPED-
42#include <qcoreapplication.h>-
43#endif-
44#include <qdebug.h>-
45#include "qjsonparser_p.h"-
46#include "qjson_p.h"-
47#include "private/qutfcodec_p.h"-
48-
49//#define PARSER_DEBUG-
50#ifdef PARSER_DEBUG-
51static int indent = 0;-
52#define BEGIN qDebug() << QByteArray(4*indent++, ' ').constData() << "pos=" << current-
53#define END --indent-
54#define DEBUG qDebug() << QByteArray(4*indent, ' ').constData()-
55#else-
56#define BEGIN if (1) ; else qDebug()-
57#define END do {} while (0)-
58#define DEBUG if (1) ; else qDebug()-
59#endif-
60-
61static const int nestingLimit = 1024;-
62-
63QT_BEGIN_NAMESPACE-
64-
65// error strings for the JSON parser-
66#define JSONERR_OK QT_TRANSLATE_NOOP("QJsonParseError", "no error occurred")-
67#define JSONERR_UNTERM_OBJ QT_TRANSLATE_NOOP("QJsonParseError", "unterminated object")-
68#define JSONERR_MISS_NSEP QT_TRANSLATE_NOOP("QJsonParseError", "missing name separator")-
69#define JSONERR_UNTERM_AR QT_TRANSLATE_NOOP("QJsonParseError", "unterminated array")-
70#define JSONERR_MISS_VSEP QT_TRANSLATE_NOOP("QJsonParseError", "missing value separator")-
71#define JSONERR_ILLEGAL_VAL QT_TRANSLATE_NOOP("QJsonParseError", "illegal value")-
72#define JSONERR_END_OF_NUM QT_TRANSLATE_NOOP("QJsonParseError", "invalid termination by number")-
73#define JSONERR_ILLEGAL_NUM QT_TRANSLATE_NOOP("QJsonParseError", "illegal number")-
74#define JSONERR_STR_ESC_SEQ QT_TRANSLATE_NOOP("QJsonParseError", "invalid escape sequence")-
75#define JSONERR_STR_UTF8 QT_TRANSLATE_NOOP("QJsonParseError", "invalid UTF8 string")-
76#define JSONERR_UTERM_STR QT_TRANSLATE_NOOP("QJsonParseError", "unterminated string")-
77#define JSONERR_MISS_OBJ QT_TRANSLATE_NOOP("QJsonParseError", "object is missing after a comma")-
78#define JSONERR_DEEP_NEST QT_TRANSLATE_NOOP("QJsonParseError", "too deeply nested document")-
79#define JSONERR_DOC_LARGE QT_TRANSLATE_NOOP("QJsonParseError", "too large document")-
80#define JSONERR_GARBAGEEND QT_TRANSLATE_NOOP("QJsonParseError", "garbage at the end of the document")-
81-
82/*!-
83 \class QJsonParseError-
84 \inmodule QtCore-
85 \ingroup json-
86 \ingroup shared-
87 \reentrant-
88 \since 5.0-
89-
90 \brief The QJsonParseError class is used to report errors during JSON parsing.-
91-
92 \sa {JSON Support in Qt}, {JSON Save Game Example}-
93*/-
94-
95/*!-
96 \enum QJsonParseError::ParseError-
97-
98 This enum describes the type of error that occurred during the parsing of a JSON document.-
99-
100 \value NoError No error occurred-
101 \value UnterminatedObject An object is not correctly terminated with a closing curly bracket-
102 \value MissingNameSeparator A comma separating different items is missing-
103 \value UnterminatedArray The array is not correctly terminated with a closing square bracket-
104 \value MissingValueSeparator A colon separating keys from values inside objects is missing-
105 \value IllegalValue The value is illegal-
106 \value TerminationByNumber The input stream ended while parsing a number-
107 \value IllegalNumber The number is not well formed-
108 \value IllegalEscapeSequence An illegal escape sequence occurred in the input-
109 \value IllegalUTF8String An illegal UTF8 sequence occurred in the input-
110 \value UnterminatedString A string wasn't terminated with a quote-
111 \value MissingObject An object was expected but couldn't be found-
112 \value DeepNesting The JSON document is too deeply nested for the parser to parse it-
113 \value DocumentTooLarge The JSON document is too large for the parser to parse it-
114 \value GarbageAtEnd The parsed document contains additional garbage characters at the end-
115-
116*/-
117-
118/*!-
119 \variable QJsonParseError::error-
120-
121 Contains the type of the parse error. Is equal to QJsonParseError::NoError if the document-
122 was parsed correctly.-
123-
124 \sa ParseError, errorString()-
125*/-
126-
127-
128/*!-
129 \variable QJsonParseError::offset-
130-
131 Contains the offset in the input string where the parse error occurred.-
132-
133 \sa error, errorString()-
134*/-
135-
136/*!-
137 Returns the human-readable message appropriate to the reported JSON parsing error.-
138-
139 \sa error-
140 */-
141QString QJsonParseError::errorString() const-
142{-
143 const char *sz = "";-
144 switch (error) {-
145 case NoError:
never executed: case NoError:
0
146 sz = JSONERR_OK;-
147 break;
never executed: break;
0
148 case UnterminatedObject:
never executed: case UnterminatedObject:
0
149 sz = JSONERR_UNTERM_OBJ;-
150 break;
never executed: break;
0
151 case MissingNameSeparator:
never executed: case MissingNameSeparator:
0
152 sz = JSONERR_MISS_NSEP;-
153 break;
never executed: break;
0
154 case UnterminatedArray:
never executed: case UnterminatedArray:
0
155 sz = JSONERR_UNTERM_AR;-
156 break;
never executed: break;
0
157 case MissingValueSeparator:
never executed: case MissingValueSeparator:
0
158 sz = JSONERR_MISS_VSEP;-
159 break;
never executed: break;
0
160 case IllegalValue:
never executed: case IllegalValue:
0
161 sz = JSONERR_ILLEGAL_VAL;-
162 break;
never executed: break;
0
163 case TerminationByNumber:
never executed: case TerminationByNumber:
0
164 sz = JSONERR_END_OF_NUM;-
165 break;
never executed: break;
0
166 case IllegalNumber:
never executed: case IllegalNumber:
0
167 sz = JSONERR_ILLEGAL_NUM;-
168 break;
never executed: break;
0
169 case IllegalEscapeSequence:
never executed: case IllegalEscapeSequence:
0
170 sz = JSONERR_STR_ESC_SEQ;-
171 break;
never executed: break;
0
172 case IllegalUTF8String:
never executed: case IllegalUTF8String:
0
173 sz = JSONERR_STR_UTF8;-
174 break;
never executed: break;
0
175 case UnterminatedString:
never executed: case UnterminatedString:
0
176 sz = JSONERR_UTERM_STR;-
177 break;
never executed: break;
0
178 case MissingObject:
never executed: case MissingObject:
0
179 sz = JSONERR_MISS_OBJ;-
180 break;
never executed: break;
0
181 case DeepNesting:
never executed: case DeepNesting:
0
182 sz = JSONERR_DEEP_NEST;-
183 break;
never executed: break;
0
184 case DocumentTooLarge:
never executed: case DocumentTooLarge:
0
185 sz = JSONERR_DOC_LARGE;-
186 break;
never executed: break;
0
187 case GarbageAtEnd:
never executed: case GarbageAtEnd:
0
188 sz = JSONERR_GARBAGEEND;-
189 break;
never executed: break;
0
190 }-
191#ifndef QT_BOOTSTRAPPED-
192 return QCoreApplication::translate("QJsonParseError", sz);
never executed: return QCoreApplication::translate("QJsonParseError", sz);
0
193#else-
194 return QLatin1String(sz);-
195#endif-
196}-
197-
198using namespace QJsonPrivate;-
199-
200Parser::Parser(const char *json, int length)-
201 : head(json), json(json), data(0), dataLength(0), current(0), nestingLevel(0), lastError(QJsonParseError::NoError)-
202{-
203 end = json + length;-
204}
executed 10 times by 4 tests: end of block
Executed by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
10
205-
206-
207-
208/*-
209-
210begin-array = ws %x5B ws ; [ left square bracket-
211-
212begin-object = ws %x7B ws ; { left curly bracket-
213-
214end-array = ws %x5D ws ; ] right square bracket-
215-
216end-object = ws %x7D ws ; } right curly bracket-
217-
218name-separator = ws %x3A ws ; : colon-
219-
220value-separator = ws %x2C ws ; , comma-
221-
222Insignificant whitespace is allowed before or after any of the six-
223structural characters.-
224-
225ws = *(-
226 %x20 / ; Space-
227 %x09 / ; Horizontal tab-
228 %x0A / ; Line feed or New line-
229 %x0D ; Carriage return-
230 )-
231-
232*/-
233-
234enum {-
235 Space = 0x20,-
236 Tab = 0x09,-
237 LineFeed = 0x0a,-
238 Return = 0x0d,-
239 BeginArray = 0x5b,-
240 BeginObject = 0x7b,-
241 EndArray = 0x5d,-
242 EndObject = 0x7d,-
243 NameSeparator = 0x3a,-
244 ValueSeparator = 0x2c,-
245 Quote = 0x22-
246};-
247-
248void Parser::eatBOM()-
249{-
250 // eat UTF-8 byte order mark-
251 uchar utf8bom[3] = { 0xef, 0xbb, 0xbf };-
252 if (end - json > 3 &&
end - json > 3Description
TRUEevaluated 10 times by 4 tests
Evaluated by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEnever evaluated
0-10
253 (uchar)json[0] == utf8bom[0] &&
(uchar)json[0] == utf8bom[0]Description
TRUEnever evaluated
FALSEevaluated 10 times by 4 tests
Evaluated by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-10
254 (uchar)json[1] == utf8bom[1] &&
(uchar)json[1] == utf8bom[1]Description
TRUEnever evaluated
FALSEnever evaluated
0
255 (uchar)json[2] == utf8bom[2])
(uchar)json[2] == utf8bom[2]Description
TRUEnever evaluated
FALSEnever evaluated
0
256 json += 3;
never executed: json += 3;
0
257}
executed 10 times by 4 tests: end of block
Executed by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
10
258-
259bool Parser::eatSpace()-
260{-
261 while (json < end) {
json < endDescription
TRUEevaluated 30245 times by 4 tests
Evaluated by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEevaluated 14 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
14-30245
262 if (*json > Space)
*json > SpaceDescription
TRUEevaluated 9523 times by 4 tests
Evaluated by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEevaluated 20722 times by 4 tests
Evaluated by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
9523-20722
263 break;
executed 9523 times by 4 tests: break;
Executed by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
9523
264 if (*json != Space &&
*json != SpaceDescription
TRUEevaluated 2643 times by 2 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
FALSEevaluated 18079 times by 4 tests
Evaluated by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
2643-18079
265 *json != Tab &&
*json != TabDescription
TRUEevaluated 2643 times by 2 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
FALSEnever evaluated
0-2643
266 *json != LineFeed &&
*json != LineFeedDescription
TRUEnever evaluated
FALSEevaluated 2643 times by 2 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
0-2643
267 *json != Return)
*json != ReturnDescription
TRUEnever evaluated
FALSEnever evaluated
0
268 break;
never executed: break;
0
269 ++json;-
270 }
executed 20722 times by 4 tests: end of block
Executed by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
20722
271 return (json < end);
executed 9537 times by 4 tests: return (json < end);
Executed by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
9537
272}-
273-
274char Parser::nextToken()-
275{-
276 if (!eatSpace())
!eatSpace()Description
TRUEnever evaluated
FALSEevaluated 5213 times by 4 tests
Evaluated by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-5213
277 return 0;
never executed: return 0;
0
278 char token = *json++;-
279 switch (token) {-
280 case BeginArray:
executed 1 time by 1 test: case BeginArray:
Executed by:
  • tst_QNetworkCookieJar
1
281 case BeginObject:
executed 8 times by 3 tests: case BeginObject:
Executed by:
  • tst_QMetaType
  • tst_QOpenGlConfig
  • tst_qmakelib
8
282 case NameSeparator:
executed 1439 times by 3 tests: case NameSeparator:
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
1439
283 case ValueSeparator:
executed 1278 times by 3 tests: case ValueSeparator:
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
1278
284 case EndArray:
executed 546 times by 3 tests: case EndArray:
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
546
285 case EndObject:
executed 499 times by 3 tests: case EndObject:
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
499
286 eatSpace();-
287 case Quote:
code before this statement executed 3771 times by 4 tests: case Quote:
Executed by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
executed 1439 times by 3 tests: case Quote:
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
1439-3771
288 break;
executed 5210 times by 4 tests: break;
Executed by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
5210
289 default:
executed 3 times by 2 tests: default:
Executed by:
  • tst_QMetaType
  • tst_qmakelib
3
290 token = 0;-
291 break;
executed 3 times by 2 tests: break;
Executed by:
  • tst_QMetaType
  • tst_qmakelib
3
292 }-
293 return token;
executed 5213 times by 4 tests: return token;
Executed by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
5213
294}-
295-
296/*-
297 JSON-text = object / array-
298*/-
299QJsonDocument Parser::parse(QJsonParseError *error)-
300{-
301#ifdef PARSER_DEBUG-
302 indent = 0;-
303 qDebug(">>>>> parser begin");-
304#endif-
305 // allocate some space-
306 dataLength = qMax(end - json, (ptrdiff_t) 256);-
307 data = (char *)malloc(dataLength);-
308-
309 // fill in Header data-
310 QJsonPrivate::Header *h = (QJsonPrivate::Header *)data;-
311 h->tag = QJsonDocument::BinaryFormatTag;-
312 h->version = 1u;-
313-
314 current = sizeof(QJsonPrivate::Header);-
315-
316 eatBOM();-
317 char token = nextToken();-
318-
319 DEBUG << hex << (uint)token;
executed 10 times by 4 tests: ;
Executed by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 319, __PRETTY_FUNCTION__).debug() << hex << (uint)token;
-
320 if (token == BeginArray) {
token == BeginArrayDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
FALSEevaluated 9 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QOpenGlConfig
  • tst_qmakelib
1-9
321 if (!parseArray())
!parseArray()Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
0-1
322 goto error;
never executed: goto error;
0
323 } else if (token == BeginObject) {
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkCookieJar
token == BeginObjectDescription
TRUEevaluated 8 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmakelib
1-8
324 if (!parseObject())
!parseObject()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMetaType
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
2-6
325 goto error;
executed 2 times by 1 test: goto error;
Executed by:
  • tst_QMetaType
2
326 } else {
executed 6 times by 2 tests: end of block
Executed by:
  • tst_QOpenGlConfig
  • tst_qmakelib
6
327 lastError = QJsonParseError::IllegalValue;-
328 goto error;
executed 1 time by 1 test: goto error;
Executed by:
  • tst_qmakelib
1
329 }-
330-
331 eatSpace();-
332 if (json < end) {
json < endDescription
TRUEnever evaluated
FALSEevaluated 7 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-7
333 lastError = QJsonParseError::GarbageAtEnd;-
334 goto error;
never executed: goto error;
0
335 }-
336-
337 END;-
338 {-
339 if (error) {
errorDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QOpenGlConfig
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_qmakelib
2-5
340 error->offset = 0;-
341 error->error = QJsonParseError::NoError;-
342 }
executed 5 times by 1 test: end of block
Executed by:
  • tst_QOpenGlConfig
5
343 QJsonPrivate::Data *d = new QJsonPrivate::Data(data, current);-
344 return QJsonDocument(d);
executed 7 times by 3 tests: return QJsonDocument(d);
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
7
345 }-
346-
347error:-
348#ifdef PARSER_DEBUG-
349 qDebug(">>>>> parser error");-
350#endif-
351 if (error) {
errorDescription
TRUEnever evaluated
FALSEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QMetaType
  • tst_qmakelib
0-3
352 error->offset = json - head;-
353 error->error = lastError;-
354 }
never executed: end of block
0
355 free(data);-
356 return QJsonDocument();
executed 3 times by 2 tests: return QJsonDocument();
Executed by:
  • tst_QMetaType
  • tst_qmakelib
3
357}-
358-
359-
360void Parser::ParsedObject::insert(uint offset) {-
361 const QJsonPrivate::Entry *newEntry = reinterpret_cast<const QJsonPrivate::Entry *>(parser->data + objectPosition + offset);-
362 int min = 0;-
363 int n = offsets.size();-
364 while (n > 0) {
n > 0Description
TRUEevaluated 1397 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEevaluated 1439 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
1397-1439
365 int half = n >> 1;-
366 int middle = min + half;-
367 if (*entryAt(middle) >= *newEntry) {
*entryAt(middle) >= *newEntryDescription
TRUEevaluated 723 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEevaluated 674 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
674-723
368 n = half;-
369 } else {
executed 723 times by 3 tests: end of block
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
723
370 min = middle + 1;-
371 n -= half + 1;-
372 }
executed 674 times by 3 tests: end of block
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
674
373 }-
374 if (min < offsets.size() && *entryAt(min) == *newEntry) {
min < offsets.size()Description
TRUEevaluated 711 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEevaluated 728 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
*entryAt(min) == *newEntryDescription
TRUEnever evaluated
FALSEevaluated 711 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-728
375 offsets[min] = offset;-
376 } else {
never executed: end of block
0
377 offsets.insert(min, offset);-
378 }
executed 1439 times by 3 tests: end of block
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
1439
379}-
380-
381/*-
382 object = begin-object [ member *( value-separator member ) ]-
383 end-object-
384*/-
385-
386bool Parser::parseObject()-
387{-
388 if (++nestingLevel > nestingLimit) {
++nestingLevel > nestingLimitDescription
TRUEnever evaluated
FALSEevaluated 501 times by 4 tests
Evaluated by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-501
389 lastError = QJsonParseError::DeepNesting;-
390 return false;
never executed: return false;
0
391 }-
392-
393 int objectOffset = reserveSpace(sizeof(QJsonPrivate::Object));-
394 if (objectOffset < 0)
objectOffset < 0Description
TRUEnever evaluated
FALSEevaluated 501 times by 4 tests
Evaluated by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-501
395 return false;
never executed: return false;
0
396 BEGIN << "parseObject pos=" << objectOffset << current << json;
executed 501 times by 4 tests: ;
Executed by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 396, __PRETTY_FUNCTION__).debug() << "parseObject pos=" << objectOffset << current << json;
-
397-
398 ParsedObject parsedObject(this, objectOffset);-
399-
400 char token = nextToken();-
401 while (token == Quote) {
token == QuoteDescription
TRUEevaluated 1439 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMetaType
2-1439
402 int off = current - objectOffset;-
403 if (!parseMember(objectOffset))
!parseMember(objectOffset)Description
TRUEnever evaluated
FALSEevaluated 1439 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-1439
404 return false;
never executed: return false;
0
405 parsedObject.insert(off);-
406 token = nextToken();-
407 if (token != ValueSeparator)
token != ValueSeparatorDescription
TRUEevaluated 499 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEevaluated 940 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
499-940
408 break;
executed 499 times by 3 tests: break;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
499
409 token = nextToken();-
410 if (token == EndObject) {
token == EndObjectDescription
TRUEnever evaluated
FALSEevaluated 940 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-940
411 lastError = QJsonParseError::MissingObject;-
412 return false;
never executed: return false;
0
413 }-
414 }
executed 940 times by 3 tests: end of block
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
940
415-
416 DEBUG << "end token=" << token;
executed 501 times by 4 tests: ;
Executed by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 416, __PRETTY_FUNCTION__).debug() << "end token=" << token;
-
417 if (token != EndObject) {
token != EndObjectDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMetaType
FALSEevaluated 499 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
2-499
418 lastError = QJsonParseError::UnterminatedObject;-
419 return false;
executed 2 times by 1 test: return false;
Executed by:
  • tst_QMetaType
2
420 }-
421-
422 DEBUG << "numEntries" << parsedObject.offsets.size();
executed 499 times by 3 tests: ;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 422, __PRETTY_FUNCTION__).debug() << "numEntries" << parsedObject.offsets.size();
-
423 int table = objectOffset;-
424 // finalize the object-
425 if (parsedObject.offsets.size()) {
parsedObject.offsets.size()Description
TRUEevaluated 499 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEnever evaluated
0-499
426 int tableSize = parsedObject.offsets.size()*sizeof(uint);-
427 table = reserveSpace(tableSize);-
428 if (table < 0)
table < 0Description
TRUEnever evaluated
FALSEevaluated 499 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-499
429 return false;
never executed: return false;
0
430-
431#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN-
432 memcpy(data + table, parsedObject.offsets.constData(), tableSize);-
433#else-
434 offset *o = (offset *)(data + table);-
435 for (int i = 0; i < parsedObject.offsets.size(); ++i)-
436 o[i] = parsedObject.offsets[i];-
437-
438#endif-
439 }
executed 499 times by 3 tests: end of block
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
499
440-
441 QJsonPrivate::Object *o = (QJsonPrivate::Object *)(data + objectOffset);-
442 o->tableOffset = table - objectOffset;-
443 o->size = current - objectOffset;-
444 o->is_object = true;-
445 o->length = parsedObject.offsets.size();-
446-
447 DEBUG << "current=" << current;
executed 499 times by 3 tests: ;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 447, __PRETTY_FUNCTION__).debug() << "current=" << current;
-
448 END;-
449-
450 --nestingLevel;-
451 return true;
executed 499 times by 3 tests: return true;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
499
452}-
453-
454/*-
455 member = string name-separator value-
456*/-
457bool Parser::parseMember(int baseOffset)-
458{-
459 int entryOffset = reserveSpace(sizeof(QJsonPrivate::Entry));-
460 if (entryOffset < 0)
entryOffset < 0Description
TRUEnever evaluated
FALSEevaluated 1439 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-1439
461 return false;
never executed: return false;
0
462 BEGIN << "parseMember pos=" << entryOffset;
executed 1439 times by 3 tests: ;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 462, __PRETTY_FUNCTION__).debug() << "parseMember pos=" << entryOffset;
-
463-
464 bool latin1;-
465 if (!parseString(&latin1))
!parseString(&latin1)Description
TRUEnever evaluated
FALSEevaluated 1439 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-1439
466 return false;
never executed: return false;
0
467 char token = nextToken();-
468 if (token != NameSeparator) {
token != NameSeparatorDescription
TRUEnever evaluated
FALSEevaluated 1439 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-1439
469 lastError = QJsonParseError::MissingNameSeparator;-
470 return false;
never executed: return false;
0
471 }-
472 QJsonPrivate::Value val;-
473 if (!parseValue(&val, baseOffset))
!parseValue(&val, baseOffset)Description
TRUEnever evaluated
FALSEevaluated 1439 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-1439
474 return false;
never executed: return false;
0
475-
476 // finalize the entry-
477 QJsonPrivate::Entry *e = (QJsonPrivate::Entry *)(data + entryOffset);-
478 e->value = val;-
479 e->value.latinKey = latin1;-
480-
481 END;-
482 return true;
executed 1439 times by 3 tests: return true;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
1439
483}-
484-
485namespace {-
486 struct ValueArray {-
487 static const int prealloc = 128;-
488 ValueArray() : data(stackValues), alloc(prealloc), size(0) {}
executed 546 times by 3 tests: end of block
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
546
489 ~ValueArray() { if (data != stackValues) free(data); }
executed 546 times by 3 tests: end of block
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
executed 1 time by 1 test: free(data);
Executed by:
  • tst_QNetworkCookieJar
data != stackValuesDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
FALSEevaluated 545 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
1-546
490-
491 inline bool grow() {-
492 alloc *= 2;-
493 if (data == stackValues) {
data == stackValuesDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
FALSEnever evaluated
0-1
494 QJsonPrivate::Value *newValues = static_cast<QJsonPrivate::Value *>(malloc(alloc*sizeof(QJsonPrivate::Value)));-
495 if (!newValues)
!newValuesDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
0-1
496 return false;
never executed: return false;
0
497 memcpy(newValues, data, size*sizeof(QJsonPrivate::Value));-
498 data = newValues;-
499 } else {
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkCookieJar
1
500 void *newValues = realloc(data, alloc * sizeof(QJsonPrivate::Value));-
501 if (!newValues)
!newValuesDescription
TRUEnever evaluated
FALSEnever evaluated
0
502 return false;
never executed: return false;
0
503 data = static_cast<QJsonPrivate::Value *>(newValues);-
504 }
never executed: end of block
0
505 return true;
executed 1 time by 1 test: return true;
Executed by:
  • tst_QNetworkCookieJar
1
506 }-
507 bool append(const QJsonPrivate::Value &v) {-
508 if (alloc == size && !grow())
alloc == sizeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
FALSEevaluated 796 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
!grow()Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
0-796
509 return false;
never executed: return false;
0
510 data[size] = v;-
511 ++size;-
512 return true;
executed 797 times by 3 tests: return true;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
797
513 }-
514-
515 QJsonPrivate::Value stackValues[prealloc];-
516 QJsonPrivate::Value *data;-
517 int alloc;-
518 int size;-
519 };-
520}-
521-
522/*-
523 array = begin-array [ value *( value-separator value ) ] end-array-
524*/-
525bool Parser::parseArray()-
526{-
527 BEGIN << "parseArray";
executed 546 times by 3 tests: ;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 527, __PRETTY_FUNCTION__).debug() << "parseArray";
-
528-
529 if (++nestingLevel > nestingLimit) {
++nestingLevel > nestingLimitDescription
TRUEnever evaluated
FALSEevaluated 546 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-546
530 lastError = QJsonParseError::DeepNesting;-
531 return false;
never executed: return false;
0
532 }-
533-
534 int arrayOffset = reserveSpace(sizeof(QJsonPrivate::Array));-
535 if (arrayOffset < 0)
arrayOffset < 0Description
TRUEnever evaluated
FALSEevaluated 546 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-546
536 return false;
never executed: return false;
0
537-
538 ValueArray values;-
539-
540 if (!eatSpace()) {
!eatSpace()Description
TRUEnever evaluated
FALSEevaluated 546 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-546
541 lastError = QJsonParseError::UnterminatedArray;-
542 return false;
never executed: return false;
0
543 }-
544 if (*json == EndArray) {
*json == EndArrayDescription
TRUEevaluated 87 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
FALSEevaluated 459 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
87-459
545 nextToken();-
546 } else {
executed 87 times by 1 test: end of block
Executed by:
  • tst_QNetworkCookieJar
87
547 while (1) {-
548 QJsonPrivate::Value val;-
549 if (!parseValue(&val, arrayOffset))
!parseValue(&val, arrayOffset)Description
TRUEnever evaluated
FALSEevaluated 797 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-797
550 return false;
never executed: return false;
0
551 if (!values.append(val)) {
!values.append(val)Description
TRUEnever evaluated
FALSEevaluated 797 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-797
552 lastError = QJsonParseError::DocumentTooLarge;-
553 return false;
never executed: return false;
0
554 }-
555 char token = nextToken();-
556 if (token == EndArray)
token == EndArrayDescription
TRUEevaluated 459 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEevaluated 338 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
338-459
557 break;
executed 459 times by 3 tests: break;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
459
558 else if (token != ValueSeparator) {
token != ValueSeparatorDescription
TRUEnever evaluated
FALSEevaluated 338 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-338
559 if (!eatSpace())
!eatSpace()Description
TRUEnever evaluated
FALSEnever evaluated
0
560 lastError = QJsonParseError::UnterminatedArray;
never executed: lastError = QJsonParseError::UnterminatedArray;
0
561 else-
562 lastError = QJsonParseError::MissingValueSeparator;
never executed: lastError = QJsonParseError::MissingValueSeparator;
0
563 return false;
never executed: return false;
0
564 }-
565 }
executed 338 times by 3 tests: end of block
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
338
566 }
executed 459 times by 3 tests: end of block
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
459
567-
568 DEBUG << "size =" << values.size;
executed 546 times by 3 tests: ;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 568, __PRETTY_FUNCTION__).debug() << "size =" << values.size;
-
569 int table = arrayOffset;-
570 // finalize the object-
571 if (values.size) {
values.sizeDescription
TRUEevaluated 459 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEevaluated 87 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
87-459
572 int tableSize = values.size*sizeof(QJsonPrivate::Value);-
573 table = reserveSpace(tableSize);-
574 if (table < 0)
table < 0Description
TRUEnever evaluated
FALSEevaluated 459 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-459
575 return false;
never executed: return false;
0
576 memcpy(data + table, values.data, tableSize);-
577 }
executed 459 times by 3 tests: end of block
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
459
578-
579 QJsonPrivate::Array *a = (QJsonPrivate::Array *)(data + arrayOffset);-
580 a->tableOffset = table - arrayOffset;-
581 a->size = current - arrayOffset;-
582 a->is_object = false;-
583 a->length = values.size;-
584-
585 DEBUG << "current=" << current;
executed 546 times by 3 tests: ;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 585, __PRETTY_FUNCTION__).debug() << "current=" << current;
-
586 END;-
587-
588 --nestingLevel;-
589 return true;
executed 546 times by 3 tests: return true;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
546
590}-
591-
592/*-
593value = false / null / true / object / array / number / string-
594-
595*/-
596-
597bool Parser::parseValue(QJsonPrivate::Value *val, int baseOffset)-
598{-
599 BEGIN << "parse Value" << json;
executed 2236 times by 3 tests: ;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 599, __PRETTY_FUNCTION__).debug() << "parse Value" << json;
-
600 val->_dummy = 0;-
601-
602 switch (*json++) {-
603 case 'n':
executed 1 time by 1 test: case 'n':
Executed by:
  • tst_qmakelib
1
604 if (end - json < 4) {
end - json < 4Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmakelib
0-1
605 lastError = QJsonParseError::IllegalValue;-
606 return false;
never executed: return false;
0
607 }-
608 if (*json++ == 'u' &&
*json++ == 'u'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmakelib
FALSEnever evaluated
0-1
609 *json++ == 'l' &&
*json++ == 'l'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmakelib
FALSEnever evaluated
0-1
610 *json++ == 'l') {
*json++ == 'l'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmakelib
FALSEnever evaluated
0-1
611 val->type = QJsonValue::Null;-
612 DEBUG << "value: null";
executed 1 time by 1 test: ;
Executed by:
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 612, __PRETTY_FUNCTION__).debug() << "value: null";
-
613 END;-
614 return true;
executed 1 time by 1 test: return true;
Executed by:
  • tst_qmakelib
1
615 }-
616 lastError = QJsonParseError::IllegalValue;-
617 return false;
never executed: return false;
0
618 case 't':
executed 1 time by 1 test: case 't':
Executed by:
  • tst_qmakelib
1
619 if (end - json < 4) {
end - json < 4Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmakelib
0-1
620 lastError = QJsonParseError::IllegalValue;-
621 return false;
never executed: return false;
0
622 }-
623 if (*json++ == 'r' &&
*json++ == 'r'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmakelib
FALSEnever evaluated
0-1
624 *json++ == 'u' &&
*json++ == 'u'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmakelib
FALSEnever evaluated
0-1
625 *json++ == 'e') {
*json++ == 'e'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmakelib
FALSEnever evaluated
0-1
626 val->type = QJsonValue::Bool;-
627 val->value = true;-
628 DEBUG << "value: true";
executed 1 time by 1 test: ;
Executed by:
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 628, __PRETTY_FUNCTION__).debug() << "value: true";
-
629 END;-
630 return true;
executed 1 time by 1 test: return true;
Executed by:
  • tst_qmakelib
1
631 }-
632 lastError = QJsonParseError::IllegalValue;-
633 return false;
never executed: return false;
0
634 case 'f':
executed 1 time by 1 test: case 'f':
Executed by:
  • tst_qmakelib
1
635 if (end - json < 5) {
end - json < 5Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmakelib
0-1
636 lastError = QJsonParseError::IllegalValue;-
637 return false;
never executed: return false;
0
638 }-
639 if (*json++ == 'a' &&
*json++ == 'a'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmakelib
FALSEnever evaluated
0-1
640 *json++ == 'l' &&
*json++ == 'l'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmakelib
FALSEnever evaluated
0-1
641 *json++ == 's' &&
*json++ == 's'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmakelib
FALSEnever evaluated
0-1
642 *json++ == 'e') {
*json++ == 'e'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmakelib
FALSEnever evaluated
0-1
643 val->type = QJsonValue::Bool;-
644 val->value = false;-
645 DEBUG << "value: false";
executed 1 time by 1 test: ;
Executed by:
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 645, __PRETTY_FUNCTION__).debug() << "value: false";
-
646 END;-
647 return true;
executed 1 time by 1 test: return true;
Executed by:
  • tst_qmakelib
1
648 }-
649 lastError = QJsonParseError::IllegalValue;-
650 return false;
never executed: return false;
0
651 case Quote: {
executed 1144 times by 3 tests: case Quote:
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
1144
652 val->type = QJsonValue::String;-
653 if (current - baseOffset >= Value::MaxSize) {
current - base...Value::MaxSizeDescription
TRUEnever evaluated
FALSEevaluated 1144 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-1144
654 lastError = QJsonParseError::DocumentTooLarge;-
655 return false;
never executed: return false;
0
656 }-
657 val->value = current - baseOffset;-
658 bool latin1;-
659 if (!parseString(&latin1))
!parseString(&latin1)Description
TRUEnever evaluated
FALSEevaluated 1144 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-1144
660 return false;
never executed: return false;
0
661 val->latinOrIntValue = latin1;-
662 DEBUG << "value: string";
executed 1144 times by 3 tests: ;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 662, __PRETTY_FUNCTION__).debug() << "value: string";
-
663 END;-
664 return true;
executed 1144 times by 3 tests: return true;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
1144
665 }-
666 case BeginArray:
executed 545 times by 3 tests: case BeginArray:
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
545
667 val->type = QJsonValue::Array;-
668 if (current - baseOffset >= Value::MaxSize) {
current - base...Value::MaxSizeDescription
TRUEnever evaluated
FALSEevaluated 545 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-545
669 lastError = QJsonParseError::DocumentTooLarge;-
670 return false;
never executed: return false;
0
671 }-
672 val->value = current - baseOffset;-
673 if (!parseArray())
!parseArray()Description
TRUEnever evaluated
FALSEevaluated 545 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-545
674 return false;
never executed: return false;
0
675 DEBUG << "value: array";
executed 545 times by 3 tests: ;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 675, __PRETTY_FUNCTION__).debug() << "value: array";
-
676 END;-
677 return true;
executed 545 times by 3 tests: return true;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
545
678 case BeginObject:
executed 493 times by 3 tests: case BeginObject:
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
493
679 val->type = QJsonValue::Object;-
680 if (current - baseOffset >= Value::MaxSize) {
current - base...Value::MaxSizeDescription
TRUEnever evaluated
FALSEevaluated 493 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-493
681 lastError = QJsonParseError::DocumentTooLarge;-
682 return false;
never executed: return false;
0
683 }-
684 val->value = current - baseOffset;-
685 if (!parseObject())
!parseObject()Description
TRUEnever evaluated
FALSEevaluated 493 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-493
686 return false;
never executed: return false;
0
687 DEBUG << "value: object";
executed 493 times by 3 tests: ;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 687, __PRETTY_FUNCTION__).debug() << "value: object";
-
688 END;-
689 return true;
executed 493 times by 3 tests: return true;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
493
690 case EndArray:
never executed: case EndArray:
0
691 lastError = QJsonParseError::MissingObject;-
692 return false;
never executed: return false;
0
693 default:
executed 51 times by 2 tests: default:
Executed by:
  • tst_QOpenGlConfig
  • tst_qmakelib
51
694 --json;-
695 if (!parseNumber(val, baseOffset))
!parseNumber(val, baseOffset)Description
TRUEnever evaluated
FALSEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
0-51
696 return false;
never executed: return false;
0
697 DEBUG << "value: number";
executed 51 times by 2 tests: ;
Executed by:
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 697, __PRETTY_FUNCTION__).debug() << "value: number";
-
698 END;-
699 }
executed 51 times by 2 tests: end of block
Executed by:
  • tst_QOpenGlConfig
  • tst_qmakelib
51
700-
701 return true;
executed 51 times by 2 tests: return true;
Executed by:
  • tst_QOpenGlConfig
  • tst_qmakelib
51
702}-
703-
704-
705-
706-
707-
708/*-
709 number = [ minus ] int [ frac ] [ exp ]-
710 decimal-point = %x2E ; .-
711 digit1-9 = %x31-39 ; 1-9-
712 e = %x65 / %x45 ; e E-
713 exp = e [ minus / plus ] 1*DIGIT-
714 frac = decimal-point 1*DIGIT-
715 int = zero / ( digit1-9 *DIGIT )-
716 minus = %x2D ; --
717 plus = %x2B ; +-
718 zero = %x30 ; 0-
719-
720*/-
721-
722bool Parser::parseNumber(QJsonPrivate::Value *val, int baseOffset)-
723{-
724 BEGIN << "parseNumber" << json;
executed 51 times by 2 tests: ;
Executed by:
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 724, __PRETTY_FUNCTION__).debug() << "parseNumber" << json;
-
725 val->type = QJsonValue::Double;-
726-
727 const char *start = json;-
728 bool isInt = true;-
729-
730 // minus-
731 if (json < end && *json == '-')
json < endDescription
TRUEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEnever evaluated
*json == '-'Description
TRUEnever evaluated
FALSEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
0-51
732 ++json;
never executed: ++json;
0
733-
734 // int = zero / ( digit1-9 *DIGIT )-
735 if (json < end && *json == '0') {
json < endDescription
TRUEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEnever evaluated
*json == '0'Description
TRUEnever evaluated
FALSEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
0-51
736 ++json;-
737 } else {
never executed: end of block
0
738 while (json < end && *json >= '0' && *json <= '9')
json < endDescription
TRUEevaluated 114 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEnever evaluated
*json >= '0'Description
TRUEevaluated 63 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
*json <= '9'Description
TRUEevaluated 63 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEnever evaluated
0-114
739 ++json;
executed 63 times by 2 tests: ++json;
Executed by:
  • tst_QOpenGlConfig
  • tst_qmakelib
63
740 }
executed 51 times by 2 tests: end of block
Executed by:
  • tst_QOpenGlConfig
  • tst_qmakelib
51
741-
742 // frac = decimal-point 1*DIGIT-
743 if (json < end && *json == '.') {
json < endDescription
TRUEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEnever evaluated
*json == '.'Description
TRUEnever evaluated
FALSEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
0-51
744 isInt = false;-
745 ++json;-
746 while (json < end && *json >= '0' && *json <= '9')
json < endDescription
TRUEnever evaluated
FALSEnever evaluated
*json >= '0'Description
TRUEnever evaluated
FALSEnever evaluated
*json <= '9'Description
TRUEnever evaluated
FALSEnever evaluated
0
747 ++json;
never executed: ++json;
0
748 }
never executed: end of block
0
749-
750 // exp = e [ minus / plus ] 1*DIGIT-
751 if (json < end && (*json == 'e' || *json == 'E')) {
json < endDescription
TRUEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEnever evaluated
*json == 'e'Description
TRUEnever evaluated
FALSEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
*json == 'E'Description
TRUEnever evaluated
FALSEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
0-51
752 isInt = false;-
753 ++json;-
754 if (json < end && (*json == '-' || *json == '+'))
json < endDescription
TRUEnever evaluated
FALSEnever evaluated
*json == '-'Description
TRUEnever evaluated
FALSEnever evaluated
*json == '+'Description
TRUEnever evaluated
FALSEnever evaluated
0
755 ++json;
never executed: ++json;
0
756 while (json < end && *json >= '0' && *json <= '9')
json < endDescription
TRUEnever evaluated
FALSEnever evaluated
*json >= '0'Description
TRUEnever evaluated
FALSEnever evaluated
*json <= '9'Description
TRUEnever evaluated
FALSEnever evaluated
0
757 ++json;
never executed: ++json;
0
758 }
never executed: end of block
0
759-
760 if (json >= end) {
json >= endDescription
TRUEnever evaluated
FALSEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
0-51
761 lastError = QJsonParseError::TerminationByNumber;-
762 return false;
never executed: return false;
0
763 }-
764-
765 QByteArray number(start, json - start);-
766 DEBUG << "numberstring" << number;
executed 51 times by 2 tests: ;
Executed by:
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 766, __PRETTY_FUNCTION__).debug() << "numberstring" << number;
-
767-
768 if (isInt) {
isIntDescription
TRUEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEnever evaluated
0-51
769 bool ok;-
770 int n = number.toInt(&ok);-
771 if (ok && n < (1<<25) && n > -(1<<25)) {
okDescription
TRUEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEnever evaluated
n < (1<<25)Description
TRUEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEnever evaluated
n > -(1<<25)Description
TRUEevaluated 51 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEnever evaluated
0-51
772 val->int_value = n;-
773 val->latinOrIntValue = true;-
774 END;-
775 return true;
executed 51 times by 2 tests: return true;
Executed by:
  • tst_QOpenGlConfig
  • tst_qmakelib
51
776 }-
777 }
never executed: end of block
0
778-
779 bool ok;-
780 union {-
781 quint64 ui;-
782 double d;-
783 };-
784 d = number.toDouble(&ok);-
785-
786 if (!ok) {
!okDescription
TRUEnever evaluated
FALSEnever evaluated
0
787 lastError = QJsonParseError::IllegalNumber;-
788 return false;
never executed: return false;
0
789 }-
790-
791 int pos = reserveSpace(sizeof(double));-
792 if (pos < 0)
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
793 return false;
never executed: return false;
0
794 qToLittleEndian(ui, data + pos);-
795 if (current - baseOffset >= Value::MaxSize) {
current - base...Value::MaxSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
796 lastError = QJsonParseError::DocumentTooLarge;-
797 return false;
never executed: return false;
0
798 }-
799 val->value = pos - baseOffset;-
800 val->latinOrIntValue = false;-
801-
802 END;-
803 return true;
never executed: return true;
0
804}-
805-
806/*-
807-
808 string = quotation-mark *char quotation-mark-
809-
810 char = unescaped /-
811 escape (-
812 %x22 / ; " quotation mark U+0022-
813 %x5C / ; \ reverse solidus U+005C-
814 %x2F / ; / solidus U+002F-
815 %x62 / ; b backspace U+0008-
816 %x66 / ; f form feed U+000C-
817 %x6E / ; n line feed U+000A-
818 %x72 / ; r carriage return U+000D-
819 %x74 / ; t tab U+0009-
820 %x75 4HEXDIG ) ; uXXXX U+XXXX-
821-
822 escape = %x5C ; \-
823-
824 quotation-mark = %x22 ; "-
825-
826 unescaped = %x20-21 / %x23-5B / %x5D-10FFFF-
827 */-
828static inline bool addHexDigit(char digit, uint *result)-
829{-
830 *result <<= 4;-
831 if (digit >= '0' && digit <= '9')
digit >= '0'Description
TRUEevaluated 412 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
FALSEnever evaluated
digit <= '9'Description
TRUEevaluated 300 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
FALSEevaluated 112 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
0-412
832 *result |= (digit - '0');
executed 300 times by 1 test: *result |= (digit - '0');
Executed by:
  • tst_QNetworkCookieJar
300
833 else if (digit >= 'a' && digit <= 'f')
digit >= 'a'Description
TRUEnever evaluated
FALSEevaluated 112 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
digit <= 'f'Description
TRUEnever evaluated
FALSEnever evaluated
0-112
834 *result |= (digit - 'a') + 10;
never executed: *result |= (digit - 'a') + 10;
0
835 else if (digit >= 'A' && digit <= 'F')
digit >= 'A'Description
TRUEevaluated 112 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
FALSEnever evaluated
digit <= 'F'Description
TRUEevaluated 112 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
FALSEnever evaluated
0-112
836 *result |= (digit - 'A') + 10;
executed 112 times by 1 test: *result |= (digit - 'A') + 10;
Executed by:
  • tst_QNetworkCookieJar
112
837 else-
838 return false;
never executed: return false;
0
839 return true;
executed 412 times by 1 test: return true;
Executed by:
  • tst_QNetworkCookieJar
412
840}-
841-
842static inline bool scanEscapeSequence(const char *&json, const char *end, uint *ch)-
843{-
844 ++json;-
845 if (json >= end)
json >= endDescription
TRUEnever evaluated
FALSEevaluated 206 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
0-206
846 return false;
never executed: return false;
0
847-
848 DEBUG << "scan escape" << (char)*json;
executed 206 times by 1 test: ;
Executed by:
  • tst_QNetworkCookieJar
dead code: QMessageLogger(__FILE__, 848, __PRETTY_FUNCTION__).debug() << "scan escape" << (char)*json;
-
849 uint escaped = *json++;-
850 switch (escaped) {-
851 case '"':
executed 98 times by 1 test: case '"':
Executed by:
  • tst_QNetworkCookieJar
98
852 *ch = '"'; break;
executed 98 times by 1 test: break;
Executed by:
  • tst_QNetworkCookieJar
98
853 case '\\':
executed 4 times by 1 test: case '\\':
Executed by:
  • tst_QNetworkCookieJar
4
854 *ch = '\\'; break;
executed 4 times by 1 test: break;
Executed by:
  • tst_QNetworkCookieJar
4
855 case '/':
never executed: case '/':
0
856 *ch = '/'; break;
never executed: break;
0
857 case 'b':
never executed: case 'b':
0
858 *ch = 0x8; break;
never executed: break;
0
859 case 'f':
never executed: case 'f':
0
860 *ch = 0xc; break;
never executed: break;
0
861 case 'n':
never executed: case 'n':
0
862 *ch = 0xa; break;
never executed: break;
0
863 case 'r':
executed 1 time by 1 test: case 'r':
Executed by:
  • tst_QNetworkCookieJar
1
864 *ch = 0xd; break;
executed 1 time by 1 test: break;
Executed by:
  • tst_QNetworkCookieJar
1
865 case 't':
never executed: case 't':
0
866 *ch = 0x9; break;
never executed: break;
0
867 case 'u': {
executed 103 times by 1 test: case 'u':
Executed by:
  • tst_QNetworkCookieJar
103
868 *ch = 0;-
869 if (json > end - 4)
json > end - 4Description
TRUEnever evaluated
FALSEevaluated 103 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
0-103
870 return false;
never executed: return false;
0
871 for (int i = 0; i < 4; ++i) {
i < 4Description
TRUEevaluated 412 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
FALSEevaluated 103 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
103-412
872 if (!addHexDigit(*json, ch))
!addHexDigit(*json, ch)Description
TRUEnever evaluated
FALSEevaluated 412 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
0-412
873 return false;
never executed: return false;
0
874 ++json;-
875 }
executed 412 times by 1 test: end of block
Executed by:
  • tst_QNetworkCookieJar
412
876 return true;
executed 103 times by 1 test: return true;
Executed by:
  • tst_QNetworkCookieJar
103
877 }-
878 default:
never executed: default:
0
879 // this is not as strict as one could be, but allows for more Json files-
880 // to be parsed correctly.-
881 *ch = escaped;-
882 return true;
never executed: return true;
0
883 }-
884 return true;
executed 103 times by 1 test: return true;
Executed by:
  • tst_QNetworkCookieJar
103
885}-
886-
887static inline bool scanUtf8Char(const char *&json, const char *end, uint *result)-
888{-
889 const uchar *&src = reinterpret_cast<const uchar *&>(json);-
890 const uchar *uend = reinterpret_cast<const uchar *>(end);-
891 uchar b = *src++;-
892 int res = QUtf8Functions::fromUtf8<QUtf8BaseTraits>(b, result, src, uend);-
893 if (res < 0) {
res < 0Description
TRUEnever evaluated
FALSEevaluated 35995 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-35995
894 // decoding error, backtrack the character we read above-
895 --json;-
896 return false;
never executed: return false;
0
897 }-
898-
899 return true;
executed 35995 times by 3 tests: return true;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
35995
900}-
901-
902bool Parser::parseString(bool *latin1)-
903{-
904 *latin1 = true;-
905-
906 const char *start = json;-
907 int outStart = current;-
908-
909 // try to write out a latin1 string-
910-
911 int stringPos = reserveSpace(2);-
912 if (stringPos < 0)
stringPos < 0Description
TRUEnever evaluated
FALSEevaluated 2583 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-2583
913 return false;
never executed: return false;
0
914-
915 BEGIN << "parse string stringPos=" << stringPos << json;
executed 2583 times by 3 tests: ;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 915, __PRETTY_FUNCTION__).debug() << "parse string stringPos=" << stringPos << json;
-
916 while (json < end) {
json < endDescription
TRUEevaluated 38666 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEnever evaluated
0-38666
917 uint ch = 0;-
918 if (*json == '"')
*json == '"'Description
TRUEevaluated 2573 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEevaluated 36093 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
2573-36093
919 break;
executed 2573 times by 3 tests: break;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
2573
920 else if (*json == '\\') {
*json == '\\'Description
TRUEevaluated 110 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
FALSEevaluated 35983 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
110-35983
921 if (!scanEscapeSequence(json, end, &ch)) {
!scanEscapeSeq...son, end, &ch)Description
TRUEnever evaluated
FALSEevaluated 110 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
0-110
922 lastError = QJsonParseError::IllegalEscapeSequence;-
923 return false;
never executed: return false;
0
924 }-
925 } else {
executed 110 times by 1 test: end of block
Executed by:
  • tst_QNetworkCookieJar
110
926 if (!scanUtf8Char(json, end, &ch)) {
!scanUtf8Char(json, end, &ch)Description
TRUEnever evaluated
FALSEevaluated 35983 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-35983
927 lastError = QJsonParseError::IllegalUTF8String;-
928 return false;
never executed: return false;
0
929 }-
930 }
executed 35983 times by 3 tests: end of block
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
35983
931 // bail out if the string is not pure latin1 or too long to hold as a latin1string (which has only 16 bit for the length)-
932 if (ch > 0xff || json - start >= 0x8000) {
ch > 0xffDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
FALSEevaluated 36083 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
json - start >= 0x8000Description
TRUEnever evaluated
FALSEevaluated 36083 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-36083
933 *latin1 = false;-
934 break;
executed 10 times by 1 test: break;
Executed by:
  • tst_QNetworkCookieJar
10
935 }-
936 int pos = reserveSpace(1);-
937 if (pos < 0)
pos < 0Description
TRUEnever evaluated
FALSEevaluated 36083 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-36083
938 return false;
never executed: return false;
0
939 DEBUG << " " << ch << (char)ch;
executed 36083 times by 3 tests: ;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 939, __PRETTY_FUNCTION__).debug() << " " << ch << (char)ch;
-
940 data[pos] = (uchar)ch;-
941 }
executed 36083 times by 3 tests: end of block
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
36083
942 ++json;-
943 DEBUG << "end of string";
executed 2583 times by 3 tests: ;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
dead code: QMessageLogger(__FILE__, 943, __PRETTY_FUNCTION__).debug() << "end of string";
-
944 if (json >= end) {
json >= endDescription
TRUEnever evaluated
FALSEevaluated 2583 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-2583
945 lastError = QJsonParseError::UnterminatedString;-
946 return false;
never executed: return false;
0
947 }-
948-
949 // no unicode string, we are done-
950 if (*latin1) {
*latin1Description
TRUEevaluated 2573 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
10-2573
951 // write string length-
952 *(QJsonPrivate::qle_ushort *)(data + stringPos) = ushort(current - outStart - sizeof(ushort));-
953 int pos = reserveSpace((4 - current) & 3);-
954 if (pos < 0)
pos < 0Description
TRUEnever evaluated
FALSEevaluated 2573 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
0-2573
955 return false;
never executed: return false;
0
956 while (pos & 3)
pos & 3Description
TRUEevaluated 4433 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
FALSEevaluated 2573 times by 3 tests
Evaluated by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
2573-4433
957 data[pos++] = 0;
executed 4433 times by 3 tests: data[pos++] = 0;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
4433
958 END;-
959 return true;
executed 2573 times by 3 tests: return true;
Executed by:
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_qmakelib
2573
960 }-
961-
962 *latin1 = false;-
963 DEBUG << "not latin";
executed 10 times by 1 test: ;
Executed by:
  • tst_QNetworkCookieJar
dead code: QMessageLogger(__FILE__, 963, __PRETTY_FUNCTION__).debug() << "not latin";
-
964-
965 json = start;-
966 current = outStart + sizeof(int);-
967-
968 while (json < end) {
json < endDescription
TRUEevaluated 118 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
FALSEnever evaluated
0-118
969 uint ch = 0;-
970 if (*json == '"')
*json == '"'Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
FALSEevaluated 108 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
10-108
971 break;
executed 10 times by 1 test: break;
Executed by:
  • tst_QNetworkCookieJar
10
972 else if (*json == '\\') {
*json == '\\'Description
TRUEevaluated 96 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
12-96
973 if (!scanEscapeSequence(json, end, &ch)) {
!scanEscapeSeq...son, end, &ch)Description
TRUEnever evaluated
FALSEevaluated 96 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
0-96
974 lastError = QJsonParseError::IllegalEscapeSequence;-
975 return false;
never executed: return false;
0
976 }-
977 } else {
executed 96 times by 1 test: end of block
Executed by:
  • tst_QNetworkCookieJar
96
978 if (!scanUtf8Char(json, end, &ch)) {
!scanUtf8Char(json, end, &ch)Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
0-12
979 lastError = QJsonParseError::IllegalUTF8String;-
980 return false;
never executed: return false;
0
981 }-
982 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_QNetworkCookieJar
12
983 if (QChar::requiresSurrogates(ch)) {
QChar::requiresSurrogates(ch)Description
TRUEnever evaluated
FALSEevaluated 108 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
0-108
984 int pos = reserveSpace(4);-
985 if (pos < 0)
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
986 return false;
never executed: return false;
0
987 *(QJsonPrivate::qle_ushort *)(data + pos) = QChar::highSurrogate(ch);-
988 *(QJsonPrivate::qle_ushort *)(data + pos + 2) = QChar::lowSurrogate(ch);-
989 } else {
never executed: end of block
0
990 int pos = reserveSpace(2);-
991 if (pos < 0)
pos < 0Description
TRUEnever evaluated
FALSEevaluated 108 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
0-108
992 return false;
never executed: return false;
0
993 *(QJsonPrivate::qle_ushort *)(data + pos) = (ushort)ch;-
994 }
executed 108 times by 1 test: end of block
Executed by:
  • tst_QNetworkCookieJar
108
995 }-
996 ++json;-
997-
998 if (json >= end) {
json >= endDescription
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
0-10
999 lastError = QJsonParseError::UnterminatedString;-
1000 return false;
never executed: return false;
0
1001 }-
1002-
1003 // write string length-
1004 *(QJsonPrivate::qle_int *)(data + stringPos) = (current - outStart - sizeof(int))/2;-
1005 int pos = reserveSpace((4 - current) & 3);-
1006 if (pos < 0)
pos < 0Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
0-10
1007 return false;
never executed: return false;
0
1008 while (pos & 3)
pos & 3Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QNetworkCookieJar
10-12
1009 data[pos++] = 0;
executed 12 times by 1 test: data[pos++] = 0;
Executed by:
  • tst_QNetworkCookieJar
12
1010 END;-
1011 return true;
executed 10 times by 1 test: return true;
Executed by:
  • tst_QNetworkCookieJar
10
1012}-
1013-
1014QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9