Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | int qFindByteArray( | - |
14 | const char *haystack0, int haystackLen, int from, | - |
15 | const char *needle0, int needleLen); | - |
16 | | - |
17 | | - |
18 | int qAllocMore(int alloc, int extra) | - |
19 | { | - |
20 | qt_noop(); | - |
21 | qt_noop(); | - |
22 | | - |
23 | unsigned nalloc = alloc + extra; | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | nalloc |= nalloc >> 1; | - |
31 | nalloc |= nalloc >> 2; | - |
32 | nalloc |= nalloc >> 4; | - |
33 | nalloc |= nalloc >> 8; | - |
34 | nalloc |= nalloc >> 16; | - |
35 | ++nalloc; | - |
36 | | - |
37 | qt_noop(); | - |
38 | | - |
39 | return nalloc - extra; executed: return nalloc - extra; Execution Count:11464229 | 11464229 |
40 | } | - |
41 | char *qstrdup(const char *src) | - |
42 | { | - |
43 | if (!src) evaluated: !src yes Evaluation Count:1 | yes Evaluation Count:303558 |
| 1-303558 |
44 | return 0; executed: return 0; Execution Count:1 | 1 |
45 | char *dst = new char[strlen(src) + 1]; | - |
46 | return qstrcpy(dst, src); executed: return qstrcpy(dst, src); Execution Count:303559 | 303559 |
47 | } | - |
48 | char *qstrcpy(char *dst, const char *src) | - |
49 | { | - |
50 | if (!src) evaluated: !src yes Evaluation Count:2 | yes Evaluation Count:304768 |
| 2-304768 |
51 | return 0; executed: return 0; Execution Count:2 | 2 |
52 | return strcpy(dst, src); executed: return strcpy(dst, src); Execution Count:304768 | 304768 |
53 | | - |
54 | } | - |
55 | char *qstrncpy(char *dst, const char *src, uint len) | - |
56 | { | - |
57 | if (!src || !dst) evaluated: !src yes Evaluation Count:2 | yes Evaluation Count:19 |
partially evaluated: !dst no Evaluation Count:0 | yes Evaluation Count:19 |
| 0-19 |
58 | return 0; executed: return 0; Execution Count:2 | 2 |
59 | | - |
60 | | - |
61 | | - |
62 | strncpy(dst, src, len); | - |
63 | | - |
64 | if (len > 0) partially evaluated: len > 0 yes Evaluation Count:19 | no Evaluation Count:0 |
| 0-19 |
65 | dst[len-1] = '\0'; executed: dst[len-1] = '\0'; Execution Count:19 | 19 |
66 | return dst; executed: return dst; Execution Count:19 | 19 |
67 | } | - |
68 | int qstrcmp(const char *str1, const char *str2) | - |
69 | { | - |
70 | return (str1 && str2) ? strcmp(str1, str2) | 158581 |
71 | : (str1 ? 1 : (str2 ? -1 : 0)); executed: return (str1 && str2) ? strcmp(str1, str2) : (str1 ? 1 : (str2 ? -1 : 0)); Execution Count:158581 | 158581 |
72 | } | - |
73 | int qstricmp(const char *str1, const char *str2) | - |
74 | { | - |
75 | register const uchar *s1 = reinterpret_cast<const uchar *>(str1); | - |
76 | register const uchar *s2 = reinterpret_cast<const uchar *>(str2); | - |
77 | int res; | - |
78 | uchar c; | - |
79 | if (!s1 || !s2) evaluated: !s1 yes Evaluation Count:2 | yes Evaluation Count:107537 |
evaluated: !s2 yes Evaluation Count:1 | yes Evaluation Count:107536 |
| 1-107537 |
80 | return s1 ? 1 : (s2 ? -1 : 0); executed: return s1 ? 1 : (s2 ? -1 : 0); Execution Count:3 | 3 |
81 | for (; !(res = (c = QChar::toLower((ushort)*s1)) - QChar::toLower((ushort)*s2)); s1++, s2++) evaluated: !(res = (c = QChar::toLower((ushort)*s1)) - QChar::toLower((ushort)*s2)) yes Evaluation Count:177464 | yes Evaluation Count:99489 |
| 99489-177464 |
82 | if (!c) evaluated: !c yes Evaluation Count:8046 | yes Evaluation Count:169421 |
| 8046-169421 |
83 | break; executed: break; Execution Count:8046 | 8046 |
84 | return res; executed: return res; Execution Count:107532 | 107532 |
85 | } | - |
86 | int qstrnicmp(const char *str1, const char *str2, uint len) | - |
87 | { | - |
88 | register const uchar *s1 = reinterpret_cast<const uchar *>(str1); | - |
89 | register const uchar *s2 = reinterpret_cast<const uchar *>(str2); | - |
90 | int res; | - |
91 | uchar c; | - |
92 | if (!s1 || !s2) evaluated: !s1 yes Evaluation Count:2 | yes Evaluation Count:124 |
evaluated: !s2 yes Evaluation Count:1 | yes Evaluation Count:123 |
| 1-124 |
93 | return s1 ? 1 : (s2 ? -1 : 0); executed: return s1 ? 1 : (s2 ? -1 : 0); Execution Count:3 | 3 |
94 | for (; len--; s1++, s2++) { evaluated: len-- yes Evaluation Count:244 | yes Evaluation Count:10 |
| 10-244 |
95 | if ((res = (c = QChar::toLower((ushort)*s1)) - QChar::toLower((ushort)*s2))) evaluated: (res = (c = QChar::toLower((ushort)*s1)) - QChar::toLower((ushort)*s2)) yes Evaluation Count:112 | yes Evaluation Count:132 |
| 112-132 |
96 | return res; executed: return res; Execution Count:112 | 112 |
97 | if (!c) evaluated: !c yes Evaluation Count:1 | yes Evaluation Count:131 |
| 1-131 |
98 | break; executed: break; Execution Count:1 | 1 |
99 | } executed: } Execution Count:131 | 131 |
100 | return 0; executed: return 0; Execution Count:11 | 11 |
101 | } | - |
102 | | - |
103 | | - |
104 | | - |
105 | | - |
106 | int qstrcmp(const QByteArray &str1, const char *str2) | - |
107 | { | - |
108 | if (!str2) evaluated: !str2 yes Evaluation Count:32 | yes Evaluation Count:1258189 |
| 32-1258189 |
109 | return str1.isEmpty() ? 0 : +1; executed: return str1.isEmpty() ? 0 : +1; Execution Count:32 | 32 |
110 | | - |
111 | const char *str1data = str1.constData(); | - |
112 | const char *str1end = str1data + str1.length(); | - |
113 | for ( ; str1data < str1end && *str2; ++str1data, ++str2) { evaluated: str1data < str1end yes Evaluation Count:4915566 | yes Evaluation Count:414398 |
evaluated: *str2 yes Evaluation Count:4915284 | yes Evaluation Count:279 |
| 279-4915566 |
114 | register int diff = int(uchar(*str1data)) - uchar(*str2); | - |
115 | if (diff) evaluated: diff yes Evaluation Count:843509 | yes Evaluation Count:4071777 |
| 843509-4071777 |
116 | | - |
117 | return diff; executed: return diff; Execution Count:843509 | 843509 |
118 | } executed: } Execution Count:4071779 | 4071779 |
119 | | - |
120 | | - |
121 | if (*str2 != '\0') evaluated: *str2 != '\0' yes Evaluation Count:1697 | yes Evaluation Count:412980 |
| 1697-412980 |
122 | | - |
123 | return -1; executed: return -1; Execution Count:1697 | 1697 |
124 | if (str1data < str1end) evaluated: str1data < str1end yes Evaluation Count:279 | yes Evaluation Count:412701 |
| 279-412701 |
125 | | - |
126 | return +1; executed: return +1; Execution Count:279 | 279 |
127 | return 0; executed: return 0; Execution Count:412701 | 412701 |
128 | } | - |
129 | | - |
130 | | - |
131 | | - |
132 | | - |
133 | int qstrcmp(const QByteArray &str1, const QByteArray &str2) | - |
134 | { | - |
135 | int l1 = str1.length(); | - |
136 | int l2 = str2.length(); | - |
137 | int ret = memcmp(str1.constData(), str2.constData(), qMin(l1, l2)); | - |
138 | if (ret != 0) evaluated: ret != 0 yes Evaluation Count:32180 | yes Evaluation Count:1002 |
| 1002-32180 |
139 | return ret; executed: return ret; Execution Count:32180 | 32180 |
140 | | - |
141 | | - |
142 | | - |
143 | return l1 - l2; executed: return l1 - l2; Execution Count:1002 | 1002 |
144 | } | - |
145 | static const quint16 crc_tbl[16] = { | - |
146 | 0x0000, 0x1081, 0x2102, 0x3183, | - |
147 | 0x4204, 0x5285, 0x6306, 0x7387, | - |
148 | 0x8408, 0x9489, 0xa50a, 0xb58b, | - |
149 | 0xc60c, 0xd68d, 0xe70e, 0xf78f | - |
150 | }; | - |
151 | quint16 qChecksum(const char *data, uint len) | - |
152 | { | - |
153 | register quint16 crc = 0xffff; | - |
154 | uchar c; | - |
155 | const uchar *p = reinterpret_cast<const uchar *>(data); | - |
156 | while (len--) { evaluated: len-- yes Evaluation Count:5933 | yes Evaluation Count:21 |
| 21-5933 |
157 | c = *p++; | - |
158 | crc = ((crc >> 4) & 0x0fff) ^ crc_tbl[((crc ^ c) & 15)]; | - |
159 | c >>= 4; | - |
160 | crc = ((crc >> 4) & 0x0fff) ^ crc_tbl[((crc ^ c) & 15)]; | - |
161 | } executed: } Execution Count:5933 | 5933 |
162 | return ~crc & 0xffff; executed: return ~crc & 0xffff; Execution Count:21 | 21 |
163 | } | - |
164 | QByteArray qCompress(const uchar* data, int nbytes, int compressionLevel) | - |
165 | { | - |
166 | if (nbytes == 0) { evaluated: nbytes == 0 yes Evaluation Count:1 | yes Evaluation Count:18 |
| 1-18 |
167 | return QByteArray(4, '\0'); executed: return QByteArray(4, '\0'); Execution Count:1 | 1 |
168 | } | - |
169 | if (!data) { partially evaluated: !data no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
170 | QMessageLogger("tools/qbytearray.cpp", 460, __PRETTY_FUNCTION__).warning("qCompress: Data is null"); | - |
171 | return QByteArray(); never executed: return QByteArray(); | 0 |
172 | } | - |
173 | if (compressionLevel < -1 || compressionLevel > 9) partially evaluated: compressionLevel < -1 no Evaluation Count:0 | yes Evaluation Count:18 |
partially evaluated: compressionLevel > 9 no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
174 | compressionLevel = -1; never executed: compressionLevel = -1; | 0 |
175 | | - |
176 | ulong len = nbytes + nbytes / 100 + 13; | - |
177 | QByteArray bazip; | - |
178 | int res; | - |
179 | do { | - |
180 | bazip.resize(len + 4); | - |
181 | res = ::compress2((uchar*)bazip.data()+4, &len, (uchar*)data, nbytes, compressionLevel); | - |
182 | | - |
183 | switch (res) { | - |
184 | case 0: | - |
185 | bazip.resize(len + 4); | - |
186 | bazip[0] = (nbytes & 0xff000000) >> 24; | - |
187 | bazip[1] = (nbytes & 0x00ff0000) >> 16; | - |
188 | bazip[2] = (nbytes & 0x0000ff00) >> 8; | - |
189 | bazip[3] = (nbytes & 0x000000ff); | - |
190 | break; executed: break; Execution Count:18 | 18 |
191 | case (-4): | - |
192 | QMessageLogger("tools/qbytearray.cpp", 482, __PRETTY_FUNCTION__).warning("qCompress: Z_MEM_ERROR: Not enough memory"); | - |
193 | bazip.resize(0); | - |
194 | break; | 0 |
195 | case (-5): | - |
196 | len *= 2; | - |
197 | break; | 0 |
198 | } | - |
199 | } while (res == (-5)); executed: } Execution Count:18 partially evaluated: res == (-5) no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
200 | | - |
201 | return bazip; executed: return bazip; Execution Count:18 | 18 |
202 | } | - |
203 | QByteArray qUncompress(const uchar* data, int nbytes) | - |
204 | { | - |
205 | if (!data) { partially evaluated: !data no Evaluation Count:0 | yes Evaluation Count:668 |
| 0-668 |
206 | QMessageLogger("tools/qbytearray.cpp", 530, __PRETTY_FUNCTION__).warning("qUncompress: Data is null"); | - |
207 | return QByteArray(); never executed: return QByteArray(); | 0 |
208 | } | - |
209 | if (nbytes <= 4) { evaluated: nbytes <= 4 yes Evaluation Count:13 | yes Evaluation Count:655 |
| 13-655 |
210 | if (nbytes < 4 || (data[0]!=0 || data[1]!=0 || data[2]!=0 || data[3]!=0)) partially evaluated: nbytes < 4 no Evaluation Count:0 | yes Evaluation Count:13 |
evaluated: data[0]!=0 yes Evaluation Count:10 | yes Evaluation Count:3 |
partially evaluated: data[1]!=0 no Evaluation Count:0 | yes Evaluation Count:3 |
partially evaluated: data[2]!=0 no Evaluation Count:0 | yes Evaluation Count:3 |
evaluated: data[3]!=0 yes Evaluation Count:1 | yes Evaluation Count:2 |
| 0-13 |
211 | QMessageLogger("tools/qbytearray.cpp", 535, __PRETTY_FUNCTION__).warning("qUncompress: Input data is corrupted"); executed: QMessageLogger("tools/qbytearray.cpp", 535, __PRETTY_FUNCTION__).warning("qUncompress: Input data is corrupted"); Execution Count:11 | 11 |
212 | return QByteArray(); executed: return QByteArray(); Execution Count:13 | 13 |
213 | } | - |
214 | ulong expectedSize = (data[0] << 24) | (data[1] << 16) | | - |
215 | (data[2] << 8) | (data[3] ); | - |
216 | ulong len = qMax(expectedSize, 1ul); | - |
217 | QScopedPointer<QByteArray::Data, QScopedPointerPodDeleter> d; | - |
218 | | - |
219 | for(;;) { | - |
220 | ulong alloc = len; | - |
221 | if (len >= (1u << 31u) - sizeof(QByteArray::Data)) { evaluated: len >= (1u << 31u) - sizeof(QByteArray::Data) yes Evaluation Count:7 | yes Evaluation Count:648 |
| 7-648 |
222 | | - |
223 | QMessageLogger("tools/qbytearray.cpp", 547, __PRETTY_FUNCTION__).warning("qUncompress: Input data is corrupted"); | - |
224 | return QByteArray(); executed: return QByteArray(); Execution Count:7 | 7 |
225 | } | - |
226 | QByteArray::Data *p = static_cast<QByteArray::Data *>(::realloc(d.data(), sizeof(QByteArray::Data) + alloc + 1)); | - |
227 | if (!p) { partially evaluated: !p no Evaluation Count:0 | yes Evaluation Count:648 |
| 0-648 |
228 | | - |
229 | QMessageLogger("tools/qbytearray.cpp", 553, __PRETTY_FUNCTION__).warning("qUncompress: could not allocate enough memory to uncompress data"); | - |
230 | return QByteArray(); never executed: return QByteArray(); | 0 |
231 | } | - |
232 | d.take(); | - |
233 | d.reset(p); | - |
234 | d->offset = sizeof(QByteArrayData); | - |
235 | | - |
236 | int res = ::uncompress((uchar*)d->data(), &len, | - |
237 | (uchar*)data+4, nbytes-4); | - |
238 | | - |
239 | switch (res) { | - |
240 | case 0: | - |
241 | if (len != alloc) { partially evaluated: len != alloc no Evaluation Count:0 | yes Evaluation Count:643 |
| 0-643 |
242 | if (len >= (1u << 31u) - sizeof(QByteArray::Data)) { never evaluated: len >= (1u << 31u) - sizeof(QByteArray::Data) | 0 |
243 | | - |
244 | QMessageLogger("tools/qbytearray.cpp", 568, __PRETTY_FUNCTION__).warning("qUncompress: Input data is corrupted"); | - |
245 | return QByteArray(); never executed: return QByteArray(); | 0 |
246 | } | - |
247 | QByteArray::Data *p = static_cast<QByteArray::Data *>(::realloc(d.data(), sizeof(QByteArray::Data) + len + 1)); | - |
248 | if (!p) { | 0 |
249 | | - |
250 | QMessageLogger("tools/qbytearray.cpp", 574, __PRETTY_FUNCTION__).warning("qUncompress: could not allocate enough memory to uncompress data"); | - |
251 | return QByteArray(); never executed: return QByteArray(); | 0 |
252 | } | - |
253 | d.take(); | - |
254 | d.reset(p); | - |
255 | } | 0 |
256 | d->ref.initializeOwned(); | - |
257 | d->size = len; | - |
258 | d->alloc = uint(len) + 1u; | - |
259 | d->capacityReserved = false; | - |
260 | d->offset = sizeof(QByteArrayData); | - |
261 | d->data()[len] = 0; | - |
262 | | - |
263 | { | - |
264 | QByteArrayDataPtr dataPtr = { reinterpret_cast<QByteArrayData *>(d.take()) }; | - |
265 | return QByteArray(dataPtr); executed: return QByteArray(dataPtr); Execution Count:643 | 643 |
266 | } | - |
267 | | - |
268 | case (-4): | - |
269 | QMessageLogger("tools/qbytearray.cpp", 593, __PRETTY_FUNCTION__).warning("qUncompress: Z_MEM_ERROR: Not enough memory"); | - |
270 | return QByteArray(); never executed: return QByteArray(); | 0 |
271 | | - |
272 | case (-5): | - |
273 | len *= 2; | - |
274 | continue; never executed: continue; | 0 |
275 | | - |
276 | case (-3): | - |
277 | QMessageLogger("tools/qbytearray.cpp", 601, __PRETTY_FUNCTION__).warning("qUncompress: Z_DATA_ERROR: Input data is corrupted"); | - |
278 | return QByteArray(); executed: return QByteArray(); Execution Count:5 | 5 |
279 | } | - |
280 | } | 0 |
281 | } | 0 |
282 | | - |
283 | | - |
284 | static inline bool qIsUpper(char c) | - |
285 | { | - |
286 | return c >= 'A' && c <= 'Z'; executed: return c >= 'A' && c <= 'Z'; Execution Count:450222 | 450222 |
287 | } | - |
288 | | - |
289 | static inline char qToLower(char c) | - |
290 | { | - |
291 | if (c >= 'A' && c <= 'Z') partially evaluated: c >= 'A' yes Evaluation Count:450222 | no Evaluation Count:0 |
partially evaluated: c <= 'Z' no Evaluation Count:0 | yes Evaluation Count:450222 |
| 0-450222 |
292 | return c - 'A' + 'a'; never executed: return c - 'A' + 'a'; | 0 |
293 | else | - |
294 | return c; executed: return c; Execution Count:450222 | 450222 |
295 | } | - |
296 | QByteArray &QByteArray::operator=(const QByteArray & other) | - |
297 | { | - |
298 | other.d->ref.ref(); | - |
299 | if (!d->ref.deref()) evaluated: !d->ref.deref() yes Evaluation Count:180923 | yes Evaluation Count:829624 |
| 180923-829624 |
300 | Data::deallocate(d); executed: Data::deallocate(d); Execution Count:180923 | 180923 |
301 | d = other.d; | - |
302 | return *this; executed: return *this; Execution Count:1010546 | 1010546 |
303 | } | - |
304 | QByteArray &QByteArray::operator=(const char *str) | - |
305 | { | - |
306 | Data *x; | - |
307 | if (!str) { evaluated: !str yes Evaluation Count:1 | yes Evaluation Count:110934 |
| 1-110934 |
308 | x = Data::sharedNull(); | - |
309 | } else if (!*str) { executed: } Execution Count:1 evaluated: !*str yes Evaluation Count:46580 | yes Evaluation Count:64354 |
| 1-64354 |
310 | x = Data::allocate(0); | - |
311 | } else { executed: } Execution Count:46580 | 46580 |
312 | const int len = int(strlen(str)); | - |
313 | const uint fullLen = len + 1; | - |
314 | if (d->ref.isShared() || fullLen > d->alloc evaluated: d->ref.isShared() yes Evaluation Count:1997 | yes Evaluation Count:62357 |
evaluated: fullLen > d->alloc yes Evaluation Count:33802 | yes Evaluation Count:28555 |
| 1997-62357 |
315 | || (len < d->size && fullLen < uint(d->alloc >> 1))) evaluated: len < d->size yes Evaluation Count:4442 | yes Evaluation Count:24113 |
evaluated: fullLen < uint(d->alloc >> 1) yes Evaluation Count:4439 | yes Evaluation Count:3 |
| 3-24113 |
316 | reallocData(fullLen, d->detachFlags()); executed: reallocData(fullLen, d->detachFlags()); Execution Count:40238 | 40238 |
317 | x = d; | - |
318 | memcpy(x->data(), str, fullLen); | - |
319 | x->size = len; | - |
320 | } executed: } Execution Count:64354 | 64354 |
321 | x->ref.ref(); | - |
322 | if (!d->ref.deref()) evaluated: !d->ref.deref() yes Evaluation Count:45312 | yes Evaluation Count:65623 |
| 45312-65623 |
323 | Data::deallocate(d); executed: Data::deallocate(d); Execution Count:45312 | 45312 |
324 | d = x; | - |
325 | return *this; executed: return *this; Execution Count:110935 | 110935 |
326 | } | - |
327 | void QByteArray::truncate(int pos) | - |
328 | { | - |
329 | if (pos < d->size) evaluated: pos < d->size yes Evaluation Count:22478 | yes Evaluation Count:859 |
| 859-22478 |
330 | resize(pos); executed: resize(pos); Execution Count:22478 | 22478 |
331 | } executed: } Execution Count:23337 | 23337 |
332 | void QByteArray::chop(int n) | - |
333 | { | - |
334 | if (n > 0) evaluated: n > 0 yes Evaluation Count:4055 | yes Evaluation Count:1 |
| 1-4055 |
335 | resize(d->size - n); executed: resize(d->size - n); Execution Count:4055 | 4055 |
336 | } executed: } Execution Count:4056 | 4056 |
337 | QByteArray::QByteArray(const char *data, int size) | - |
338 | { | - |
339 | if (!data) { evaluated: !data yes Evaluation Count:409541 | yes Evaluation Count:4405121 |
| 409541-4405121 |
340 | d = Data::sharedNull(); | - |
341 | } else { executed: } Execution Count:409541 | 409541 |
342 | if (size < 0) evaluated: size < 0 yes Evaluation Count:1999557 | yes Evaluation Count:2405570 |
| 1999557-2405570 |
343 | size = int(strlen(data)); executed: size = int(strlen(data)); Execution Count:1999557 | 1999557 |
344 | if (!size) { evaluated: !size yes Evaluation Count:5907 | yes Evaluation Count:4399213 |
| 5907-4399213 |
345 | d = Data::allocate(0); | - |
346 | } else { executed: } Execution Count:5907 | 5907 |
347 | d = Data::allocate(uint(size) + 1u); | - |
348 | do { if (!(d)) qBadAlloc(); } while (0); partially evaluated: !(d) no Evaluation Count:0 | yes Evaluation Count:4399237 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:4399231 |
never executed: qBadAlloc(); executed: } Execution Count:4399233 | 0-4399237 |
349 | d->size = size; | - |
350 | memcpy(d->data(), data, size); | - |
351 | d->data()[size] = '\0'; | - |
352 | } executed: } Execution Count:4399228 | 4399228 |
353 | } | - |
354 | } | - |
355 | QByteArray::QByteArray(int size, char ch) | - |
356 | { | - |
357 | if (size <= 0) { evaluated: size <= 0 yes Evaluation Count:1198 | yes Evaluation Count:743812 |
| 1198-743812 |
358 | d = Data::allocate(0); | - |
359 | } else { executed: } Execution Count:1198 | 1198 |
360 | d = Data::allocate(uint(size) + 1u); | - |
361 | do { if (!(d)) qBadAlloc(); } while (0); partially evaluated: !(d) no Evaluation Count:0 | yes Evaluation Count:743812 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:743812 |
never executed: qBadAlloc(); executed: } Execution Count:743812 | 0-743812 |
362 | d->size = size; | - |
363 | memset(d->data(), ch, size); | - |
364 | d->data()[size] = '\0'; | - |
365 | } executed: } Execution Count:743812 | 743812 |
366 | } | - |
367 | | - |
368 | | - |
369 | | - |
370 | | - |
371 | | - |
372 | | - |
373 | | - |
374 | QByteArray::QByteArray(int size, Qt::Initialization) | - |
375 | { | - |
376 | d = Data::allocate(uint(size) + 1u); | - |
377 | do { if (!(d)) qBadAlloc(); } while (0); partially evaluated: !(d) no Evaluation Count:0 | yes Evaluation Count:1594622 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:1594622 |
never executed: qBadAlloc(); executed: } Execution Count:1594622 | 0-1594622 |
378 | d->size = size; | - |
379 | d->data()[size] = '\0'; | - |
380 | } executed: } Execution Count:1594623 | 1594623 |
381 | void QByteArray::resize(int size) | - |
382 | { | - |
383 | if (size < 0) evaluated: size < 0 yes Evaluation Count:3 | yes Evaluation Count:12008747 |
| 3-12008747 |
384 | size = 0; executed: size = 0; Execution Count:3 | 3 |
385 | | - |
386 | if (((d)->offset != sizeof(QByteArrayData)) && !d->ref.isShared() && size < d->size) { evaluated: ((d)->offset != sizeof(QByteArrayData)) yes Evaluation Count:15 | yes Evaluation Count:12008739 |
evaluated: !d->ref.isShared() yes Evaluation Count:1 | yes Evaluation Count:14 |
partially evaluated: size < d->size yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-12008739 |
387 | d->size = size; | - |
388 | return; executed: return; Execution Count:1 | 1 |
389 | } | - |
390 | | - |
391 | if (size == 0 && !d->capacityReserved) { evaluated: size == 0 yes Evaluation Count:140090 | yes Evaluation Count:11868668 |
evaluated: !d->capacityReserved yes Evaluation Count:140089 | yes Evaluation Count:1 |
| 1-11868668 |
392 | Data *x = Data::allocate(0); | - |
393 | if (!d->ref.deref()) evaluated: !d->ref.deref() yes Evaluation Count:78916 | yes Evaluation Count:61173 |
| 61173-78916 |
394 | Data::deallocate(d); executed: Data::deallocate(d); Execution Count:78916 | 78916 |
395 | d = x; | - |
396 | } else if (d->size == 0 && d->ref.isStatic()) { evaluated: d->size == 0 yes Evaluation Count:6202510 | yes Evaluation Count:5666168 |
evaluated: d->ref.isStatic() yes Evaluation Count:5825651 | yes Evaluation Count:376860 |
executed: } Execution Count:140089 | 140089-6202510 |
397 | Data *x = Data::allocate(uint(size) + 1u); | - |
398 | do { if (!(x)) qBadAlloc(); } while (0); partially evaluated: !(x) no Evaluation Count:0 | yes Evaluation Count:5825672 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:5825663 |
never executed: qBadAlloc(); executed: } Execution Count:5825667 | 0-5825672 |
399 | x->size = size; | - |
400 | x->data()[size] = '\0'; | - |
401 | d = x; | - |
402 | } else { executed: } Execution Count:5825667 | 5825667 |
403 | if (d->ref.isShared() || uint(size) + 1u > d->alloc evaluated: d->ref.isShared() yes Evaluation Count:175 | yes Evaluation Count:6042852 |
evaluated: uint(size) + 1u > d->alloc yes Evaluation Count:1582055 | yes Evaluation Count:4460799 |
| 175-6042852 |
404 | || (!d->capacityReserved && size < d->size evaluated: !d->capacityReserved yes Evaluation Count:3455497 | yes Evaluation Count:1005302 |
evaluated: size < d->size yes Evaluation Count:2478548 | yes Evaluation Count:976947 |
| 976947-3455497 |
405 | && uint(size) + 1u < uint(d->alloc >> 1))) evaluated: uint(size) + 1u < uint(d->alloc >> 1) yes Evaluation Count:1842718 | yes Evaluation Count:635831 |
| 635831-1842718 |
406 | reallocData(uint(size) + 1u, d->detachFlags() | Data::Grow); executed: reallocData(uint(size) + 1u, d->detachFlags() | Data::Grow); Execution Count:3424948 | 3424948 |
407 | if (d->alloc) { partially evaluated: d->alloc yes Evaluation Count:6043029 | no Evaluation Count:0 |
| 0-6043029 |
408 | d->size = size; | - |
409 | d->data()[size] = '\0'; | - |
410 | } executed: } Execution Count:6043028 | 6043028 |
411 | } executed: } Execution Count:6043028 | 6043028 |
412 | } | - |
413 | QByteArray &QByteArray::fill(char ch, int size) | - |
414 | { | - |
415 | resize(size < 0 ? d->size : size); | - |
416 | if (d->size) partially evaluated: d->size yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
417 | memset(d->data(), ch, d->size); executed: memset(d->data(), ch, d->size); Execution Count:4 | 4 |
418 | return *this; executed: return *this; Execution Count:4 | 4 |
419 | } | - |
420 | | - |
421 | void QByteArray::reallocData(uint alloc, Data::AllocationOptions options) | - |
422 | { | - |
423 | if (d->ref.isShared() || ((d)->offset != sizeof(QByteArrayData))) { evaluated: d->ref.isShared() yes Evaluation Count:2354087 | yes Evaluation Count:3971311 |
evaluated: ((d)->offset != sizeof(QByteArrayData)) yes Evaluation Count:5 | yes Evaluation Count:3971306 |
| 5-3971311 |
424 | Data *x = Data::allocate(alloc, options); | - |
425 | do { if (!(x)) qBadAlloc(); } while (0); partially evaluated: !(x) no Evaluation Count:0 | yes Evaluation Count:2354121 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:2354113 |
never executed: qBadAlloc(); executed: } Execution Count:2354120 | 0-2354121 |
426 | x->size = qMin(int(alloc) - 1, d->size); | - |
427 | ::memcpy(x->data(), d->data(), x->size); | - |
428 | x->data()[x->size] = '\0'; | - |
429 | if (!d->ref.deref()) evaluated: !d->ref.deref() yes Evaluation Count:5 | yes Evaluation Count:2354127 |
| 5-2354127 |
430 | Data::deallocate(d); executed: Data::deallocate(d); Execution Count:5 | 5 |
431 | d = x; | - |
432 | } else { executed: } Execution Count:2354135 | 2354135 |
433 | if (options & Data::Grow) evaluated: options & Data::Grow yes Evaluation Count:3927235 | yes Evaluation Count:44069 |
| 44069-3927235 |
434 | alloc = qAllocMore(alloc, sizeof(Data)); executed: alloc = qAllocMore(alloc, sizeof(Data)); Execution Count:3927235 | 3927235 |
435 | Data *x = static_cast<Data *>(::realloc(d, sizeof(Data) + alloc)); | - |
436 | do { if (!(x)) qBadAlloc(); } while (0); partially evaluated: !(x) no Evaluation Count:0 | yes Evaluation Count:3971307 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:3971307 |
never executed: qBadAlloc(); executed: } Execution Count:3971307 | 0-3971307 |
437 | x->alloc = alloc; | - |
438 | x->capacityReserved = (options & Data::CapacityReserved) ? 1 : 0; evaluated: (options & Data::CapacityReserved) yes Evaluation Count:12095 | yes Evaluation Count:3959211 |
| 12095-3959211 |
439 | d = x; | - |
440 | } executed: } Execution Count:3971305 | 3971305 |
441 | } | - |
442 | | - |
443 | void QByteArray::expand(int i) | - |
444 | { | - |
445 | resize(qMax(i + 1, d->size)); | - |
446 | } executed: } Execution Count:1003594 | 1003594 |
447 | QByteArray QByteArray::nulTerminated() const | - |
448 | { | - |
449 | | - |
450 | if (!((d)->offset != sizeof(QByteArrayData))) evaluated: !((d)->offset != sizeof(QByteArrayData)) yes Evaluation Count:184206 | yes Evaluation Count:6 |
| 6-184206 |
451 | return *this; executed: return *this; Execution Count:184206 | 184206 |
452 | | - |
453 | QByteArray copy(*this); | - |
454 | copy.detach(); | - |
455 | return copy; executed: return copy; Execution Count:6 | 6 |
456 | } | - |
457 | QByteArray &QByteArray::prepend(const QByteArray &ba) | - |
458 | { | - |
459 | if (d->size == 0 && d->ref.isStatic() && !((ba.d)->offset != sizeof(QByteArrayData))) { evaluated: d->size == 0 yes Evaluation Count:19 | yes Evaluation Count:417 |
partially evaluated: d->ref.isStatic() yes Evaluation Count:19 | no Evaluation Count:0 |
evaluated: !((ba.d)->offset != sizeof(QByteArrayData)) yes Evaluation Count:11 | yes Evaluation Count:8 |
| 0-417 |
460 | *this = ba; | - |
461 | } else if (ba.d->size != 0) { executed: } Execution Count:11 evaluated: ba.d->size != 0 yes Evaluation Count:292 | yes Evaluation Count:133 |
| 11-292 |
462 | QByteArray tmp = *this; | - |
463 | *this = ba; | - |
464 | append(tmp); | - |
465 | } executed: } Execution Count:292 | 292 |
466 | return *this; executed: return *this; Execution Count:436 | 436 |
467 | } | - |
468 | | - |
469 | | - |
470 | | - |
471 | | - |
472 | | - |
473 | | - |
474 | | - |
475 | QByteArray &QByteArray::prepend(const char *str) | - |
476 | { | - |
477 | return prepend(str, qstrlen(str)); executed: return prepend(str, qstrlen(str)); Execution Count:1307 | 1307 |
478 | } | - |
479 | QByteArray &QByteArray::prepend(const char *str, int len) | - |
480 | { | - |
481 | if (str) { evaluated: str yes Evaluation Count:1307 | yes Evaluation Count:9 |
| 9-1307 |
482 | if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc) evaluated: d->ref.isShared() yes Evaluation Count:182 | yes Evaluation Count:1125 |
evaluated: uint(d->size + len) + 1u > d->alloc yes Evaluation Count:38 | yes Evaluation Count:1087 |
| 38-1125 |
483 | reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow); executed: reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow); Execution Count:220 | 220 |
484 | memmove(d->data()+len, d->data(), d->size); | - |
485 | memcpy(d->data(), str, len); | - |
486 | d->size += len; | - |
487 | d->data()[d->size] = '\0'; | - |
488 | } executed: } Execution Count:1307 | 1307 |
489 | return *this; executed: return *this; Execution Count:1316 | 1316 |
490 | } | - |
491 | | - |
492 | | - |
493 | | - |
494 | | - |
495 | | - |
496 | | - |
497 | | - |
498 | QByteArray &QByteArray::prepend(char ch) | - |
499 | { | - |
500 | if (d->ref.isShared() || uint(d->size) + 2u > d->alloc) evaluated: d->ref.isShared() yes Evaluation Count:55 | yes Evaluation Count:804 |
evaluated: uint(d->size) + 2u > d->alloc yes Evaluation Count:229 | yes Evaluation Count:575 |
| 55-804 |
501 | reallocData(uint(d->size) + 2u, d->detachFlags() | Data::Grow); executed: reallocData(uint(d->size) + 2u, d->detachFlags() | Data::Grow); Execution Count:284 | 284 |
502 | memmove(d->data()+1, d->data(), d->size); | - |
503 | d->data()[0] = ch; | - |
504 | ++d->size; | - |
505 | d->data()[d->size] = '\0'; | - |
506 | return *this; executed: return *this; Execution Count:859 | 859 |
507 | } | - |
508 | QByteArray &QByteArray::append(const QByteArray &ba) | - |
509 | { | - |
510 | if (d->size == 0 && d->ref.isStatic() && !((ba.d)->offset != sizeof(QByteArrayData))) { evaluated: d->size == 0 yes Evaluation Count:177565 | yes Evaluation Count:5484718 |
evaluated: d->ref.isStatic() yes Evaluation Count:158217 | yes Evaluation Count:19355 |
evaluated: !((ba.d)->offset != sizeof(QByteArrayData)) yes Evaluation Count:158176 | yes Evaluation Count:47 |
| 47-5484718 |
511 | *this = ba; | - |
512 | } else if (ba.d->size != 0) { executed: } Execution Count:158174 evaluated: ba.d->size != 0 yes Evaluation Count:5324962 | yes Evaluation Count:179161 |
| 158174-5324962 |
513 | if (d->ref.isShared() || uint(d->size + ba.d->size) + 1u > d->alloc) evaluated: d->ref.isShared() yes Evaluation Count:42979 | yes Evaluation Count:5281984 |
evaluated: uint(d->size + ba.d->size) + 1u > d->alloc yes Evaluation Count:407013 | yes Evaluation Count:4874971 |
| 42979-5281984 |
514 | reallocData(uint(d->size + ba.d->size) + 1u, d->detachFlags() | Data::Grow); executed: reallocData(uint(d->size + ba.d->size) + 1u, d->detachFlags() | Data::Grow); Execution Count:449992 | 449992 |
515 | memcpy(d->data() + d->size, ba.d->data(), ba.d->size); | - |
516 | d->size += ba.d->size; | - |
517 | d->data()[d->size] = '\0'; | - |
518 | } executed: } Execution Count:5324962 | 5324962 |
519 | return *this; executed: return *this; Execution Count:5662282 | 5662282 |
520 | } | - |
521 | QByteArray& QByteArray::append(const char *str) | - |
522 | { | - |
523 | if (str) { evaluated: str yes Evaluation Count:2688653 | yes Evaluation Count:9 |
| 9-2688653 |
524 | const int len = int(strlen(str)); | - |
525 | if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc) evaluated: d->ref.isShared() yes Evaluation Count:82047 | yes Evaluation Count:2606606 |
evaluated: uint(d->size + len) + 1u > d->alloc yes Evaluation Count:2903 | yes Evaluation Count:2603703 |
| 2903-2606606 |
526 | reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow); executed: reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow); Execution Count:84950 | 84950 |
527 | memcpy(d->data() + d->size, str, len + 1); | - |
528 | d->size += len; | - |
529 | } executed: } Execution Count:2688653 | 2688653 |
530 | return *this; executed: return *this; Execution Count:2688662 | 2688662 |
531 | } | - |
532 | QByteArray &QByteArray::append(const char *str, int len) | - |
533 | { | - |
534 | if (len < 0) partially evaluated: len < 0 no Evaluation Count:0 | yes Evaluation Count:438527 |
| 0-438527 |
535 | len = qstrlen(str); never executed: len = qstrlen(str); | 0 |
536 | if (str && len) { partially evaluated: str yes Evaluation Count:438527 | no Evaluation Count:0 |
partially evaluated: len yes Evaluation Count:438527 | no Evaluation Count:0 |
| 0-438527 |
537 | if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc) evaluated: d->ref.isShared() yes Evaluation Count:438416 | yes Evaluation Count:111 |
evaluated: uint(d->size + len) + 1u > d->alloc yes Evaluation Count:8 | yes Evaluation Count:103 |
| 8-438416 |
538 | reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow); executed: reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow); Execution Count:438424 | 438424 |
539 | memcpy(d->data() + d->size, str, len); | - |
540 | d->size += len; | - |
541 | d->data()[d->size] = '\0'; | - |
542 | } executed: } Execution Count:438527 | 438527 |
543 | return *this; executed: return *this; Execution Count:438527 | 438527 |
544 | } | - |
545 | | - |
546 | | - |
547 | | - |
548 | | - |
549 | | - |
550 | | - |
551 | | - |
552 | QByteArray& QByteArray::append(char ch) | - |
553 | { | - |
554 | if (d->ref.isShared() || uint(d->size) + 2u > d->alloc) evaluated: d->ref.isShared() yes Evaluation Count:54379 | yes Evaluation Count:28366541 |
evaluated: uint(d->size) + 2u > d->alloc yes Evaluation Count:92273 | yes Evaluation Count:28274620 |
| 54379-28366541 |
555 | reallocData(uint(d->size) + 2u, d->detachFlags() | Data::Grow); executed: reallocData(uint(d->size) + 2u, d->detachFlags() | Data::Grow); Execution Count:146652 | 146652 |
556 | d->data()[d->size++] = ch; | - |
557 | d->data()[d->size] = '\0'; | - |
558 | return *this; executed: return *this; Execution Count:28421177 | 28421177 |
559 | } | - |
560 | | - |
561 | | - |
562 | | - |
563 | | - |
564 | | - |
565 | | - |
566 | static inline QByteArray &qbytearray_insert(QByteArray *ba, | - |
567 | int pos, const char *arr, int len) | - |
568 | { | - |
569 | qt_noop(); | - |
570 | | - |
571 | if (pos < 0 || len <= 0 || arr == 0) partially evaluated: pos < 0 no Evaluation Count:0 | yes Evaluation Count:119289 |
partially evaluated: len <= 0 no Evaluation Count:0 | yes Evaluation Count:119289 |
partially evaluated: arr == 0 no Evaluation Count:0 | yes Evaluation Count:119289 |
| 0-119289 |
572 | return *ba; never executed: return *ba; | 0 |
573 | | - |
574 | int oldsize = ba->size(); | - |
575 | ba->resize(qMax(pos, oldsize) + len); | - |
576 | char *dst = ba->data(); | - |
577 | if (pos > oldsize) evaluated: pos > oldsize yes Evaluation Count:2 | yes Evaluation Count:119287 |
| 2-119287 |
578 | ::memset(dst + oldsize, 0x20, pos - oldsize); executed: ::memset(dst + oldsize, 0x20, pos - oldsize); Execution Count:2 | 2 |
579 | else | - |
580 | ::memmove(dst + pos + len, dst + pos, oldsize - pos); executed: ::memmove(dst + pos + len, dst + pos, oldsize - pos); Execution Count:119287 | 119287 |
581 | memcpy(dst + pos, arr, len); | - |
582 | return *ba; executed: return *ba; Execution Count:119289 | 119289 |
583 | } | - |
584 | QByteArray &QByteArray::insert(int i, const QByteArray &ba) | - |
585 | { | - |
586 | QByteArray copy(ba); | - |
587 | return qbytearray_insert(this, i, copy.d->data(), copy.d->size); executed: return qbytearray_insert(this, i, copy.d->data(), copy.d->size); Execution Count:12 | 12 |
588 | } | - |
589 | QByteArray &QByteArray::insert(int i, const char *str) | - |
590 | { | - |
591 | return qbytearray_insert(this, i, str, qstrlen(str)); executed: return qbytearray_insert(this, i, str, qstrlen(str)); Execution Count:14 | 14 |
592 | } | - |
593 | QByteArray &QByteArray::insert(int i, const char *str, int len) | - |
594 | { | - |
595 | return qbytearray_insert(this, i, str, len); executed: return qbytearray_insert(this, i, str, len); Execution Count:1 | 1 |
596 | } | - |
597 | QByteArray &QByteArray::insert(int i, char ch) | - |
598 | { | - |
599 | return qbytearray_insert(this, i, &ch, 1); executed: return qbytearray_insert(this, i, &ch, 1); Execution Count:2320 | 2320 |
600 | } | - |
601 | QByteArray &QByteArray::remove(int pos, int len) | - |
602 | { | - |
603 | if (len <= 0 || pos >= d->size || pos < 0) evaluated: len <= 0 yes Evaluation Count:63 | yes Evaluation Count:263596 |
evaluated: pos >= d->size yes Evaluation Count:3 | yes Evaluation Count:263593 |
partially evaluated: pos < 0 no Evaluation Count:0 | yes Evaluation Count:263593 |
| 0-263596 |
604 | return *this; executed: return *this; Execution Count:66 | 66 |
605 | detach(); | - |
606 | if (pos + len >= d->size) { evaluated: pos + len >= d->size yes Evaluation Count:816 | yes Evaluation Count:262776 |
| 816-262776 |
607 | resize(pos); | - |
608 | } else { executed: } Execution Count:816 | 816 |
609 | memmove(d->data() + pos, d->data() + pos + len, d->size - pos - len); | - |
610 | resize(d->size - len); | - |
611 | } executed: } Execution Count:262774 | 262774 |
612 | return *this; executed: return *this; Execution Count:263592 | 263592 |
613 | } | - |
614 | QByteArray &QByteArray::replace(int pos, int len, const QByteArray &after) | - |
615 | { | - |
616 | if (len == after.d->size && (pos + len <= d->size)) { evaluated: len == after.d->size yes Evaluation Count:3 | yes Evaluation Count:8 |
evaluated: (pos + len <= d->size) yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-8 |
617 | detach(); | - |
618 | memmove(d->data() + pos, after.d->data(), len*sizeof(char)); | - |
619 | return *this; executed: return *this; Execution Count:2 | 2 |
620 | } else { | - |
621 | QByteArray copy(after); | - |
622 | | - |
623 | remove(pos, len); | - |
624 | return insert(pos, copy); executed: return insert(pos, copy); Execution Count:9 | 9 |
625 | } | - |
626 | } | - |
627 | QByteArray &QByteArray::replace(int pos, int len, const char *after) | - |
628 | { | - |
629 | return replace(pos,len,after,qstrlen(after)); executed: return replace(pos,len,after,qstrlen(after)); Execution Count:116943 | 116943 |
630 | } | - |
631 | QByteArray &QByteArray::replace(int pos, int len, const char *after, int alen) | - |
632 | { | - |
633 | if (len == alen && (pos + len <= d->size)) { evaluated: len == alen yes Evaluation Count:3 | yes Evaluation Count:116941 |
evaluated: (pos + len <= d->size) yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-116941 |
634 | detach(); | - |
635 | memcpy(d->data() + pos, after, len*sizeof(char)); | - |
636 | return *this; executed: return *this; Execution Count:2 | 2 |
637 | } else { | - |
638 | remove(pos, len); | - |
639 | return qbytearray_insert(this, pos, after, alen); executed: return qbytearray_insert(this, pos, after, alen); Execution Count:116942 | 116942 |
640 | } | - |
641 | } | - |
642 | QByteArray &QByteArray::replace(const QByteArray &before, const QByteArray &after) | - |
643 | { | - |
644 | if (isNull() || before.d == after.d) partially evaluated: isNull() no Evaluation Count:0 | yes Evaluation Count:3 |
partially evaluated: before.d == after.d no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
645 | return *this; never executed: return *this; | 0 |
646 | | - |
647 | QByteArray aft = after; | - |
648 | if (after.d == d) evaluated: after.d == d yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
649 | aft.detach(); executed: aft.detach(); Execution Count:2 | 2 |
650 | | - |
651 | return replace(before.constData(), before.size(), aft.constData(), aft.size()); executed: return replace(before.constData(), before.size(), aft.constData(), aft.size()); Execution Count:3 | 3 |
652 | } | - |
653 | QByteArray &QByteArray::replace(const char *c, const QByteArray &after) | - |
654 | { | - |
655 | QByteArray aft = after; | - |
656 | if (after.d == d) never evaluated: after.d == d | 0 |
657 | aft.detach(); never executed: aft.detach(); | 0 |
658 | | - |
659 | return replace(c, qstrlen(c), aft.constData(), aft.size()); never executed: return replace(c, qstrlen(c), aft.constData(), aft.size()); | 0 |
660 | } | - |
661 | QByteArray &QByteArray::replace(const char *before, int bsize, const char *after, int asize) | - |
662 | { | - |
663 | if (isNull() || (before == after && bsize == asize)) evaluated: isNull() yes Evaluation Count:21 | yes Evaluation Count:1778 |
partially evaluated: before == after no Evaluation Count:0 | yes Evaluation Count:1778 |
never evaluated: bsize == asize | 0-1778 |
664 | return *this; executed: return *this; Execution Count:21 | 21 |
665 | | - |
666 | | - |
667 | const char *a = after; | - |
668 | const char *b = before; | - |
669 | if (after >= d->data() && after < d->data() + d->size) { evaluated: after >= d->data() yes Evaluation Count:1 | yes Evaluation Count:1777 |
partially evaluated: after < d->data() + d->size no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1777 |
670 | char *copy = (char *)malloc(asize); | - |
671 | do { if (!(copy)) qBadAlloc(); } while (0); never executed: qBadAlloc(); | 0 |
672 | memcpy(copy, after, asize); | - |
673 | a = copy; | - |
674 | } | 0 |
675 | if (before >= d->data() && before < d->data() + d->size) { partially evaluated: before >= d->data() yes Evaluation Count:1778 | no Evaluation Count:0 |
evaluated: before < d->data() + d->size yes Evaluation Count:2 | yes Evaluation Count:1776 |
| 0-1778 |
676 | char *copy = (char *)malloc(bsize); | - |
677 | do { if (!(copy)) qBadAlloc(); } while (0); never executed: qBadAlloc(); executed: } Execution Count:2 partially evaluated: !(copy) no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
678 | memcpy(copy, before, bsize); | - |
679 | b = copy; | - |
680 | } executed: } Execution Count:2 | 2 |
681 | | - |
682 | QByteArrayMatcher matcher(before, bsize); | - |
683 | int index = 0; | - |
684 | int len = d->size; | - |
685 | char *d = data(); | - |
686 | | - |
687 | if (bsize == asize) { evaluated: bsize == asize yes Evaluation Count:1 | yes Evaluation Count:1777 |
| 1-1777 |
688 | if (bsize) { partially evaluated: bsize yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
689 | while ((index = matcher.indexIn(*this, index)) != -1) { evaluated: (index = matcher.indexIn(*this, index)) != -1 yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
690 | memcpy(d + index, after, asize); | - |
691 | index += bsize; | - |
692 | } executed: } Execution Count:1 | 1 |
693 | } executed: } Execution Count:1 | 1 |
694 | } else if (asize < bsize) { executed: } Execution Count:1 evaluated: asize < bsize yes Evaluation Count:1775 | yes Evaluation Count:2 |
| 1-1775 |
695 | uint to = 0; | - |
696 | uint movestart = 0; | - |
697 | uint num = 0; | - |
698 | while ((index = matcher.indexIn(*this, index)) != -1) { evaluated: (index = matcher.indexIn(*this, index)) != -1 yes Evaluation Count:1 | yes Evaluation Count:1775 |
| 1-1775 |
699 | if (num) { partially evaluated: num no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
700 | int msize = index - movestart; | - |
701 | if (msize > 0) { never evaluated: msize > 0 | 0 |
702 | memmove(d + to, d + movestart, msize); | - |
703 | to += msize; | - |
704 | } | 0 |
705 | } else { | 0 |
706 | to = index; | - |
707 | } executed: } Execution Count:1 | 1 |
708 | if (asize) { partially evaluated: asize yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
709 | memcpy(d + to, after, asize); | - |
710 | to += asize; | - |
711 | } executed: } Execution Count:1 | 1 |
712 | index += bsize; | - |
713 | movestart = index; | - |
714 | num++; | - |
715 | } executed: } Execution Count:1 | 1 |
716 | if (num) { evaluated: num yes Evaluation Count:1 | yes Evaluation Count:1774 |
| 1-1774 |
717 | int msize = len - movestart; | - |
718 | if (msize > 0) partially evaluated: msize > 0 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
719 | memmove(d + to, d + movestart, msize); never executed: memmove(d + to, d + movestart, msize); | 0 |
720 | resize(len - num*(bsize-asize)); | - |
721 | } executed: } Execution Count:1 | 1 |
722 | } else { executed: } Execution Count:1775 | 1775 |
723 | | - |
724 | | - |
725 | while (index != -1) { evaluated: index != -1 yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
726 | uint indices[4096]; | - |
727 | uint pos = 0; | - |
728 | while(pos < 4095) { partially evaluated: pos < 4095 yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
729 | index = matcher.indexIn(*this, index); | - |
730 | if (index == -1) evaluated: index == -1 yes Evaluation Count:2 | yes Evaluation Count:6 |
| 2-6 |
731 | break; executed: break; Execution Count:2 | 2 |
732 | indices[pos++] = index; | - |
733 | index += bsize; | - |
734 | | - |
735 | if (!bsize) partially evaluated: !bsize no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
736 | index++; | 0 |
737 | } executed: } Execution Count:6 | 6 |
738 | if (!pos) partially evaluated: !pos no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
739 | break; | 0 |
740 | | - |
741 | | - |
742 | int adjust = pos*(asize-bsize); | - |
743 | | - |
744 | if (index != -1) partially evaluated: index != -1 no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
745 | index += adjust; never executed: index += adjust; | 0 |
746 | int newlen = len + adjust; | - |
747 | int moveend = len; | - |
748 | if (newlen > len) { partially evaluated: newlen > len yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
749 | resize(newlen); | - |
750 | len = newlen; | - |
751 | } executed: } Execution Count:2 | 2 |
752 | d = this->d->data(); | - |
753 | | - |
754 | while(pos) { evaluated: pos yes Evaluation Count:6 | yes Evaluation Count:2 |
| 2-6 |
755 | pos--; | - |
756 | int movestart = indices[pos] + bsize; | - |
757 | int insertstart = indices[pos] + pos*(asize-bsize); | - |
758 | int moveto = insertstart + asize; | - |
759 | memmove(d + moveto, d + movestart, (moveend - movestart)); | - |
760 | if (asize) partially evaluated: asize yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
761 | memcpy(d + insertstart, after, asize); executed: memcpy(d + insertstart, after, asize); Execution Count:6 | 6 |
762 | moveend = movestart - bsize; | - |
763 | } executed: } Execution Count:6 | 6 |
764 | } executed: } Execution Count:2 | 2 |
765 | } executed: } Execution Count:2 | 2 |
766 | | - |
767 | if (a != after) partially evaluated: a != after no Evaluation Count:0 | yes Evaluation Count:1778 |
| 0-1778 |
768 | ::free((char *)a); never executed: ::free((char *)a); | 0 |
769 | if (b != before) evaluated: b != before yes Evaluation Count:2 | yes Evaluation Count:1776 |
| 2-1776 |
770 | ::free((char *)b); executed: ::free((char *)b); Execution Count:2 | 2 |
771 | | - |
772 | | - |
773 | return *this; executed: return *this; Execution Count:1778 | 1778 |
774 | } | - |
775 | QByteArray &QByteArray::replace(char before, const QByteArray &after) | - |
776 | { | - |
777 | char b[2] = { before, '\0' }; | - |
778 | QByteArray cb = fromRawData(b, 1); | - |
779 | return replace(cb, after); executed: return replace(cb, after); Execution Count:2 | 2 |
780 | } | - |
781 | QByteArray &QByteArray::replace(char before, char after) | - |
782 | { | - |
783 | if (d->size) { partially evaluated: d->size yes Evaluation Count:3801895 | no Evaluation Count:0 |
| 0-3801895 |
784 | char *i = data(); | - |
785 | char *e = i + d->size; | - |
786 | for (; i != e; ++i) evaluated: i != e yes Evaluation Count:4078139 | yes Evaluation Count:3801901 |
| 3801901-4078139 |
787 | if (*i == before) evaluated: *i == before yes Evaluation Count:1034 | yes Evaluation Count:4077111 |
| 1034-4077111 |
788 | * i = after; executed: * i = after; Execution Count:1034 | 1034 |
789 | } executed: } Execution Count:3801904 | 3801904 |
790 | return *this; executed: return *this; Execution Count:3801904 | 3801904 |
791 | } | - |
792 | QList<QByteArray> QByteArray::split(char sep) const | - |
793 | { | - |
794 | QList<QByteArray> list; | - |
795 | int start = 0; | - |
796 | int end; | - |
797 | while ((end = indexOf(sep, start)) != -1) { evaluated: (end = indexOf(sep, start)) != -1 yes Evaluation Count:539375 | yes Evaluation Count:176309 |
| 176309-539375 |
798 | list.append(mid(start, end - start)); | - |
799 | start = end + 1; | - |
800 | } executed: } Execution Count:539375 | 539375 |
801 | list.append(mid(start)); | - |
802 | return list; executed: return list; Execution Count:176309 | 176309 |
803 | } | - |
804 | QByteArray QByteArray::repeated(int times) const | - |
805 | { | - |
806 | if (d->size == 0) evaluated: d->size == 0 yes Evaluation Count:5 | yes Evaluation Count:11 |
| 5-11 |
807 | return *this; executed: return *this; Execution Count:5 | 5 |
808 | | - |
809 | if (times <= 1) { evaluated: times <= 1 yes Evaluation Count:4 | yes Evaluation Count:7 |
| 4-7 |
810 | if (times == 1) evaluated: times == 1 yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
811 | return *this; executed: return *this; Execution Count:1 | 1 |
812 | return QByteArray(); executed: return QByteArray(); Execution Count:3 | 3 |
813 | } | - |
814 | | - |
815 | const int resultSize = times * d->size; | - |
816 | | - |
817 | QByteArray result; | - |
818 | result.reserve(resultSize); | - |
819 | if (result.d->alloc != uint(resultSize) + 1u) partially evaluated: result.d->alloc != uint(resultSize) + 1u no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
820 | return QByteArray(); never executed: return QByteArray(); | 0 |
821 | | - |
822 | memcpy(result.d->data(), d->data(), d->size); | - |
823 | | - |
824 | int sizeSoFar = d->size; | - |
825 | char *end = result.d->data() + sizeSoFar; | - |
826 | | - |
827 | const int halfResultSize = resultSize >> 1; | - |
828 | while (sizeSoFar <= halfResultSize) { evaluated: sizeSoFar <= halfResultSize yes Evaluation Count:12 | yes Evaluation Count:7 |
| 7-12 |
829 | memcpy(end, result.d->data(), sizeSoFar); | - |
830 | end += sizeSoFar; | - |
831 | sizeSoFar <<= 1; | - |
832 | } executed: } Execution Count:12 | 12 |
833 | memcpy(end, result.d->data(), resultSize - sizeSoFar); | - |
834 | result.d->data()[resultSize] = '\0'; | - |
835 | result.d->size = resultSize; | - |
836 | return result; executed: return result; Execution Count:7 | 7 |
837 | } | - |
838 | int QByteArray::indexOf(const QByteArray &ba, int from) const | - |
839 | { | - |
840 | const int ol = ba.d->size; | - |
841 | if (ol == 0) evaluated: ol == 0 yes Evaluation Count:16 | yes Evaluation Count:1878 |
| 16-1878 |
842 | return from; executed: return from; Execution Count:16 | 16 |
843 | if (ol == 1) evaluated: ol == 1 yes Evaluation Count:72 | yes Evaluation Count:1806 |
| 72-1806 |
844 | return indexOf(*ba.d->data(), from); executed: return indexOf(*ba.d->data(), from); Execution Count:72 | 72 |
845 | | - |
846 | const int l = d->size; | - |
847 | if (from > d->size || ol + from > l) partially evaluated: from > d->size no Evaluation Count:0 | yes Evaluation Count:1806 |
evaluated: ol + from > l yes Evaluation Count:10 | yes Evaluation Count:1796 |
| 0-1806 |
848 | return -1; executed: return -1; Execution Count:10 | 10 |
849 | | - |
850 | return qFindByteArray(d->data(), d->size, from, ba.d->data(), ol); executed: return qFindByteArray(d->data(), d->size, from, ba.d->data(), ol); Execution Count:1796 | 1796 |
851 | } | - |
852 | int QByteArray::indexOf(const char *c, int from) const | - |
853 | { | - |
854 | const int ol = qstrlen(c); | - |
855 | if (ol == 1) evaluated: ol == 1 yes Evaluation Count:24 | yes Evaluation Count:678446 |
| 24-678446 |
856 | return indexOf(*c, from); executed: return indexOf(*c, from); Execution Count:24 | 24 |
857 | | - |
858 | const int l = d->size; | - |
859 | if (from > d->size || ol + from > l) partially evaluated: from > d->size no Evaluation Count:0 | yes Evaluation Count:678446 |
evaluated: ol + from > l yes Evaluation Count:5940 | yes Evaluation Count:672506 |
| 0-678446 |
860 | return -1; executed: return -1; Execution Count:5940 | 5940 |
861 | if (ol == 0) evaluated: ol == 0 yes Evaluation Count:8 | yes Evaluation Count:672498 |
| 8-672498 |
862 | return from; executed: return from; Execution Count:8 | 8 |
863 | | - |
864 | return qFindByteArray(d->data(), d->size, from, c, ol); executed: return qFindByteArray(d->data(), d->size, from, c, ol); Execution Count:672498 | 672498 |
865 | } | - |
866 | int QByteArray::indexOf(char ch, int from) const | - |
867 | { | - |
868 | if (from < 0) evaluated: from < 0 yes Evaluation Count:1 | yes Evaluation Count:856921 |
| 1-856921 |
869 | from = qMax(from + d->size, 0); executed: from = qMax(from + d->size, 0); Execution Count:1 | 1 |
870 | if (from < d->size) { evaluated: from < d->size yes Evaluation Count:854678 | yes Evaluation Count:2244 |
| 2244-854678 |
871 | const char *n = d->data() + from - 1; | - |
872 | const char *e = d->data() + d->size; | - |
873 | while (++n != e) evaluated: ++n != e yes Evaluation Count:15032963 | yes Evaluation Count:175453 |
| 175453-15032963 |
874 | if (*n == ch) evaluated: *n == ch yes Evaluation Count:679225 | yes Evaluation Count:14353738 |
| 679225-14353738 |
875 | return n - d->data(); executed: return n - d->data(); Execution Count:679225 | 679225 |
876 | } executed: } Execution Count:175453 | 175453 |
877 | return -1; executed: return -1; Execution Count:177697 | 177697 |
878 | } | - |
879 | | - |
880 | | - |
881 | static int lastIndexOfHelper(const char *haystack, int l, const char *needle, int ol, int from) | - |
882 | { | - |
883 | int delta = l - ol; | - |
884 | if (from < 0) evaluated: from < 0 yes Evaluation Count:40 | yes Evaluation Count:20 |
| 20-40 |
885 | from = delta; executed: from = delta; Execution Count:40 | 40 |
886 | if (from < 0 || from > l) evaluated: from < 0 yes Evaluation Count:5 | yes Evaluation Count:55 |
partially evaluated: from > l no Evaluation Count:0 | yes Evaluation Count:55 |
| 0-55 |
887 | return -1; executed: return -1; Execution Count:5 | 5 |
888 | if (from > delta) evaluated: from > delta yes Evaluation Count:2 | yes Evaluation Count:53 |
| 2-53 |
889 | from = delta; executed: from = delta; Execution Count:2 | 2 |
890 | | - |
891 | const char *end = haystack; | - |
892 | haystack += from; | - |
893 | const uint ol_minus_1 = ol - 1; | - |
894 | const char *n = needle + ol_minus_1; | - |
895 | const char *h = haystack + ol_minus_1; | - |
896 | uint hashNeedle = 0, hashHaystack = 0; | - |
897 | int idx; | - |
898 | for (idx = 0; idx < ol; ++idx) { evaluated: idx < ol yes Evaluation Count:310 | yes Evaluation Count:55 |
| 55-310 |
899 | hashNeedle = ((hashNeedle<<1) + *(n-idx)); | - |
900 | hashHaystack = ((hashHaystack<<1) + *(h-idx)); | - |
901 | } executed: } Execution Count:310 | 310 |
902 | hashHaystack -= *haystack; | - |
903 | while (haystack >= end) { evaluated: haystack >= end yes Evaluation Count:285 | yes Evaluation Count:14 |
| 14-285 |
904 | hashHaystack += *haystack; | - |
905 | if (hashHaystack == hashNeedle && memcmp(needle, haystack, ol) == 0) evaluated: hashHaystack == hashNeedle yes Evaluation Count:43 | yes Evaluation Count:242 |
evaluated: memcmp(needle, haystack, ol) == 0 yes Evaluation Count:41 | yes Evaluation Count:2 |
| 2-242 |
906 | return haystack - end; executed: return haystack - end; Execution Count:41 | 41 |
907 | --haystack; | - |
908 | if (ol_minus_1 < sizeof(uint) * 8) hashHaystack -= (*(haystack + ol)) << ol_minus_1; hashHaystack <<= 1; executed: hashHaystack -= (*(haystack + ol)) << ol_minus_1; Execution Count:210 evaluated: ol_minus_1 < sizeof(uint) * 8 yes Evaluation Count:210 | yes Evaluation Count:34 |
| 34-210 |
909 | } executed: } Execution Count:244 | 244 |
910 | return -1; executed: return -1; Execution Count:14 | 14 |
911 | | - |
912 | } | - |
913 | int QByteArray::lastIndexOf(const QByteArray &ba, int from) const | - |
914 | { | - |
915 | const int ol = ba.d->size; | - |
916 | if (ol == 1) evaluated: ol == 1 yes Evaluation Count:34 | yes Evaluation Count:36 |
| 34-36 |
917 | return lastIndexOf(*ba.d->data(), from); executed: return lastIndexOf(*ba.d->data(), from); Execution Count:34 | 34 |
918 | | - |
919 | return lastIndexOfHelper(d->data(), d->size, ba.d->data(), ol, from); executed: return lastIndexOfHelper(d->data(), d->size, ba.d->data(), ol, from); Execution Count:36 | 36 |
920 | } | - |
921 | int QByteArray::lastIndexOf(const char *str, int from) const | - |
922 | { | - |
923 | const int ol = qstrlen(str); | - |
924 | if (ol == 1) evaluated: ol == 1 yes Evaluation Count:24 | yes Evaluation Count:24 |
| 24 |
925 | return lastIndexOf(*str, from); executed: return lastIndexOf(*str, from); Execution Count:24 | 24 |
926 | | - |
927 | return lastIndexOfHelper(d->data(), d->size, str, ol, from); executed: return lastIndexOfHelper(d->data(), d->size, str, ol, from); Execution Count:24 | 24 |
928 | } | - |
929 | int QByteArray::lastIndexOf(char ch, int from) const | - |
930 | { | - |
931 | if (from < 0) evaluated: from < 0 yes Evaluation Count:138 | yes Evaluation Count:42 |
| 42-138 |
932 | from += d->size; executed: from += d->size; Execution Count:138 | 138 |
933 | else if (from > d->size) partially evaluated: from > d->size no Evaluation Count:0 | yes Evaluation Count:42 |
| 0-42 |
934 | from = d->size-1; never executed: from = d->size-1; | 0 |
935 | if (from >= 0) { evaluated: from >= 0 yes Evaluation Count:166 | yes Evaluation Count:14 |
| 14-166 |
936 | const char *b = d->data(); | - |
937 | const char *n = d->data() + from + 1; | - |
938 | while (n-- != b) evaluated: n-- != b yes Evaluation Count:359 | yes Evaluation Count:33 |
| 33-359 |
939 | if (*n == ch) evaluated: *n == ch yes Evaluation Count:133 | yes Evaluation Count:226 |
| 133-226 |
940 | return n - b; executed: return n - b; Execution Count:133 | 133 |
941 | } executed: } Execution Count:33 | 33 |
942 | return -1; executed: return -1; Execution Count:47 | 47 |
943 | } | - |
944 | int QByteArray::count(const QByteArray &ba) const | - |
945 | { | - |
946 | int num = 0; | - |
947 | int i = -1; | - |
948 | if (d->size > 500 && ba.d->size > 5) { partially evaluated: d->size > 500 no Evaluation Count:0 | yes Evaluation Count:4 |
never evaluated: ba.d->size > 5 | 0-4 |
949 | QByteArrayMatcher matcher(ba); | - |
950 | while ((i = matcher.indexIn(*this, i + 1)) != -1) never evaluated: (i = matcher.indexIn(*this, i + 1)) != -1 | 0 |
951 | ++num; | 0 |
952 | } else { | 0 |
953 | while ((i = indexOf(ba, i + 1)) != -1) evaluated: (i = indexOf(ba, i + 1)) != -1 yes Evaluation Count:33 | yes Evaluation Count:4 |
| 4-33 |
954 | ++num; executed: ++num; Execution Count:33 | 33 |
955 | } executed: } Execution Count:4 | 4 |
956 | return num; executed: return num; Execution Count:4 | 4 |
957 | } | - |
958 | int QByteArray::count(const char *str) const | - |
959 | { | - |
960 | return count(fromRawData(str, qstrlen(str))); executed: return count(fromRawData(str, qstrlen(str))); Execution Count:4 | 4 |
961 | } | - |
962 | int QByteArray::count(char ch) const | - |
963 | { | - |
964 | int num = 0; | - |
965 | const char *i = d->data() + d->size; | - |
966 | const char *b = d->data(); | - |
967 | while (i != b) evaluated: i != b yes Evaluation Count:80 | yes Evaluation Count:4 |
| 4-80 |
968 | if (*--i == ch) evaluated: *--i == ch yes Evaluation Count:23 | yes Evaluation Count:57 |
| 23-57 |
969 | ++num; executed: ++num; Execution Count:23 | 23 |
970 | return num; executed: return num; Execution Count:4 | 4 |
971 | } | - |
972 | bool QByteArray::startsWith(const QByteArray &ba) const | - |
973 | { | - |
974 | if (d == ba.d || ba.d->size == 0) evaluated: d == ba.d yes Evaluation Count:2 | yes Evaluation Count:57 |
evaluated: ba.d->size == 0 yes Evaluation Count:4 | yes Evaluation Count:53 |
| 2-57 |
975 | return true; executed: return true; Execution Count:6 | 6 |
976 | if (d->size < ba.d->size) evaluated: d->size < ba.d->size yes Evaluation Count:11 | yes Evaluation Count:42 |
| 11-42 |
977 | return false; executed: return false; Execution Count:11 | 11 |
978 | return memcmp(d->data(), ba.d->data(), ba.d->size) == 0; executed: return memcmp(d->data(), ba.d->data(), ba.d->size) == 0; Execution Count:42 | 42 |
979 | } | - |
980 | | - |
981 | | - |
982 | | - |
983 | | - |
984 | | - |
985 | | - |
986 | bool QByteArray::startsWith(const char *str) const | - |
987 | { | - |
988 | if (!str || !*str) evaluated: !str yes Evaluation Count:3 | yes Evaluation Count:507467 |
evaluated: !*str yes Evaluation Count:3 | yes Evaluation Count:507464 |
| 3-507467 |
989 | return true; executed: return true; Execution Count:6 | 6 |
990 | const int len = int(strlen(str)); | - |
991 | if (d->size < len) evaluated: d->size < len yes Evaluation Count:43032 | yes Evaluation Count:464432 |
| 43032-464432 |
992 | return false; executed: return false; Execution Count:43032 | 43032 |
993 | return qstrncmp(d->data(), str, len) == 0; executed: return qstrncmp(d->data(), str, len) == 0; Execution Count:464432 | 464432 |
994 | } | - |
995 | | - |
996 | | - |
997 | | - |
998 | | - |
999 | | - |
1000 | | - |
1001 | bool QByteArray::startsWith(char ch) const | - |
1002 | { | - |
1003 | if (d->size == 0) evaluated: d->size == 0 yes Evaluation Count:51 | yes Evaluation Count:101469 |
| 51-101469 |
1004 | return false; executed: return false; Execution Count:51 | 51 |
1005 | return d->data()[0] == ch; executed: return d->data()[0] == ch; Execution Count:101469 | 101469 |
1006 | } | - |
1007 | bool QByteArray::endsWith(const QByteArray &ba) const | - |
1008 | { | - |
1009 | if (d == ba.d || ba.d->size == 0) evaluated: d == ba.d yes Evaluation Count:2 | yes Evaluation Count:9 |
evaluated: ba.d->size == 0 yes Evaluation Count:4 | yes Evaluation Count:5 |
| 2-9 |
1010 | return true; executed: return true; Execution Count:6 | 6 |
1011 | if (d->size < ba.d->size) evaluated: d->size < ba.d->size yes Evaluation Count:3 | yes Evaluation Count:2 |
| 2-3 |
1012 | return false; executed: return false; Execution Count:3 | 3 |
1013 | return memcmp(d->data() + d->size - ba.d->size, ba.d->data(), ba.d->size) == 0; executed: return memcmp(d->data() + d->size - ba.d->size, ba.d->data(), ba.d->size) == 0; Execution Count:2 | 2 |
1014 | } | - |
1015 | | - |
1016 | | - |
1017 | | - |
1018 | | - |
1019 | | - |
1020 | | - |
1021 | bool QByteArray::endsWith(const char *str) const | - |
1022 | { | - |
1023 | if (!str || !*str) evaluated: !str yes Evaluation Count:3 | yes Evaluation Count:184172 |
evaluated: !*str yes Evaluation Count:3 | yes Evaluation Count:184169 |
| 3-184172 |
1024 | return true; executed: return true; Execution Count:6 | 6 |
1025 | const int len = int(strlen(str)); | - |
1026 | if (d->size < len) evaluated: d->size < len yes Evaluation Count:48150 | yes Evaluation Count:136019 |
| 48150-136019 |
1027 | return false; executed: return false; Execution Count:48150 | 48150 |
1028 | return qstrncmp(d->data() + d->size - len, str, len) == 0; executed: return qstrncmp(d->data() + d->size - len, str, len) == 0; Execution Count:136019 | 136019 |
1029 | } | - |
1030 | | - |
1031 | | - |
1032 | | - |
1033 | | - |
1034 | | - |
1035 | | - |
1036 | bool QByteArray::endsWith(char ch) const | - |
1037 | { | - |
1038 | if (d->size == 0) evaluated: d->size == 0 yes Evaluation Count:45 | yes Evaluation Count:36351 |
| 45-36351 |
1039 | return false; executed: return false; Execution Count:45 | 45 |
1040 | return d->data()[d->size - 1] == ch; executed: return d->data()[d->size - 1] == ch; Execution Count:36351 | 36351 |
1041 | } | - |
1042 | QByteArray QByteArray::left(int len) const | - |
1043 | { | - |
1044 | if (len >= d->size) evaluated: len >= d->size yes Evaluation Count:40 | yes Evaluation Count:82387 |
| 40-82387 |
1045 | return *this; executed: return *this; Execution Count:40 | 40 |
1046 | if (len < 0) partially evaluated: len < 0 no Evaluation Count:0 | yes Evaluation Count:82387 |
| 0-82387 |
1047 | len = 0; | 0 |
1048 | return QByteArray(d->data(), len); executed: return QByteArray(d->data(), len); Execution Count:82387 | 82387 |
1049 | } | - |
1050 | QByteArray QByteArray::right(int len) const | - |
1051 | { | - |
1052 | if (len >= d->size) evaluated: len >= d->size yes Evaluation Count:4 | yes Evaluation Count:14 |
| 4-14 |
1053 | return *this; executed: return *this; Execution Count:4 | 4 |
1054 | if (len < 0) partially evaluated: len < 0 no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-14 |
1055 | len = 0; | 0 |
1056 | return QByteArray(d->data() + d->size - len, len); executed: return QByteArray(d->data() + d->size - len, len); Execution Count:14 | 14 |
1057 | } | - |
1058 | QByteArray QByteArray::mid(int pos, int len) const | - |
1059 | { | - |
1060 | if ((d->size == 0 && d->ref.isStatic()) || pos > d->size) evaluated: d->size == 0 yes Evaluation Count:284 | yes Evaluation Count:801537 |
partially evaluated: d->ref.isStatic() yes Evaluation Count:284 | no Evaluation Count:0 |
partially evaluated: pos > d->size no Evaluation Count:0 | yes Evaluation Count:801537 |
| 0-801537 |
1061 | return QByteArray(); executed: return QByteArray(); Execution Count:284 | 284 |
1062 | if (len < 0) evaluated: len < 0 yes Evaluation Count:239934 | yes Evaluation Count:561603 |
| 239934-561603 |
1063 | len = d->size - pos; executed: len = d->size - pos; Execution Count:239934 | 239934 |
1064 | if (pos < 0) { evaluated: pos < 0 yes Evaluation Count:1 | yes Evaluation Count:801536 |
| 1-801536 |
1065 | len += pos; | - |
1066 | pos = 0; | - |
1067 | } executed: } Execution Count:1 | 1 |
1068 | if (len + pos > d->size) evaluated: len + pos > d->size yes Evaluation Count:4 | yes Evaluation Count:801533 |
| 4-801533 |
1069 | len = d->size - pos; executed: len = d->size - pos; Execution Count:4 | 4 |
1070 | if (pos == 0 && len == d->size) evaluated: pos == 0 yes Evaluation Count:178137 | yes Evaluation Count:623400 |
evaluated: len == d->size yes Evaluation Count:58565 | yes Evaluation Count:119572 |
| 58565-623400 |
1071 | return *this; executed: return *this; Execution Count:58565 | 58565 |
1072 | return QByteArray(d->data() + pos, len); executed: return QByteArray(d->data() + pos, len); Execution Count:742972 | 742972 |
1073 | } | - |
1074 | QByteArray QByteArray::toLower() const | - |
1075 | { | - |
1076 | QByteArray s(*this); | - |
1077 | register uchar *p = reinterpret_cast<uchar *>(s.data()); | - |
1078 | if (p) { partially evaluated: p yes Evaluation Count:75041 | no Evaluation Count:0 |
| 0-75041 |
1079 | while (*p) { evaluated: *p yes Evaluation Count:673153 | yes Evaluation Count:75041 |
| 75041-673153 |
1080 | *p = QChar::toLower((ushort)*p); | - |
1081 | p++; | - |
1082 | } executed: } Execution Count:673153 | 673153 |
1083 | } executed: } Execution Count:75041 | 75041 |
1084 | return s; executed: return s; Execution Count:75041 | 75041 |
1085 | } | - |
1086 | QByteArray QByteArray::toUpper() const | - |
1087 | { | - |
1088 | QByteArray s(*this); | - |
1089 | register uchar *p = reinterpret_cast<uchar *>(s.data()); | - |
1090 | if (p) { partially evaluated: p yes Evaluation Count:189 | no Evaluation Count:0 |
| 0-189 |
1091 | while (*p) { evaluated: *p yes Evaluation Count:675 | yes Evaluation Count:189 |
| 189-675 |
1092 | *p = QChar::toUpper((ushort)*p); | - |
1093 | p++; | - |
1094 | } executed: } Execution Count:675 | 675 |
1095 | } executed: } Execution Count:189 | 189 |
1096 | return s; executed: return s; Execution Count:189 | 189 |
1097 | } | - |
1098 | void QByteArray::clear() | - |
1099 | { | - |
1100 | if (!d->ref.deref()) evaluated: !d->ref.deref() yes Evaluation Count:5827 | yes Evaluation Count:616296 |
| 5827-616296 |
1101 | Data::deallocate(d); executed: Data::deallocate(d); Execution Count:5827 | 5827 |
1102 | d = Data::sharedNull(); | - |
1103 | } executed: } Execution Count:622123 | 622123 |
1104 | QDataStream &operator<<(QDataStream &out, const QByteArray &ba) | - |
1105 | { | - |
1106 | if (ba.isNull() && out.version() >= 6) { evaluated: ba.isNull() yes Evaluation Count:19 | yes Evaluation Count:1440 |
partially evaluated: out.version() >= 6 yes Evaluation Count:19 | no Evaluation Count:0 |
| 0-1440 |
1107 | out << (quint32)0xffffffff; | - |
1108 | return out; executed: return out; Execution Count:19 | 19 |
1109 | } | - |
1110 | return out.writeBytes(ba.constData(), ba.size()); executed: return out.writeBytes(ba.constData(), ba.size()); Execution Count:1440 | 1440 |
1111 | } | - |
1112 | QDataStream &operator>>(QDataStream &in, QByteArray &ba) | - |
1113 | { | - |
1114 | ba.clear(); | - |
1115 | quint32 len; | - |
1116 | in >> len; | - |
1117 | if (len == 0xffffffff) evaluated: len == 0xffffffff yes Evaluation Count:24 | yes Evaluation Count:1269 |
| 24-1269 |
1118 | return in; executed: return in; Execution Count:24 | 24 |
1119 | | - |
1120 | const quint32 Step = 1024 * 1024; | - |
1121 | quint32 allocated = 0; | - |
1122 | | - |
1123 | do { | - |
1124 | int blockSize = qMin(Step, len - allocated); | - |
1125 | ba.resize(allocated + blockSize); | - |
1126 | if (in.readRawData(ba.data() + allocated, blockSize) != blockSize) { evaluated: in.readRawData(ba.data() + allocated, blockSize) != blockSize yes Evaluation Count:11 | yes Evaluation Count:1272 |
| 11-1272 |
1127 | ba.clear(); | - |
1128 | in.setStatus(QDataStream::ReadPastEnd); | - |
1129 | return in; executed: return in; Execution Count:11 | 11 |
1130 | } | - |
1131 | allocated += blockSize; | - |
1132 | } while (allocated < len); executed: } Execution Count:1272 evaluated: allocated < len yes Evaluation Count:14 | yes Evaluation Count:1258 |
| 14-1272 |
1133 | | - |
1134 | return in; executed: return in; Execution Count:1258 | 1258 |
1135 | } | - |
1136 | QByteArray QByteArray::simplified() const | - |
1137 | { | - |
1138 | if (d->size == 0) partially evaluated: d->size == 0 no Evaluation Count:0 | yes Evaluation Count:63194 |
| 0-63194 |
1139 | return *this; never executed: return *this; | 0 |
1140 | QByteArray result(d->size, Qt::Uninitialized); | - |
1141 | const char *from = d->data(); | - |
1142 | const char *fromend = from + d->size; | - |
1143 | int outc=0; | - |
1144 | char *to = result.d->data(); | - |
1145 | for (;;) { | - |
1146 | while (from!=fromend && isspace(uchar(*from))) evaluated: from!=fromend yes Evaluation Count:260063 | yes Evaluation Count:228 |
evaluated: isspace(uchar(*from)) yes Evaluation Count:131980 | yes Evaluation Count:128083 |
| 228-260063 |
1147 | from++; executed: from++; Execution Count:131980 | 131980 |
1148 | while (from!=fromend && !isspace(uchar(*from))) evaluated: from!=fromend yes Evaluation Count:570757 | yes Evaluation Count:63194 |
evaluated: !isspace(uchar(*from)) yes Evaluation Count:505640 | yes Evaluation Count:65117 |
| 63194-570757 |
1149 | to[outc++] = *from++; executed: to[outc++] = *from++; Execution Count:505640 | 505640 |
1150 | if (from!=fromend) evaluated: from!=fromend yes Evaluation Count:65117 | yes Evaluation Count:63194 |
| 63194-65117 |
1151 | to[outc++] = ' '; executed: to[outc++] = ' '; Execution Count:65117 | 65117 |
1152 | else | - |
1153 | break; executed: break; Execution Count:63194 | 63194 |
1154 | } | - |
1155 | if (outc > 0 && to[outc-1] == ' ') partially evaluated: outc > 0 yes Evaluation Count:63194 | no Evaluation Count:0 |
evaluated: to[outc-1] == ' ' yes Evaluation Count:228 | yes Evaluation Count:62966 |
| 0-63194 |
1156 | outc--; executed: outc--; Execution Count:228 | 228 |
1157 | result.resize(outc); | - |
1158 | return result; executed: return result; Execution Count:63194 | 63194 |
1159 | } | - |
1160 | QByteArray QByteArray::trimmed() const | - |
1161 | { | - |
1162 | if (d->size == 0) evaluated: d->size == 0 yes Evaluation Count:103 | yes Evaluation Count:97181 |
| 103-97181 |
1163 | return *this; executed: return *this; Execution Count:103 | 103 |
1164 | const char *s = d->data(); | - |
1165 | if (!isspace(uchar(*s)) && !isspace(uchar(s[d->size-1]))) evaluated: !isspace(uchar(*s)) yes Evaluation Count:91875 | yes Evaluation Count:5306 |
evaluated: !isspace(uchar(s[d->size-1])) yes Evaluation Count:73297 | yes Evaluation Count:18578 |
| 5306-91875 |
1166 | return *this; executed: return *this; Execution Count:73297 | 73297 |
1167 | int start = 0; | - |
1168 | int end = d->size - 1; | - |
1169 | while (start<=end && isspace(uchar(s[start]))) evaluated: start<=end yes Evaluation Count:29210 | yes Evaluation Count:6 |
evaluated: isspace(uchar(s[start])) yes Evaluation Count:5332 | yes Evaluation Count:23878 |
| 6-29210 |
1170 | start++; executed: start++; Execution Count:5332 | 5332 |
1171 | if (start <= end) { evaluated: start <= end yes Evaluation Count:23878 | yes Evaluation Count:6 |
| 6-23878 |
1172 | while (end && isspace(uchar(s[end]))) evaluated: end yes Evaluation Count:42496 | yes Evaluation Count:35 |
evaluated: isspace(uchar(s[end])) yes Evaluation Count:18653 | yes Evaluation Count:23843 |
| 35-42496 |
1173 | end--; executed: end--; Execution Count:18653 | 18653 |
1174 | } executed: } Execution Count:23878 | 23878 |
1175 | int l = end - start + 1; | - |
1176 | if (l <= 0) { evaluated: l <= 0 yes Evaluation Count:6 | yes Evaluation Count:23878 |
| 6-23878 |
1177 | QByteArrayDataPtr empty = { reinterpret_cast<QByteArrayData *>(Data::allocate(0)) }; | - |
1178 | return QByteArray(empty); executed: return QByteArray(empty); Execution Count:6 | 6 |
1179 | } | - |
1180 | return QByteArray(s+start, l); executed: return QByteArray(s+start, l); Execution Count:23878 | 23878 |
1181 | } | - |
1182 | QByteArray QByteArray::leftJustified(int width, char fill, bool truncate) const | - |
1183 | { | - |
1184 | QByteArray result; | - |
1185 | int len = d->size; | - |
1186 | int padlen = width - len; | - |
1187 | if (padlen > 0) { evaluated: padlen > 0 yes Evaluation Count:5 | yes Evaluation Count:8 |
| 5-8 |
1188 | result.resize(len+padlen); | - |
1189 | if (len) evaluated: len yes Evaluation Count:4 | yes Evaluation Count:1 |
| 1-4 |
1190 | memcpy(result.d->data(), d->data(), len); executed: memcpy(result.d->data(), d->data(), len); Execution Count:4 | 4 |
1191 | memset(result.d->data()+len, fill, padlen); | - |
1192 | } else { executed: } Execution Count:5 | 5 |
1193 | if (truncate) evaluated: truncate yes Evaluation Count:4 | yes Evaluation Count:4 |
| 4 |
1194 | result = left(width); executed: result = left(width); Execution Count:4 | 4 |
1195 | else | - |
1196 | result = *this; executed: result = *this; Execution Count:4 | 4 |
1197 | } | - |
1198 | return result; executed: return result; Execution Count:13 | 13 |
1199 | } | - |
1200 | QByteArray QByteArray::rightJustified(int width, char fill, bool truncate) const | - |
1201 | { | - |
1202 | QByteArray result; | - |
1203 | int len = d->size; | - |
1204 | int padlen = width - len; | - |
1205 | if (padlen > 0) { evaluated: padlen > 0 yes Evaluation Count:113 | yes Evaluation Count:444 |
| 113-444 |
1206 | result.resize(len+padlen); | - |
1207 | if (len) evaluated: len yes Evaluation Count:112 | yes Evaluation Count:1 |
| 1-112 |
1208 | memcpy(result.d->data()+padlen, data(), len); executed: memcpy(result.d->data()+padlen, data(), len); Execution Count:112 | 112 |
1209 | memset(result.d->data(), fill, padlen); | - |
1210 | } else { executed: } Execution Count:113 | 113 |
1211 | if (truncate) evaluated: truncate yes Evaluation Count:4 | yes Evaluation Count:440 |
| 4-440 |
1212 | result = left(width); executed: result = left(width); Execution Count:4 | 4 |
1213 | else | - |
1214 | result = *this; executed: result = *this; Execution Count:440 | 440 |
1215 | } | - |
1216 | return result; executed: return result; Execution Count:557 | 557 |
1217 | } | - |
1218 | | - |
1219 | bool QByteArray::isNull() const { return d == QArrayData::sharedNull(); } executed: return d == QArrayData::sharedNull(); Execution Count:12425 | 12425 |
1220 | qlonglong QByteArray::toLongLong(bool *ok, int base) const | - |
1221 | { | - |
1222 | | - |
1223 | | - |
1224 | | - |
1225 | | - |
1226 | | - |
1227 | | - |
1228 | | - |
1229 | return QLocalePrivate::bytearrayToLongLong(nulTerminated().constData(), base, ok); executed: return QLocalePrivate::bytearrayToLongLong(nulTerminated().constData(), base, ok); Execution Count:180505 | 180505 |
1230 | } | - |
1231 | qulonglong QByteArray::toULongLong(bool *ok, int base) const | - |
1232 | { | - |
1233 | | - |
1234 | | - |
1235 | | - |
1236 | | - |
1237 | | - |
1238 | | - |
1239 | | - |
1240 | return QLocalePrivate::bytearrayToUnsLongLong(nulTerminated().constData(), base, ok); executed: return QLocalePrivate::bytearrayToUnsLongLong(nulTerminated().constData(), base, ok); Execution Count:3260 | 3260 |
1241 | } | - |
1242 | int QByteArray::toInt(bool *ok, int base) const | - |
1243 | { | - |
1244 | qlonglong v = toLongLong(ok, base); | - |
1245 | if (v < (-2147483647 - 1) || v > 2147483647) { partially evaluated: v < (-2147483647 - 1) no Evaluation Count:0 | yes Evaluation Count:179751 |
evaluated: v > 2147483647 yes Evaluation Count:96 | yes Evaluation Count:179655 |
| 0-179751 |
1246 | if (ok) partially evaluated: ok yes Evaluation Count:96 | no Evaluation Count:0 |
| 0-96 |
1247 | *ok = false; executed: *ok = false; Execution Count:96 | 96 |
1248 | v = 0; | - |
1249 | } executed: } Execution Count:96 | 96 |
1250 | return int(v); executed: return int(v); Execution Count:179751 | 179751 |
1251 | } | - |
1252 | uint QByteArray::toUInt(bool *ok, int base) const | - |
1253 | { | - |
1254 | qulonglong v = toULongLong(ok, base); | - |
1255 | if (v > (2147483647 * 2U + 1U)) { never evaluated: v > (2147483647 * 2U + 1U) | 0 |
1256 | if (ok) | 0 |
1257 | *ok = false; never executed: *ok = false; | 0 |
1258 | v = 0; | - |
1259 | } | 0 |
1260 | return uint(v); never executed: return uint(v); | 0 |
1261 | } | - |
1262 | long QByteArray::toLong(bool *ok, int base) const | - |
1263 | { | - |
1264 | qlonglong v = toLongLong(ok, base); | - |
1265 | if (v < (-9223372036854775807L - 1L) || v > 9223372036854775807L) { partially evaluated: v < (-9223372036854775807L - 1L) no Evaluation Count:0 | yes Evaluation Count:216 |
partially evaluated: v > 9223372036854775807L no Evaluation Count:0 | yes Evaluation Count:216 |
| 0-216 |
1266 | if (ok) | 0 |
1267 | *ok = false; never executed: *ok = false; | 0 |
1268 | v = 0; | - |
1269 | } | 0 |
1270 | return long(v); executed: return long(v); Execution Count:216 | 216 |
1271 | } | - |
1272 | ulong QByteArray::toULong(bool *ok, int base) const | - |
1273 | { | - |
1274 | qulonglong v = toULongLong(ok, base); | - |
1275 | if (v > (9223372036854775807L * 2UL + 1UL)) { partially evaluated: v > (9223372036854775807L * 2UL + 1UL) no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
1276 | if (ok) | 0 |
1277 | *ok = false; never executed: *ok = false; | 0 |
1278 | v = 0; | - |
1279 | } | 0 |
1280 | return ulong(v); executed: return ulong(v); Execution Count:10 | 10 |
1281 | } | - |
1282 | short QByteArray::toShort(bool *ok, int base) const | - |
1283 | { | - |
1284 | qlonglong v = toLongLong(ok, base); | - |
1285 | if (v < (-32767 - 1) || v > 32767) { never evaluated: v < (-32767 - 1) never evaluated: v > 32767 | 0 |
1286 | if (ok) | 0 |
1287 | *ok = false; never executed: *ok = false; | 0 |
1288 | v = 0; | - |
1289 | } | 0 |
1290 | return short(v); never executed: return short(v); | 0 |
1291 | } | - |
1292 | ushort QByteArray::toUShort(bool *ok, int base) const | - |
1293 | { | - |
1294 | qulonglong v = toULongLong(ok, base); | - |
1295 | if (v > (32767 * 2 + 1)) { never evaluated: v > (32767 * 2 + 1) | 0 |
1296 | if (ok) | 0 |
1297 | *ok = false; never executed: *ok = false; | 0 |
1298 | v = 0; | - |
1299 | } | 0 |
1300 | return ushort(v); never executed: return ushort(v); | 0 |
1301 | } | - |
1302 | double QByteArray::toDouble(bool *ok) const | - |
1303 | { | - |
1304 | return QLocalePrivate::bytearrayToDouble(nulTerminated().constData(), ok); executed: return QLocalePrivate::bytearrayToDouble(nulTerminated().constData(), ok); Execution Count:395 | 395 |
1305 | } | - |
1306 | float QByteArray::toFloat(bool *ok) const | - |
1307 | { | - |
1308 | return float(toDouble(ok)); executed: return float(toDouble(ok)); Execution Count:1 | 1 |
1309 | } | - |
1310 | QByteArray QByteArray::toBase64() const | - |
1311 | { | - |
1312 | const char alphabet[] = "ABCDEFGH" "IJKLMNOP" "QRSTUVWX" "YZabcdef" | - |
1313 | "ghijklmn" "opqrstuv" "wxyz0123" "456789+/"; | - |
1314 | const char padchar = '='; | - |
1315 | int padlen = 0; | - |
1316 | | - |
1317 | QByteArray tmp((d->size * 4) / 3 + 3, Qt::Uninitialized); | - |
1318 | | - |
1319 | int i = 0; | - |
1320 | char *out = tmp.data(); | - |
1321 | while (i < d->size) { evaluated: i < d->size yes Evaluation Count:755905 | yes Evaluation Count:563 |
| 563-755905 |
1322 | int chunk = 0; | - |
1323 | chunk |= int(uchar(d->data()[i++])) << 16; | - |
1324 | if (i == d->size) { evaluated: i == d->size yes Evaluation Count:212 | yes Evaluation Count:755693 |
| 212-755693 |
1325 | padlen = 2; | - |
1326 | } else { executed: } Execution Count:212 | 212 |
1327 | chunk |= int(uchar(d->data()[i++])) << 8; | - |
1328 | if (i == d->size) padlen = 1; executed: padlen = 1; Execution Count:189 evaluated: i == d->size yes Evaluation Count:189 | yes Evaluation Count:755504 |
| 189-755504 |
1329 | else chunk |= int(uchar(d->data()[i++])); executed: chunk |= int(uchar(d->data()[i++])); Execution Count:755504 | 755504 |
1330 | } | - |
1331 | | - |
1332 | int j = (chunk & 0x00fc0000) >> 18; | - |
1333 | int k = (chunk & 0x0003f000) >> 12; | - |
1334 | int l = (chunk & 0x00000fc0) >> 6; | - |
1335 | int m = (chunk & 0x0000003f); | - |
1336 | *out++ = alphabet[j]; | - |
1337 | *out++ = alphabet[k]; | - |
1338 | if (padlen > 1) *out++ = padchar; executed: *out++ = padchar; Execution Count:212 evaluated: padlen > 1 yes Evaluation Count:212 | yes Evaluation Count:755693 |
| 212-755693 |
1339 | else *out++ = alphabet[l]; executed: *out++ = alphabet[l]; Execution Count:755693 | 755693 |
1340 | if (padlen > 0) *out++ = padchar; executed: *out++ = padchar; Execution Count:401 evaluated: padlen > 0 yes Evaluation Count:401 | yes Evaluation Count:755504 |
| 401-755504 |
1341 | else *out++ = alphabet[m]; executed: *out++ = alphabet[m]; Execution Count:755504 | 755504 |
1342 | } | - |
1343 | | - |
1344 | tmp.truncate(out - tmp.data()); | - |
1345 | return tmp; executed: return tmp; Execution Count:563 | 563 |
1346 | } | - |
1347 | static char *qulltoa2(char *p, qulonglong n, int base) | - |
1348 | { | - |
1349 | | - |
1350 | | - |
1351 | | - |
1352 | | - |
1353 | | - |
1354 | | - |
1355 | const char b = 'a' - 10; | - |
1356 | do { | - |
1357 | const int c = n % base; | - |
1358 | n /= base; | - |
1359 | *--p = c + (c < 10 ? '0' : b); evaluated: c < 10 yes Evaluation Count:2265345 | yes Evaluation Count:19239 |
| 19239-2265345 |
1360 | } while (n); executed: } Execution Count:2284584 evaluated: n yes Evaluation Count:1846168 | yes Evaluation Count:438416 |
| 438416-2284584 |
1361 | | - |
1362 | return p; executed: return p; Execution Count:438416 | 438416 |
1363 | } | - |
1364 | | - |
1365 | QByteArray &QByteArray::setNum(qlonglong n, int base) | - |
1366 | { | - |
1367 | const int buffsize = 66; | - |
1368 | char buff[buffsize]; | - |
1369 | char *p; | - |
1370 | | - |
1371 | if (n < 0 && base == 10) { evaluated: n < 0 yes Evaluation Count:127 | yes Evaluation Count:416966 |
evaluated: base == 10 yes Evaluation Count:12 | yes Evaluation Count:115 |
| 12-416966 |
1372 | p = qulltoa2(buff + buffsize, qulonglong(-(1 + n)) + 1, base); | - |
1373 | *--p = '-'; | - |
1374 | } else { executed: } Execution Count:12 | 12 |
1375 | p = qulltoa2(buff + buffsize, qulonglong(n), base); | - |
1376 | } executed: } Execution Count:417081 | 417081 |
1377 | | - |
1378 | clear(); | - |
1379 | append(p, buffsize - (p - buff)); | - |
1380 | return *this; executed: return *this; Execution Count:417093 | 417093 |
1381 | } | - |
1382 | | - |
1383 | | - |
1384 | | - |
1385 | | - |
1386 | | - |
1387 | | - |
1388 | | - |
1389 | QByteArray &QByteArray::setNum(qulonglong n, int base) | - |
1390 | { | - |
1391 | const int buffsize = 66; | - |
1392 | char buff[buffsize]; | - |
1393 | char *p = qulltoa2(buff + buffsize, n, base); | - |
1394 | | - |
1395 | clear(); | - |
1396 | append(p, buffsize - (p - buff)); | - |
1397 | return *this; executed: return *this; Execution Count:21323 | 21323 |
1398 | } | - |
1399 | QByteArray &QByteArray::setNum(double n, char f, int prec) | - |
1400 | { | - |
1401 | QLocalePrivate::DoubleForm form = QLocalePrivate::DFDecimal; | - |
1402 | uint flags = 0; | - |
1403 | | - |
1404 | if (qIsUpper(f)) partially evaluated: qIsUpper(f) no Evaluation Count:0 | yes Evaluation Count:450222 |
| 0-450222 |
1405 | flags = QLocalePrivate::CapitalEorX; never executed: flags = QLocalePrivate::CapitalEorX; | 0 |
1406 | f = qToLower(f); | - |
1407 | | - |
1408 | switch (f) { | - |
1409 | case 'f': | - |
1410 | form = QLocalePrivate::DFDecimal; | - |
1411 | break; | 0 |
1412 | case 'e': | - |
1413 | form = QLocalePrivate::DFExponent; | - |
1414 | break; | 0 |
1415 | case 'g': | - |
1416 | form = QLocalePrivate::DFSignificantDigits; | - |
1417 | break; executed: break; Execution Count:450222 | 450222 |
1418 | default: | - |
1419 | | - |
1420 | | - |
1421 | | - |
1422 | break; | 0 |
1423 | } | - |
1424 | | - |
1425 | QLocale locale(QLocale::C); | - |
1426 | *this = locale.d->doubleToString(n, prec, form, -1, flags).toLatin1(); | - |
1427 | return *this; executed: return *this; Execution Count:450222 | 450222 |
1428 | } | - |
1429 | QByteArray QByteArray::number(int n, int base) | - |
1430 | { | - |
1431 | QByteArray s; | - |
1432 | s.setNum(n, base); | - |
1433 | return s; executed: return s; Execution Count:420367 | 420367 |
1434 | } | - |
1435 | | - |
1436 | | - |
1437 | | - |
1438 | | - |
1439 | | - |
1440 | | - |
1441 | QByteArray QByteArray::number(uint n, int base) | - |
1442 | { | - |
1443 | QByteArray s; | - |
1444 | s.setNum(n, base); | - |
1445 | return s; executed: return s; Execution Count:17387 | 17387 |
1446 | } | - |
1447 | | - |
1448 | | - |
1449 | | - |
1450 | | - |
1451 | | - |
1452 | | - |
1453 | QByteArray QByteArray::number(qlonglong n, int base) | - |
1454 | { | - |
1455 | QByteArray s; | - |
1456 | s.setNum(n, base); | - |
1457 | return s; executed: return s; Execution Count:633 | 633 |
1458 | } | - |
1459 | | - |
1460 | | - |
1461 | | - |
1462 | | - |
1463 | | - |
1464 | | - |
1465 | QByteArray QByteArray::number(qulonglong n, int base) | - |
1466 | { | - |
1467 | QByteArray s; | - |
1468 | s.setNum(n, base); | - |
1469 | return s; executed: return s; Execution Count:6 | 6 |
1470 | } | - |
1471 | QByteArray QByteArray::number(double n, char f, int prec) | - |
1472 | { | - |
1473 | QByteArray s; | - |
1474 | s.setNum(n, f, prec); | - |
1475 | return s; executed: return s; Execution Count:450219 | 450219 |
1476 | } | - |
1477 | QByteArray QByteArray::fromRawData(const char *data, int size) | - |
1478 | { | - |
1479 | Data *x; | - |
1480 | if (!data) { partially evaluated: !data no Evaluation Count:0 | yes Evaluation Count:1824399 |
| 0-1824399 |
1481 | x = Data::sharedNull(); | - |
1482 | } else if (!size) { evaluated: !size yes Evaluation Count:32 | yes Evaluation Count:1824374 |
| 0-1824374 |
1483 | x = Data::allocate(0); | - |
1484 | } else { executed: } Execution Count:32 | 32 |
1485 | x = Data::fromRawData(data, size); | - |
1486 | do { if (!(x)) qBadAlloc(); } while (0); never executed: qBadAlloc(); executed: } Execution Count:1824371 partially evaluated: !(x) no Evaluation Count:0 | yes Evaluation Count:1824370 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:1824370 |
| 0-1824371 |
1487 | } executed: } Execution Count:1824372 | 1824372 |
1488 | QByteArrayDataPtr dataPtr = { reinterpret_cast<QByteArrayData *>(x) }; | - |
1489 | return QByteArray(dataPtr); executed: return QByteArray(dataPtr); Execution Count:1824403 | 1824403 |
1490 | } | - |
1491 | QByteArray &QByteArray::setRawData(const char *data, uint size) | - |
1492 | { | - |
1493 | if (d->ref.isShared() || d->alloc) { never evaluated: d->ref.isShared() never evaluated: d->alloc | 0 |
1494 | *this = fromRawData(data, size); | - |
1495 | } else { | 0 |
1496 | if (data) { | 0 |
1497 | d->size = size; | - |
1498 | d->offset = data - reinterpret_cast<char *>(d); | - |
1499 | } else { | 0 |
1500 | d->offset = sizeof(QByteArrayData); | - |
1501 | d->size = 0; | - |
1502 | *d->data() = 0; | - |
1503 | } | 0 |
1504 | } | - |
1505 | return *this; never executed: return *this; | 0 |
1506 | } | - |
1507 | QByteArray QByteArray::fromBase64(const QByteArray &base64) | - |
1508 | { | - |
1509 | unsigned int buf = 0; | - |
1510 | int nbits = 0; | - |
1511 | QByteArray tmp((base64.size() * 3) / 4, Qt::Uninitialized); | - |
1512 | | - |
1513 | int offset = 0; | - |
1514 | for (int i = 0; i < base64.size(); ++i) { evaluated: i < base64.size() yes Evaluation Count:3767698 | yes Evaluation Count:1276 |
| 1276-3767698 |
1515 | int ch = base64.at(i); | - |
1516 | int d; | - |
1517 | | - |
1518 | if (ch >= 'A' && ch <= 'Z') evaluated: ch >= 'A' yes Evaluation Count:3291549 | yes Evaluation Count:476149 |
evaluated: ch <= 'Z' yes Evaluation Count:2059347 | yes Evaluation Count:1232202 |
| 476149-3291549 |
1519 | d = ch - 'A'; executed: d = ch - 'A'; Execution Count:2059347 | 2059347 |
1520 | else if (ch >= 'a' && ch <= 'z') evaluated: ch >= 'a' yes Evaluation Count:1232202 | yes Evaluation Count:476149 |
partially evaluated: ch <= 'z' yes Evaluation Count:1232202 | no Evaluation Count:0 |
| 0-1232202 |
1521 | d = ch - 'a' + 26; executed: d = ch - 'a' + 26; Execution Count:1232202 | 1232202 |
1522 | else if (ch >= '0' && ch <= '9') evaluated: ch >= '0' yes Evaluation Count:412750 | yes Evaluation Count:63399 |
evaluated: ch <= '9' yes Evaluation Count:411246 | yes Evaluation Count:1504 |
| 1504-412750 |
1523 | d = ch - '0' + 52; executed: d = ch - '0' + 52; Execution Count:411246 | 411246 |
1524 | else if (ch == '+') evaluated: ch == '+' yes Evaluation Count:21917 | yes Evaluation Count:42986 |
| 21917-42986 |
1525 | d = 62; executed: d = 62; Execution Count:21917 | 21917 |
1526 | else if (ch == '/') evaluated: ch == '/' yes Evaluation Count:25979 | yes Evaluation Count:17007 |
| 17007-25979 |
1527 | d = 63; executed: d = 63; Execution Count:25979 | 25979 |
1528 | else | - |
1529 | d = -1; executed: d = -1; Execution Count:17007 | 17007 |
1530 | | - |
1531 | if (d != -1) { evaluated: d != -1 yes Evaluation Count:3750691 | yes Evaluation Count:17007 |
| 17007-3750691 |
1532 | buf = (buf << 6) | d; | - |
1533 | nbits += 6; | - |
1534 | if (nbits >= 8) { evaluated: nbits >= 8 yes Evaluation Count:2812663 | yes Evaluation Count:938028 |
| 938028-2812663 |
1535 | nbits -= 8; | - |
1536 | tmp[offset++] = buf >> nbits; | - |
1537 | buf &= (1 << nbits) - 1; | - |
1538 | } executed: } Execution Count:2812663 | 2812663 |
1539 | } executed: } Execution Count:3750691 | 3750691 |
1540 | } executed: } Execution Count:3767698 | 3767698 |
1541 | | - |
1542 | tmp.truncate(offset); | - |
1543 | return tmp; executed: return tmp; Execution Count:1276 | 1276 |
1544 | } | - |
1545 | QByteArray QByteArray::fromHex(const QByteArray &hexEncoded) | - |
1546 | { | - |
1547 | QByteArray res((hexEncoded.size() + 1)/ 2, Qt::Uninitialized); | - |
1548 | uchar *result = (uchar *)res.data() + res.size(); | - |
1549 | | - |
1550 | bool odd_digit = true; | - |
1551 | for (int i = hexEncoded.size() - 1; i >= 0; --i) { evaluated: i >= 0 yes Evaluation Count:5648 | yes Evaluation Count:66 |
| 66-5648 |
1552 | int ch = hexEncoded.at(i); | - |
1553 | int tmp; | - |
1554 | if (ch >= '0' && ch <= '9') evaluated: ch >= '0' yes Evaluation Count:5615 | yes Evaluation Count:33 |
evaluated: ch <= '9' yes Evaluation Count:3170 | yes Evaluation Count:2445 |
| 33-5615 |
1555 | tmp = ch - '0'; executed: tmp = ch - '0'; Execution Count:3170 | 3170 |
1556 | else if (ch >= 'a' && ch <= 'f') evaluated: ch >= 'a' yes Evaluation Count:631 | yes Evaluation Count:1847 |
evaluated: ch <= 'f' yes Evaluation Count:609 | yes Evaluation Count:22 |
| 22-1847 |
1557 | tmp = ch - 'a' + 10; executed: tmp = ch - 'a' + 10; Execution Count:609 | 609 |
1558 | else if (ch >= 'A' && ch <= 'F') evaluated: ch >= 'A' yes Evaluation Count:860 | yes Evaluation Count:1009 |
evaluated: ch <= 'F' yes Evaluation Count:838 | yes Evaluation Count:22 |
| 22-1009 |
1559 | tmp = ch - 'A' + 10; executed: tmp = ch - 'A' + 10; Execution Count:838 | 838 |
1560 | else | - |
1561 | continue; executed: continue; Execution Count:1031 | 1031 |
1562 | if (odd_digit) { evaluated: odd_digit yes Evaluation Count:2311 | yes Evaluation Count:2306 |
| 2306-2311 |
1563 | --result; | - |
1564 | *result = tmp; | - |
1565 | odd_digit = false; | - |
1566 | } else { executed: } Execution Count:2311 | 2311 |
1567 | *result |= tmp << 4; | - |
1568 | odd_digit = true; | - |
1569 | } executed: } Execution Count:2306 | 2306 |
1570 | } | - |
1571 | | - |
1572 | res.remove(0, result - (const uchar *)res.constData()); | - |
1573 | return res; executed: return res; Execution Count:66 | 66 |
1574 | } | - |
1575 | | - |
1576 | | - |
1577 | | - |
1578 | | - |
1579 | | - |
1580 | | - |
1581 | | - |
1582 | QByteArray QByteArray::toHex() const | - |
1583 | { | - |
1584 | QByteArray hex(d->size * 2, Qt::Uninitialized); | - |
1585 | char *hexData = hex.data(); | - |
1586 | const uchar *data = (const uchar *)d->data(); | - |
1587 | for (int i = 0; i < d->size; ++i) { evaluated: i < d->size yes Evaluation Count:34511 | yes Evaluation Count:1916 |
| 1916-34511 |
1588 | int j = (data[i] >> 4) & 0xf; | - |
1589 | if (j <= 9) evaluated: j <= 9 yes Evaluation Count:25219 | yes Evaluation Count:9292 |
| 9292-25219 |
1590 | hexData[i*2] = (j + '0'); executed: hexData[i*2] = (j + '0'); Execution Count:25219 | 25219 |
1591 | else | - |
1592 | hexData[i*2] = (j + 'a' - 10); executed: hexData[i*2] = (j + 'a' - 10); Execution Count:9292 | 9292 |
1593 | j = data[i] & 0xf; | - |
1594 | if (j <= 9) evaluated: j <= 9 yes Evaluation Count:20855 | yes Evaluation Count:13656 |
| 13656-20855 |
1595 | hexData[i*2+1] = (j + '0'); executed: hexData[i*2+1] = (j + '0'); Execution Count:20855 | 20855 |
1596 | else | - |
1597 | hexData[i*2+1] = (j + 'a' - 10); executed: hexData[i*2+1] = (j + 'a' - 10); Execution Count:13656 | 13656 |
1598 | } | - |
1599 | return hex; executed: return hex; Execution Count:1916 | 1916 |
1600 | } | - |
1601 | | - |
1602 | static void q_fromPercentEncoding(QByteArray *ba, char percent) | - |
1603 | { | - |
1604 | if (ba->isEmpty()) partially evaluated: ba->isEmpty() no Evaluation Count:0 | yes Evaluation Count:60 |
| 0-60 |
1605 | return; | 0 |
1606 | | - |
1607 | char *data = ba->data(); | - |
1608 | const char *inputPtr = data; | - |
1609 | | - |
1610 | int i = 0; | - |
1611 | int len = ba->count(); | - |
1612 | int outlen = 0; | - |
1613 | int a, b; | - |
1614 | char c; | - |
1615 | while (i < len) { evaluated: i < len yes Evaluation Count:1845 | yes Evaluation Count:60 |
| 60-1845 |
1616 | c = inputPtr[i]; | - |
1617 | if (c == percent && i + 2 < len) { evaluated: c == percent yes Evaluation Count:145 | yes Evaluation Count:1700 |
partially evaluated: i + 2 < len yes Evaluation Count:145 | no Evaluation Count:0 |
| 0-1700 |
1618 | a = inputPtr[++i]; | - |
1619 | b = inputPtr[++i]; | - |
1620 | | - |
1621 | if (a >= '0' && a <= '9') a -= '0'; executed: a -= '0'; Execution Count:138 partially evaluated: a >= '0' yes Evaluation Count:145 | no Evaluation Count:0 |
evaluated: a <= '9' yes Evaluation Count:138 | yes Evaluation Count:7 |
| 0-145 |
1622 | else if (a >= 'a' && a <= 'f') a = a - 'a' + 10; never executed: a = a - 'a' + 10; partially evaluated: a >= 'a' no Evaluation Count:0 | yes Evaluation Count:7 |
never evaluated: a <= 'f' | 0-7 |
1623 | else if (a >= 'A' && a <= 'F') a = a - 'A' + 10; executed: a = a - 'A' + 10; Execution Count:7 partially evaluated: a >= 'A' yes Evaluation Count:7 | no Evaluation Count:0 |
partially evaluated: a <= 'F' yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
1624 | | - |
1625 | if (b >= '0' && b <= '9') b -= '0'; executed: b -= '0'; Execution Count:78 partially evaluated: b >= '0' yes Evaluation Count:145 | no Evaluation Count:0 |
evaluated: b <= '9' yes Evaluation Count:78 | yes Evaluation Count:67 |
| 0-145 |
1626 | else if (b >= 'a' && b <= 'f') b = b - 'a' + 10; never executed: b = b - 'a' + 10; partially evaluated: b >= 'a' no Evaluation Count:0 | yes Evaluation Count:67 |
never evaluated: b <= 'f' | 0-67 |
1627 | else if (b >= 'A' && b <= 'F') b = b - 'A' + 10; executed: b = b - 'A' + 10; Execution Count:67 partially evaluated: b >= 'A' yes Evaluation Count:67 | no Evaluation Count:0 |
partially evaluated: b <= 'F' yes Evaluation Count:67 | no Evaluation Count:0 |
| 0-67 |
1628 | | - |
1629 | *data++ = (char)((a << 4) | b); | - |
1630 | } else { executed: } Execution Count:145 | 145 |
1631 | *data++ = c; | - |
1632 | } executed: } Execution Count:1700 | 1700 |
1633 | | - |
1634 | ++i; | - |
1635 | ++outlen; | - |
1636 | } executed: } Execution Count:1845 | 1845 |
1637 | | - |
1638 | if (outlen != len) evaluated: outlen != len yes Evaluation Count:34 | yes Evaluation Count:26 |
| 26-34 |
1639 | ba->truncate(outlen); executed: ba->truncate(outlen); Execution Count:34 | 34 |
1640 | } executed: } Execution Count:60 | 60 |
1641 | | - |
1642 | void q_fromPercentEncoding(QByteArray *ba) | - |
1643 | { | - |
1644 | q_fromPercentEncoding(ba, '%'); | - |
1645 | } | 0 |
1646 | QByteArray QByteArray::fromPercentEncoding(const QByteArray &input, char percent) | - |
1647 | { | - |
1648 | if (input.isNull()) evaluated: input.isNull() yes Evaluation Count:2 | yes Evaluation Count:64 |
| 2-64 |
1649 | return QByteArray(); executed: return QByteArray(); Execution Count:2 | 2 |
1650 | if (input.isEmpty()) evaluated: input.isEmpty() yes Evaluation Count:4 | yes Evaluation Count:60 |
| 4-60 |
1651 | return QByteArray(input.data(), 0); executed: return QByteArray(input.data(), 0); Execution Count:4 | 4 |
1652 | | - |
1653 | QByteArray tmp = input; | - |
1654 | q_fromPercentEncoding(&tmp, percent); | - |
1655 | return tmp; executed: return tmp; Execution Count:60 | 60 |
1656 | } | - |
1657 | | - |
1658 | static inline bool q_strchr(const char str[], char chr) | - |
1659 | { | - |
1660 | if (!str) return false; never executed: return false; partially evaluated: !str no Evaluation Count:0 | yes Evaluation Count:438 |
| 0-438 |
1661 | | - |
1662 | const char *ptr = str; | - |
1663 | char c; | - |
1664 | while ((c = *ptr++)) evaluated: (c = *ptr++) yes Evaluation Count:520 | yes Evaluation Count:389 |
| 389-520 |
1665 | if (c == chr) evaluated: c == chr yes Evaluation Count:49 | yes Evaluation Count:471 |
| 49-471 |
1666 | return true; executed: return true; Execution Count:49 | 49 |
1667 | return false; executed: return false; Execution Count:389 | 389 |
1668 | } | - |
1669 | | - |
1670 | static inline char toHexHelper(char c) | - |
1671 | { | - |
1672 | static const char hexnumbers[] = "0123456789ABCDEF"; | - |
1673 | return hexnumbers[c & 0xf]; executed: return hexnumbers[c & 0xf]; Execution Count:216 | 216 |
1674 | } | - |
1675 | | - |
1676 | static void q_toPercentEncoding(QByteArray *ba, const char *dontEncode, const char *alsoEncode, char percent) | - |
1677 | { | - |
1678 | if (ba->isEmpty()) partially evaluated: ba->isEmpty() no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-26 |
1679 | return; | 0 |
1680 | | - |
1681 | QByteArray input = *ba; | - |
1682 | int len = input.count(); | - |
1683 | const char *inputData = input.constData(); | - |
1684 | char *output = 0; | - |
1685 | int length = 0; | - |
1686 | | - |
1687 | for (int i = 0; i < len; ++i) { evaluated: i < len yes Evaluation Count:405 | yes Evaluation Count:26 |
| 26-405 |
1688 | unsigned char c = *inputData++; | - |
1689 | if (((c >= 0x61 && c <= 0x7A) evaluated: c >= 0x61 yes Evaluation Count:202 | yes Evaluation Count:203 |
evaluated: c <= 0x7A yes Evaluation Count:192 | yes Evaluation Count:10 |
| 10-203 |
1690 | || (c >= 0x41 && c <= 0x5A) evaluated: c >= 0x41 yes Evaluation Count:80 | yes Evaluation Count:133 |
evaluated: c <= 0x5A yes Evaluation Count:58 | yes Evaluation Count:22 |
| 22-133 |
1691 | || (c >= 0x30 && c <= 0x39) evaluated: c >= 0x30 yes Evaluation Count:64 | yes Evaluation Count:91 |
evaluated: c <= 0x39 yes Evaluation Count:18 | yes Evaluation Count:46 |
| 18-91 |
1692 | || c == 0x2D evaluated: c == 0x2D yes Evaluation Count:2 | yes Evaluation Count:135 |
| 2-135 |
1693 | || c == 0x2E evaluated: c == 0x2E yes Evaluation Count:6 | yes Evaluation Count:129 |
| 6-129 |
1694 | || c == 0x5F evaluated: c == 0x5F yes Evaluation Count:2 | yes Evaluation Count:127 |
| 2-127 |
1695 | || c == 0x7E evaluated: c == 0x7E yes Evaluation Count:2 | yes Evaluation Count:125 |
| 2-125 |
1696 | || q_strchr(dontEncode, c)) evaluated: q_strchr(dontEncode, c) yes Evaluation Count:33 | yes Evaluation Count:92 |
| 33-92 |
1697 | && !q_strchr(alsoEncode, c)) { evaluated: !q_strchr(alsoEncode, c) yes Evaluation Count:297 | yes Evaluation Count:16 |
| 16-297 |
1698 | if (output) evaluated: output yes Evaluation Count:114 | yes Evaluation Count:183 |
| 114-183 |
1699 | output[length] = c; executed: output[length] = c; Execution Count:114 | 114 |
1700 | ++length; | - |
1701 | } else { executed: } Execution Count:297 | 297 |
1702 | if (!output) { evaluated: !output yes Evaluation Count:22 | yes Evaluation Count:86 |
| 22-86 |
1703 | | - |
1704 | ba->resize(len*3); | - |
1705 | output = ba->data(); | - |
1706 | } executed: } Execution Count:22 | 22 |
1707 | output[length++] = percent; | - |
1708 | output[length++] = toHexHelper((c & 0xf0) >> 4); | - |
1709 | output[length++] = toHexHelper(c & 0xf); | - |
1710 | } executed: } Execution Count:108 | 108 |
1711 | } | - |
1712 | if (output) evaluated: output yes Evaluation Count:22 | yes Evaluation Count:4 |
| 4-22 |
1713 | ba->truncate(length); executed: ba->truncate(length); Execution Count:22 | 22 |
1714 | } executed: } Execution Count:26 | 26 |
1715 | | - |
1716 | void q_toPercentEncoding(QByteArray *ba, const char *exclude, const char *include) | - |
1717 | { | - |
1718 | q_toPercentEncoding(ba, exclude, include, '%'); | - |
1719 | } | 0 |
1720 | | - |
1721 | void q_normalizePercentEncoding(QByteArray *ba, const char *exclude) | - |
1722 | { | - |
1723 | q_fromPercentEncoding(ba, '%'); | - |
1724 | q_toPercentEncoding(ba, exclude, 0, '%'); | - |
1725 | } | 0 |
1726 | QByteArray QByteArray::toPercentEncoding(const QByteArray &exclude, const QByteArray &include, | - |
1727 | char percent) const | - |
1728 | { | - |
1729 | if (isNull()) evaluated: isNull() yes Evaluation Count:2 | yes Evaluation Count:30 |
| 2-30 |
1730 | return QByteArray(); executed: return QByteArray(); Execution Count:2 | 2 |
1731 | if (isEmpty()) evaluated: isEmpty() yes Evaluation Count:4 | yes Evaluation Count:26 |
| 4-26 |
1732 | return QByteArray(data(), 0); executed: return QByteArray(data(), 0); Execution Count:4 | 4 |
1733 | | - |
1734 | QByteArray include2 = include; | - |
1735 | if (percent != '%') evaluated: percent != '%' yes Evaluation Count:1 | yes Evaluation Count:25 |
| 1-25 |
1736 | if ((percent >= 0x61 && percent <= 0x7A) partially evaluated: percent >= 0x61 no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: percent <= 0x7A | 0-1 |
1737 | || (percent >= 0x41 && percent <= 0x5A) partially evaluated: percent >= 0x41 yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: percent <= 0x5A yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1738 | || (percent >= 0x30 && percent <= 0x39) never evaluated: percent >= 0x30 never evaluated: percent <= 0x39 | 0 |
1739 | || percent == 0x2D never evaluated: percent == 0x2D | 0 |
1740 | || percent == 0x2E never evaluated: percent == 0x2E | 0 |
1741 | || percent == 0x5F never evaluated: percent == 0x5F | 0 |
1742 | || percent == 0x7E) never evaluated: percent == 0x7E | 0 |
1743 | include2 += percent; executed: include2 += percent; Execution Count:1 | 1 |
1744 | | - |
1745 | QByteArray result = *this; | - |
1746 | q_toPercentEncoding(&result, exclude.nulTerminated().constData(), include2.nulTerminated().constData(), percent); | - |
1747 | | - |
1748 | return result; executed: return result; Execution Count:26 | 26 |
1749 | } | - |
1750 | | - |
1751 | | - |
| | |