| 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 | #include "qutfcodec_p.h" | - |
| 43 | #include "qlist.h" | - |
| 44 | #include "qendian.h" | - |
| 45 | #include "qchar.h" | - |
| 46 | | - |
| 47 | QT_BEGIN_NAMESPACE | - |
| 48 | | - |
| 49 | enum { Endian = 0, Data = 1 }; | - |
| 50 | | - |
| 51 | QByteArray QUtf8::convertFromUnicode(const QChar *uc, int len, QTextCodec::ConverterState *state) | - |
| 52 | { | - |
| 53 | uchar replacement = '?'; executed (the execution status of this line is deduced): uchar replacement = '?'; | - |
| 54 | int rlen = 3*len; executed (the execution status of this line is deduced): int rlen = 3*len; | - |
| 55 | int surrogate_high = -1; executed (the execution status of this line is deduced): int surrogate_high = -1; | - |
| 56 | if (state) { evaluated: state| yes Evaluation Count:526492 | yes Evaluation Count:296270 |
| 296270-526492 |
| 57 | if (state->flags & QTextCodec::ConvertInvalidToNull) evaluated: state->flags & QTextCodec::ConvertInvalidToNull| yes Evaluation Count:497380 | yes Evaluation Count:29112 |
| 29112-497380 |
| 58 | replacement = 0; executed: replacement = 0;Execution Count:497380 | 497380 |
| 59 | if (!(state->flags & QTextCodec::IgnoreHeader)) evaluated: !(state->flags & QTextCodec::IgnoreHeader)| yes Evaluation Count:497633 | yes Evaluation Count:28859 |
| 28859-497633 |
| 60 | rlen += 3; executed: rlen += 3;Execution Count:497633 | 497633 |
| 61 | if (state->remainingChars) evaluated: state->remainingChars| yes Evaluation Count:6 | yes Evaluation Count:526486 |
| 6-526486 |
| 62 | surrogate_high = state->state_data[0]; executed: surrogate_high = state->state_data[0];Execution Count:6 | 6 |
| 63 | } executed: }Execution Count:526492 | 526492 |
| 64 | | - |
| 65 | QByteArray rstr; executed (the execution status of this line is deduced): QByteArray rstr; | - |
| 66 | rstr.resize(rlen); executed (the execution status of this line is deduced): rstr.resize(rlen); | - |
| 67 | uchar* cursor = (uchar*)rstr.data(); executed (the execution status of this line is deduced): uchar* cursor = (uchar*)rstr.data(); | - |
| 68 | const QChar *ch = uc; executed (the execution status of this line is deduced): const QChar *ch = uc; | - |
| 69 | int invalid = 0; executed (the execution status of this line is deduced): int invalid = 0; | - |
| 70 | if (state && !(state->flags & QTextCodec::IgnoreHeader)) { evaluated: state| yes Evaluation Count:526492 | yes Evaluation Count:296269 |
evaluated: !(state->flags & QTextCodec::IgnoreHeader)| yes Evaluation Count:497633 | yes Evaluation Count:28859 |
| 28859-526492 |
| 71 | *cursor++ = 0xef; executed (the execution status of this line is deduced): *cursor++ = 0xef; | - |
| 72 | *cursor++ = 0xbb; executed (the execution status of this line is deduced): *cursor++ = 0xbb; | - |
| 73 | *cursor++ = 0xbf; executed (the execution status of this line is deduced): *cursor++ = 0xbf; | - |
| 74 | } executed: }Execution Count:497633 | 497633 |
| 75 | | - |
| 76 | const QChar *end = ch + len; executed (the execution status of this line is deduced): const QChar *end = ch + len; | - |
| 77 | while (ch < end) { evaluated: ch < end| yes Evaluation Count:26531872 | yes Evaluation Count:822763 |
| 822763-26531872 |
| 78 | uint u = ch->unicode(); executed (the execution status of this line is deduced): uint u = ch->unicode(); | - |
| 79 | if (surrogate_high >= 0) { evaluated: surrogate_high >= 0| yes Evaluation Count:186 | yes Evaluation Count:26531675 |
| 186-26531675 |
| 80 | if (ch->isLowSurrogate()) { partially evaluated: ch->isLowSurrogate()| yes Evaluation Count:186 | no Evaluation Count:0 |
| 0-186 |
| 81 | u = QChar::surrogateToUcs4(surrogate_high, u); executed (the execution status of this line is deduced): u = QChar::surrogateToUcs4(surrogate_high, u); | - |
| 82 | surrogate_high = -1; executed (the execution status of this line is deduced): surrogate_high = -1; | - |
| 83 | } else { executed: }Execution Count:186 | 186 |
| 84 | // high surrogate without low | - |
| 85 | *cursor = replacement; never executed (the execution status of this line is deduced): *cursor = replacement; | - |
| 86 | ++ch; never executed (the execution status of this line is deduced): ++ch; | - |
| 87 | ++invalid; never executed (the execution status of this line is deduced): ++invalid; | - |
| 88 | surrogate_high = -1; never executed (the execution status of this line is deduced): surrogate_high = -1; | - |
| 89 | continue; never executed: continue; | 0 |
| 90 | } | - |
| 91 | } else if (ch->isLowSurrogate()) { partially evaluated: ch->isLowSurrogate()| no Evaluation Count:0 | yes Evaluation Count:26531688 |
| 0-26531688 |
| 92 | // low surrogate without high | - |
| 93 | *cursor = replacement; never executed (the execution status of this line is deduced): *cursor = replacement; | - |
| 94 | ++ch; never executed (the execution status of this line is deduced): ++ch; | - |
| 95 | ++invalid; never executed (the execution status of this line is deduced): ++invalid; | - |
| 96 | continue; never executed: continue; | 0 |
| 97 | } else if (ch->isHighSurrogate()) { evaluated: ch->isHighSurrogate()| yes Evaluation Count:186 | yes Evaluation Count:26531499 |
| 186-26531499 |
| 98 | surrogate_high = u; executed (the execution status of this line is deduced): surrogate_high = u; | - |
| 99 | ++ch; executed (the execution status of this line is deduced): ++ch; | - |
| 100 | continue; executed: continue;Execution Count:186 | 186 |
| 101 | } | - |
| 102 | | - |
| 103 | if (u < 0x80) { evaluated: u < 0x80| yes Evaluation Count:26116723 | yes Evaluation Count:414970 |
| 414970-26116723 |
| 104 | *cursor++ = (uchar)u; executed (the execution status of this line is deduced): *cursor++ = (uchar)u; | - |
| 105 | } else { executed: }Execution Count:26116720 | 26116720 |
| 106 | if (u < 0x0800) { evaluated: u < 0x0800| yes Evaluation Count:5209 | yes Evaluation Count:409761 |
| 5209-409761 |
| 107 | *cursor++ = 0xc0 | ((uchar) (u >> 6)); executed (the execution status of this line is deduced): *cursor++ = 0xc0 | ((uchar) (u >> 6)); | - |
| 108 | } else { executed: }Execution Count:5209 | 5209 |
| 109 | // is it one of the Unicode non-characters? | - |
| 110 | if (QChar::isNonCharacter(u)) { evaluated: QChar::isNonCharacter(u)| yes Evaluation Count:233 | yes Evaluation Count:409528 |
| 233-409528 |
| 111 | *cursor++ = replacement; executed (the execution status of this line is deduced): *cursor++ = replacement; | - |
| 112 | ++ch; executed (the execution status of this line is deduced): ++ch; | - |
| 113 | ++invalid; executed (the execution status of this line is deduced): ++invalid; | - |
| 114 | continue; executed: continue;Execution Count:233 | 233 |
| 115 | } | - |
| 116 | | - |
| 117 | if (QChar::requiresSurrogates(u)) { evaluated: QChar::requiresSurrogates(u)| yes Evaluation Count:58 | yes Evaluation Count:409470 |
| 58-409470 |
| 118 | *cursor++ = 0xf0 | ((uchar) (u >> 18)); executed (the execution status of this line is deduced): *cursor++ = 0xf0 | ((uchar) (u >> 18)); | - |
| 119 | *cursor++ = 0x80 | (((uchar) (u >> 12)) & 0x3f); executed (the execution status of this line is deduced): *cursor++ = 0x80 | (((uchar) (u >> 12)) & 0x3f); | - |
| 120 | } else { executed: }Execution Count:58 | 58 |
| 121 | *cursor++ = 0xe0 | (((uchar) (u >> 12)) & 0x3f); executed (the execution status of this line is deduced): *cursor++ = 0xe0 | (((uchar) (u >> 12)) & 0x3f); | - |
| 122 | } executed: }Execution Count:409470 | 409470 |
| 123 | *cursor++ = 0x80 | (((uchar) (u >> 6)) & 0x3f); executed (the execution status of this line is deduced): *cursor++ = 0x80 | (((uchar) (u >> 6)) & 0x3f); | - |
| 124 | } executed: }Execution Count:409528 | 409528 |
| 125 | *cursor++ = 0x80 | ((uchar) (u&0x3f)); executed (the execution status of this line is deduced): *cursor++ = 0x80 | ((uchar) (u&0x3f)); | - |
| 126 | } executed: }Execution Count:414737 | 414737 |
| 127 | ++ch; executed (the execution status of this line is deduced): ++ch; | - |
| 128 | } executed: }Execution Count:26531459 | 26531459 |
| 129 | | - |
| 130 | rstr.resize(cursor - (const uchar*)rstr.constData()); executed (the execution status of this line is deduced): rstr.resize(cursor - (const uchar*)rstr.constData()); | - |
| 131 | if (state) { evaluated: state| yes Evaluation Count:526492 | yes Evaluation Count:296275 |
| 296275-526492 |
| 132 | state->invalidChars += invalid; executed (the execution status of this line is deduced): state->invalidChars += invalid; | - |
| 133 | state->flags |= QTextCodec::IgnoreHeader; executed (the execution status of this line is deduced): state->flags |= QTextCodec::IgnoreHeader; | - |
| 134 | state->remainingChars = 0; executed (the execution status of this line is deduced): state->remainingChars = 0; | - |
| 135 | if (surrogate_high >= 0) { evaluated: surrogate_high >= 0| yes Evaluation Count:6 | yes Evaluation Count:526486 |
| 6-526486 |
| 136 | state->remainingChars = 1; executed (the execution status of this line is deduced): state->remainingChars = 1; | - |
| 137 | state->state_data[0] = surrogate_high; executed (the execution status of this line is deduced): state->state_data[0] = surrogate_high; | - |
| 138 | } executed: }Execution Count:6 | 6 |
| 139 | } executed: }Execution Count:526492 | 526492 |
| 140 | return rstr; executed: return rstr;Execution Count:822767 | 822767 |
| 141 | } | - |
| 142 | | - |
| 143 | QString QUtf8::convertToUnicode(const char *chars, int len, QTextCodec::ConverterState *state) | - |
| 144 | { | - |
| 145 | bool headerdone = false; executed (the execution status of this line is deduced): bool headerdone = false; | - |
| 146 | ushort replacement = QChar::ReplacementCharacter; executed (the execution status of this line is deduced): ushort replacement = QChar::ReplacementCharacter; | - |
| 147 | int need = 0; executed (the execution status of this line is deduced): int need = 0; | - |
| 148 | int error = -1; executed (the execution status of this line is deduced): int error = -1; | - |
| 149 | uint uc = 0; executed (the execution status of this line is deduced): uint uc = 0; | - |
| 150 | uint min_uc = 0; executed (the execution status of this line is deduced): uint min_uc = 0; | - |
| 151 | if (state) { evaluated: state| yes Evaluation Count:41144773 | yes Evaluation Count:20727340 |
| 20727340-41144773 |
| 152 | if (state->flags & QTextCodec::IgnoreHeader) evaluated: state->flags & QTextCodec::IgnoreHeader| yes Evaluation Count:41135273 | yes Evaluation Count:9500 |
| 9500-41135273 |
| 153 | headerdone = true; executed: headerdone = true;Execution Count:41135273 | 41135273 |
| 154 | if (state->flags & QTextCodec::ConvertInvalidToNull) evaluated: state->flags & QTextCodec::ConvertInvalidToNull| yes Evaluation Count:4 | yes Evaluation Count:41144769 |
| 4-41144769 |
| 155 | replacement = QChar::Null; executed: replacement = QChar::Null;Execution Count:4 | 4 |
| 156 | need = state->remainingChars; executed (the execution status of this line is deduced): need = state->remainingChars; | - |
| 157 | if (need) { evaluated: need| yes Evaluation Count:671 | yes Evaluation Count:41144102 |
| 671-41144102 |
| 158 | uc = state->state_data[0]; executed (the execution status of this line is deduced): uc = state->state_data[0]; | - |
| 159 | min_uc = state->state_data[1]; executed (the execution status of this line is deduced): min_uc = state->state_data[1]; | - |
| 160 | } executed: }Execution Count:671 | 671 |
| 161 | } executed: }Execution Count:41144773 | 41144773 |
| 162 | if (!headerdone && len > 3 evaluated: !headerdone| yes Evaluation Count:20736843 | yes Evaluation Count:41135273 |
evaluated: len > 3| yes Evaluation Count:5241607 | yes Evaluation Count:15495250 |
| 5241607-41135273 |
| 163 | && (uchar)chars[0] == 0xef && (uchar)chars[1] == 0xbb && (uchar)chars[2] == 0xbf) { evaluated: (uchar)chars[0] == 0xef| yes Evaluation Count:15 | yes Evaluation Count:5241613 |
partially evaluated: (uchar)chars[1] == 0xbb| yes Evaluation Count:15 | no Evaluation Count:0 |
partially evaluated: (uchar)chars[2] == 0xbf| yes Evaluation Count:15 | no Evaluation Count:0 |
| 0-5241613 |
| 164 | // starts with a byte order mark | - |
| 165 | chars += 3; executed (the execution status of this line is deduced): chars += 3; | - |
| 166 | len -= 3; executed (the execution status of this line is deduced): len -= 3; | - |
| 167 | headerdone = true; executed (the execution status of this line is deduced): headerdone = true; | - |
| 168 | } executed: }Execution Count:15 | 15 |
| 169 | | - |
| 170 | QString result(need + len + 1, Qt::Uninitialized); // worst case executed (the execution status of this line is deduced): QString result(need + len + 1, Qt::Uninitialized); | - |
| 171 | ushort *qch = (ushort *)result.unicode(); executed (the execution status of this line is deduced): ushort *qch = (ushort *)result.unicode(); | - |
| 172 | uchar ch; executed (the execution status of this line is deduced): uchar ch; | - |
| 173 | int invalid = 0; executed (the execution status of this line is deduced): int invalid = 0; | - |
| 174 | | - |
| 175 | for (int i = 0; i < len; ++i) { evaluated: i < len| yes Evaluation Count:145837819 | yes Evaluation Count:61872075 |
| 61872075-145837819 |
| 176 | ch = chars[i]; executed (the execution status of this line is deduced): ch = chars[i]; | - |
| 177 | if (need) { evaluated: need| yes Evaluation Count:279039 | yes Evaluation Count:145558840 |
| 279039-145558840 |
| 178 | if ((ch&0xc0) == 0x80) { evaluated: (ch&0xc0) == 0x80| yes Evaluation Count:277529 | yes Evaluation Count:1510 |
| 1510-277529 |
| 179 | uc = (uc << 6) | (ch & 0x3f); executed (the execution status of this line is deduced): uc = (uc << 6) | (ch & 0x3f); | - |
| 180 | --need; executed (the execution status of this line is deduced): --need; | - |
| 181 | if (!need) { evaluated: !need| yes Evaluation Count:141211 | yes Evaluation Count:136318 |
| 136318-141211 |
| 182 | // utf-8 bom composes into 0xfeff code point | - |
| 183 | bool nonCharacter; executed (the execution status of this line is deduced): bool nonCharacter; | - |
| 184 | if (!headerdone && uc == 0xfeff) { evaluated: !headerdone| yes Evaluation Count:304 | yes Evaluation Count:140907 |
evaluated: uc == 0xfeff| yes Evaluation Count:8 | yes Evaluation Count:296 |
| 8-140907 |
| 185 | // don't do anything, just skip the BOM | - |
| 186 | } else if (!(nonCharacter = QChar::isNonCharacter(uc)) && QChar::requiresSurrogates(uc) && uc <= QChar::LastValidCodePoint) { executed: }Execution Count:8 evaluated: !(nonCharacter = QChar::isNonCharacter(uc))| yes Evaluation Count:140937 | yes Evaluation Count:266 |
evaluated: QChar::requiresSurrogates(uc)| yes Evaluation Count:175 | yes Evaluation Count:140762 |
evaluated: uc <= QChar::LastValidCodePoint| yes Evaluation Count:163 | yes Evaluation Count:12 |
| 8-140937 |
| 187 | // surrogate pair | - |
| 188 | Q_ASSERT((qch - (ushort*)result.unicode()) + 2 < result.length()); executed (the execution status of this line is deduced): qt_noop(); | - |
| 189 | *qch++ = QChar::highSurrogate(uc); executed (the execution status of this line is deduced): *qch++ = QChar::highSurrogate(uc); | - |
| 190 | *qch++ = QChar::lowSurrogate(uc); executed (the execution status of this line is deduced): *qch++ = QChar::lowSurrogate(uc); | - |
| 191 | } else if ((uc < min_uc) || QChar::isSurrogate(uc) || nonCharacter || uc > QChar::LastValidCodePoint) { executed: }Execution Count:163 evaluated: (uc < min_uc)| yes Evaluation Count:49 | yes Evaluation Count:140991 |
evaluated: QChar::isSurrogate(uc)| yes Evaluation Count:67 | yes Evaluation Count:140924 |
evaluated: nonCharacter| yes Evaluation Count:264 | yes Evaluation Count:140660 |
evaluated: uc > QChar::LastValidCodePoint| yes Evaluation Count:12 | yes Evaluation Count:140648 |
| 12-140991 |
| 192 | // error: overlong sequence, UTF16 surrogate or non-character | - |
| 193 | *qch++ = replacement; executed (the execution status of this line is deduced): *qch++ = replacement; | - |
| 194 | ++invalid; executed (the execution status of this line is deduced): ++invalid; | - |
| 195 | } else { executed: }Execution Count:392 | 392 |
| 196 | *qch++ = uc; executed (the execution status of this line is deduced): *qch++ = uc; | - |
| 197 | } executed: }Execution Count:140648 | 140648 |
| 198 | headerdone = true; executed (the execution status of this line is deduced): headerdone = true; | - |
| 199 | } executed: }Execution Count:141211 | 141211 |
| 200 | } else { executed: }Execution Count:277529 | 277529 |
| 201 | // error | - |
| 202 | i = error; executed (the execution status of this line is deduced): i = error; | - |
| 203 | *qch++ = replacement; executed (the execution status of this line is deduced): *qch++ = replacement; | - |
| 204 | ++invalid; executed (the execution status of this line is deduced): ++invalid; | - |
| 205 | need = 0; executed (the execution status of this line is deduced): need = 0; | - |
| 206 | headerdone = true; executed (the execution status of this line is deduced): headerdone = true; | - |
| 207 | } executed: }Execution Count:1510 | 1510 |
| 208 | } else { | - |
| 209 | if (ch < 128) { evaluated: ch < 128| yes Evaluation Count:145413700 | yes Evaluation Count:145111 |
| 145111-145413700 |
| 210 | *qch++ = ushort(ch); executed (the execution status of this line is deduced): *qch++ = ushort(ch); | - |
| 211 | headerdone = true; executed (the execution status of this line is deduced): headerdone = true; | - |
| 212 | } else if ((ch & 0xe0) == 0xc0) { executed: }Execution Count:145413886 evaluated: (ch & 0xe0) == 0xc0| yes Evaluation Count:6514 | yes Evaluation Count:138597 |
| 6514-145413886 |
| 213 | uc = ch & 0x1f; executed (the execution status of this line is deduced): uc = ch & 0x1f; | - |
| 214 | need = 1; executed (the execution status of this line is deduced): need = 1; | - |
| 215 | error = i; executed (the execution status of this line is deduced): error = i; | - |
| 216 | min_uc = 0x80; executed (the execution status of this line is deduced): min_uc = 0x80; | - |
| 217 | headerdone = true; executed (the execution status of this line is deduced): headerdone = true; | - |
| 218 | } else if ((ch & 0xf0) == 0xe0) { executed: }Execution Count:6514 evaluated: (ch & 0xf0) == 0xe0| yes Evaluation Count:135754 | yes Evaluation Count:2843 |
| 2843-135754 |
| 219 | uc = ch & 0x0f; executed (the execution status of this line is deduced): uc = ch & 0x0f; | - |
| 220 | need = 2; executed (the execution status of this line is deduced): need = 2; | - |
| 221 | error = i; executed (the execution status of this line is deduced): error = i; | - |
| 222 | min_uc = 0x800; executed (the execution status of this line is deduced): min_uc = 0x800; | - |
| 223 | } else if ((ch&0xf8) == 0xf0) { executed: }Execution Count:135754 evaluated: (ch&0xf8) == 0xf0| yes Evaluation Count:497 | yes Evaluation Count:2346 |
| 497-135754 |
| 224 | uc = ch & 0x07; executed (the execution status of this line is deduced): uc = ch & 0x07; | - |
| 225 | need = 3; executed (the execution status of this line is deduced): need = 3; | - |
| 226 | error = i; executed (the execution status of this line is deduced): error = i; | - |
| 227 | min_uc = 0x10000; executed (the execution status of this line is deduced): min_uc = 0x10000; | - |
| 228 | headerdone = true; executed (the execution status of this line is deduced): headerdone = true; | - |
| 229 | } else { executed: }Execution Count:497 | 497 |
| 230 | // error | - |
| 231 | *qch++ = replacement; executed (the execution status of this line is deduced): *qch++ = replacement; | - |
| 232 | ++invalid; executed (the execution status of this line is deduced): ++invalid; | - |
| 233 | headerdone = true; executed (the execution status of this line is deduced): headerdone = true; | - |
| 234 | } executed: }Execution Count:2346 | 2346 |
| 235 | } | - |
| 236 | } | - |
| 237 | if (!state && need > 0) { evaluated: !state| yes Evaluation Count:20727302 | yes Evaluation Count:41144773 |
evaluated: need > 0| yes Evaluation Count:27 | yes Evaluation Count:20727253 |
| 27-41144773 |
| 238 | // unterminated UTF sequence | - |
| 239 | for (int i = error; i < len; ++i) { evaluated: i < len| yes Evaluation Count:43 | yes Evaluation Count:27 |
| 27-43 |
| 240 | *qch++ = replacement; executed (the execution status of this line is deduced): *qch++ = replacement; | - |
| 241 | ++invalid; executed (the execution status of this line is deduced): ++invalid; | - |
| 242 | } executed: }Execution Count:43 | 43 |
| 243 | } executed: }Execution Count:27 | 27 |
| 244 | result.truncate(qch - (ushort *)result.unicode()); executed (the execution status of this line is deduced): result.truncate(qch - (ushort *)result.unicode()); | - |
| 245 | if (state) { evaluated: state| yes Evaluation Count:41144773 | yes Evaluation Count:20727290 |
| 20727290-41144773 |
| 246 | state->invalidChars += invalid; executed (the execution status of this line is deduced): state->invalidChars += invalid; | - |
| 247 | state->remainingChars = need; executed (the execution status of this line is deduced): state->remainingChars = need; | - |
| 248 | if (headerdone) evaluated: headerdone| yes Evaluation Count:41144749 | yes Evaluation Count:24 |
| 24-41144749 |
| 249 | state->flags |= QTextCodec::IgnoreHeader; executed: state->flags |= QTextCodec::IgnoreHeader;Execution Count:41144749 | 41144749 |
| 250 | state->state_data[0] = need ? uc : 0; evaluated: need| yes Evaluation Count:688 | yes Evaluation Count:41144085 |
| 688-41144085 |
| 251 | state->state_data[1] = need ? min_uc : 0; evaluated: need| yes Evaluation Count:688 | yes Evaluation Count:41144085 |
| 688-41144085 |
| 252 | } executed: }Execution Count:41144773 | 41144773 |
| 253 | return result; executed: return result;Execution Count:61872069 | 61872069 |
| 254 | } | - |
| 255 | | - |
| 256 | QByteArray QUtf16::convertFromUnicode(const QChar *uc, int len, QTextCodec::ConverterState *state, DataEndianness e) | - |
| 257 | { | - |
| 258 | DataEndianness endian = e; executed (the execution status of this line is deduced): DataEndianness endian = e; | - |
| 259 | int length = 2*len; executed (the execution status of this line is deduced): int length = 2*len; | - |
| 260 | if (!state || (!(state->flags & QTextCodec::IgnoreHeader))) { evaluated: !state| yes Evaluation Count:52 | yes Evaluation Count:257121 |
evaluated: (!(state->flags & QTextCodec::IgnoreHeader))| yes Evaluation Count:248388 | yes Evaluation Count:8733 |
| 52-257121 |
| 261 | length += 2; executed (the execution status of this line is deduced): length += 2; | - |
| 262 | } executed: }Execution Count:248440 | 248440 |
| 263 | if (e == DetectEndianness) { evaluated: e == DetectEndianness| yes Evaluation Count:85717 | yes Evaluation Count:171456 |
| 85717-171456 |
| 264 | endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BigEndianness : LittleEndianness; partially evaluated: (QSysInfo::ByteOrder == QSysInfo::BigEndian)| no Evaluation Count:0 | yes Evaluation Count:85717 |
| 0-85717 |
| 265 | } executed: }Execution Count:85717 | 85717 |
| 266 | | - |
| 267 | QByteArray d; executed (the execution status of this line is deduced): QByteArray d; | - |
| 268 | d.resize(length); executed (the execution status of this line is deduced): d.resize(length); | - |
| 269 | char *data = d.data(); executed (the execution status of this line is deduced): char *data = d.data(); | - |
| 270 | if (!state || !(state->flags & QTextCodec::IgnoreHeader)) { evaluated: !state| yes Evaluation Count:52 | yes Evaluation Count:257121 |
evaluated: !(state->flags & QTextCodec::IgnoreHeader)| yes Evaluation Count:248388 | yes Evaluation Count:8733 |
| 52-257121 |
| 271 | QChar bom(QChar::ByteOrderMark); executed (the execution status of this line is deduced): QChar bom(QChar::ByteOrderMark); | - |
| 272 | if (endian == BigEndianness) { evaluated: endian == BigEndianness| yes Evaluation Count:82818 | yes Evaluation Count:165622 |
| 82818-165622 |
| 273 | data[0] = bom.row(); executed (the execution status of this line is deduced): data[0] = bom.row(); | - |
| 274 | data[1] = bom.cell(); executed (the execution status of this line is deduced): data[1] = bom.cell(); | - |
| 275 | } else { executed: }Execution Count:82818 | 82818 |
| 276 | data[0] = bom.cell(); executed (the execution status of this line is deduced): data[0] = bom.cell(); | - |
| 277 | data[1] = bom.row(); executed (the execution status of this line is deduced): data[1] = bom.row(); | - |
| 278 | } executed: }Execution Count:165622 | 165622 |
| 279 | data += 2; executed (the execution status of this line is deduced): data += 2; | - |
| 280 | } executed: }Execution Count:248440 | 248440 |
| 281 | if (endian == BigEndianness) { evaluated: endian == BigEndianness| yes Evaluation Count:85725 | yes Evaluation Count:171448 |
| 85725-171448 |
| 282 | for (int i = 0; i < len; ++i) { evaluated: i < len| yes Evaluation Count:255542 | yes Evaluation Count:85725 |
| 85725-255542 |
| 283 | *(data++) = uc[i].row(); executed (the execution status of this line is deduced): *(data++) = uc[i].row(); | - |
| 284 | *(data++) = uc[i].cell(); executed (the execution status of this line is deduced): *(data++) = uc[i].cell(); | - |
| 285 | } executed: }Execution Count:255542 | 255542 |
| 286 | } else { executed: }Execution Count:85725 | 85725 |
| 287 | for (int i = 0; i < len; ++i) { evaluated: i < len| yes Evaluation Count:510988 | yes Evaluation Count:171448 |
| 171448-510988 |
| 288 | *(data++) = uc[i].cell(); executed (the execution status of this line is deduced): *(data++) = uc[i].cell(); | - |
| 289 | *(data++) = uc[i].row(); executed (the execution status of this line is deduced): *(data++) = uc[i].row(); | - |
| 290 | } executed: }Execution Count:510988 | 510988 |
| 291 | } executed: }Execution Count:171448 | 171448 |
| 292 | | - |
| 293 | if (state) { evaluated: state| yes Evaluation Count:257121 | yes Evaluation Count:52 |
| 52-257121 |
| 294 | state->remainingChars = 0; executed (the execution status of this line is deduced): state->remainingChars = 0; | - |
| 295 | state->flags |= QTextCodec::IgnoreHeader; executed (the execution status of this line is deduced): state->flags |= QTextCodec::IgnoreHeader; | - |
| 296 | } executed: }Execution Count:257121 | 257121 |
| 297 | return d; executed: return d;Execution Count:257173 | 257173 |
| 298 | } | - |
| 299 | | - |
| 300 | QString QUtf16::convertToUnicode(const char *chars, int len, QTextCodec::ConverterState *state, DataEndianness e) | - |
| 301 | { | - |
| 302 | DataEndianness endian = e; executed (the execution status of this line is deduced): DataEndianness endian = e; | - |
| 303 | bool half = false; executed (the execution status of this line is deduced): bool half = false; | - |
| 304 | uchar buf = 0; executed (the execution status of this line is deduced): uchar buf = 0; | - |
| 305 | bool headerdone = false; executed (the execution status of this line is deduced): bool headerdone = false; | - |
| 306 | if (state) { evaluated: state| yes Evaluation Count:4645 | yes Evaluation Count:186 |
| 186-4645 |
| 307 | headerdone = state->flags & QTextCodec::IgnoreHeader; executed (the execution status of this line is deduced): headerdone = state->flags & QTextCodec::IgnoreHeader; | - |
| 308 | if (endian == DetectEndianness) evaluated: endian == DetectEndianness| yes Evaluation Count:3128 | yes Evaluation Count:1517 |
| 1517-3128 |
| 309 | endian = (DataEndianness)state->state_data[Endian]; executed: endian = (DataEndianness)state->state_data[Endian];Execution Count:3128 | 3128 |
| 310 | if (state->remainingChars) { evaluated: state->remainingChars| yes Evaluation Count:651 | yes Evaluation Count:3994 |
| 651-3994 |
| 311 | half = true; executed (the execution status of this line is deduced): half = true; | - |
| 312 | buf = state->state_data[Data]; executed (the execution status of this line is deduced): buf = state->state_data[Data]; | - |
| 313 | } executed: }Execution Count:651 | 651 |
| 314 | } executed: }Execution Count:4645 | 4645 |
| 315 | if (headerdone && endian == DetectEndianness) evaluated: headerdone| yes Evaluation Count:4262 | yes Evaluation Count:569 |
evaluated: endian == DetectEndianness| yes Evaluation Count:1 | yes Evaluation Count:4261 |
| 1-4262 |
| 316 | endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BigEndianness : LittleEndianness; executed: endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BigEndianness : LittleEndianness;Execution Count:1 partially evaluated: (QSysInfo::ByteOrder == QSysInfo::BigEndian)| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 317 | | - |
| 318 | QString result(len, Qt::Uninitialized); // worst case executed (the execution status of this line is deduced): QString result(len, Qt::Uninitialized); | - |
| 319 | QChar *qch = (QChar *)result.unicode(); executed (the execution status of this line is deduced): QChar *qch = (QChar *)result.unicode(); | - |
| 320 | while (len--) { evaluated: len--| yes Evaluation Count:2107581 | yes Evaluation Count:4831 |
| 4831-2107581 |
| 321 | if (half) { evaluated: half| yes Evaluation Count:1053790 | yes Evaluation Count:1053791 |
| 1053790-1053791 |
| 322 | QChar ch; executed (the execution status of this line is deduced): QChar ch; | - |
| 323 | if (endian == LittleEndianness) { evaluated: endian == LittleEndianness| yes Evaluation Count:702655 | yes Evaluation Count:351135 |
| 351135-702655 |
| 324 | ch.setRow(*chars++); executed (the execution status of this line is deduced): ch.setRow(*chars++); | - |
| 325 | ch.setCell(buf); executed (the execution status of this line is deduced): ch.setCell(buf); | - |
| 326 | } else { executed: }Execution Count:702655 | 702655 |
| 327 | ch.setRow(buf); executed (the execution status of this line is deduced): ch.setRow(buf); | - |
| 328 | ch.setCell(*chars++); executed (the execution status of this line is deduced): ch.setCell(*chars++); | - |
| 329 | } executed: }Execution Count:351135 | 351135 |
| 330 | if (!headerdone) { evaluated: !headerdone| yes Evaluation Count:511 | yes Evaluation Count:1053279 |
| 511-1053279 |
| 331 | headerdone = true; executed (the execution status of this line is deduced): headerdone = true; | - |
| 332 | if (endian == DetectEndianness) { evaluated: endian == DetectEndianness| yes Evaluation Count:213 | yes Evaluation Count:298 |
| 213-298 |
| 333 | if (ch == QChar::ByteOrderSwapped) { evaluated: ch == QChar::ByteOrderSwapped| yes Evaluation Count:80 | yes Evaluation Count:133 |
| 80-133 |
| 334 | endian = LittleEndianness; executed (the execution status of this line is deduced): endian = LittleEndianness; | - |
| 335 | } else if (ch == QChar::ByteOrderMark) { executed: }Execution Count:80 evaluated: ch == QChar::ByteOrderMark| yes Evaluation Count:5 | yes Evaluation Count:128 |
| 5-128 |
| 336 | endian = BigEndianness; executed (the execution status of this line is deduced): endian = BigEndianness; | - |
| 337 | } else { executed: }Execution Count:5 | 5 |
| 338 | if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { partially evaluated: QSysInfo::ByteOrder == QSysInfo::BigEndian| no Evaluation Count:0 | yes Evaluation Count:128 |
| 0-128 |
| 339 | endian = BigEndianness; never executed (the execution status of this line is deduced): endian = BigEndianness; | - |
| 340 | } else { | 0 |
| 341 | endian = LittleEndianness; executed (the execution status of this line is deduced): endian = LittleEndianness; | - |
| 342 | ch = QChar((ch.unicode() >> 8) | ((ch.unicode() & 0xff) << 8)); executed (the execution status of this line is deduced): ch = QChar((ch.unicode() >> 8) | ((ch.unicode() & 0xff) << 8)); | - |
| 343 | } executed: }Execution Count:128 | 128 |
| 344 | *qch++ = ch; executed (the execution status of this line is deduced): *qch++ = ch; | - |
| 345 | } executed: }Execution Count:128 | 128 |
| 346 | } else if (ch != QChar::ByteOrderMark) { evaluated: ch != QChar::ByteOrderMark| yes Evaluation Count:54 | yes Evaluation Count:244 |
| 54-244 |
| 347 | *qch++ = ch; executed (the execution status of this line is deduced): *qch++ = ch; | - |
| 348 | } executed: }Execution Count:54 | 54 |
| 349 | } else { | - |
| 350 | *qch++ = ch; executed (the execution status of this line is deduced): *qch++ = ch; | - |
| 351 | } executed: }Execution Count:1053279 | 1053279 |
| 352 | half = false; executed (the execution status of this line is deduced): half = false; | - |
| 353 | } else { executed: }Execution Count:1053790 | 1053790 |
| 354 | buf = *chars++; executed (the execution status of this line is deduced): buf = *chars++; | - |
| 355 | half = true; executed (the execution status of this line is deduced): half = true; | - |
| 356 | } executed: }Execution Count:1053791 | 1053791 |
| 357 | } | - |
| 358 | result.truncate(qch - result.unicode()); executed (the execution status of this line is deduced): result.truncate(qch - result.unicode()); | - |
| 359 | | - |
| 360 | if (state) { evaluated: state| yes Evaluation Count:4645 | yes Evaluation Count:186 |
| 186-4645 |
| 361 | if (headerdone) evaluated: headerdone| yes Evaluation Count:4587 | yes Evaluation Count:58 |
| 58-4587 |
| 362 | state->flags |= QTextCodec::IgnoreHeader; executed: state->flags |= QTextCodec::IgnoreHeader;Execution Count:4587 | 4587 |
| 363 | state->state_data[Endian] = endian; executed (the execution status of this line is deduced): state->state_data[Endian] = endian; | - |
| 364 | if (half) { evaluated: half| yes Evaluation Count:652 | yes Evaluation Count:3993 |
| 652-3993 |
| 365 | state->remainingChars = 1; executed (the execution status of this line is deduced): state->remainingChars = 1; | - |
| 366 | state->state_data[Data] = buf; executed (the execution status of this line is deduced): state->state_data[Data] = buf; | - |
| 367 | } else { executed: }Execution Count:652 | 652 |
| 368 | state->remainingChars = 0; executed (the execution status of this line is deduced): state->remainingChars = 0; | - |
| 369 | state->state_data[Data] = 0; executed (the execution status of this line is deduced): state->state_data[Data] = 0; | - |
| 370 | } executed: }Execution Count:3993 | 3993 |
| 371 | } | - |
| 372 | return result; executed: return result;Execution Count:4831 | 4831 |
| 373 | } | - |
| 374 | | - |
| 375 | QByteArray QUtf32::convertFromUnicode(const QChar *uc, int len, QTextCodec::ConverterState *state, DataEndianness e) | - |
| 376 | { | - |
| 377 | DataEndianness endian = e; executed (the execution status of this line is deduced): DataEndianness endian = e; | - |
| 378 | int length = 4*len; executed (the execution status of this line is deduced): int length = 4*len; | - |
| 379 | if (!state || (!(state->flags & QTextCodec::IgnoreHeader))) { evaluated: !state| yes Evaluation Count:22 | yes Evaluation Count:85706 |
evaluated: (!(state->flags & QTextCodec::IgnoreHeader))| yes Evaluation Count:82797 | yes Evaluation Count:2909 |
| 22-85706 |
| 380 | length += 4; executed (the execution status of this line is deduced): length += 4; | - |
| 381 | } executed: }Execution Count:82819 | 82819 |
| 382 | if (e == DetectEndianness) { evaluated: e == DetectEndianness| yes Evaluation Count:85713 | yes Evaluation Count:15 |
| 15-85713 |
| 383 | endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BigEndianness : LittleEndianness; partially evaluated: (QSysInfo::ByteOrder == QSysInfo::BigEndian)| no Evaluation Count:0 | yes Evaluation Count:85713 |
| 0-85713 |
| 384 | } executed: }Execution Count:85713 | 85713 |
| 385 | | - |
| 386 | QByteArray d(length, Qt::Uninitialized); executed (the execution status of this line is deduced): QByteArray d(length, Qt::Uninitialized); | - |
| 387 | char *data = d.data(); executed (the execution status of this line is deduced): char *data = d.data(); | - |
| 388 | if (!state || !(state->flags & QTextCodec::IgnoreHeader)) { evaluated: !state| yes Evaluation Count:22 | yes Evaluation Count:85706 |
evaluated: !(state->flags & QTextCodec::IgnoreHeader)| yes Evaluation Count:82797 | yes Evaluation Count:2909 |
| 22-85706 |
| 389 | if (endian == BigEndianness) { evaluated: endian == BigEndianness| yes Evaluation Count:7 | yes Evaluation Count:82812 |
| 7-82812 |
| 390 | data[0] = 0; executed (the execution status of this line is deduced): data[0] = 0; | - |
| 391 | data[1] = 0; executed (the execution status of this line is deduced): data[1] = 0; | - |
| 392 | data[2] = (char)0xfe; executed (the execution status of this line is deduced): data[2] = (char)0xfe; | - |
| 393 | data[3] = (char)0xff; executed (the execution status of this line is deduced): data[3] = (char)0xff; | - |
| 394 | } else { executed: }Execution Count:7 | 7 |
| 395 | data[0] = (char)0xff; executed (the execution status of this line is deduced): data[0] = (char)0xff; | - |
| 396 | data[1] = (char)0xfe; executed (the execution status of this line is deduced): data[1] = (char)0xfe; | - |
| 397 | data[2] = 0; executed (the execution status of this line is deduced): data[2] = 0; | - |
| 398 | data[3] = 0; executed (the execution status of this line is deduced): data[3] = 0; | - |
| 399 | } executed: }Execution Count:82812 | 82812 |
| 400 | data += 4; executed (the execution status of this line is deduced): data += 4; | - |
| 401 | } executed: }Execution Count:82819 | 82819 |
| 402 | if (endian == BigEndianness) { evaluated: endian == BigEndianness| yes Evaluation Count:7 | yes Evaluation Count:85721 |
| 7-85721 |
| 403 | for (int i = 0; i < len; ++i) { evaluated: i < len| yes Evaluation Count:54 | yes Evaluation Count:7 |
| 7-54 |
| 404 | uint cp = uc[i].unicode(); executed (the execution status of this line is deduced): uint cp = uc[i].unicode(); | - |
| 405 | if (uc[i].isHighSurrogate() && i < len - 1) partially evaluated: uc[i].isHighSurrogate()| no Evaluation Count:0 | yes Evaluation Count:54 |
never evaluated: i < len - 1 | 0-54 |
| 406 | cp = QChar::surrogateToUcs4(cp, uc[++i].unicode()); never executed: cp = QChar::surrogateToUcs4(cp, uc[++i].unicode()); | 0 |
| 407 | *(data++) = cp >> 24; executed (the execution status of this line is deduced): *(data++) = cp >> 24; | - |
| 408 | *(data++) = (cp >> 16) & 0xff; executed (the execution status of this line is deduced): *(data++) = (cp >> 16) & 0xff; | - |
| 409 | *(data++) = (cp >> 8) & 0xff; executed (the execution status of this line is deduced): *(data++) = (cp >> 8) & 0xff; | - |
| 410 | *(data++) = cp & 0xff; executed (the execution status of this line is deduced): *(data++) = cp & 0xff; | - |
| 411 | } executed: }Execution Count:54 | 54 |
| 412 | } else { executed: }Execution Count:7 | 7 |
| 413 | for (int i = 0; i < len; ++i) { evaluated: i < len| yes Evaluation Count:255438 | yes Evaluation Count:85721 |
| 85721-255438 |
| 414 | uint cp = uc[i].unicode(); executed (the execution status of this line is deduced): uint cp = uc[i].unicode(); | - |
| 415 | if (uc[i].isHighSurrogate() && i < len - 1) partially evaluated: uc[i].isHighSurrogate()| no Evaluation Count:0 | yes Evaluation Count:255438 |
never evaluated: i < len - 1 | 0-255438 |
| 416 | cp = QChar::surrogateToUcs4(cp, uc[++i].unicode()); never executed: cp = QChar::surrogateToUcs4(cp, uc[++i].unicode()); | 0 |
| 417 | *(data++) = cp & 0xff; executed (the execution status of this line is deduced): *(data++) = cp & 0xff; | - |
| 418 | *(data++) = (cp >> 8) & 0xff; executed (the execution status of this line is deduced): *(data++) = (cp >> 8) & 0xff; | - |
| 419 | *(data++) = (cp >> 16) & 0xff; executed (the execution status of this line is deduced): *(data++) = (cp >> 16) & 0xff; | - |
| 420 | *(data++) = cp >> 24; executed (the execution status of this line is deduced): *(data++) = cp >> 24; | - |
| 421 | } executed: }Execution Count:255438 | 255438 |
| 422 | } executed: }Execution Count:85721 | 85721 |
| 423 | | - |
| 424 | if (state) { evaluated: state| yes Evaluation Count:85706 | yes Evaluation Count:22 |
| 22-85706 |
| 425 | state->remainingChars = 0; executed (the execution status of this line is deduced): state->remainingChars = 0; | - |
| 426 | state->flags |= QTextCodec::IgnoreHeader; executed (the execution status of this line is deduced): state->flags |= QTextCodec::IgnoreHeader; | - |
| 427 | } executed: }Execution Count:85706 | 85706 |
| 428 | return d; executed: return d;Execution Count:85728 | 85728 |
| 429 | } | - |
| 430 | | - |
| 431 | QString QUtf32::convertToUnicode(const char *chars, int len, QTextCodec::ConverterState *state, DataEndianness e) | - |
| 432 | { | - |
| 433 | DataEndianness endian = e; executed (the execution status of this line is deduced): DataEndianness endian = e; | - |
| 434 | uchar tuple[4]; executed (the execution status of this line is deduced): uchar tuple[4]; | - |
| 435 | int num = 0; executed (the execution status of this line is deduced): int num = 0; | - |
| 436 | bool headerdone = false; executed (the execution status of this line is deduced): bool headerdone = false; | - |
| 437 | if (state) { evaluated: state| yes Evaluation Count:1065 | yes Evaluation Count:49 |
| 49-1065 |
| 438 | headerdone = state->flags & QTextCodec::IgnoreHeader; executed (the execution status of this line is deduced): headerdone = state->flags & QTextCodec::IgnoreHeader; | - |
| 439 | if (endian == DetectEndianness) { evaluated: endian == DetectEndianness| yes Evaluation Count:695 | yes Evaluation Count:370 |
| 370-695 |
| 440 | endian = (DataEndianness)state->state_data[Endian]; executed (the execution status of this line is deduced): endian = (DataEndianness)state->state_data[Endian]; | - |
| 441 | } executed: }Execution Count:695 | 695 |
| 442 | num = state->remainingChars; executed (the execution status of this line is deduced): num = state->remainingChars; | - |
| 443 | memcpy(tuple, &state->state_data[Data], 4); executed (the execution status of this line is deduced): memcpy(tuple, &state->state_data[Data], 4); | - |
| 444 | } executed: }Execution Count:1065 | 1065 |
| 445 | if (headerdone && endian == DetectEndianness) evaluated: headerdone| yes Evaluation Count:3 | yes Evaluation Count:1111 |
evaluated: endian == DetectEndianness| yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-1111 |
| 446 | endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BigEndianness : LittleEndianness; executed: endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BigEndianness : LittleEndianness;Execution Count:1 partially evaluated: (QSysInfo::ByteOrder == QSysInfo::BigEndian)| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 447 | | - |
| 448 | QString result; executed (the execution status of this line is deduced): QString result; | - |
| 449 | result.resize((num + len) >> 2 << 1); // worst case executed (the execution status of this line is deduced): result.resize((num + len) >> 2 << 1); | - |
| 450 | QChar *qch = (QChar *)result.unicode(); executed (the execution status of this line is deduced): QChar *qch = (QChar *)result.unicode(); | - |
| 451 | | - |
| 452 | const char *end = chars + len; executed (the execution status of this line is deduced): const char *end = chars + len; | - |
| 453 | while (chars < end) { evaluated: chars < end| yes Evaluation Count:1390772 | yes Evaluation Count:1114 |
| 1114-1390772 |
| 454 | tuple[num++] = *chars++; executed (the execution status of this line is deduced): tuple[num++] = *chars++; | - |
| 455 | if (num == 4) { evaluated: num == 4| yes Evaluation Count:347693 | yes Evaluation Count:1043079 |
| 347693-1043079 |
| 456 | if (!headerdone) { evaluated: !headerdone| yes Evaluation Count:347681 | yes Evaluation Count:12 |
| 12-347681 |
| 457 | if (endian == DetectEndianness) { evaluated: endian == DetectEndianness| yes Evaluation Count:51 | yes Evaluation Count:347630 |
| 51-347630 |
| 458 | if (tuple[0] == 0xff && tuple[1] == 0xfe && tuple[2] == 0 && tuple[3] == 0 && endian != BigEndianness) { evaluated: tuple[0] == 0xff| yes Evaluation Count:9 | yes Evaluation Count:42 |
partially evaluated: tuple[1] == 0xfe| yes Evaluation Count:9 | no Evaluation Count:0 |
partially evaluated: tuple[2] == 0| yes Evaluation Count:9 | no Evaluation Count:0 |
partially evaluated: tuple[3] == 0| yes Evaluation Count:9 | no Evaluation Count:0 |
partially evaluated: endian != BigEndianness| yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-42 |
| 459 | endian = LittleEndianness; executed (the execution status of this line is deduced): endian = LittleEndianness; | - |
| 460 | num = 0; executed (the execution status of this line is deduced): num = 0; | - |
| 461 | continue; executed: continue;Execution Count:9 | 9 |
| 462 | } else if (tuple[0] == 0 && tuple[1] == 0 && tuple[2] == 0xfe && tuple[3] == 0xff && endian != LittleEndianness) { evaluated: tuple[0] == 0| yes Evaluation Count:7 | yes Evaluation Count:35 |
partially evaluated: tuple[1] == 0| yes Evaluation Count:7 | no Evaluation Count:0 |
evaluated: tuple[2] == 0xfe| yes Evaluation Count:1 | yes Evaluation Count:6 |
partially evaluated: tuple[3] == 0xff| yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: endian != LittleEndianness| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-35 |
| 463 | endian = BigEndianness; executed (the execution status of this line is deduced): endian = BigEndianness; | - |
| 464 | num = 0; executed (the execution status of this line is deduced): num = 0; | - |
| 465 | continue; executed: continue;Execution Count:1 | 1 |
| 466 | } else if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { partially evaluated: QSysInfo::ByteOrder == QSysInfo::BigEndian| no Evaluation Count:0 | yes Evaluation Count:41 |
| 0-41 |
| 467 | endian = BigEndianness; never executed (the execution status of this line is deduced): endian = BigEndianness; | - |
| 468 | } else { | 0 |
| 469 | endian = LittleEndianness; executed (the execution status of this line is deduced): endian = LittleEndianness; | - |
| 470 | } executed: }Execution Count:41 | 41 |
| 471 | } else if (((endian == BigEndianness) ? qFromBigEndian<quint32>(tuple) : qFromLittleEndian<quint32>(tuple)) == QChar::ByteOrderMark) { evaluated: ((endian == BigEndianness) ? qFromBigEndian<quint32>(tuple) : qFromLittleEndian<quint32>(tuple)) == QChar::ByteOrderMark| yes Evaluation Count:47 | yes Evaluation Count:347583 |
evaluated: (endian == BigEndianness)| yes Evaluation Count:220 | yes Evaluation Count:347410 |
| 47-347583 |
| 472 | num = 0; executed (the execution status of this line is deduced): num = 0; | - |
| 473 | continue; executed: continue;Execution Count:47 | 47 |
| 474 | } | - |
| 475 | } | - |
| 476 | uint code = (endian == BigEndianness) ? qFromBigEndian<quint32>(tuple) : qFromLittleEndian<quint32>(tuple); evaluated: (endian == BigEndianness)| yes Evaluation Count:200 | yes Evaluation Count:347436 |
| 200-347436 |
| 477 | if (QChar::requiresSurrogates(code)) { evaluated: QChar::requiresSurrogates(code)| yes Evaluation Count:19 | yes Evaluation Count:347617 |
| 19-347617 |
| 478 | *qch++ = QChar::highSurrogate(code); executed (the execution status of this line is deduced): *qch++ = QChar::highSurrogate(code); | - |
| 479 | *qch++ = QChar::lowSurrogate(code); executed (the execution status of this line is deduced): *qch++ = QChar::lowSurrogate(code); | - |
| 480 | } else { executed: }Execution Count:19 | 19 |
| 481 | *qch++ = code; executed (the execution status of this line is deduced): *qch++ = code; | - |
| 482 | } executed: }Execution Count:347617 | 347617 |
| 483 | num = 0; executed (the execution status of this line is deduced): num = 0; | - |
| 484 | } executed: }Execution Count:347636 | 347636 |
| 485 | } executed: }Execution Count:1390715 | 1390715 |
| 486 | result.truncate(qch - result.unicode()); executed (the execution status of this line is deduced): result.truncate(qch - result.unicode()); | - |
| 487 | | - |
| 488 | if (state) { evaluated: state| yes Evaluation Count:1065 | yes Evaluation Count:49 |
| 49-1065 |
| 489 | if (headerdone) evaluated: headerdone| yes Evaluation Count:3 | yes Evaluation Count:1062 |
| 3-1062 |
| 490 | state->flags |= QTextCodec::IgnoreHeader; executed: state->flags |= QTextCodec::IgnoreHeader;Execution Count:3 | 3 |
| 491 | state->state_data[Endian] = endian; executed (the execution status of this line is deduced): state->state_data[Endian] = endian; | - |
| 492 | state->remainingChars = num; executed (the execution status of this line is deduced): state->remainingChars = num; | - |
| 493 | memcpy(&state->state_data[Data], tuple, 4); executed (the execution status of this line is deduced): memcpy(&state->state_data[Data], tuple, 4); | - |
| 494 | } executed: }Execution Count:1065 | 1065 |
| 495 | return result; executed: return result;Execution Count:1114 | 1114 |
| 496 | } | - |
| 497 | | - |
| 498 | | - |
| 499 | #ifndef QT_NO_TEXTCODEC | - |
| 500 | | - |
| 501 | QUtf8Codec::~QUtf8Codec() | - |
| 502 | { | - |
| 503 | } | - |
| 504 | | - |
| 505 | QByteArray QUtf8Codec::convertFromUnicode(const QChar *uc, int len, ConverterState *state) const | - |
| 506 | { | - |
| 507 | return QUtf8::convertFromUnicode(uc, len, state); executed: return QUtf8::convertFromUnicode(uc, len, state);Execution Count:797595 | 797595 |
| 508 | } | - |
| 509 | | - |
| 510 | void QUtf8Codec::convertToUnicode(QString *target, const char *chars, int len, ConverterState *state) const | - |
| 511 | { | - |
| 512 | *target += QUtf8::convertToUnicode(chars, len, state); executed (the execution status of this line is deduced): *target += QUtf8::convertToUnicode(chars, len, state); | - |
| 513 | } executed: }Execution Count:59082 | 59082 |
| 514 | | - |
| 515 | QString QUtf8Codec::convertToUnicode(const char *chars, int len, ConverterState *state) const | - |
| 516 | { | - |
| 517 | return QUtf8::convertToUnicode(chars, len, state); executed: return QUtf8::convertToUnicode(chars, len, state);Execution Count:41267178 | 41267178 |
| 518 | } | - |
| 519 | | - |
| 520 | QByteArray QUtf8Codec::name() const | - |
| 521 | { | - |
| 522 | return "UTF-8"; executed: return "UTF-8";Execution Count:227 | 227 |
| 523 | } | - |
| 524 | | - |
| 525 | int QUtf8Codec::mibEnum() const | - |
| 526 | { | - |
| 527 | return 106; executed: return 106;Execution Count:59208 | 59208 |
| 528 | } | - |
| 529 | | - |
| 530 | QUtf16Codec::~QUtf16Codec() | - |
| 531 | { | - |
| 532 | } | - |
| 533 | | - |
| 534 | QByteArray QUtf16Codec::convertFromUnicode(const QChar *uc, int len, ConverterState *state) const | - |
| 535 | { | - |
| 536 | return QUtf16::convertFromUnicode(uc, len, state, e); executed: return QUtf16::convertFromUnicode(uc, len, state, e);Execution Count:257173 | 257173 |
| 537 | } | - |
| 538 | | - |
| 539 | QString QUtf16Codec::convertToUnicode(const char *chars, int len, ConverterState *state) const | - |
| 540 | { | - |
| 541 | return QUtf16::convertToUnicode(chars, len, state, e); executed: return QUtf16::convertToUnicode(chars, len, state, e);Execution Count:4725 | 4725 |
| 542 | } | - |
| 543 | | - |
| 544 | int QUtf16Codec::mibEnum() const | - |
| 545 | { | - |
| 546 | return 1015; executed: return 1015;Execution Count:458 | 458 |
| 547 | } | - |
| 548 | | - |
| 549 | QByteArray QUtf16Codec::name() const | - |
| 550 | { | - |
| 551 | return "UTF-16"; executed: return "UTF-16";Execution Count:153 | 153 |
| 552 | } | - |
| 553 | | - |
| 554 | QList<QByteArray> QUtf16Codec::aliases() const | - |
| 555 | { | - |
| 556 | return QList<QByteArray>(); executed: return QList<QByteArray>();Execution Count:140 | 140 |
| 557 | } | - |
| 558 | | - |
| 559 | int QUtf16BECodec::mibEnum() const | - |
| 560 | { | - |
| 561 | return 1013; executed: return 1013;Execution Count:35 | 35 |
| 562 | } | - |
| 563 | | - |
| 564 | QByteArray QUtf16BECodec::name() const | - |
| 565 | { | - |
| 566 | return "UTF-16BE"; executed: return "UTF-16BE";Execution Count:166 | 166 |
| 567 | } | - |
| 568 | | - |
| 569 | QList<QByteArray> QUtf16BECodec::aliases() const | - |
| 570 | { | - |
| 571 | QList<QByteArray> list; executed (the execution status of this line is deduced): QList<QByteArray> list; | - |
| 572 | return list; executed: return list;Execution Count:154 | 154 |
| 573 | } | - |
| 574 | | - |
| 575 | int QUtf16LECodec::mibEnum() const | - |
| 576 | { | - |
| 577 | return 1014; executed: return 1014;Execution Count:33 | 33 |
| 578 | } | - |
| 579 | | - |
| 580 | QByteArray QUtf16LECodec::name() const | - |
| 581 | { | - |
| 582 | return "UTF-16LE"; executed: return "UTF-16LE";Execution Count:161 | 161 |
| 583 | } | - |
| 584 | | - |
| 585 | QList<QByteArray> QUtf16LECodec::aliases() const | - |
| 586 | { | - |
| 587 | QList<QByteArray> list; executed (the execution status of this line is deduced): QList<QByteArray> list; | - |
| 588 | return list; executed: return list;Execution Count:146 | 146 |
| 589 | } | - |
| 590 | | - |
| 591 | QUtf32Codec::~QUtf32Codec() | - |
| 592 | { | - |
| 593 | } | - |
| 594 | | - |
| 595 | QByteArray QUtf32Codec::convertFromUnicode(const QChar *uc, int len, ConverterState *state) const | - |
| 596 | { | - |
| 597 | return QUtf32::convertFromUnicode(uc, len, state, e); executed: return QUtf32::convertFromUnicode(uc, len, state, e);Execution Count:85728 | 85728 |
| 598 | } | - |
| 599 | | - |
| 600 | QString QUtf32Codec::convertToUnicode(const char *chars, int len, ConverterState *state) const | - |
| 601 | { | - |
| 602 | return QUtf32::convertToUnicode(chars, len, state, e); executed: return QUtf32::convertToUnicode(chars, len, state, e);Execution Count:1094 | 1094 |
| 603 | } | - |
| 604 | | - |
| 605 | int QUtf32Codec::mibEnum() const | - |
| 606 | { | - |
| 607 | return 1017; executed: return 1017;Execution Count:28 | 28 |
| 608 | } | - |
| 609 | | - |
| 610 | QByteArray QUtf32Codec::name() const | - |
| 611 | { | - |
| 612 | return "UTF-32"; executed: return "UTF-32";Execution Count:137 | 137 |
| 613 | } | - |
| 614 | | - |
| 615 | QList<QByteArray> QUtf32Codec::aliases() const | - |
| 616 | { | - |
| 617 | QList<QByteArray> list; executed (the execution status of this line is deduced): QList<QByteArray> list; | - |
| 618 | return list; executed: return list;Execution Count:125 | 125 |
| 619 | } | - |
| 620 | | - |
| 621 | int QUtf32BECodec::mibEnum() const | - |
| 622 | { | - |
| 623 | return 1018; executed: return 1018;Execution Count:21 | 21 |
| 624 | } | - |
| 625 | | - |
| 626 | QByteArray QUtf32BECodec::name() const | - |
| 627 | { | - |
| 628 | return "UTF-32BE"; executed: return "UTF-32BE";Execution Count:128 | 128 |
| 629 | } | - |
| 630 | | - |
| 631 | QList<QByteArray> QUtf32BECodec::aliases() const | - |
| 632 | { | - |
| 633 | QList<QByteArray> list; executed (the execution status of this line is deduced): QList<QByteArray> list; | - |
| 634 | return list; executed: return list;Execution Count:127 | 127 |
| 635 | } | - |
| 636 | | - |
| 637 | int QUtf32LECodec::mibEnum() const | - |
| 638 | { | - |
| 639 | return 1019; executed: return 1019;Execution Count:23 | 23 |
| 640 | } | - |
| 641 | | - |
| 642 | QByteArray QUtf32LECodec::name() const | - |
| 643 | { | - |
| 644 | return "UTF-32LE"; executed: return "UTF-32LE";Execution Count:127 | 127 |
| 645 | } | - |
| 646 | | - |
| 647 | QList<QByteArray> QUtf32LECodec::aliases() const | - |
| 648 | { | - |
| 649 | QList<QByteArray> list; executed (the execution status of this line is deduced): QList<QByteArray> list; | - |
| 650 | return list; executed: return list;Execution Count:126 | 126 |
| 651 | } | - |
| 652 | | - |
| 653 | #endif //QT_NO_TEXTCODEC | - |
| 654 | | - |
| 655 | QT_END_NAMESPACE | - |
| 656 | | - |
| | |