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