| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qstring.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | - | |||||||||||||||||||||||||
| 13 | - | |||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||
| 15 | int qFindString(const QChar *haystack, int haystackLen, int from, | - | ||||||||||||||||||||||||
| 16 | const QChar *needle, int needleLen, Qt::CaseSensitivity cs); | - | ||||||||||||||||||||||||
| 17 | int qFindStringBoyerMoore(const QChar *haystack, int haystackLen, int from, | - | ||||||||||||||||||||||||
| 18 | const QChar *needle, int needleLen, Qt::CaseSensitivity cs); | - | ||||||||||||||||||||||||
| 19 | static inline int qt_last_index_of(const QChar *haystack, int haystackLen, QChar needle, | - | ||||||||||||||||||||||||
| 20 | int from, Qt::CaseSensitivity cs); | - | ||||||||||||||||||||||||
| 21 | static inline int qt_string_count(const QChar *haystack, int haystackLen, | - | ||||||||||||||||||||||||
| 22 | const QChar *needle, int needleLen, | - | ||||||||||||||||||||||||
| 23 | Qt::CaseSensitivity cs); | - | ||||||||||||||||||||||||
| 24 | static inline int qt_string_count(const QChar *haystack, int haystackLen, | - | ||||||||||||||||||||||||
| 25 | QChar needle, Qt::CaseSensitivity cs); | - | ||||||||||||||||||||||||
| 26 | static inline int qt_find_latin1_string(const QChar *hay, int size, QLatin1String needle, | - | ||||||||||||||||||||||||
| 27 | int from, Qt::CaseSensitivity cs); | - | ||||||||||||||||||||||||
| 28 | static inline bool qt_starts_with(const QChar *haystack, int haystackLen, | - | ||||||||||||||||||||||||
| 29 | const QChar *needle, int needleLen, Qt::CaseSensitivity cs); | - | ||||||||||||||||||||||||
| 30 | static inline bool qt_starts_with(const QChar *haystack, int haystackLen, | - | ||||||||||||||||||||||||
| 31 | QLatin1String needle, Qt::CaseSensitivity cs); | - | ||||||||||||||||||||||||
| 32 | static inline bool qt_ends_with(const QChar *haystack, int haystackLen, | - | ||||||||||||||||||||||||
| 33 | const QChar *needle, int needleLen, Qt::CaseSensitivity cs); | - | ||||||||||||||||||||||||
| 34 | static inline bool qt_ends_with(const QChar *haystack, int haystackLen, | - | ||||||||||||||||||||||||
| 35 | QLatin1String needle, Qt::CaseSensitivity cs); | - | ||||||||||||||||||||||||
| 36 | - | |||||||||||||||||||||||||
| 37 | - | |||||||||||||||||||||||||
| 38 | namespace { | - | ||||||||||||||||||||||||
| 39 | template <uint MaxCount> struct UnrollTailLoop | - | ||||||||||||||||||||||||
| 40 | { | - | ||||||||||||||||||||||||
| 41 | template <typename RetType, typename Functor1, typename Functor2> | - | ||||||||||||||||||||||||
| 42 | static inline RetType exec(int count, RetType returnIfExited, Functor1 loopCheck, Functor2 returnIfFailed, int i = 0) | - | ||||||||||||||||||||||||
| 43 | { | - | ||||||||||||||||||||||||
| 44 | if (!count) | - | ||||||||||||||||||||||||
| 45 | return returnIfExited; | - | ||||||||||||||||||||||||
| 46 | - | |||||||||||||||||||||||||
| 47 | bool check = loopCheck(i); | - | ||||||||||||||||||||||||
| 48 | if (check) { | - | ||||||||||||||||||||||||
| 49 | const RetType &retval = returnIfFailed(i); | - | ||||||||||||||||||||||||
| 50 | return retval; | - | ||||||||||||||||||||||||
| 51 | } | - | ||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||
| 53 | return UnrollTailLoop<MaxCount - 1>::exec(count - 1, returnIfExited, loopCheck, returnIfFailed, i + 1); | - | ||||||||||||||||||||||||
| 54 | } | - | ||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||
| 56 | template <typename Functor> | - | ||||||||||||||||||||||||
| 57 | static inline void exec(int count, Functor code) | - | ||||||||||||||||||||||||
| 58 | { | - | ||||||||||||||||||||||||
| 59 | - | |||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||
| 61 | - | |||||||||||||||||||||||||
| 62 | - | |||||||||||||||||||||||||
| 63 | exec(count, 0, [=](int i) -> bool { code(i); return false; }, [](int) { return 0; }); | - | ||||||||||||||||||||||||
| 64 | } | - | ||||||||||||||||||||||||
| 65 | }; | - | ||||||||||||||||||||||||
| 66 | template <> template <typename RetType, typename Functor1, typename Functor2> | - | ||||||||||||||||||||||||
| 67 | inline RetType UnrollTailLoop<0>::exec(int, RetType returnIfExited, Functor1, Functor2, int) | - | ||||||||||||||||||||||||
| 68 | { | - | ||||||||||||||||||||||||
| 69 | return returnIfExited; | - | ||||||||||||||||||||||||
| 70 | } | - | ||||||||||||||||||||||||
| 71 | } | - | ||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||
| 74 | - | |||||||||||||||||||||||||
| 75 | void qt_from_latin1(ushort *dst, const char *str, size_t size) noexcept | - | ||||||||||||||||||||||||
| 76 | { | - | ||||||||||||||||||||||||
| 77 | - | |||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||
| 79 | - | |||||||||||||||||||||||||
| 80 | - | |||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||
| 82 | const char *e = str + size; | - | ||||||||||||||||||||||||
| 83 | qptrdiff offset = 0; | - | ||||||||||||||||||||||||
| 84 | - | |||||||||||||||||||||||||
| 85 | - | |||||||||||||||||||||||||
| 86 | for ( ; str + offset + 15 < e
| 1702045-2360203 | ||||||||||||||||||||||||
| 87 | const __m128i chunk = _mm_loadu_si128((const __m128i*)(str + offset)); | - | ||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||
| 89 | - | |||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||
| 92 | - | |||||||||||||||||||||||||
| 93 | - | |||||||||||||||||||||||||
| 94 | - | |||||||||||||||||||||||||
| 95 | const __m128i nullMask = _mm_set1_epi32(0); | - | ||||||||||||||||||||||||
| 96 | - | |||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | const __m128i firstHalf = _mm_unpacklo_epi8(chunk, nullMask); | - | ||||||||||||||||||||||||
| 99 | _mm_storeu_si128((__m128i*)(dst + offset), firstHalf); | - | ||||||||||||||||||||||||
| 100 | - | |||||||||||||||||||||||||
| 101 | - | |||||||||||||||||||||||||
| 102 | const __m128i secondHalf = _mm_unpackhi_epi8 (chunk, nullMask); | - | ||||||||||||||||||||||||
| 103 | _mm_storeu_si128((__m128i*)(dst + offset + 8), secondHalf); | - | ||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||
| 105 | } executed 1702045 times by 504 tests: end of blockExecuted by:
| 1702045 | ||||||||||||||||||||||||
| 106 | - | |||||||||||||||||||||||||
| 107 | size = size % 16; | - | ||||||||||||||||||||||||
| 108 | dst += offset; | - | ||||||||||||||||||||||||
| 109 | str += offset; | - | ||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||
| 111 | return executed 2360203 times by 686 tests: UnrollTailLoop<15>::exec(int(size), [=](int i) { dst[i] = (uchar)str[i]; });return UnrollTailLoop<15>::exec(int(size), [=](int i) { dst[i] = (uchar)str[i]; });Executed by:
executed 2360203 times by 686 tests: return UnrollTailLoop<15>::exec(int(size), [=](int i) { dst[i] = (uchar)str[i]; });Executed by:
| 2360203 | ||||||||||||||||||||||||
| 112 | while dead code: (size--)while (size--) *dst++ = (uchar)*str++;dead code: while (size--) *dst++ = (uchar)*str++; | - | ||||||||||||||||||||||||
| 113 | *dst++ = (uchar)*str++; dead code: while (size--) *dst++ = (uchar)*str++; | - | ||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||
| 115 | } | - | ||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||
| 118 | static inline __m128i mergeQuestionMarks(__m128i chunk) | - | ||||||||||||||||||||||||
| 119 | { | - | ||||||||||||||||||||||||
| 120 | const __m128i questionMark = _mm_set1_epi16('?'); | - | ||||||||||||||||||||||||
| 121 | const __m128i signedBitOffset = _mm_set1_epi16(short(0x8000)); | - | ||||||||||||||||||||||||
| 122 | const __m128i thresholdMask = _mm_set1_epi16(short(0xff + 0x8000)); | - | ||||||||||||||||||||||||
| 123 | - | |||||||||||||||||||||||||
| 124 | const __m128i signedChunk = _mm_add_epi16(chunk, signedBitOffset); | - | ||||||||||||||||||||||||
| 125 | const __m128i offLimitMask = _mm_cmpgt_epi16(signedChunk, thresholdMask); | - | ||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||
| 128 | - | |||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||
| 133 | const __m128i offLimitQuestionMark = _mm_and_si128(offLimitMask, questionMark); | - | ||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||
| 136 | - | |||||||||||||||||||||||||
| 137 | const __m128i correctBytes = _mm_andnot_si128(offLimitMask, chunk); | - | ||||||||||||||||||||||||
| 138 | - | |||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||
| 140 | chunk = _mm_or_si128(correctBytes, offLimitQuestionMark); | - | ||||||||||||||||||||||||
| 141 | - | |||||||||||||||||||||||||
| 142 | - | |||||||||||||||||||||||||
| 143 | return chunk; | - | ||||||||||||||||||||||||
| 144 | } | - | ||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||
| 146 | - | |||||||||||||||||||||||||
| 147 | static void qt_to_latin1(uchar *dst, const ushort *src, int length) | - | ||||||||||||||||||||||||
| 148 | { | - | ||||||||||||||||||||||||
| 149 | - | |||||||||||||||||||||||||
| 150 | uchar *e = dst + length; | - | ||||||||||||||||||||||||
| 151 | qptrdiff offset = 0; | - | ||||||||||||||||||||||||
| 152 | - | |||||||||||||||||||||||||
| 153 | - | |||||||||||||||||||||||||
| 154 | for ( ; dst + offset + 15 < e; offset += 16) { | - | ||||||||||||||||||||||||
| 155 | __m128i chunk1 = _mm_loadu_si128((const __m128i*)(src + offset)); | - | ||||||||||||||||||||||||
| 156 | chunk1 = mergeQuestionMarks(chunk1); | - | ||||||||||||||||||||||||
| 157 | - | |||||||||||||||||||||||||
| 158 | __m128i chunk2 = _mm_loadu_si128((const __m128i*)(src + offset + 8)); | - | ||||||||||||||||||||||||
| 159 | chunk2 = mergeQuestionMarks(chunk2); | - | ||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||
| 161 | - | |||||||||||||||||||||||||
| 162 | const __m128i result = _mm_packus_epi16(chunk1, chunk2); | - | ||||||||||||||||||||||||
| 163 | _mm_storeu_si128((__m128i*)(dst + offset), result); | - | ||||||||||||||||||||||||
| 164 | } | - | ||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||
| 166 | length = length % 16; | - | ||||||||||||||||||||||||
| 167 | dst += offset; | - | ||||||||||||||||||||||||
| 168 | src += offset; | - | ||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||
| 171 | return UnrollTailLoop<15>::exec(length, [=](int i) { dst[i] = (src[i]>0xff) ? '?' : (uchar) src[i]; }); | - | ||||||||||||||||||||||||
| 172 | while dead code: (length--) {while (length--) { *dst++ = (*src>0xff) ? '?' : (uchar) *src; ++src; }dead code: while (length--) { *dst++ = (*src>0xff) ? '?' : (uchar) *src; ++src; } | - | ||||||||||||||||||||||||
| 173 | *dst++ = (*src>0xff) ? '?' : (uchar) *src; dead code: while (length--) { *dst++ = (*src>0xff) ? '?' : (uchar) *src; ++src; } | - | ||||||||||||||||||||||||
| 174 | ++src; dead code: while (length--) { *dst++ = (*src>0xff) ? '?' : (uchar) *src; ++src; } | - | ||||||||||||||||||||||||
| 175 | } dead code: while (length--) { *dst++ = (*src>0xff) ? '?' : (uchar) *src; ++src; } | - | ||||||||||||||||||||||||
| 176 | - | |||||||||||||||||||||||||
| 177 | } | - | ||||||||||||||||||||||||
| 178 | - | |||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||
| 180 | static int ucstricmp(const ushort *a, const ushort *ae, const ushort *b, const ushort *be) | - | ||||||||||||||||||||||||
| 181 | { | - | ||||||||||||||||||||||||
| 182 | if (a == b) | - | ||||||||||||||||||||||||
| 183 | return (ae - be); | - | ||||||||||||||||||||||||
| 184 | if (a == 0) | - | ||||||||||||||||||||||||
| 185 | return 1; | - | ||||||||||||||||||||||||
| 186 | if (b == 0) | - | ||||||||||||||||||||||||
| 187 | return -1; | - | ||||||||||||||||||||||||
| 188 | - | |||||||||||||||||||||||||
| 189 | const ushort *e = ae; | - | ||||||||||||||||||||||||
| 190 | if (be - b < ae - a) | - | ||||||||||||||||||||||||
| 191 | e = a + (be - b); | - | ||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||
| 193 | uint alast = 0; | - | ||||||||||||||||||||||||
| 194 | uint blast = 0; | - | ||||||||||||||||||||||||
| 195 | while (a < e) { | - | ||||||||||||||||||||||||
| 196 | - | |||||||||||||||||||||||||
| 197 | - | |||||||||||||||||||||||||
| 198 | - | |||||||||||||||||||||||||
| 199 | int diff = foldCase(*a, alast) - foldCase(*b, blast); | - | ||||||||||||||||||||||||
| 200 | if ((diff)) | - | ||||||||||||||||||||||||
| 201 | return diff; | - | ||||||||||||||||||||||||
| 202 | ++a; | - | ||||||||||||||||||||||||
| 203 | ++b; | - | ||||||||||||||||||||||||
| 204 | } | - | ||||||||||||||||||||||||
| 205 | if (a == ae) { | - | ||||||||||||||||||||||||
| 206 | if (b == be) | - | ||||||||||||||||||||||||
| 207 | return 0; | - | ||||||||||||||||||||||||
| 208 | return -1; | - | ||||||||||||||||||||||||
| 209 | } | - | ||||||||||||||||||||||||
| 210 | return 1; | - | ||||||||||||||||||||||||
| 211 | } | - | ||||||||||||||||||||||||
| 212 | - | |||||||||||||||||||||||||
| 213 | - | |||||||||||||||||||||||||
| 214 | static int ucstricmp(const ushort *a, const ushort *ae, const uchar *b, const uchar *be) | - | ||||||||||||||||||||||||
| 215 | { | - | ||||||||||||||||||||||||
| 216 | if (a == 0) { | - | ||||||||||||||||||||||||
| 217 | if (b == 0) | - | ||||||||||||||||||||||||
| 218 | return 0; | - | ||||||||||||||||||||||||
| 219 | return 1; | - | ||||||||||||||||||||||||
| 220 | } | - | ||||||||||||||||||||||||
| 221 | if (b == 0) | - | ||||||||||||||||||||||||
| 222 | return -1; | - | ||||||||||||||||||||||||
| 223 | - | |||||||||||||||||||||||||
| 224 | const ushort *e = ae; | - | ||||||||||||||||||||||||
| 225 | if (be - b < ae - a) | - | ||||||||||||||||||||||||
| 226 | e = a + (be - b); | - | ||||||||||||||||||||||||
| 227 | - | |||||||||||||||||||||||||
| 228 | while (a < e) { | - | ||||||||||||||||||||||||
| 229 | int diff = foldCase(*a) - foldCase(*b); | - | ||||||||||||||||||||||||
| 230 | if ((diff)) | - | ||||||||||||||||||||||||
| 231 | return diff; | - | ||||||||||||||||||||||||
| 232 | ++a; | - | ||||||||||||||||||||||||
| 233 | ++b; | - | ||||||||||||||||||||||||
| 234 | } | - | ||||||||||||||||||||||||
| 235 | if (a == ae) { | - | ||||||||||||||||||||||||
| 236 | if (b == be) | - | ||||||||||||||||||||||||
| 237 | return 0; | - | ||||||||||||||||||||||||
| 238 | return -1; | - | ||||||||||||||||||||||||
| 239 | } | - | ||||||||||||||||||||||||
| 240 | return 1; | - | ||||||||||||||||||||||||
| 241 | } | - | ||||||||||||||||||||||||
| 242 | static int ucstrncmp(const QChar *a, const QChar *b, int l) | - | ||||||||||||||||||||||||
| 243 | { | - | ||||||||||||||||||||||||
| 244 | const char *ptr = reinterpret_cast<const char*>(a); | - | ||||||||||||||||||||||||
| 245 | qptrdiff distance = reinterpret_cast<const char*>(b) - ptr; | - | ||||||||||||||||||||||||
| 246 | a += l & ~7; | - | ||||||||||||||||||||||||
| 247 | b += l & ~7; | - | ||||||||||||||||||||||||
| 248 | l &= 7; | - | ||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||
| 250 | - | |||||||||||||||||||||||||
| 251 | for ( ; ptr + 15 < reinterpret_cast<const char *>(a); ptr += 16) { | - | ||||||||||||||||||||||||
| 252 | __m128i a_data = _mm_loadu_si128((const __m128i*)ptr); | - | ||||||||||||||||||||||||
| 253 | __m128i b_data = _mm_loadu_si128((const __m128i*)(ptr + distance)); | - | ||||||||||||||||||||||||
| 254 | __m128i result = _mm_cmpeq_epi16(a_data, b_data); | - | ||||||||||||||||||||||||
| 255 | uint mask = ~_mm_movemask_epi8(result); | - | ||||||||||||||||||||||||
| 256 | if (ushort(mask)) { | - | ||||||||||||||||||||||||
| 257 | - | |||||||||||||||||||||||||
| 258 | uint idx = uint(__bsfd(mask)); | - | ||||||||||||||||||||||||
| 259 | return reinterpret_cast<const QChar *>(ptr + idx)->unicode() | - | ||||||||||||||||||||||||
| 260 | - reinterpret_cast<const QChar *>(ptr + distance + idx)->unicode(); | - | ||||||||||||||||||||||||
| 261 | } | - | ||||||||||||||||||||||||
| 262 | } | - | ||||||||||||||||||||||||
| 263 | - | |||||||||||||||||||||||||
| 264 | const auto &lambda = [=](int i) -> int { | - | ||||||||||||||||||||||||
| 265 | return reinterpret_cast<const QChar *>(ptr)[i].unicode() | - | ||||||||||||||||||||||||
| 266 | - reinterpret_cast<const QChar *>(ptr + distance)[i].unicode(); | - | ||||||||||||||||||||||||
| 267 | }; | - | ||||||||||||||||||||||||
| 268 | return UnrollTailLoop<7>::exec(l, 0, lambda, lambda); | - | ||||||||||||||||||||||||
| 269 | - | |||||||||||||||||||||||||
| 270 | - | |||||||||||||||||||||||||
| 271 | if dead code: (!l)if (!l) return 0;dead code: if (!l) return 0; | - | ||||||||||||||||||||||||
| 272 | return 0; dead code: if (!l) return 0; | - | ||||||||||||||||||||||||
| 273 | - | |||||||||||||||||||||||||
| 274 | - | |||||||||||||||||||||||||
| 275 | if dead code: ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) {if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } }dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 276 | - | |||||||||||||||||||||||||
| 277 | if (reinterpret_cast<quintptr>(a) & 2) { dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 278 | - | |||||||||||||||||||||||||
| 279 | - | |||||||||||||||||||||||||
| 280 | if (*a != *b) dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 281 | return a->unicode() - b->unicode(); dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 282 | --l; dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 283 | ++a; dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 284 | ++b; dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 285 | - | |||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||
| 287 | } dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||
| 290 | - | |||||||||||||||||||||||||
| 291 | const quint32 *da = reinterpret_cast<const quint32 *>(a); dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 292 | const quint32 *db = reinterpret_cast<const quint32 *>(b); dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 293 | const quint32 *e = da + (l >> 1); dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 294 | for ( ; da != e; ++da, ++db) { dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 295 | if (*da != *db) { dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 296 | a = reinterpret_cast<const QChar *>(da); dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 297 | b = reinterpret_cast<const QChar *>(db); dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 298 | if (*a != *b) dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 299 | return a->unicode() - b->unicode(); dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 300 | return a[1].unicode() - b[1].unicode(); dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 301 | } dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 302 | } dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 303 | - | |||||||||||||||||||||||||
| 304 | - | |||||||||||||||||||||||||
| 305 | a = reinterpret_cast<const QChar *>(da); dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 306 | b = reinterpret_cast<const QChar *>(db); dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 307 | return (l & 1) ? a->unicode() - b->unicode() : 0; dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 308 | } else { dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||
| 310 | const QChar *e = a + l; dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 311 | for ( ; a != e; ++a, ++b) { dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 312 | if (*a != *b) dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 313 | return a->unicode() - b->unicode(); dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 314 | } dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 315 | } dead code: if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) { if (reinterpret_cast<quintptr>(a) & 2) { if (*a != *b) return a->unicode() - b->unicode(); --l; ++a; ++b; } const quint32 *da = reinterpret_cast<const quint32 *>(a); const q...e(); } } a = reinterpret_cast<const QChar *>(da); b = reinterpret_cast<const QChar *>(db); return (l & 1) ? a->unicode() - b->unicode() : 0; } else { const QChar *e = a + l; for ( ; a != e; ++a, ++b) { if (*a != *b) return a->unicode() - b->unicode(); } } | - | ||||||||||||||||||||||||
| 316 | return dead code: 0;return 0;dead code: return 0; | - | ||||||||||||||||||||||||
| 317 | } | - | ||||||||||||||||||||||||
| 318 | - | |||||||||||||||||||||||||
| 319 | static int ucstrncmp(const QChar *a, const uchar *c, int l) | - | ||||||||||||||||||||||||
| 320 | { | - | ||||||||||||||||||||||||
| 321 | const ushort *uc = reinterpret_cast<const ushort *>(a); | - | ||||||||||||||||||||||||
| 322 | const ushort *e = uc + l; | - | ||||||||||||||||||||||||
| 323 | - | |||||||||||||||||||||||||
| 324 | - | |||||||||||||||||||||||||
| 325 | __m128i nullmask = _mm_setzero_si128(); | - | ||||||||||||||||||||||||
| 326 | qptrdiff offset = 0; | - | ||||||||||||||||||||||||
| 327 | - | |||||||||||||||||||||||||
| 328 | - | |||||||||||||||||||||||||
| 329 | - | |||||||||||||||||||||||||
| 330 | for ( ; uc + offset + 15 < e; offset += 16) { | - | ||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||
| 332 | - | |||||||||||||||||||||||||
| 333 | __m128i chunk = _mm_loadu_si128((const __m128i*)(c + offset)); | - | ||||||||||||||||||||||||
| 334 | __m128i firstHalf = _mm_unpacklo_epi8(chunk, nullmask); | - | ||||||||||||||||||||||||
| 335 | __m128i secondHalf = _mm_unpackhi_epi8(chunk, nullmask); | - | ||||||||||||||||||||||||
| 336 | - | |||||||||||||||||||||||||
| 337 | - | |||||||||||||||||||||||||
| 338 | __m128i ucdata1 = _mm_loadu_si128((const __m128i*)(uc + offset)); | - | ||||||||||||||||||||||||
| 339 | __m128i ucdata2 = _mm_loadu_si128((const __m128i*)(uc + offset + 8)); | - | ||||||||||||||||||||||||
| 340 | __m128i result1 = _mm_cmpeq_epi16(firstHalf, ucdata1); | - | ||||||||||||||||||||||||
| 341 | __m128i result2 = _mm_cmpeq_epi16(secondHalf, ucdata2); | - | ||||||||||||||||||||||||
| 342 | - | |||||||||||||||||||||||||
| 343 | uint mask = ~(_mm_movemask_epi8(result1) | _mm_movemask_epi8(result2) << 16); | - | ||||||||||||||||||||||||
| 344 | - | |||||||||||||||||||||||||
| 345 | if (mask) { | - | ||||||||||||||||||||||||
| 346 | - | |||||||||||||||||||||||||
| 347 | uint idx = uint(__bsfd(mask)); | - | ||||||||||||||||||||||||
| 348 | return uc[offset + idx / 2] - c[offset + idx / 2]; | - | ||||||||||||||||||||||||
| 349 | } | - | ||||||||||||||||||||||||
| 350 | } | - | ||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||
| 352 | - | |||||||||||||||||||||||||
| 353 | enum { MaxTailLength = 7 }; | - | ||||||||||||||||||||||||
| 354 | - | |||||||||||||||||||||||||
| 355 | if (uc + offset + 7 < e) { | - | ||||||||||||||||||||||||
| 356 | - | |||||||||||||||||||||||||
| 357 | __m128i chunk = _mm_cvtsi64_si128(qFromUnaligned<long long>(c + offset)); | - | ||||||||||||||||||||||||
| 358 | __m128i secondHalf = _mm_unpacklo_epi8(chunk, nullmask); | - | ||||||||||||||||||||||||
| 359 | - | |||||||||||||||||||||||||
| 360 | __m128i ucdata = _mm_loadu_si128((const __m128i*)(uc + offset)); | - | ||||||||||||||||||||||||
| 361 | __m128i result = _mm_cmpeq_epi16(secondHalf, ucdata); | - | ||||||||||||||||||||||||
| 362 | uint mask = ~_mm_movemask_epi8(result); | - | ||||||||||||||||||||||||
| 363 | if (ushort(mask)) { | - | ||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||
| 365 | uint idx = uint(__bsfd(mask)); | - | ||||||||||||||||||||||||
| 366 | return uc[offset + idx / 2] - c[offset + idx / 2]; | - | ||||||||||||||||||||||||
| 367 | } | - | ||||||||||||||||||||||||
| 368 | - | |||||||||||||||||||||||||
| 369 | - | |||||||||||||||||||||||||
| 370 | offset += 8; | - | ||||||||||||||||||||||||
| 371 | } | - | ||||||||||||||||||||||||
| 372 | - | |||||||||||||||||||||||||
| 373 | - | |||||||||||||||||||||||||
| 374 | - | |||||||||||||||||||||||||
| 375 | - | |||||||||||||||||||||||||
| 376 | - | |||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||
| 378 | - | |||||||||||||||||||||||||
| 379 | uc += offset; | - | ||||||||||||||||||||||||
| 380 | c += offset; | - | ||||||||||||||||||||||||
| 381 | - | |||||||||||||||||||||||||
| 382 | - | |||||||||||||||||||||||||
| 383 | const auto &lambda = [=](int i) { return uc[i] - ushort(c[i]); }; | - | ||||||||||||||||||||||||
| 384 | return UnrollTailLoop<MaxTailLength>::exec(e - uc, 0, lambda, lambda); | - | ||||||||||||||||||||||||
| 385 | - | |||||||||||||||||||||||||
| 386 | - | |||||||||||||||||||||||||
| 387 | - | |||||||||||||||||||||||||
| 388 | while dead code: (uc < e) {while (uc < e) { int diff = *uc - *c; if (diff) return diff; uc++, c++; }dead code: while (uc < e) { int diff = *uc - *c; if (diff) return diff; uc++, c++; } | - | ||||||||||||||||||||||||
| 389 | int diff = *uc - *c; dead code: while (uc < e) { int diff = *uc - *c; if (diff) return diff; uc++, c++; } | - | ||||||||||||||||||||||||
| 390 | if (diff) dead code: while (uc < e) { int diff = *uc - *c; if (diff) return diff; uc++, c++; } | - | ||||||||||||||||||||||||
| 391 | return diff; dead code: while (uc < e) { int diff = *uc - *c; if (diff) return diff; uc++, c++; } | - | ||||||||||||||||||||||||
| 392 | uc++, c++; dead code: while (uc < e) { int diff = *uc - *c; if (diff) return diff; uc++, c++; } | - | ||||||||||||||||||||||||
| 393 | } dead code: while (uc < e) { int diff = *uc - *c; if (diff) return diff; uc++, c++; } | - | ||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||
| 395 | return dead code: 0;return 0;dead code: return 0; | - | ||||||||||||||||||||||||
| 396 | } | - | ||||||||||||||||||||||||
| 397 | - | |||||||||||||||||||||||||
| 398 | - | |||||||||||||||||||||||||
| 399 | static int ucstrcmp(const QChar *a, int alen, const QChar *b, int blen) | - | ||||||||||||||||||||||||
| 400 | { | - | ||||||||||||||||||||||||
| 401 | if (a == b && alen == blen) | - | ||||||||||||||||||||||||
| 402 | return 0; | - | ||||||||||||||||||||||||
| 403 | int l = qMin(alen, blen); | - | ||||||||||||||||||||||||
| 404 | int cmp = ucstrncmp(a, b, l); | - | ||||||||||||||||||||||||
| 405 | return cmp ? cmp : (alen-blen); | - | ||||||||||||||||||||||||
| 406 | } | - | ||||||||||||||||||||||||
| 407 | - | |||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||
| 409 | static int ucstrnicmp(const ushort *a, const ushort *b, int l) | - | ||||||||||||||||||||||||
| 410 | { | - | ||||||||||||||||||||||||
| 411 | return ucstricmp(a, a + l, b, b + l); | - | ||||||||||||||||||||||||
| 412 | } | - | ||||||||||||||||||||||||
| 413 | - | |||||||||||||||||||||||||
| 414 | static bool qMemEquals(const quint16 *a, const quint16 *b, int length) | - | ||||||||||||||||||||||||
| 415 | { | - | ||||||||||||||||||||||||
| 416 | if (a == b || !length) | - | ||||||||||||||||||||||||
| 417 | return true; | - | ||||||||||||||||||||||||
| 418 | - | |||||||||||||||||||||||||
| 419 | return ucstrncmp(reinterpret_cast<const QChar *>(a), reinterpret_cast<const QChar *>(b), length) == 0; | - | ||||||||||||||||||||||||
| 420 | } | - | ||||||||||||||||||||||||
| 421 | - | |||||||||||||||||||||||||
| 422 | static int ucstrcmp(const QChar *a, int alen, const uchar *b, int blen) | - | ||||||||||||||||||||||||
| 423 | { | - | ||||||||||||||||||||||||
| 424 | int l = qMin(alen, blen); | - | ||||||||||||||||||||||||
| 425 | int cmp = ucstrncmp(a, b, l); | - | ||||||||||||||||||||||||
| 426 | return cmp ? cmp : (alen-blen); | - | ||||||||||||||||||||||||
| 427 | } | - | ||||||||||||||||||||||||
| 428 | static int findChar(const QChar *str, int len, QChar ch, int from, | - | ||||||||||||||||||||||||
| 429 | Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 430 | { | - | ||||||||||||||||||||||||
| 431 | const ushort *s = (const ushort *)str; | - | ||||||||||||||||||||||||
| 432 | ushort c = ch.unicode(); | - | ||||||||||||||||||||||||
| 433 | if (from < 0) | - | ||||||||||||||||||||||||
| 434 | from = qMax(from + len, 0); | - | ||||||||||||||||||||||||
| 435 | if (from < len) { | - | ||||||||||||||||||||||||
| 436 | const ushort *n = s + from; | - | ||||||||||||||||||||||||
| 437 | const ushort *e = s + len; | - | ||||||||||||||||||||||||
| 438 | if (cs == Qt::CaseSensitive) { | - | ||||||||||||||||||||||||
| 439 | - | |||||||||||||||||||||||||
| 440 | __m128i mch = _mm_set1_epi32(c | (c << 16)); | - | ||||||||||||||||||||||||
| 441 | - | |||||||||||||||||||||||||
| 442 | - | |||||||||||||||||||||||||
| 443 | for (const ushort *next = n + 8; next <= e; n = next, next += 8) { | - | ||||||||||||||||||||||||
| 444 | __m128i data = _mm_loadu_si128((const __m128i*)n); | - | ||||||||||||||||||||||||
| 445 | __m128i result = _mm_cmpeq_epi16(data, mch); | - | ||||||||||||||||||||||||
| 446 | uint mask = _mm_movemask_epi8(result); | - | ||||||||||||||||||||||||
| 447 | if (ushort(mask)) { | - | ||||||||||||||||||||||||
| 448 | - | |||||||||||||||||||||||||
| 449 | - | |||||||||||||||||||||||||
| 450 | return (reinterpret_cast<const char *>(n) - reinterpret_cast<const char *>(s) | - | ||||||||||||||||||||||||
| 451 | + __bsfd(mask)) >> 1; | - | ||||||||||||||||||||||||
| 452 | } | - | ||||||||||||||||||||||||
| 453 | } | - | ||||||||||||||||||||||||
| 454 | - | |||||||||||||||||||||||||
| 455 | - | |||||||||||||||||||||||||
| 456 | return UnrollTailLoop<7>::exec(e - n, -1, | - | ||||||||||||||||||||||||
| 457 | [=](int i) { return n[i] == c; }, | - | ||||||||||||||||||||||||
| 458 | [=](int i) { return n - s + i; }); | - | ||||||||||||||||||||||||
| 459 | - | |||||||||||||||||||||||||
| 460 | - | |||||||||||||||||||||||||
| 461 | -- dead code: n;--n;dead code: --n; | - | ||||||||||||||||||||||||
| 462 | while dead code: (++n != e)while (++n != e) if (*n == c) return n - s;dead code: while (++n != e) if (*n == c) return n - s; | - | ||||||||||||||||||||||||
| 463 | if (*n == c) dead code: while (++n != e) if (*n == c) return n - s; | - | ||||||||||||||||||||||||
| 464 | return n - s; dead code: while (++n != e) if (*n == c) return n - s; | - | ||||||||||||||||||||||||
| 465 | } else { | - | ||||||||||||||||||||||||
| 466 | c = foldCase(c); | - | ||||||||||||||||||||||||
| 467 | --n; | - | ||||||||||||||||||||||||
| 468 | while (++n != e) | - | ||||||||||||||||||||||||
| 469 | if (foldCase(*n) == c) | - | ||||||||||||||||||||||||
| 470 | return n - s; | - | ||||||||||||||||||||||||
| 471 | } | - | ||||||||||||||||||||||||
| 472 | } | - | ||||||||||||||||||||||||
| 473 | return -1; | - | ||||||||||||||||||||||||
| 474 | } | - | ||||||||||||||||||||||||
| 475 | - | |||||||||||||||||||||||||
| 476 | - | |||||||||||||||||||||||||
| 477 | - | |||||||||||||||||||||||||
| 478 | - | |||||||||||||||||||||||||
| 479 | - | |||||||||||||||||||||||||
| 480 | - | |||||||||||||||||||||||||
| 481 | inline bool qIsUpper(char ch) | - | ||||||||||||||||||||||||
| 482 | { | - | ||||||||||||||||||||||||
| 483 | return ch >= 'A' && ch <= 'Z'; | - | ||||||||||||||||||||||||
| 484 | } | - | ||||||||||||||||||||||||
| 485 | - | |||||||||||||||||||||||||
| 486 | inline bool qIsDigit(char ch) | - | ||||||||||||||||||||||||
| 487 | { | - | ||||||||||||||||||||||||
| 488 | return ch >= '0' && ch <= '9'; | - | ||||||||||||||||||||||||
| 489 | } | - | ||||||||||||||||||||||||
| 490 | - | |||||||||||||||||||||||||
| 491 | inline char qToLower(char ch) | - | ||||||||||||||||||||||||
| 492 | { | - | ||||||||||||||||||||||||
| 493 | if (ch >= 'A' && ch <= 'Z') | - | ||||||||||||||||||||||||
| 494 | return ch - 'A' + 'a'; | - | ||||||||||||||||||||||||
| 495 | else | - | ||||||||||||||||||||||||
| 496 | return ch; | - | ||||||||||||||||||||||||
| 497 | } | - | ||||||||||||||||||||||||
| 498 | - | |||||||||||||||||||||||||
| 499 | - | |||||||||||||||||||||||||
| 500 | const QString::Null QString::null = { }; | - | ||||||||||||||||||||||||
| 501 | int QString::toUcs4_helper(const ushort *uc, int length, uint *out) | - | ||||||||||||||||||||||||
| 502 | { | - | ||||||||||||||||||||||||
| 503 | int count = 0; | - | ||||||||||||||||||||||||
| 504 | - | |||||||||||||||||||||||||
| 505 | QStringIterator i(reinterpret_cast<const QChar *>(uc), reinterpret_cast<const QChar *>(uc + length)); | - | ||||||||||||||||||||||||
| 506 | while (i.hasNext()) | - | ||||||||||||||||||||||||
| 507 | out[count++] = i.next(); | - | ||||||||||||||||||||||||
| 508 | - | |||||||||||||||||||||||||
| 509 | return count; | - | ||||||||||||||||||||||||
| 510 | } | - | ||||||||||||||||||||||||
| 511 | QString::QString(const QChar *unicode, int size) | - | ||||||||||||||||||||||||
| 512 | { | - | ||||||||||||||||||||||||
| 513 | if (!unicode) { | - | ||||||||||||||||||||||||
| 514 | d = Data::sharedNull(); | - | ||||||||||||||||||||||||
| 515 | } else { | - | ||||||||||||||||||||||||
| 516 | if (size < 0) { | - | ||||||||||||||||||||||||
| 517 | size = 0; | - | ||||||||||||||||||||||||
| 518 | while (!unicode[size].isNull()) | - | ||||||||||||||||||||||||
| 519 | ++size; | - | ||||||||||||||||||||||||
| 520 | } | - | ||||||||||||||||||||||||
| 521 | if (!size) { | - | ||||||||||||||||||||||||
| 522 | d = Data::allocate(0); | - | ||||||||||||||||||||||||
| 523 | } else { | - | ||||||||||||||||||||||||
| 524 | d = Data::allocate(size + 1); | - | ||||||||||||||||||||||||
| 525 | do { if (!(d)) qBadAlloc(); } while (0); | - | ||||||||||||||||||||||||
| 526 | d->size = size; | - | ||||||||||||||||||||||||
| 527 | memcpy(d->data(), unicode, size * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 528 | d->data()[size] = '\0'; | - | ||||||||||||||||||||||||
| 529 | } | - | ||||||||||||||||||||||||
| 530 | } | - | ||||||||||||||||||||||||
| 531 | } | - | ||||||||||||||||||||||||
| 532 | - | |||||||||||||||||||||||||
| 533 | - | |||||||||||||||||||||||||
| 534 | - | |||||||||||||||||||||||||
| 535 | - | |||||||||||||||||||||||||
| 536 | - | |||||||||||||||||||||||||
| 537 | - | |||||||||||||||||||||||||
| 538 | - | |||||||||||||||||||||||||
| 539 | QString::QString(int size, QChar ch) | - | ||||||||||||||||||||||||
| 540 | { | - | ||||||||||||||||||||||||
| 541 | if (size <= 0) { | - | ||||||||||||||||||||||||
| 542 | d = Data::allocate(0); | - | ||||||||||||||||||||||||
| 543 | } else { | - | ||||||||||||||||||||||||
| 544 | d = Data::allocate(size + 1); | - | ||||||||||||||||||||||||
| 545 | do { if (!(d)) qBadAlloc(); } while (0); | - | ||||||||||||||||||||||||
| 546 | d->size = size; | - | ||||||||||||||||||||||||
| 547 | d->data()[size] = '\0'; | - | ||||||||||||||||||||||||
| 548 | ushort *i = d->data() + size; | - | ||||||||||||||||||||||||
| 549 | ushort *b = d->data(); | - | ||||||||||||||||||||||||
| 550 | const ushort value = ch.unicode(); | - | ||||||||||||||||||||||||
| 551 | while (i != b) | - | ||||||||||||||||||||||||
| 552 | *--i = value; | - | ||||||||||||||||||||||||
| 553 | } | - | ||||||||||||||||||||||||
| 554 | } | - | ||||||||||||||||||||||||
| 555 | - | |||||||||||||||||||||||||
| 556 | - | |||||||||||||||||||||||||
| 557 | - | |||||||||||||||||||||||||
| 558 | - | |||||||||||||||||||||||||
| 559 | - | |||||||||||||||||||||||||
| 560 | - | |||||||||||||||||||||||||
| 561 | - | |||||||||||||||||||||||||
| 562 | QString::QString(int size, Qt::Initialization) | - | ||||||||||||||||||||||||
| 563 | { | - | ||||||||||||||||||||||||
| 564 | d = Data::allocate(size + 1); | - | ||||||||||||||||||||||||
| 565 | do { if (!(d)) qBadAlloc(); } while (0); | - | ||||||||||||||||||||||||
| 566 | d->size = size; | - | ||||||||||||||||||||||||
| 567 | d->data()[size] = '\0'; | - | ||||||||||||||||||||||||
| 568 | } | - | ||||||||||||||||||||||||
| 569 | QString::QString(QChar ch) | - | ||||||||||||||||||||||||
| 570 | { | - | ||||||||||||||||||||||||
| 571 | d = Data::allocate(2); | - | ||||||||||||||||||||||||
| 572 | do { if (!(d)) qBadAlloc(); } while (0); | - | ||||||||||||||||||||||||
| 573 | d->size = 1; | - | ||||||||||||||||||||||||
| 574 | d->data()[0] = ch.unicode(); | - | ||||||||||||||||||||||||
| 575 | d->data()[1] = '\0'; | - | ||||||||||||||||||||||||
| 576 | } | - | ||||||||||||||||||||||||
| 577 | void QString::resize(int size) | - | ||||||||||||||||||||||||
| 578 | { | - | ||||||||||||||||||||||||
| 579 | if (size < 0) | - | ||||||||||||||||||||||||
| 580 | size = 0; | - | ||||||||||||||||||||||||
| 581 | - | |||||||||||||||||||||||||
| 582 | if (((d)->offset != sizeof(QStringData)) && !d->ref.isShared() && size < d->size) { | - | ||||||||||||||||||||||||
| 583 | d->size = size; | - | ||||||||||||||||||||||||
| 584 | return; | - | ||||||||||||||||||||||||
| 585 | } | - | ||||||||||||||||||||||||
| 586 | - | |||||||||||||||||||||||||
| 587 | if (d->ref.isShared() || uint(size) + 1u > d->alloc) | - | ||||||||||||||||||||||||
| 588 | reallocData(uint(size) + 1u, true); | - | ||||||||||||||||||||||||
| 589 | if (d->alloc) { | - | ||||||||||||||||||||||||
| 590 | d->size = size; | - | ||||||||||||||||||||||||
| 591 | d->data()[size] = '\0'; | - | ||||||||||||||||||||||||
| 592 | } | - | ||||||||||||||||||||||||
| 593 | } | - | ||||||||||||||||||||||||
| 594 | void QString::resize(int size, QChar fillChar) | - | ||||||||||||||||||||||||
| 595 | { | - | ||||||||||||||||||||||||
| 596 | const int oldSize = length(); | - | ||||||||||||||||||||||||
| 597 | resize(size); | - | ||||||||||||||||||||||||
| 598 | const int difference = length() - oldSize; | - | ||||||||||||||||||||||||
| 599 | if (difference > 0
| 2239-28747 | ||||||||||||||||||||||||
| 600 | std::fill_n(d->begin() + oldSize, difference, fillChar.unicode()); executed 28747 times by 13 tests: std::fill_n(d->begin() + oldSize, difference, fillChar.unicode());Executed by:
| 28747 | ||||||||||||||||||||||||
| 601 | } executed 30986 times by 13 tests: end of blockExecuted by:
| 30986 | ||||||||||||||||||||||||
| 602 | void QString::reallocData(uint alloc, bool grow) | - | ||||||||||||||||||||||||
| 603 | { | - | ||||||||||||||||||||||||
| 604 | size_t blockSize; | - | ||||||||||||||||||||||||
| 605 | if (grow
| 1024048-17320378 | ||||||||||||||||||||||||
| 606 | ifauto r = qCalculateGrowingBlockSize(alloc> (uint(MaxAllocSize) -, sizeof(Data)) /QChar), sizeof(QChar)) | - | ||||||||||||||||||||||||
| qBadAlloc();Data)); | ||||||||||||||||||||||||||
| 607 | blockSize = r.size; | - | ||||||||||||||||||||||||
| 608 | alloc = qAllocMoreuint(r.elementCount); | - | ||||||||||||||||||||||||
| 609 | } executed 17320378 times by 539 tests: else {end of blockExecuted by:
| 17320378 | ||||||||||||||||||||||||
| 610 | blockSize = qCalculateBlockSize(alloc*, sizeof(QChar), sizeof(Data)) / sizeof(QChar);)); | - | ||||||||||||||||||||||||
| 611 | } executed 1024049 times by 311 tests: end of blockExecuted by:
| 1024049 | ||||||||||||||||||||||||
| 612 | - | |||||||||||||||||||||||||
| 613 | if (d->ref.isShared()
| 1718-17139594 | ||||||||||||||||||||||||
| 614 | Data::AllocationOptions allocOptions(d->capacityReserved ? Data::CapacityReserved : 0); | - | ||||||||||||||||||||||||
| 615 | Data *x = Data::allocate(alloc, allocOptions); | - | ||||||||||||||||||||||||
| 616 | do { if (!(x)
never executed: } while (0);qBadAlloc(); | 0-17141536 | ||||||||||||||||||||||||
| 617 | x->size = qMin(int(alloc) - 1, d->size); | - | ||||||||||||||||||||||||
| 618 | ::memcpy(x->data(), d->data(), x->size * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 619 | x->data()[x->size] = 0; | - | ||||||||||||||||||||||||
| 620 | if (!d->ref.deref()
| 1718-17139818 | ||||||||||||||||||||||||
| 621 | Data::deallocate(d); executed 1718 times by 12 tests: Data::deallocate(d);Executed by:
| 1718 | ||||||||||||||||||||||||
| 622 | d = x; | - | ||||||||||||||||||||||||
| 623 | } executed 17141536 times by 543 tests: else {end of blockExecuted by:
| 17141536 | ||||||||||||||||||||||||
| 624 | Data *p = static_cast<Data *>(::realloc(d, sizeof(Data) + alloc * sizeof(QChar)));blockSize)); | - | ||||||||||||||||||||||||
| 625 | do { if (!(p)
never executed: } while (0);qBadAlloc(); | 0-1202891 | ||||||||||||||||||||||||
| 626 | d = p; | - | ||||||||||||||||||||||||
| 627 | d->alloc = alloc; | - | ||||||||||||||||||||||||
| 628 | d->offset = sizeof(QStringData); | - | ||||||||||||||||||||||||
| 629 | } executed 1202891 times by 500 tests: end of blockExecuted by:
| 1202891 | ||||||||||||||||||||||||
| 630 | } | - | ||||||||||||||||||||||||
| 631 | - | |||||||||||||||||||||||||
| 632 | - | |||||||||||||||||||||||||
| 633 | void QString::expand(int i) | - | ||||||||||||||||||||||||
| 634 | { | - | ||||||||||||||||||||||||
| 635 | int sz = d->size;resize(qMax(i + 1, sz)); | - | ||||||||||||||||||||||||
| if (d->size - 1 > sz) { | ||||||||||||||||||||||||||
| ushort *n = d->data() +d->size- 1; | ||||||||||||||||||||||||||
| ushort *e = d->data() + sz; | ||||||||||||||||||||||||||
| while), QLatin1Char(n != e) | ||||||||||||||||||||||||||
| * --n =' '; | ||||||||||||||||||||||||||
| })); | ||||||||||||||||||||||||||
| 636 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 637 | QString &QString::operator=(const QString &other) noexcept | - | ||||||||||||||||||||||||
| 638 | { | - | ||||||||||||||||||||||||
| 639 | other.d->ref.ref(); | - | ||||||||||||||||||||||||
| 640 | if (!d->ref.deref()
| 853249-6633512 | ||||||||||||||||||||||||
| 641 | Data::deallocate(d); executed 853249 times by 265 tests: Data::deallocate(d);Executed by:
| 853249 | ||||||||||||||||||||||||
| 642 | d = other.d; | - | ||||||||||||||||||||||||
| 643 | return executed 7486761 times by 451 tests: *this;return *this;Executed by:
executed 7486761 times by 451 tests: return *this;Executed by:
| 7486761 | ||||||||||||||||||||||||
| 644 | } | - | ||||||||||||||||||||||||
| 645 | QString &QString::operator=(QLatin1String other) | - | ||||||||||||||||||||||||
| 646 | { | - | ||||||||||||||||||||||||
| 647 | if (isDetached() && other.size() <= capacity()) { | - | ||||||||||||||||||||||||
| 648 | d->size = other.size(); | - | ||||||||||||||||||||||||
| 649 | d->data()[other.size()] = 0; | - | ||||||||||||||||||||||||
| 650 | qt_from_latin1(d->data(), other.latin1(), other.size()); | - | ||||||||||||||||||||||||
| 651 | } else { | - | ||||||||||||||||||||||||
| 652 | *this = fromLatin1(other.latin1(), other.size()); | - | ||||||||||||||||||||||||
| 653 | } | - | ||||||||||||||||||||||||
| 654 | return *this; | - | ||||||||||||||||||||||||
| 655 | } | - | ||||||||||||||||||||||||
| 656 | QString &QString::operator=(QChar ch) | - | ||||||||||||||||||||||||
| 657 | { | - | ||||||||||||||||||||||||
| 658 | if (isDetached() && capacity() >= 1) { | - | ||||||||||||||||||||||||
| 659 | - | |||||||||||||||||||||||||
| 660 | ushort *dat = d->data(); | - | ||||||||||||||||||||||||
| 661 | dat[0] = ch.unicode(); | - | ||||||||||||||||||||||||
| 662 | dat[1] = 0; | - | ||||||||||||||||||||||||
| 663 | d->size = 1; | - | ||||||||||||||||||||||||
| 664 | } else { | - | ||||||||||||||||||||||||
| 665 | operator=(QString(ch)); | - | ||||||||||||||||||||||||
| 666 | } | - | ||||||||||||||||||||||||
| 667 | return *this; | - | ||||||||||||||||||||||||
| 668 | } | - | ||||||||||||||||||||||||
| 669 | QString &QString::insert(int i, QLatin1String str) | - | ||||||||||||||||||||||||
| 670 | { | - | ||||||||||||||||||||||||
| 671 | const char *s = str.latin1(); | - | ||||||||||||||||||||||||
| 672 | if (i < 0
| 0-17409 | ||||||||||||||||||||||||
| 673 | return executed 16 times by 1 test: *this;return *this;Executed by:
executed 16 times by 1 test: return *this;Executed by:
| 16 | ||||||||||||||||||||||||
| 674 | - | |||||||||||||||||||||||||
| 675 | int len = str.size(); | - | ||||||||||||||||||||||||
| 676 | expand(qMaxif (__builtin_expect(!!(i >
| 0-17393 | ||||||||||||||||||||||||
| 677 | resize( never executed: resize(i + len, QLatin1Char(' '));never executed: i )+ len- 1, QLatin1Char(' '));resize(i + len, QLatin1Char(' '));never executed: resize(i + len, QLatin1Char(' ')); | 0 | ||||||||||||||||||||||||
| 678 | else | - | ||||||||||||||||||||||||
| 679 | resize(d->size + len executed 17393 times by 58 tests: resize(d->size + len);Executed by:
executed 17393 times by 58 tests: );resize(d->size + len);Executed by:
executed 17393 times by 58 tests: resize(d->size + len);Executed by:
| 17393 | ||||||||||||||||||||||||
| 680 | - | |||||||||||||||||||||||||
| 681 | ::memmove(d->data() + i + len, d->data() + i, (d->size - i - len) * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 682 | qt_from_latin1(d->data() + i, s, uint(len)); | - | ||||||||||||||||||||||||
| 683 | return executed 17393 times by 58 tests: *this;return *this;Executed by:
executed 17393 times by 58 tests: return *this;Executed by:
| 17393 | ||||||||||||||||||||||||
| 684 | } | - | ||||||||||||||||||||||||
| 685 | QString& QString::insert(int i, const QChar *unicode, int size) | - | ||||||||||||||||||||||||
| 686 | { | - | ||||||||||||||||||||||||
| 687 | if (i < 0
| 0-1414856 | ||||||||||||||||||||||||
| 688 | return executed 353295 times by 39 tests: *this;return *this;Executed by:
executed 353295 times by 39 tests: return *this;Executed by:
| 353295 | ||||||||||||||||||||||||
| 689 | - | |||||||||||||||||||||||||
| 690 | const ushort *s = (const ushort *)unicode; | - | ||||||||||||||||||||||||
| 691 | if (s >= d->data()
| 3-587789 | ||||||||||||||||||||||||
| 692 | - | |||||||||||||||||||||||||
| 693 | ushort *tmp = static_cast<ushort *>(::malloc(size * sizeof(QChar))); | - | ||||||||||||||||||||||||
| 694 | do { if (!(tmp)
never executed: } while (0);qBadAlloc(); | 0-3 | ||||||||||||||||||||||||
| 695 | memcpy(tmp, s, size * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 696 | insert(i, reinterpret_cast<const QChar *>(tmp), size); | - | ||||||||||||||||||||||||
| 697 | ::free(tmp); | - | ||||||||||||||||||||||||
| 698 | return executed 3 times by 2 tests: *this;return *this;Executed by:
executed 3 times by 2 tests: return *this;Executed by:
| 3 | ||||||||||||||||||||||||
| 699 | } | - | ||||||||||||||||||||||||
| 700 | - | |||||||||||||||||||||||||
| 701 | expand(qMaxif (__builtin_expect(!!(i >
| 2-1061556 | ||||||||||||||||||||||||
| 702 | resize( executed 2 times by 2 tests: resize(i + size, QLatin1Char(' '));Executed by:
executed 2 times by 2 tests: i )+ size- 1, QLatin1Char(' '));resize(i + size, QLatin1Char(' '));Executed by:
executed 2 times by 2 tests: resize(i + size, QLatin1Char(' '));Executed by:
| 2 | ||||||||||||||||||||||||
| 703 | else | - | ||||||||||||||||||||||||
| 704 | resize(d->size + size executed 1061556 times by 75 tests: resize(d->size + size);Executed by:
executed 1061556 times by 75 tests: );resize(d->size + size);Executed by:
executed 1061556 times by 75 tests: resize(d->size + size);Executed by:
| 1061556 | ||||||||||||||||||||||||
| 705 | - | |||||||||||||||||||||||||
| 706 | ::memmove(d->data() + i + size, d->data() + i, (d->size - i - size) * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 707 | memcpy(d->data() + i, s, size * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 708 | return executed 1061558 times by 75 tests: *this;return *this;Executed by:
executed 1061558 times by 75 tests: return *this;Executed by:
| 1061558 | ||||||||||||||||||||||||
| 709 | } | - | ||||||||||||||||||||||||
| 710 | QString& QString::insert(int i, QChar ch) | - | ||||||||||||||||||||||||
| 711 | { | - | ||||||||||||||||||||||||
| 712 | if (i < 0
| 0-510830 | ||||||||||||||||||||||||
| 713 | i += d->size; never executed: i += d->size; | 0 | ||||||||||||||||||||||||
| 714 | if (i < 0
| 0-510830 | ||||||||||||||||||||||||
| 715 | return never executed: *this;return *this;never executed: return *this; | 0 | ||||||||||||||||||||||||
| 716 | expandif (qMax__builtin_expect(!!(i > d->size), false)
| 2-510828 | ||||||||||||||||||||||||
| 717 | resize executed 2 times by 2 tests: resize(i + 1, QLatin1Char(' '));Executed by:
executed 2 times by 2 tests: (i + 1, QLatin1Char(' '));resize(i + 1, QLatin1Char(' '));Executed by:
executed 2 times by 2 tests: resize(i + 1, QLatin1Char(' '));Executed by:
| 2 | ||||||||||||||||||||||||
| 718 | else | - | ||||||||||||||||||||||||
| 719 | resize( executed 510828 times by 413 tests: resize(d->size + 1);Executed by:
executed 510828 times by 413 tests: d->size ));+ 1);resize(d->size + 1);Executed by:
executed 510828 times by 413 tests: resize(d->size + 1);Executed by:
| 510828 | ||||||||||||||||||||||||
| 720 | ::memmove(d->data() + i + 1, d->data() + i, (d->size - i - 1) * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 721 | d->data()[i] = ch.unicode(); | - | ||||||||||||||||||||||||
| 722 | return executed 510830 times by 413 tests: *this;return *this;Executed by:
executed 510830 times by 413 tests: return *this;Executed by:
| 510830 | ||||||||||||||||||||||||
| 723 | } | - | ||||||||||||||||||||||||
| 724 | QString &QString::append(const QString &str) | - | ||||||||||||||||||||||||
| 725 | { | - | ||||||||||||||||||||||||
| 726 | if (str.d != Data::sharedNull()) { | - | ||||||||||||||||||||||||
| 727 | if (d == Data::sharedNull()) { | - | ||||||||||||||||||||||||
| 728 | operator=(str); | - | ||||||||||||||||||||||||
| 729 | } else { | - | ||||||||||||||||||||||||
| 730 | if (d->ref.isShared() || uint(d->size + str.d->size) + 1u > d->alloc) | - | ||||||||||||||||||||||||
| 731 | reallocData(uint(d->size + str.d->size) + 1u, true); | - | ||||||||||||||||||||||||
| 732 | memcpy(d->data() + d->size, str.d->data(), str.d->size * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 733 | d->size += str.d->size; | - | ||||||||||||||||||||||||
| 734 | d->data()[d->size] = '\0'; | - | ||||||||||||||||||||||||
| 735 | } | - | ||||||||||||||||||||||||
| 736 | } | - | ||||||||||||||||||||||||
| 737 | return *this; | - | ||||||||||||||||||||||||
| 738 | } | - | ||||||||||||||||||||||||
| 739 | - | |||||||||||||||||||||||||
| 740 | - | |||||||||||||||||||||||||
| 741 | - | |||||||||||||||||||||||||
| 742 | - | |||||||||||||||||||||||||
| 743 | - | |||||||||||||||||||||||||
| 744 | - | |||||||||||||||||||||||||
| 745 | - | |||||||||||||||||||||||||
| 746 | QString &QString::append(const QChar *str, int len) | - | ||||||||||||||||||||||||
| 747 | { | - | ||||||||||||||||||||||||
| 748 | if (str && len > 0) { | - | ||||||||||||||||||||||||
| 749 | if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc) | - | ||||||||||||||||||||||||
| 750 | reallocData(uint(d->size + len) + 1u, true); | - | ||||||||||||||||||||||||
| 751 | memcpy(d->data() + d->size, str, len * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 752 | d->size += len; | - | ||||||||||||||||||||||||
| 753 | d->data()[d->size] = '\0'; | - | ||||||||||||||||||||||||
| 754 | } | - | ||||||||||||||||||||||||
| 755 | return *this; | - | ||||||||||||||||||||||||
| 756 | } | - | ||||||||||||||||||||||||
| 757 | - | |||||||||||||||||||||||||
| 758 | - | |||||||||||||||||||||||||
| 759 | - | |||||||||||||||||||||||||
| 760 | - | |||||||||||||||||||||||||
| 761 | - | |||||||||||||||||||||||||
| 762 | - | |||||||||||||||||||||||||
| 763 | QString &QString::append(QLatin1String str) | - | ||||||||||||||||||||||||
| 764 | { | - | ||||||||||||||||||||||||
| 765 | const char *s = str.latin1(); | - | ||||||||||||||||||||||||
| 766 | if (s) { | - | ||||||||||||||||||||||||
| 767 | int len = str.size(); | - | ||||||||||||||||||||||||
| 768 | if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc) | - | ||||||||||||||||||||||||
| 769 | reallocData(uint(d->size + len) + 1u, true); | - | ||||||||||||||||||||||||
| 770 | ushort *i = d->data() + d->size; | - | ||||||||||||||||||||||||
| 771 | qt_from_latin1(i, s, uint(len)); | - | ||||||||||||||||||||||||
| 772 | i[len] = '\0'; | - | ||||||||||||||||||||||||
| 773 | d->size += len; | - | ||||||||||||||||||||||||
| 774 | } | - | ||||||||||||||||||||||||
| 775 | return *this; | - | ||||||||||||||||||||||||
| 776 | } | - | ||||||||||||||||||||||||
| 777 | QString &QString::append(QChar ch) | - | ||||||||||||||||||||||||
| 778 | { | - | ||||||||||||||||||||||||
| 779 | if (d->ref.isShared() || uint(d->size) + 2u > d->alloc) | - | ||||||||||||||||||||||||
| 780 | reallocData(uint(d->size) + 2u, true); | - | ||||||||||||||||||||||||
| 781 | d->data()[d->size++] = ch.unicode(); | - | ||||||||||||||||||||||||
| 782 | d->data()[d->size] = '\0'; | - | ||||||||||||||||||||||||
| 783 | return *this; | - | ||||||||||||||||||||||||
| 784 | } | - | ||||||||||||||||||||||||
| 785 | QString &QString::remove(int pos, int len) | - | ||||||||||||||||||||||||
| 786 | { | - | ||||||||||||||||||||||||
| 787 | if (pos < 0) | - | ||||||||||||||||||||||||
| 788 | pos += d->size; | - | ||||||||||||||||||||||||
| 789 | if (uint(pos) >= uint(d->size)) { | - | ||||||||||||||||||||||||
| 790 | - | |||||||||||||||||||||||||
| 791 | } else if (len >= d->size - pos) { | - | ||||||||||||||||||||||||
| 792 | resize(pos); | - | ||||||||||||||||||||||||
| 793 | } else if (len > 0) { | - | ||||||||||||||||||||||||
| 794 | detach(); | - | ||||||||||||||||||||||||
| 795 | memmove(d->data() + pos, d->data() + pos + len, | - | ||||||||||||||||||||||||
| 796 | (d->size - pos - len + 1) * sizeof(ushort)); | - | ||||||||||||||||||||||||
| 797 | d->size -= len; | - | ||||||||||||||||||||||||
| 798 | } | - | ||||||||||||||||||||||||
| 799 | return *this; | - | ||||||||||||||||||||||||
| 800 | } | - | ||||||||||||||||||||||||
| 801 | QString &QString::remove(const QString &str, Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 802 | { | - | ||||||||||||||||||||||||
| 803 | if (str.d->size) { | - | ||||||||||||||||||||||||
| 804 | int i = 0; | - | ||||||||||||||||||||||||
| 805 | while ((i = indexOf(str, i, cs)) != -1) | - | ||||||||||||||||||||||||
| 806 | remove(i, str.d->size); | - | ||||||||||||||||||||||||
| 807 | } | - | ||||||||||||||||||||||||
| 808 | return *this; | - | ||||||||||||||||||||||||
| 809 | } | - | ||||||||||||||||||||||||
| 810 | QString &QString::remove(QChar ch, Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 811 | { | - | ||||||||||||||||||||||||
| 812 | int i = 0; | - | ||||||||||||||||||||||||
| 813 | ushort c = ch.unicode(); | - | ||||||||||||||||||||||||
| 814 | if (cs == Qt::CaseSensitive) { | - | ||||||||||||||||||||||||
| 815 | while (i < d->size) | - | ||||||||||||||||||||||||
| 816 | if (d->data()[i] == ch) | - | ||||||||||||||||||||||||
| 817 | remove(i, 1); | - | ||||||||||||||||||||||||
| 818 | else | - | ||||||||||||||||||||||||
| 819 | i++; | - | ||||||||||||||||||||||||
| 820 | } else { | - | ||||||||||||||||||||||||
| 821 | c = foldCase(c); | - | ||||||||||||||||||||||||
| 822 | while (i < d->size) | - | ||||||||||||||||||||||||
| 823 | if (foldCase(d->data()[i]) == c) | - | ||||||||||||||||||||||||
| 824 | remove(i, 1); | - | ||||||||||||||||||||||||
| 825 | else | - | ||||||||||||||||||||||||
| 826 | i++; | - | ||||||||||||||||||||||||
| 827 | } | - | ||||||||||||||||||||||||
| 828 | return *this; | - | ||||||||||||||||||||||||
| 829 | } | - | ||||||||||||||||||||||||
| 830 | QString &QString::replace(int pos, int len, const QString &after) | - | ||||||||||||||||||||||||
| 831 | { | - | ||||||||||||||||||||||||
| 832 | QString copy = after;return executed 2000587 times by 9 tests: replace(pos, len, copyafter.constData(), copyafter.length());return replace(pos, len, after.constData(), after.length());Executed by:
executed 2000587 times by 9 tests: return replace(pos, len, after.constData(), after.length());Executed by:
| 2000587 | ||||||||||||||||||||||||
| 833 | } | - | ||||||||||||||||||||||||
| 834 | QString &QString::replace(int pos, int len, const QChar *unicode, int size) | - | ||||||||||||||||||||||||
| 835 | { | - | ||||||||||||||||||||||||
| 836 | if (uint(pos) > uint(d->size)) | - | ||||||||||||||||||||||||
| 837 | return *this; | - | ||||||||||||||||||||||||
| 838 | if (len > d->size - pos) | - | ||||||||||||||||||||||||
| 839 | len = d->size - pos; | - | ||||||||||||||||||||||||
| 840 | - | |||||||||||||||||||||||||
| 841 | uint index = pos; | - | ||||||||||||||||||||||||
| 842 | replace_helper(&index, 1, len, unicode, size); | - | ||||||||||||||||||||||||
| 843 | return *this; | - | ||||||||||||||||||||||||
| 844 | } | - | ||||||||||||||||||||||||
| 845 | QString &QString::replace(int pos, int len, QChar after) | - | ||||||||||||||||||||||||
| 846 | { | - | ||||||||||||||||||||||||
| 847 | return replace(pos, len, &after, 1); | - | ||||||||||||||||||||||||
| 848 | } | - | ||||||||||||||||||||||||
| 849 | QString &QString::replace(const QString &before, const QString &after, Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 850 | { | - | ||||||||||||||||||||||||
| 851 | return replace(before.constData(), before.size(), after.constData(), after.size(), cs); | - | ||||||||||||||||||||||||
| 852 | } | - | ||||||||||||||||||||||||
| 853 | - | |||||||||||||||||||||||||
| 854 | namespace { | - | ||||||||||||||||||||||||
| 855 | QChar *textCopy(const QChar *start, int len) | - | ||||||||||||||||||||||||
| 856 | { | - | ||||||||||||||||||||||||
| 857 | const size_t size = len * sizeof(QChar); | - | ||||||||||||||||||||||||
| 858 | QChar *const copy = static_cast<QChar *>(::malloc(size)); | - | ||||||||||||||||||||||||
| 859 | do { if (!(copy)) qBadAlloc(); } while (0); | - | ||||||||||||||||||||||||
| 860 | ::memcpy(copy, start, size); | - | ||||||||||||||||||||||||
| 861 | return copy; | - | ||||||||||||||||||||||||
| 862 | } | - | ||||||||||||||||||||||||
| 863 | - | |||||||||||||||||||||||||
| 864 | bool pointsIntoRange(const QChar *ptr, const ushort *base, int len) | - | ||||||||||||||||||||||||
| 865 | { | - | ||||||||||||||||||||||||
| 866 | const QChar *const start = reinterpret_cast<const QChar *>(base); | - | ||||||||||||||||||||||||
| 867 | return start <= ptr && ptr < start + len; | - | ||||||||||||||||||||||||
| 868 | } | - | ||||||||||||||||||||||||
| 869 | } | - | ||||||||||||||||||||||||
| 870 | - | |||||||||||||||||||||||||
| 871 | - | |||||||||||||||||||||||||
| 872 | - | |||||||||||||||||||||||||
| 873 | - | |||||||||||||||||||||||||
| 874 | void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar *after, int alen) | - | ||||||||||||||||||||||||
| 875 | { | - | ||||||||||||||||||||||||
| 876 | - | |||||||||||||||||||||||||
| 877 | - | |||||||||||||||||||||||||
| 878 | QChar *afterBuffer = 0; | - | ||||||||||||||||||||||||
| 879 | if (pointsIntoRange(after, d->data(), d->size)) | - | ||||||||||||||||||||||||
| 880 | after = afterBuffer = textCopy(after, alen); | - | ||||||||||||||||||||||||
| 881 | - | |||||||||||||||||||||||||
| 882 | try { | - | ||||||||||||||||||||||||
| 883 | if (blen == alen) { | - | ||||||||||||||||||||||||
| 884 | - | |||||||||||||||||||||||||
| 885 | detach(); | - | ||||||||||||||||||||||||
| 886 | for (int i = 0; i < nIndices; ++i) | - | ||||||||||||||||||||||||
| 887 | memcpy(d->data() + indices[i], after, alen * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 888 | } else if (alen < blen) { | - | ||||||||||||||||||||||||
| 889 | - | |||||||||||||||||||||||||
| 890 | detach(); | - | ||||||||||||||||||||||||
| 891 | uint to = indices[0]; | - | ||||||||||||||||||||||||
| 892 | if (alen) | - | ||||||||||||||||||||||||
| 893 | memcpy(d->data()+to, after, alen*sizeof(QChar)); | - | ||||||||||||||||||||||||
| 894 | to += alen; | - | ||||||||||||||||||||||||
| 895 | uint movestart = indices[0] + blen; | - | ||||||||||||||||||||||||
| 896 | for (int i = 1; i < nIndices; ++i) { | - | ||||||||||||||||||||||||
| 897 | int msize = indices[i] - movestart; | - | ||||||||||||||||||||||||
| 898 | if (msize > 0) { | - | ||||||||||||||||||||||||
| 899 | memmove(d->data() + to, d->data() + movestart, msize * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 900 | to += msize; | - | ||||||||||||||||||||||||
| 901 | } | - | ||||||||||||||||||||||||
| 902 | if (alen) { | - | ||||||||||||||||||||||||
| 903 | memcpy(d->data() + to, after, alen * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 904 | to += alen; | - | ||||||||||||||||||||||||
| 905 | } | - | ||||||||||||||||||||||||
| 906 | movestart = indices[i] + blen; | - | ||||||||||||||||||||||||
| 907 | } | - | ||||||||||||||||||||||||
| 908 | int msize = d->size - movestart; | - | ||||||||||||||||||||||||
| 909 | if (msize > 0) | - | ||||||||||||||||||||||||
| 910 | memmove(d->data() + to, d->data() + movestart, msize * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 911 | resize(d->size - nIndices*(blen-alen)); | - | ||||||||||||||||||||||||
| 912 | } else { | - | ||||||||||||||||||||||||
| 913 | - | |||||||||||||||||||||||||
| 914 | int adjust = nIndices*(alen-blen); | - | ||||||||||||||||||||||||
| 915 | int newLen = d->size + adjust; | - | ||||||||||||||||||||||||
| 916 | int moveend = d->size; | - | ||||||||||||||||||||||||
| 917 | resize(newLen); | - | ||||||||||||||||||||||||
| 918 | - | |||||||||||||||||||||||||
| 919 | while (nIndices) { | - | ||||||||||||||||||||||||
| 920 | --nIndices; | - | ||||||||||||||||||||||||
| 921 | int movestart = indices[nIndices] + blen; | - | ||||||||||||||||||||||||
| 922 | int insertstart = indices[nIndices] + nIndices*(alen-blen); | - | ||||||||||||||||||||||||
| 923 | int moveto = insertstart + alen; | - | ||||||||||||||||||||||||
| 924 | memmove(d->data() + moveto, d->data() + movestart, | - | ||||||||||||||||||||||||
| 925 | (moveend - movestart)*sizeof(QChar)); | - | ||||||||||||||||||||||||
| 926 | memcpy(d->data() + insertstart, after, alen * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 927 | moveend = movestart-blen; | - | ||||||||||||||||||||||||
| 928 | } | - | ||||||||||||||||||||||||
| 929 | } | - | ||||||||||||||||||||||||
| 930 | } catch (const std::bad_alloc &) { | - | ||||||||||||||||||||||||
| 931 | ::free(afterBuffer); | - | ||||||||||||||||||||||||
| 932 | throw; | - | ||||||||||||||||||||||||
| 933 | } | - | ||||||||||||||||||||||||
| 934 | ::free(afterBuffer); | - | ||||||||||||||||||||||||
| 935 | } | - | ||||||||||||||||||||||||
| 936 | QString &QString::replace(const QChar *before, int blen, | - | ||||||||||||||||||||||||
| 937 | const QChar *after, int alen, | - | ||||||||||||||||||||||||
| 938 | Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 939 | { | - | ||||||||||||||||||||||||
| 940 | if (d->size == 0) { | - | ||||||||||||||||||||||||
| 941 | if (blen) | - | ||||||||||||||||||||||||
| 942 | return *this; | - | ||||||||||||||||||||||||
| 943 | } else { | - | ||||||||||||||||||||||||
| 944 | if (cs == Qt::CaseSensitive && before == after && blen == alen) | - | ||||||||||||||||||||||||
| 945 | return *this; | - | ||||||||||||||||||||||||
| 946 | } | - | ||||||||||||||||||||||||
| 947 | if (alen == 0 && blen == 0) | - | ||||||||||||||||||||||||
| 948 | return *this; | - | ||||||||||||||||||||||||
| 949 | - | |||||||||||||||||||||||||
| 950 | QStringMatcher matcher(before, blen, cs); | - | ||||||||||||||||||||||||
| 951 | QChar *beforeBuffer = 0, *afterBuffer = 0; | - | ||||||||||||||||||||||||
| 952 | - | |||||||||||||||||||||||||
| 953 | int index = 0; | - | ||||||||||||||||||||||||
| 954 | while (1) { | - | ||||||||||||||||||||||||
| 955 | uint indices[1024]; | - | ||||||||||||||||||||||||
| 956 | uint pos = 0; | - | ||||||||||||||||||||||||
| 957 | while (pos < 1024) { | - | ||||||||||||||||||||||||
| 958 | index = matcher.indexIn(*this, index); | - | ||||||||||||||||||||||||
| 959 | if (index == -1) | - | ||||||||||||||||||||||||
| 960 | break; | - | ||||||||||||||||||||||||
| 961 | indices[pos++] = index; | - | ||||||||||||||||||||||||
| 962 | if (blen) | - | ||||||||||||||||||||||||
| 963 | index += blen; | - | ||||||||||||||||||||||||
| 964 | else | - | ||||||||||||||||||||||||
| 965 | index++; | - | ||||||||||||||||||||||||
| 966 | } | - | ||||||||||||||||||||||||
| 967 | if (!pos) | - | ||||||||||||||||||||||||
| 968 | break; | - | ||||||||||||||||||||||||
| 969 | - | |||||||||||||||||||||||||
| 970 | if (__builtin_expect(!!(index != -1), false)) { | - | ||||||||||||||||||||||||
| 971 | - | |||||||||||||||||||||||||
| 972 | - | |||||||||||||||||||||||||
| 973 | - | |||||||||||||||||||||||||
| 974 | - | |||||||||||||||||||||||||
| 975 | if (!afterBuffer && pointsIntoRange(after, d->data(), d->size)) | - | ||||||||||||||||||||||||
| 976 | after = afterBuffer = textCopy(after, alen); | - | ||||||||||||||||||||||||
| 977 | - | |||||||||||||||||||||||||
| 978 | if (!beforeBuffer && pointsIntoRange(before, d->data(), d->size)) { | - | ||||||||||||||||||||||||
| 979 | beforeBuffer = textCopy(before, blen); | - | ||||||||||||||||||||||||
| 980 | matcher = QStringMatcher(beforeBuffer, blen, cs); | - | ||||||||||||||||||||||||
| 981 | } | - | ||||||||||||||||||||||||
| 982 | } | - | ||||||||||||||||||||||||
| 983 | - | |||||||||||||||||||||||||
| 984 | replace_helper(indices, pos, blen, after, alen); | - | ||||||||||||||||||||||||
| 985 | - | |||||||||||||||||||||||||
| 986 | if (__builtin_expect(!!(index == -1), true)) | - | ||||||||||||||||||||||||
| 987 | break; | - | ||||||||||||||||||||||||
| 988 | - | |||||||||||||||||||||||||
| 989 | index += pos*(alen-blen); | - | ||||||||||||||||||||||||
| 990 | } | - | ||||||||||||||||||||||||
| 991 | ::free(afterBuffer); | - | ||||||||||||||||||||||||
| 992 | ::free(beforeBuffer); | - | ||||||||||||||||||||||||
| 993 | - | |||||||||||||||||||||||||
| 994 | return *this; | - | ||||||||||||||||||||||||
| 995 | } | - | ||||||||||||||||||||||||
| 996 | QString& QString::replace(QChar ch, const QString &after, Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 997 | { | - | ||||||||||||||||||||||||
| 998 | if (after.d->size == 0) | - | ||||||||||||||||||||||||
| 999 | return remove(ch, cs); | - | ||||||||||||||||||||||||
| 1000 | - | |||||||||||||||||||||||||
| 1001 | if (after.d->size == 1) | - | ||||||||||||||||||||||||
| 1002 | return replace(ch, after.d->data()[0], cs); | - | ||||||||||||||||||||||||
| 1003 | - | |||||||||||||||||||||||||
| 1004 | if (d->size == 0) | - | ||||||||||||||||||||||||
| 1005 | return *this; | - | ||||||||||||||||||||||||
| 1006 | - | |||||||||||||||||||||||||
| 1007 | ushort cc = (cs == Qt::CaseSensitive ? ch.unicode() : ch.toCaseFolded().unicode()); | - | ||||||||||||||||||||||||
| 1008 | - | |||||||||||||||||||||||||
| 1009 | int index = 0; | - | ||||||||||||||||||||||||
| 1010 | while (1) { | - | ||||||||||||||||||||||||
| 1011 | uint indices[1024]; | - | ||||||||||||||||||||||||
| 1012 | uint pos = 0; | - | ||||||||||||||||||||||||
| 1013 | if (cs == Qt::CaseSensitive) { | - | ||||||||||||||||||||||||
| 1014 | while (pos < 1024 && index < d->size) { | - | ||||||||||||||||||||||||
| 1015 | if (d->data()[index] == cc) | - | ||||||||||||||||||||||||
| 1016 | indices[pos++] = index; | - | ||||||||||||||||||||||||
| 1017 | index++; | - | ||||||||||||||||||||||||
| 1018 | } | - | ||||||||||||||||||||||||
| 1019 | } else { | - | ||||||||||||||||||||||||
| 1020 | while (pos < 1024 && index < d->size) { | - | ||||||||||||||||||||||||
| 1021 | if (QChar::toCaseFolded(d->data()[index]) == cc) | - | ||||||||||||||||||||||||
| 1022 | indices[pos++] = index; | - | ||||||||||||||||||||||||
| 1023 | index++; | - | ||||||||||||||||||||||||
| 1024 | } | - | ||||||||||||||||||||||||
| 1025 | } | - | ||||||||||||||||||||||||
| 1026 | if (!pos) | - | ||||||||||||||||||||||||
| 1027 | break; | - | ||||||||||||||||||||||||
| 1028 | - | |||||||||||||||||||||||||
| 1029 | replace_helper(indices, pos, 1, after.constData(), after.d->size); | - | ||||||||||||||||||||||||
| 1030 | - | |||||||||||||||||||||||||
| 1031 | if (__builtin_expect(!!(index == -1), true)) | - | ||||||||||||||||||||||||
| 1032 | break; | - | ||||||||||||||||||||||||
| 1033 | - | |||||||||||||||||||||||||
| 1034 | index += pos*(after.d->size - 1); | - | ||||||||||||||||||||||||
| 1035 | } | - | ||||||||||||||||||||||||
| 1036 | return *this; | - | ||||||||||||||||||||||||
| 1037 | } | - | ||||||||||||||||||||||||
| 1038 | QString& QString::replace(QChar before, QChar after, Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 1039 | { | - | ||||||||||||||||||||||||
| 1040 | ushort a = after.unicode(); | - | ||||||||||||||||||||||||
| 1041 | ushort b = before.unicode(); | - | ||||||||||||||||||||||||
| 1042 | if (d->size) { | - | ||||||||||||||||||||||||
| 1043 | detach(); | - | ||||||||||||||||||||||||
| 1044 | ushort *i = d->data(); | - | ||||||||||||||||||||||||
| 1045 | const ushort *e = i + d->size; | - | ||||||||||||||||||||||||
| 1046 | if (cs == Qt::CaseSensitive) { | - | ||||||||||||||||||||||||
| 1047 | for (; i != e; ++i) | - | ||||||||||||||||||||||||
| 1048 | if (*i == b) | - | ||||||||||||||||||||||||
| 1049 | *i = a; | - | ||||||||||||||||||||||||
| 1050 | } else { | - | ||||||||||||||||||||||||
| 1051 | b = foldCase(b); | - | ||||||||||||||||||||||||
| 1052 | for (; i != e; ++i) | - | ||||||||||||||||||||||||
| 1053 | if (foldCase(*i) == b) | - | ||||||||||||||||||||||||
| 1054 | *i = a; | - | ||||||||||||||||||||||||
| 1055 | } | - | ||||||||||||||||||||||||
| 1056 | } | - | ||||||||||||||||||||||||
| 1057 | return *this; | - | ||||||||||||||||||||||||
| 1058 | } | - | ||||||||||||||||||||||||
| 1059 | QString &QString::replace(QLatin1String before, QLatin1String after, Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 1060 | { | - | ||||||||||||||||||||||||
| 1061 | int alen = after.size(); | - | ||||||||||||||||||||||||
| 1062 | int blen = before.size(); | - | ||||||||||||||||||||||||
| 1063 | QVarLengthArray<ushort> a(alen); | - | ||||||||||||||||||||||||
| 1064 | QVarLengthArray<ushort> b(blen); | - | ||||||||||||||||||||||||
| 1065 | qt_from_latin1(a.data(), after.latin1(), alen); | - | ||||||||||||||||||||||||
| 1066 | qt_from_latin1(b.data(), before.latin1(), blen); | - | ||||||||||||||||||||||||
| 1067 | return replace((const QChar *)b.data(), blen, (const QChar *)a.data(), alen, cs); | - | ||||||||||||||||||||||||
| 1068 | } | - | ||||||||||||||||||||||||
| 1069 | QString &QString::replace(QLatin1String before, const QString &after, Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 1070 | { | - | ||||||||||||||||||||||||
| 1071 | int blen = before.size(); | - | ||||||||||||||||||||||||
| 1072 | QVarLengthArray<ushort> b(blen); | - | ||||||||||||||||||||||||
| 1073 | qt_from_latin1(b.data(), before.latin1(), blen); | - | ||||||||||||||||||||||||
| 1074 | return replace((const QChar *)b.data(), blen, after.constData(), after.d->size, cs); | - | ||||||||||||||||||||||||
| 1075 | } | - | ||||||||||||||||||||||||
| 1076 | QString &QString::replace(const QString &before, QLatin1String after, Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 1077 | { | - | ||||||||||||||||||||||||
| 1078 | int alen = after.size(); | - | ||||||||||||||||||||||||
| 1079 | QVarLengthArray<ushort> a(alen); | - | ||||||||||||||||||||||||
| 1080 | qt_from_latin1(a.data(), after.latin1(), alen); | - | ||||||||||||||||||||||||
| 1081 | return replace(before.constData(), before.d->size, (const QChar *)a.data(), alen, cs); | - | ||||||||||||||||||||||||
| 1082 | } | - | ||||||||||||||||||||||||
| 1083 | QString &QString::replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 1084 | { | - | ||||||||||||||||||||||||
| 1085 | int alen = after.size(); | - | ||||||||||||||||||||||||
| 1086 | QVarLengthArray<ushort> a(alen); | - | ||||||||||||||||||||||||
| 1087 | qt_from_latin1(a.data(), after.latin1(), alen); | - | ||||||||||||||||||||||||
| 1088 | return replace(&c, 1, (const QChar *)a.data(), alen, cs); | - | ||||||||||||||||||||||||
| 1089 | } | - | ||||||||||||||||||||||||
| 1090 | bool operator==(const QString &s1, const QString &s2) noexcept | - | ||||||||||||||||||||||||
| 1091 | { | - | ||||||||||||||||||||||||
| 1092 | if (s1.d->size != s2.d->size
| 358990-2791400 | ||||||||||||||||||||||||
| 1093 | return executed 358990 times by 302 tests: false;return false;Executed by:
executed 358990 times by 302 tests: return false;Executed by:
| 358990 | ||||||||||||||||||||||||
| 1094 | - | |||||||||||||||||||||||||
| 1095 | return executed 2791400 times by 526 tests: qMemEquals(s1.d->data(), s2.d->data(), s1.d->size);return qMemEquals(s1.d->data(), s2.d->data(), s1.d->size);Executed by:
executed 2791400 times by 526 tests: return qMemEquals(s1.d->data(), s2.d->data(), s1.d->size);Executed by:
| 2791400 | ||||||||||||||||||||||||
| 1096 | } | - | ||||||||||||||||||||||||
| 1097 | - | |||||||||||||||||||||||||
| 1098 | - | |||||||||||||||||||||||||
| 1099 | - | |||||||||||||||||||||||||
| 1100 | - | |||||||||||||||||||||||||
| 1101 | - | |||||||||||||||||||||||||
| 1102 | - | |||||||||||||||||||||||||
| 1103 | bool QString::operator==(QLatin1String other) const noexcept | - | ||||||||||||||||||||||||
| 1104 | { | - | ||||||||||||||||||||||||
| 1105 | if (d->size != other.size()
| 195896-1117851 | ||||||||||||||||||||||||
| 1106 | return executed 1117851 times by 341 tests: false;return false;Executed by:
executed 1117851 times by 341 tests: return false;Executed by:
| 1117851 | ||||||||||||||||||||||||
| 1107 | - | |||||||||||||||||||||||||
| 1108 | if (!other.size()
| 4-195892 | ||||||||||||||||||||||||
| 1109 | return executed 4 times by 1 test: isEmpty();return isEmpty();Executed by:
executed 4 times by 1 test: return isEmpty();Executed by:
| 4 | ||||||||||||||||||||||||
| 1110 | - | |||||||||||||||||||||||||
| 1111 | return executed 195892 times by 444 tests: compare_helper(data(), size(), other, Qt::CaseSensitive) == 0;return compare_helper(data(), size(), other, Qt::CaseSensitive) == 0;Executed by:
executed 195892 times by 444 tests: return compare_helper(data(), size(), other, Qt::CaseSensitive) == 0;Executed by:
| 195892 | ||||||||||||||||||||||||
| 1112 | } | - | ||||||||||||||||||||||||
| 1113 | bool operator<(const QString &s1, const QString &s2) noexcept | - | ||||||||||||||||||||||||
| 1114 | { | - | ||||||||||||||||||||||||
| 1115 | return executed 1719191 times by 420 tests: ucstrcmp(s1.constData(), s1.length(), s2.constData(), s2.length()) < 0;return ucstrcmp(s1.constData(), s1.length(), s2.constData(), s2.length()) < 0;Executed by:
executed 1719191 times by 420 tests: return ucstrcmp(s1.constData(), s1.length(), s2.constData(), s2.length()) < 0;Executed by:
| 1719191 | ||||||||||||||||||||||||
| 1116 | } | - | ||||||||||||||||||||||||
| 1117 | - | |||||||||||||||||||||||||
| 1118 | - | |||||||||||||||||||||||||
| 1119 | - | |||||||||||||||||||||||||
| 1120 | - | |||||||||||||||||||||||||
| 1121 | - | |||||||||||||||||||||||||
| 1122 | - | |||||||||||||||||||||||||
| 1123 | bool QString::operator<(QLatin1String other) const noexcept | - | ||||||||||||||||||||||||
| 1124 | { | - | ||||||||||||||||||||||||
| 1125 | const uchar *c = (const uchar *) other.latin1(); | - | ||||||||||||||||||||||||
| 1126 | if (!c
| 5-2354 | ||||||||||||||||||||||||
| 1127 | return executed 12 times by 1 test: false;return false;Executed by:
executed 12 times by 1 test: return false;Executed by:
| 12 | ||||||||||||||||||||||||
| 1128 | - | |||||||||||||||||||||||||
| 1129 | return executed 2347 times by 19 tests: compare_helper(data(), size(), other, Qt::CaseSensitive) < 0;return compare_helper(data(), size(), other, Qt::CaseSensitive) < 0;Executed by:
executed 2347 times by 19 tests: return compare_helper(data(), size(), other, Qt::CaseSensitive) < 0;Executed by:
| 2347 | ||||||||||||||||||||||||
| 1130 | } | - | ||||||||||||||||||||||||
| 1131 | bool QString::operator>(QLatin1String other) const noexcept | - | ||||||||||||||||||||||||
| 1132 | { | - | ||||||||||||||||||||||||
| 1133 | const uchar *c = (const uchar *) other.latin1(); | - | ||||||||||||||||||||||||
| 1134 | if (!c
| 5-17569 | ||||||||||||||||||||||||
| 1135 | return executed 12 times by 1 test: !isEmpty();return !isEmpty();Executed by:
executed 12 times by 1 test: return !isEmpty();Executed by:
| 12 | ||||||||||||||||||||||||
| 1136 | - | |||||||||||||||||||||||||
| 1137 | return executed 17562 times by 27 tests: compare_helper(data(), size(), other, Qt::CaseSensitive) > 0;return compare_helper(data(), size(), other, Qt::CaseSensitive) > 0;Executed by:
executed 17562 times by 27 tests: return compare_helper(data(), size(), other, Qt::CaseSensitive) > 0;Executed by:
| 17562 | ||||||||||||||||||||||||
| 1138 | } | - | ||||||||||||||||||||||||
| 1139 | int QString::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1140 | { | - | ||||||||||||||||||||||||
| 1141 | return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs); | - | ||||||||||||||||||||||||
| 1142 | } | - | ||||||||||||||||||||||||
| 1143 | int QString::indexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1144 | { | - | ||||||||||||||||||||||||
| 1145 | return qt_find_latin1_string(unicode(), size(), str, from, cs); | - | ||||||||||||||||||||||||
| 1146 | } | - | ||||||||||||||||||||||||
| 1147 | - | |||||||||||||||||||||||||
| 1148 | int qFindString( | - | ||||||||||||||||||||||||
| 1149 | const QChar *haystack0, int haystackLen, int from, | - | ||||||||||||||||||||||||
| 1150 | const QChar *needle0, int needleLen, Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 1151 | { | - | ||||||||||||||||||||||||
| 1152 | const int l = haystackLen; | - | ||||||||||||||||||||||||
| 1153 | const int sl = needleLen; | - | ||||||||||||||||||||||||
| 1154 | if (from < 0) | - | ||||||||||||||||||||||||
| 1155 | from += l; | - | ||||||||||||||||||||||||
| 1156 | if (uint(sl + from) > (uint)l) | - | ||||||||||||||||||||||||
| 1157 | return -1; | - | ||||||||||||||||||||||||
| 1158 | if (!sl) | - | ||||||||||||||||||||||||
| 1159 | return from; | - | ||||||||||||||||||||||||
| 1160 | if (!l) | - | ||||||||||||||||||||||||
| 1161 | return -1; | - | ||||||||||||||||||||||||
| 1162 | - | |||||||||||||||||||||||||
| 1163 | if (sl == 1) | - | ||||||||||||||||||||||||
| 1164 | return findChar(haystack0, haystackLen, needle0[0], from, cs); | - | ||||||||||||||||||||||||
| 1165 | - | |||||||||||||||||||||||||
| 1166 | - | |||||||||||||||||||||||||
| 1167 | - | |||||||||||||||||||||||||
| 1168 | - | |||||||||||||||||||||||||
| 1169 | - | |||||||||||||||||||||||||
| 1170 | - | |||||||||||||||||||||||||
| 1171 | if (l > 500 && sl > 5) | - | ||||||||||||||||||||||||
| 1172 | return qFindStringBoyerMoore(haystack0, haystackLen, from, | - | ||||||||||||||||||||||||
| 1173 | needle0, needleLen, cs); | - | ||||||||||||||||||||||||
| 1174 | - | |||||||||||||||||||||||||
| 1175 | - | |||||||||||||||||||||||||
| 1176 | - | |||||||||||||||||||||||||
| 1177 | - | |||||||||||||||||||||||||
| 1178 | - | |||||||||||||||||||||||||
| 1179 | - | |||||||||||||||||||||||||
| 1180 | - | |||||||||||||||||||||||||
| 1181 | const ushort *needle = (const ushort *)needle0; | - | ||||||||||||||||||||||||
| 1182 | const ushort *haystack = (const ushort *)haystack0 + from; | - | ||||||||||||||||||||||||
| 1183 | const ushort *end = (const ushort *)haystack0 + (l-sl); | - | ||||||||||||||||||||||||
| 1184 | const uint sl_minus_1 = sl - 1; | - | ||||||||||||||||||||||||
| 1185 | uint hashNeedle = 0, hashHaystack = 0; | - | ||||||||||||||||||||||||
| 1186 | int idx; | - | ||||||||||||||||||||||||
| 1187 | - | |||||||||||||||||||||||||
| 1188 | if (cs == Qt::CaseSensitive) { | - | ||||||||||||||||||||||||
| 1189 | for (idx = 0; idx < sl; ++idx) { | - | ||||||||||||||||||||||||
| 1190 | hashNeedle = ((hashNeedle<<1) + needle[idx]); | - | ||||||||||||||||||||||||
| 1191 | hashHaystack = ((hashHaystack<<1) + haystack[idx]); | - | ||||||||||||||||||||||||
| 1192 | } | - | ||||||||||||||||||||||||
| 1193 | hashHaystack -= haystack[sl_minus_1]; | - | ||||||||||||||||||||||||
| 1194 | - | |||||||||||||||||||||||||
| 1195 | while (haystack <= end) { | - | ||||||||||||||||||||||||
| 1196 | hashHaystack += haystack[sl_minus_1]; | - | ||||||||||||||||||||||||
| 1197 | if (hashHaystack == hashNeedle | - | ||||||||||||||||||||||||
| 1198 | && ucstrncmp((const QChar *)needle, (const QChar *)haystack, sl) == 0) | - | ||||||||||||||||||||||||
| 1199 | return haystack - (const ushort *)haystack0; | - | ||||||||||||||||||||||||
| 1200 | - | |||||||||||||||||||||||||
| 1201 | if (sl_minus_1 < sizeof(uint) * 8) hashHaystack -= uint(*haystack) << sl_minus_1; hashHaystack <<= 1; | - | ||||||||||||||||||||||||
| 1202 | ++haystack; | - | ||||||||||||||||||||||||
| 1203 | } | - | ||||||||||||||||||||||||
| 1204 | } else { | - | ||||||||||||||||||||||||
| 1205 | const ushort *haystack_start = (const ushort *)haystack0; | - | ||||||||||||||||||||||||
| 1206 | for (idx = 0; idx < sl; ++idx) { | - | ||||||||||||||||||||||||
| 1207 | hashNeedle = (hashNeedle<<1) + foldCase(needle + idx, needle); | - | ||||||||||||||||||||||||
| 1208 | hashHaystack = (hashHaystack<<1) + foldCase(haystack + idx, haystack_start); | - | ||||||||||||||||||||||||
| 1209 | } | - | ||||||||||||||||||||||||
| 1210 | hashHaystack -= foldCase(haystack + sl_minus_1, haystack_start); | - | ||||||||||||||||||||||||
| 1211 | - | |||||||||||||||||||||||||
| 1212 | while (haystack <= end) { | - | ||||||||||||||||||||||||
| 1213 | hashHaystack += foldCase(haystack + sl_minus_1, haystack_start); | - | ||||||||||||||||||||||||
| 1214 | if (hashHaystack == hashNeedle && ucstrnicmp(needle, haystack, sl) == 0) | - | ||||||||||||||||||||||||
| 1215 | return haystack - (const ushort *)haystack0; | - | ||||||||||||||||||||||||
| 1216 | - | |||||||||||||||||||||||||
| 1217 | if (sl_minus_1 < sizeof(uint) * 8) hashHaystack -= uint(foldCase(haystack, haystack_start)) << sl_minus_1; hashHaystack <<= 1; | - | ||||||||||||||||||||||||
| 1218 | ++haystack; | - | ||||||||||||||||||||||||
| 1219 | } | - | ||||||||||||||||||||||||
| 1220 | } | - | ||||||||||||||||||||||||
| 1221 | return -1; | - | ||||||||||||||||||||||||
| 1222 | } | - | ||||||||||||||||||||||||
| 1223 | int QString::indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1224 | { | - | ||||||||||||||||||||||||
| 1225 | return findChar(unicode(), length(), ch, from, cs); | - | ||||||||||||||||||||||||
| 1226 | } | - | ||||||||||||||||||||||||
| 1227 | int QString::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1228 | { | - | ||||||||||||||||||||||||
| 1229 | return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs); | - | ||||||||||||||||||||||||
| 1230 | } | - | ||||||||||||||||||||||||
| 1231 | - | |||||||||||||||||||||||||
| 1232 | static int lastIndexOfHelper(const ushort *haystack, int from, const ushort *needle, int sl, Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 1233 | { | - | ||||||||||||||||||||||||
| 1234 | - | |||||||||||||||||||||||||
| 1235 | - | |||||||||||||||||||||||||
| 1236 | - | |||||||||||||||||||||||||
| 1237 | - | |||||||||||||||||||||||||
| 1238 | const ushort *end = haystack; | - | ||||||||||||||||||||||||
| 1239 | haystack += from; | - | ||||||||||||||||||||||||
| 1240 | const uint sl_minus_1 = sl - 1; | - | ||||||||||||||||||||||||
| 1241 | const ushort *n = needle+sl_minus_1; | - | ||||||||||||||||||||||||
| 1242 | const ushort *h = haystack+sl_minus_1; | - | ||||||||||||||||||||||||
| 1243 | uint hashNeedle = 0, hashHaystack = 0; | - | ||||||||||||||||||||||||
| 1244 | int idx; | - | ||||||||||||||||||||||||
| 1245 | - | |||||||||||||||||||||||||
| 1246 | if (cs == Qt::CaseSensitive) { | - | ||||||||||||||||||||||||
| 1247 | for (idx = 0; idx < sl; ++idx) { | - | ||||||||||||||||||||||||
| 1248 | hashNeedle = ((hashNeedle<<1) + *(n-idx)); | - | ||||||||||||||||||||||||
| 1249 | hashHaystack = ((hashHaystack<<1) + *(h-idx)); | - | ||||||||||||||||||||||||
| 1250 | } | - | ||||||||||||||||||||||||
| 1251 | hashHaystack -= *haystack; | - | ||||||||||||||||||||||||
| 1252 | - | |||||||||||||||||||||||||
| 1253 | while (haystack >= end) { | - | ||||||||||||||||||||||||
| 1254 | hashHaystack += *haystack; | - | ||||||||||||||||||||||||
| 1255 | if (hashHaystack == hashNeedle | - | ||||||||||||||||||||||||
| 1256 | && ucstrncmp((const QChar *)needle, (const QChar *)haystack, sl) == 0) | - | ||||||||||||||||||||||||
| 1257 | return haystack - end; | - | ||||||||||||||||||||||||
| 1258 | --haystack; | - | ||||||||||||||||||||||||
| 1259 | if (sl_minus_1 < sizeof(uint) * 8) hashHaystack -= uint(haystack[sl]) << sl_minus_1; hashHaystack <<= 1; | - | ||||||||||||||||||||||||
| 1260 | } | - | ||||||||||||||||||||||||
| 1261 | } else { | - | ||||||||||||||||||||||||
| 1262 | for (idx = 0; idx < sl; ++idx) { | - | ||||||||||||||||||||||||
| 1263 | hashNeedle = ((hashNeedle<<1) + foldCase(n-idx, needle)); | - | ||||||||||||||||||||||||
| 1264 | hashHaystack = ((hashHaystack<<1) + foldCase(h-idx, end)); | - | ||||||||||||||||||||||||
| 1265 | } | - | ||||||||||||||||||||||||
| 1266 | hashHaystack -= foldCase(haystack, end); | - | ||||||||||||||||||||||||
| 1267 | - | |||||||||||||||||||||||||
| 1268 | while (haystack >= end) { | - | ||||||||||||||||||||||||
| 1269 | hashHaystack += foldCase(haystack, end); | - | ||||||||||||||||||||||||
| 1270 | if (hashHaystack == hashNeedle && ucstrnicmp(needle, haystack, sl) == 0) | - | ||||||||||||||||||||||||
| 1271 | return haystack - end; | - | ||||||||||||||||||||||||
| 1272 | --haystack; | - | ||||||||||||||||||||||||
| 1273 | if (sl_minus_1 < sizeof(uint) * 8) hashHaystack -= uint(foldCase(haystack + sl, end)) << sl_minus_1; hashHaystack <<= 1; | - | ||||||||||||||||||||||||
| 1274 | } | - | ||||||||||||||||||||||||
| 1275 | } | - | ||||||||||||||||||||||||
| 1276 | return -1; | - | ||||||||||||||||||||||||
| 1277 | } | - | ||||||||||||||||||||||||
| 1278 | int QString::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1279 | { | - | ||||||||||||||||||||||||
| 1280 | const int sl = str.d->size; | - | ||||||||||||||||||||||||
| 1281 | if (sl == 1) | - | ||||||||||||||||||||||||
| 1282 | return lastIndexOf(QChar(str.d->data()[0]), from, cs); | - | ||||||||||||||||||||||||
| 1283 | - | |||||||||||||||||||||||||
| 1284 | const int l = d->size; | - | ||||||||||||||||||||||||
| 1285 | if (from < 0) | - | ||||||||||||||||||||||||
| 1286 | from += l; | - | ||||||||||||||||||||||||
| 1287 | int delta = l-sl; | - | ||||||||||||||||||||||||
| 1288 | if (from == l && sl == 0) | - | ||||||||||||||||||||||||
| 1289 | return from; | - | ||||||||||||||||||||||||
| 1290 | if (uint(from) >= uint(l) || delta < 0) | - | ||||||||||||||||||||||||
| 1291 | return -1; | - | ||||||||||||||||||||||||
| 1292 | if (from > delta) | - | ||||||||||||||||||||||||
| 1293 | from = delta; | - | ||||||||||||||||||||||||
| 1294 | - | |||||||||||||||||||||||||
| 1295 | return lastIndexOfHelper(d->data(), from, str.d->data(), str.d->size, cs); | - | ||||||||||||||||||||||||
| 1296 | } | - | ||||||||||||||||||||||||
| 1297 | int QString::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1298 | { | - | ||||||||||||||||||||||||
| 1299 | const int sl = str.size(); | - | ||||||||||||||||||||||||
| 1300 | if (sl == 1) | - | ||||||||||||||||||||||||
| 1301 | return lastIndexOf(QLatin1Char(str.latin1()[0]), from, cs); | - | ||||||||||||||||||||||||
| 1302 | - | |||||||||||||||||||||||||
| 1303 | const int l = d->size; | - | ||||||||||||||||||||||||
| 1304 | if (from < 0) | - | ||||||||||||||||||||||||
| 1305 | from += l; | - | ||||||||||||||||||||||||
| 1306 | int delta = l-sl; | - | ||||||||||||||||||||||||
| 1307 | if (from == l && sl == 0) | - | ||||||||||||||||||||||||
| 1308 | return from; | - | ||||||||||||||||||||||||
| 1309 | if (uint(from) >= uint(l) || delta < 0) | - | ||||||||||||||||||||||||
| 1310 | return -1; | - | ||||||||||||||||||||||||
| 1311 | if (from > delta) | - | ||||||||||||||||||||||||
| 1312 | from = delta; | - | ||||||||||||||||||||||||
| 1313 | - | |||||||||||||||||||||||||
| 1314 | QVarLengthArray<ushort> s(sl); | - | ||||||||||||||||||||||||
| 1315 | qt_from_latin1(s.data(), str.latin1(), sl); | - | ||||||||||||||||||||||||
| 1316 | - | |||||||||||||||||||||||||
| 1317 | return lastIndexOfHelper(d->data(), from, s.data(), sl, cs); | - | ||||||||||||||||||||||||
| 1318 | } | - | ||||||||||||||||||||||||
| 1319 | - | |||||||||||||||||||||||||
| 1320 | - | |||||||||||||||||||||||||
| 1321 | - | |||||||||||||||||||||||||
| 1322 | - | |||||||||||||||||||||||||
| 1323 | - | |||||||||||||||||||||||||
| 1324 | - | |||||||||||||||||||||||||
| 1325 | - | |||||||||||||||||||||||||
| 1326 | int QString::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1327 | { | - | ||||||||||||||||||||||||
| 1328 | return qt_last_index_of(unicode(), size(), ch, from, cs); | - | ||||||||||||||||||||||||
| 1329 | } | - | ||||||||||||||||||||||||
| 1330 | int QString::lastIndexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1331 | { | - | ||||||||||||||||||||||||
| 1332 | const int sl = str.size(); | - | ||||||||||||||||||||||||
| 1333 | if (sl == 1) | - | ||||||||||||||||||||||||
| 1334 | return lastIndexOf(str.at(0), from, cs); | - | ||||||||||||||||||||||||
| 1335 | - | |||||||||||||||||||||||||
| 1336 | const int l = d->size; | - | ||||||||||||||||||||||||
| 1337 | if (from < 0) | - | ||||||||||||||||||||||||
| 1338 | from += l; | - | ||||||||||||||||||||||||
| 1339 | int delta = l - sl; | - | ||||||||||||||||||||||||
| 1340 | if (from == l && sl == 0) | - | ||||||||||||||||||||||||
| 1341 | return from; | - | ||||||||||||||||||||||||
| 1342 | if (uint(from) >= uint(l) || delta < 0) | - | ||||||||||||||||||||||||
| 1343 | return -1; | - | ||||||||||||||||||||||||
| 1344 | if (from > delta) | - | ||||||||||||||||||||||||
| 1345 | from = delta; | - | ||||||||||||||||||||||||
| 1346 | - | |||||||||||||||||||||||||
| 1347 | return lastIndexOfHelper(d->data(), from, reinterpret_cast<const ushort*>(str.unicode()), | - | ||||||||||||||||||||||||
| 1348 | str.size(), cs); | - | ||||||||||||||||||||||||
| 1349 | } | - | ||||||||||||||||||||||||
| 1350 | - | |||||||||||||||||||||||||
| 1351 | - | |||||||||||||||||||||||||
| 1352 | - | |||||||||||||||||||||||||
| 1353 | struct QStringCapture | - | ||||||||||||||||||||||||
| 1354 | { | - | ||||||||||||||||||||||||
| 1355 | int pos; | - | ||||||||||||||||||||||||
| 1356 | int len; | - | ||||||||||||||||||||||||
| 1357 | int no; | - | ||||||||||||||||||||||||
| 1358 | }; | - | ||||||||||||||||||||||||
| 1359 | template<> class QTypeInfo<QStringCapture > { public: enum { isComplex = (((Q_PRIMITIVE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_PRIMITIVE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_PRIMITIVE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QStringCapture)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< QStringCapture >::value, isDummy = (((Q_PRIMITIVE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QStringCapture) }; static inline const char *name() { return "QStringCapture"; } }; | - | ||||||||||||||||||||||||
| 1360 | QString& QString::replace(const QRegExp &rx, const QString &after) | - | ||||||||||||||||||||||||
| 1361 | { | - | ||||||||||||||||||||||||
| 1362 | QRegExp rx2(rx); | - | ||||||||||||||||||||||||
| 1363 | - | |||||||||||||||||||||||||
| 1364 | if (isEmpty() && rx2.indexIn(*this) == -1) | - | ||||||||||||||||||||||||
| 1365 | return *this; | - | ||||||||||||||||||||||||
| 1366 | - | |||||||||||||||||||||||||
| 1367 | reallocData(uint(d->size) + 1u); | - | ||||||||||||||||||||||||
| 1368 | - | |||||||||||||||||||||||||
| 1369 | int index = 0; | - | ||||||||||||||||||||||||
| 1370 | int numCaptures = rx2.captureCount(); | - | ||||||||||||||||||||||||
| 1371 | int al = after.length(); | - | ||||||||||||||||||||||||
| 1372 | QRegExp::CaretMode caretMode = QRegExp::CaretAtZero; | - | ||||||||||||||||||||||||
| 1373 | - | |||||||||||||||||||||||||
| 1374 | if (numCaptures > 0) { | - | ||||||||||||||||||||||||
| 1375 | const QChar *uc = after.unicode(); | - | ||||||||||||||||||||||||
| 1376 | int numBackRefs = 0; | - | ||||||||||||||||||||||||
| 1377 | - | |||||||||||||||||||||||||
| 1378 | for (int i = 0; i < al - 1; i++) { | - | ||||||||||||||||||||||||
| 1379 | if (uc[i] == QLatin1Char('\\')) { | - | ||||||||||||||||||||||||
| 1380 | int no = uc[i + 1].digitValue(); | - | ||||||||||||||||||||||||
| 1381 | if (no > 0 && no <= numCaptures) | - | ||||||||||||||||||||||||
| 1382 | numBackRefs++; | - | ||||||||||||||||||||||||
| 1383 | } | - | ||||||||||||||||||||||||
| 1384 | } | - | ||||||||||||||||||||||||
| 1385 | - | |||||||||||||||||||||||||
| 1386 | - | |||||||||||||||||||||||||
| 1387 | - | |||||||||||||||||||||||||
| 1388 | - | |||||||||||||||||||||||||
| 1389 | if (numBackRefs > 0) { | - | ||||||||||||||||||||||||
| 1390 | QVarLengthArray<QStringCapture, 16> captures(numBackRefs); | - | ||||||||||||||||||||||||
| 1391 | int j = 0; | - | ||||||||||||||||||||||||
| 1392 | - | |||||||||||||||||||||||||
| 1393 | for (int i = 0; i < al - 1; i++) { | - | ||||||||||||||||||||||||
| 1394 | if (uc[i] == QLatin1Char('\\')) { | - | ||||||||||||||||||||||||
| 1395 | int no = uc[i + 1].digitValue(); | - | ||||||||||||||||||||||||
| 1396 | if (no > 0 && no <= numCaptures) { | - | ||||||||||||||||||||||||
| 1397 | QStringCapture capture; | - | ||||||||||||||||||||||||
| 1398 | capture.pos = i; | - | ||||||||||||||||||||||||
| 1399 | capture.len = 2; | - | ||||||||||||||||||||||||
| 1400 | - | |||||||||||||||||||||||||
| 1401 | if (i < al - 2) { | - | ||||||||||||||||||||||||
| 1402 | int secondDigit = uc[i + 2].digitValue(); | - | ||||||||||||||||||||||||
| 1403 | if (secondDigit != -1 && ((no * 10) + secondDigit) <= numCaptures) { | - | ||||||||||||||||||||||||
| 1404 | no = (no * 10) + secondDigit; | - | ||||||||||||||||||||||||
| 1405 | ++capture.len; | - | ||||||||||||||||||||||||
| 1406 | } | - | ||||||||||||||||||||||||
| 1407 | } | - | ||||||||||||||||||||||||
| 1408 | - | |||||||||||||||||||||||||
| 1409 | capture.no = no; | - | ||||||||||||||||||||||||
| 1410 | captures[j++] = capture; | - | ||||||||||||||||||||||||
| 1411 | } | - | ||||||||||||||||||||||||
| 1412 | } | - | ||||||||||||||||||||||||
| 1413 | } | - | ||||||||||||||||||||||||
| 1414 | - | |||||||||||||||||||||||||
| 1415 | while (index <= length()) { | - | ||||||||||||||||||||||||
| 1416 | index = rx2.indexIn(*this, index, caretMode); | - | ||||||||||||||||||||||||
| 1417 | if (index == -1) | - | ||||||||||||||||||||||||
| 1418 | break; | - | ||||||||||||||||||||||||
| 1419 | - | |||||||||||||||||||||||||
| 1420 | QString after2(after); | - | ||||||||||||||||||||||||
| 1421 | for (j = numBackRefs - 1; j >= 0; j--) { | - | ||||||||||||||||||||||||
| 1422 | const QStringCapture &capture = captures[j]; | - | ||||||||||||||||||||||||
| 1423 | after2.replace(capture.pos, capture.len, rx2.cap(capture.no)); | - | ||||||||||||||||||||||||
| 1424 | } | - | ||||||||||||||||||||||||
| 1425 | - | |||||||||||||||||||||||||
| 1426 | replace(index, rx2.matchedLength(), after2); | - | ||||||||||||||||||||||||
| 1427 | index += after2.length(); | - | ||||||||||||||||||||||||
| 1428 | - | |||||||||||||||||||||||||
| 1429 | - | |||||||||||||||||||||||||
| 1430 | if (rx2.matchedLength() == 0) | - | ||||||||||||||||||||||||
| 1431 | ++index; | - | ||||||||||||||||||||||||
| 1432 | - | |||||||||||||||||||||||||
| 1433 | caretMode = QRegExp::CaretWontMatch; | - | ||||||||||||||||||||||||
| 1434 | } | - | ||||||||||||||||||||||||
| 1435 | return *this; | - | ||||||||||||||||||||||||
| 1436 | } | - | ||||||||||||||||||||||||
| 1437 | } | - | ||||||||||||||||||||||||
| 1438 | - | |||||||||||||||||||||||||
| 1439 | - | |||||||||||||||||||||||||
| 1440 | - | |||||||||||||||||||||||||
| 1441 | - | |||||||||||||||||||||||||
| 1442 | - | |||||||||||||||||||||||||
| 1443 | while (index != -1) { | - | ||||||||||||||||||||||||
| 1444 | struct { | - | ||||||||||||||||||||||||
| 1445 | int pos; | - | ||||||||||||||||||||||||
| 1446 | int length; | - | ||||||||||||||||||||||||
| 1447 | } replacements[2048]; | - | ||||||||||||||||||||||||
| 1448 | - | |||||||||||||||||||||||||
| 1449 | int pos = 0; | - | ||||||||||||||||||||||||
| 1450 | int adjust = 0; | - | ||||||||||||||||||||||||
| 1451 | while (pos < 2047) { | - | ||||||||||||||||||||||||
| 1452 | index = rx2.indexIn(*this, index, caretMode); | - | ||||||||||||||||||||||||
| 1453 | if (index == -1) | - | ||||||||||||||||||||||||
| 1454 | break; | - | ||||||||||||||||||||||||
| 1455 | int ml = rx2.matchedLength(); | - | ||||||||||||||||||||||||
| 1456 | replacements[pos].pos = index; | - | ||||||||||||||||||||||||
| 1457 | replacements[pos++].length = ml; | - | ||||||||||||||||||||||||
| 1458 | index += ml; | - | ||||||||||||||||||||||||
| 1459 | adjust += al - ml; | - | ||||||||||||||||||||||||
| 1460 | - | |||||||||||||||||||||||||
| 1461 | if (!ml) | - | ||||||||||||||||||||||||
| 1462 | index++; | - | ||||||||||||||||||||||||
| 1463 | } | - | ||||||||||||||||||||||||
| 1464 | if (!pos) | - | ||||||||||||||||||||||||
| 1465 | break; | - | ||||||||||||||||||||||||
| 1466 | replacements[pos].pos = d->size; | - | ||||||||||||||||||||||||
| 1467 | int newlen = d->size + adjust; | - | ||||||||||||||||||||||||
| 1468 | - | |||||||||||||||||||||||||
| 1469 | - | |||||||||||||||||||||||||
| 1470 | - | |||||||||||||||||||||||||
| 1471 | if (index != -1) | - | ||||||||||||||||||||||||
| 1472 | index += adjust; | - | ||||||||||||||||||||||||
| 1473 | QString newstring; | - | ||||||||||||||||||||||||
| 1474 | newstring.reserve(newlen + 1); | - | ||||||||||||||||||||||||
| 1475 | QChar *newuc = newstring.data(); | - | ||||||||||||||||||||||||
| 1476 | QChar *uc = newuc; | - | ||||||||||||||||||||||||
| 1477 | int copystart = 0; | - | ||||||||||||||||||||||||
| 1478 | int i = 0; | - | ||||||||||||||||||||||||
| 1479 | while (i < pos) { | - | ||||||||||||||||||||||||
| 1480 | int copyend = replacements[i].pos; | - | ||||||||||||||||||||||||
| 1481 | int size = copyend - copystart; | - | ||||||||||||||||||||||||
| 1482 | memcpy(uc, d->data() + copystart, size * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 1483 | uc += size; | - | ||||||||||||||||||||||||
| 1484 | memcpy(uc, after.d->data(), al * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 1485 | uc += al; | - | ||||||||||||||||||||||||
| 1486 | copystart = copyend + replacements[i].length; | - | ||||||||||||||||||||||||
| 1487 | i++; | - | ||||||||||||||||||||||||
| 1488 | } | - | ||||||||||||||||||||||||
| 1489 | memcpy(uc, d->data() + copystart, (d->size - copystart) * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 1490 | newstring.resize(newlen); | - | ||||||||||||||||||||||||
| 1491 | *this = newstring; | - | ||||||||||||||||||||||||
| 1492 | caretMode = QRegExp::CaretWontMatch; | - | ||||||||||||||||||||||||
| 1493 | } | - | ||||||||||||||||||||||||
| 1494 | return *this; | - | ||||||||||||||||||||||||
| 1495 | } | - | ||||||||||||||||||||||||
| 1496 | QString &QString::replace(const QRegularExpression &re, const QString &after) | - | ||||||||||||||||||||||||
| 1497 | { | - | ||||||||||||||||||||||||
| 1498 | if (!re.isValid()
| 2-7185 | ||||||||||||||||||||||||
| 1499 | QMessageLogger(__FILE__, 35353565, __PRETTY_FUNCTION__).warning("QString::replace: invalid QRegularExpression object"); | - | ||||||||||||||||||||||||
| 1500 | return executed 2 times by 1 test: *this;return *this;Executed by:
executed 2 times by 1 test: return *this;Executed by:
| 2 | ||||||||||||||||||||||||
| 1501 | } | - | ||||||||||||||||||||||||
| 1502 | - | |||||||||||||||||||||||||
| 1503 | const QString copy(*this); | - | ||||||||||||||||||||||||
| 1504 | QRegularExpressionMatchIterator iterator = re.globalMatch(copy); | - | ||||||||||||||||||||||||
| 1505 | if (!iterator.hasNext()
| 1501-5684 | ||||||||||||||||||||||||
| 1506 | return executed 5684 times by 3 tests: *this;return *this;Executed by:
executed 5684 times by 3 tests: return *this;Executed by:
| 5684 | ||||||||||||||||||||||||
| 1507 | - | |||||||||||||||||||||||||
| 1508 | reallocData(uint(d->size) + 1u); | - | ||||||||||||||||||||||||
| 1509 | - | |||||||||||||||||||||||||
| 1510 | int numCaptures = re.captureCount(); | - | ||||||||||||||||||||||||
| 1511 | - | |||||||||||||||||||||||||
| 1512 | - | |||||||||||||||||||||||||
| 1513 | - | |||||||||||||||||||||||||
| 1514 | QVector<QStringCapture> backReferences; | - | ||||||||||||||||||||||||
| 1515 | const int al = after.length(); | - | ||||||||||||||||||||||||
| 1516 | const QChar *ac = after.unicode(); | - | ||||||||||||||||||||||||
| 1517 | - | |||||||||||||||||||||||||
| 1518 | for (int i = 0; i < al - 1
| 1501-30058 | ||||||||||||||||||||||||
| 1519 | if (ac[i] == QLatin1Char('\\')
| 55-30003 | ||||||||||||||||||||||||
| 1520 | int no = ac[i + 1].digitValue(); | - | ||||||||||||||||||||||||
| 1521 | if (no > 0
| 3-51 | ||||||||||||||||||||||||
| 1522 | QStringCapture backReference; | - | ||||||||||||||||||||||||
| 1523 | backReference.pos = i; | - | ||||||||||||||||||||||||
| 1524 | backReference.len = 2; | - | ||||||||||||||||||||||||
| 1525 | - | |||||||||||||||||||||||||
| 1526 | if (i < al - 2
| 5-43 | ||||||||||||||||||||||||
| 1527 | int secondDigit = ac[i + 2].digitValue(); | - | ||||||||||||||||||||||||
| 1528 | if (secondDigit != -1
| 6-28 | ||||||||||||||||||||||||
| 1529 | no = (no * 10) + secondDigit; | - | ||||||||||||||||||||||||
| 1530 | ++backReference.len; | - | ||||||||||||||||||||||||
| 1531 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||
| 1532 | } executed 43 times by 2 tests: end of blockExecuted by:
| 43 | ||||||||||||||||||||||||
| 1533 | - | |||||||||||||||||||||||||
| 1534 | backReference.no = no; | - | ||||||||||||||||||||||||
| 1535 | backReferences.append(backReference); | - | ||||||||||||||||||||||||
| 1536 | } executed 48 times by 2 tests: end of blockExecuted by:
| 48 | ||||||||||||||||||||||||
| 1537 | } executed 55 times by 2 tests: end of blockExecuted by:
| 55 | ||||||||||||||||||||||||
| 1538 | } executed 30058 times by 3 tests: end of blockExecuted by:
| 30058 | ||||||||||||||||||||||||
| 1539 | - | |||||||||||||||||||||||||
| 1540 | - | |||||||||||||||||||||||||
| 1541 | - | |||||||||||||||||||||||||
| 1542 | - | |||||||||||||||||||||||||
| 1543 | - | |||||||||||||||||||||||||
| 1544 | int newLength = 0; | - | ||||||||||||||||||||||||
| 1545 | int lastEnd = 0; | - | ||||||||||||||||||||||||
| 1546 | QVector<QStringRef> chunks; | - | ||||||||||||||||||||||||
| 1547 | while (iterator.hasNext()
| 1501-1518 | ||||||||||||||||||||||||
| 1548 | QRegularExpressionMatch match = iterator.next(); | - | ||||||||||||||||||||||||
| 1549 | int len; | - | ||||||||||||||||||||||||
| 1550 | - | |||||||||||||||||||||||||
| 1551 | len = match.capturedStart() - lastEnd; | - | ||||||||||||||||||||||||
| 1552 | if (len > 0
| 154-1364 | ||||||||||||||||||||||||
| 1553 | chunks << copy.midRef(lastEnd, len); | - | ||||||||||||||||||||||||
| 1554 | newLength += len; | - | ||||||||||||||||||||||||
| 1555 | } executed 1364 times by 2 tests: end of blockExecuted by:
| 1364 | ||||||||||||||||||||||||
| 1556 | - | |||||||||||||||||||||||||
| 1557 | lastEnd = 0; | - | ||||||||||||||||||||||||
| for (QForeachContainer<typename QtPrivate::remove_reference<decltype(backReferences)>::type> _container_((backReferences)); _container_.control && _container_.i != _container_.e; | ||||||||||||||||||||||||||
| 1558 | - | |||||||||||||||||||||||||
| 1559 | ++_container_.i, _container_.control ^= 1)for (const QStringCapture &backReference = *_container_.i; _container_.control; _container_.control = 0): qAsConst(backReferences)) { | - | ||||||||||||||||||||||||
| 1560 | - | |||||||||||||||||||||||||
| 1561 | len = backReference.pos - lastEnd; | - | ||||||||||||||||||||||||
| 1562 | if (len > 0
| 28-30 | ||||||||||||||||||||||||
| 1563 | chunks << after.midRef(lastEnd, len); | - | ||||||||||||||||||||||||
| 1564 | newLength += len; | - | ||||||||||||||||||||||||
| 1565 | } executed 28 times by 2 tests: end of blockExecuted by:
| 28 | ||||||||||||||||||||||||
| 1566 | - | |||||||||||||||||||||||||
| 1567 | - | |||||||||||||||||||||||||
| 1568 | len = match.capturedLength(backReference.no); | - | ||||||||||||||||||||||||
| 1569 | if (len > 0
| 1-57 | ||||||||||||||||||||||||
| 1570 | chunks << copy.midRef(match.capturedStart(backReference.no), len); | - | ||||||||||||||||||||||||
| 1571 | newLength += len; | - | ||||||||||||||||||||||||
| 1572 | } executed 57 times by 2 tests: end of blockExecuted by:
| 57 | ||||||||||||||||||||||||
| 1573 | - | |||||||||||||||||||||||||
| 1574 | lastEnd = backReference.pos + backReference.len; | - | ||||||||||||||||||||||||
| 1575 | } executed 58 times by 2 tests: end of blockExecuted by:
| 58 | ||||||||||||||||||||||||
| 1576 | - | |||||||||||||||||||||||||
| 1577 | - | |||||||||||||||||||||||||
| 1578 | len = after.length() - lastEnd; | - | ||||||||||||||||||||||||
| 1579 | if (len > 0
| 131-1387 | ||||||||||||||||||||||||
| 1580 | chunks << after.midRef(lastEnd, len); | - | ||||||||||||||||||||||||
| 1581 | newLength += len; | - | ||||||||||||||||||||||||
| 1582 | } executed 1387 times by 3 tests: end of blockExecuted by:
| 1387 | ||||||||||||||||||||||||
| 1583 | - | |||||||||||||||||||||||||
| 1584 | lastEnd = match.capturedEnd(); | - | ||||||||||||||||||||||||
| 1585 | } executed 1518 times by 4 tests: end of blockExecuted by:
| 1518 | ||||||||||||||||||||||||
| 1586 | - | |||||||||||||||||||||||||
| 1587 | - | |||||||||||||||||||||||||
| 1588 | if (copy.length() > lastEnd
| 14-1487 | ||||||||||||||||||||||||
| 1589 | chunks << copy.midRef(lastEnd); | - | ||||||||||||||||||||||||
| 1590 | newLength += copy.length() - lastEnd; | - | ||||||||||||||||||||||||
| 1591 | } executed 1487 times by 4 tests: end of blockExecuted by:
| 1487 | ||||||||||||||||||||||||
| 1592 | - | |||||||||||||||||||||||||
| 1593 | - | |||||||||||||||||||||||||
| 1594 | resize(newLength); | - | ||||||||||||||||||||||||
| 1595 | int i = 0; | - | ||||||||||||||||||||||||
| 1596 | QChar *uc = data(); | - | ||||||||||||||||||||||||
| 1597 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(chunks)>::type> _container_((chunks)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const QStringRef &chunk = *_container_.i; _container_.control; _container_.control = 0): qAsConst(chunks)) { | - | ||||||||||||||||||||||||
| 1598 | int len = chunk.length(); | - | ||||||||||||||||||||||||
| 1599 | memcpy(uc + i, chunk.unicode(), len * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 1600 | i += len; | - | ||||||||||||||||||||||||
| 1601 | } executed 4323 times by 4 tests: end of blockExecuted by:
| 4323 | ||||||||||||||||||||||||
| 1602 | - | |||||||||||||||||||||||||
| 1603 | return executed 1501 times by 4 tests: *this;return *this;Executed by:
executed 1501 times by 4 tests: return *this;Executed by:
| 1501 | ||||||||||||||||||||||||
| 1604 | } | - | ||||||||||||||||||||||||
| 1605 | int QString::count(const QString &str, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1606 | { | - | ||||||||||||||||||||||||
| 1607 | return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs); | - | ||||||||||||||||||||||||
| 1608 | } | - | ||||||||||||||||||||||||
| 1609 | int QString::count(QChar ch, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1610 | { | - | ||||||||||||||||||||||||
| 1611 | return qt_string_count(unicode(), size(), ch, cs); | - | ||||||||||||||||||||||||
| 1612 | } | - | ||||||||||||||||||||||||
| 1613 | int QString::count(const QStringRef &str, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1614 | { | - | ||||||||||||||||||||||||
| 1615 | return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs); | - | ||||||||||||||||||||||||
| 1616 | } | - | ||||||||||||||||||||||||
| 1617 | int QString::indexOf(const QRegExp& rx, int from) const | - | ||||||||||||||||||||||||
| 1618 | { | - | ||||||||||||||||||||||||
| 1619 | QRegExp rx2(rx); | - | ||||||||||||||||||||||||
| 1620 | return rx2.indexIn(*this, from); | - | ||||||||||||||||||||||||
| 1621 | } | - | ||||||||||||||||||||||||
| 1622 | int QString::indexOf(QRegExp& rx, int from) const | - | ||||||||||||||||||||||||
| 1623 | { | - | ||||||||||||||||||||||||
| 1624 | return rx.indexIn(*this, from); | - | ||||||||||||||||||||||||
| 1625 | } | - | ||||||||||||||||||||||||
| 1626 | int QString::lastIndexOf(const QRegExp& rx, int from) const | - | ||||||||||||||||||||||||
| 1627 | { | - | ||||||||||||||||||||||||
| 1628 | QRegExp rx2(rx); | - | ||||||||||||||||||||||||
| 1629 | return rx2.lastIndexIn(*this, from); | - | ||||||||||||||||||||||||
| 1630 | } | - | ||||||||||||||||||||||||
| 1631 | int QString::lastIndexOf(QRegExp& rx, int from) const | - | ||||||||||||||||||||||||
| 1632 | { | - | ||||||||||||||||||||||||
| 1633 | return rx.lastIndexIn(*this, from); | - | ||||||||||||||||||||||||
| 1634 | } | - | ||||||||||||||||||||||||
| 1635 | int QString::count(const QRegExp& rx) const | - | ||||||||||||||||||||||||
| 1636 | { | - | ||||||||||||||||||||||||
| 1637 | QRegExp rx2(rx); | - | ||||||||||||||||||||||||
| 1638 | int count = 0; | - | ||||||||||||||||||||||||
| 1639 | int index = -1; | - | ||||||||||||||||||||||||
| 1640 | int len = length(); | - | ||||||||||||||||||||||||
| 1641 | while (index < len - 1) { | - | ||||||||||||||||||||||||
| 1642 | index = rx2.indexIn(*this, index + 1); | - | ||||||||||||||||||||||||
| 1643 | if (index == -1) | - | ||||||||||||||||||||||||
| 1644 | break; | - | ||||||||||||||||||||||||
| 1645 | count++; | - | ||||||||||||||||||||||||
| 1646 | } | - | ||||||||||||||||||||||||
| 1647 | return count; | - | ||||||||||||||||||||||||
| 1648 | } | - | ||||||||||||||||||||||||
| 1649 | int QString::indexOf(const QRegularExpression& re, int from) const | - | ||||||||||||||||||||||||
| 1650 | { | - | ||||||||||||||||||||||||
| 1651 | return indexOf(re, from, nullptr); | - | ||||||||||||||||||||||||
| 1652 | } | - | ||||||||||||||||||||||||
| 1653 | int QString::indexOf(const QRegularExpression &re, int from, QRegularExpressionMatch *rmatch) const | - | ||||||||||||||||||||||||
| 1654 | { | - | ||||||||||||||||||||||||
| 1655 | if (!re.isValid()) { | - | ||||||||||||||||||||||||
| 1656 | QMessageLogger(__FILE__, 38953925, __PRETTY_FUNCTION__).warning("QString::indexOf: invalid QRegularExpression object"); | - | ||||||||||||||||||||||||
| 1657 | return -1; | - | ||||||||||||||||||||||||
| 1658 | } | - | ||||||||||||||||||||||||
| 1659 | - | |||||||||||||||||||||||||
| 1660 | QRegularExpressionMatch match = re.match(*this, from); | - | ||||||||||||||||||||||||
| 1661 | if (match.hasMatch()) { | - | ||||||||||||||||||||||||
| 1662 | const int ret = match.capturedStart(); | - | ||||||||||||||||||||||||
| 1663 | if (rmatch) | - | ||||||||||||||||||||||||
| 1664 | *rmatch = std::move(match); | - | ||||||||||||||||||||||||
| 1665 | return ret; | - | ||||||||||||||||||||||||
| 1666 | } | - | ||||||||||||||||||||||||
| 1667 | - | |||||||||||||||||||||||||
| 1668 | return -1; | - | ||||||||||||||||||||||||
| 1669 | } | - | ||||||||||||||||||||||||
| 1670 | int QString::lastIndexOf(const QRegularExpression &re, int from) const | - | ||||||||||||||||||||||||
| 1671 | { | - | ||||||||||||||||||||||||
| 1672 | return lastIndexOf(re, from, nullptr); | - | ||||||||||||||||||||||||
| 1673 | } | - | ||||||||||||||||||||||||
| 1674 | int QString::lastIndexOf(const QRegularExpression &re, int from, QRegularExpressionMatch *rmatch) const | - | ||||||||||||||||||||||||
| 1675 | { | - | ||||||||||||||||||||||||
| 1676 | if (!re.isValid()) { | - | ||||||||||||||||||||||||
| 1677 | QMessageLogger(__FILE__, 39463976, __PRETTY_FUNCTION__).warning("QString::lastIndexOf: invalid QRegularExpression object"); | - | ||||||||||||||||||||||||
| 1678 | return -1; | - | ||||||||||||||||||||||||
| 1679 | } | - | ||||||||||||||||||||||||
| 1680 | - | |||||||||||||||||||||||||
| 1681 | int endpos = (from < 0) ? (size() + from + 1) : (from + 1); | - | ||||||||||||||||||||||||
| 1682 | QRegularExpressionMatchIterator iterator = re.globalMatch(*this); | - | ||||||||||||||||||||||||
| 1683 | int lastIndex = -1; | - | ||||||||||||||||||||||||
| 1684 | while (iterator.hasNext()) { | - | ||||||||||||||||||||||||
| 1685 | QRegularExpressionMatch match = iterator.next(); | - | ||||||||||||||||||||||||
| 1686 | int start = match.capturedStart(); | - | ||||||||||||||||||||||||
| 1687 | if (start < endpos) { | - | ||||||||||||||||||||||||
| 1688 | lastIndex = start; | - | ||||||||||||||||||||||||
| 1689 | if (rmatch) | - | ||||||||||||||||||||||||
| 1690 | *rmatch = std::move(match); | - | ||||||||||||||||||||||||
| 1691 | } else { | - | ||||||||||||||||||||||||
| 1692 | break; | - | ||||||||||||||||||||||||
| 1693 | } | - | ||||||||||||||||||||||||
| 1694 | } | - | ||||||||||||||||||||||||
| 1695 | - | |||||||||||||||||||||||||
| 1696 | return lastIndex; | - | ||||||||||||||||||||||||
| 1697 | } | - | ||||||||||||||||||||||||
| 1698 | - | |||||||||||||||||||||||||
| 1699 | - | |||||||||||||||||||||||||
| 1700 | - | |||||||||||||||||||||||||
| 1701 | - | |||||||||||||||||||||||||
| 1702 | - | |||||||||||||||||||||||||
| 1703 | - | |||||||||||||||||||||||||
| 1704 | - | |||||||||||||||||||||||||
| 1705 | bool QString::contains(const QRegularExpression &re) const | - | ||||||||||||||||||||||||
| 1706 | { | - | ||||||||||||||||||||||||
| 1707 | return contains(re, nullptr); | - | ||||||||||||||||||||||||
| 1708 | } | - | ||||||||||||||||||||||||
| 1709 | bool QString::contains(const QRegularExpression &re, QRegularExpressionMatch *match) const | - | ||||||||||||||||||||||||
| 1710 | { | - | ||||||||||||||||||||||||
| 1711 | if (!re.isValid()) { | - | ||||||||||||||||||||||||
| 1712 | QMessageLogger(__FILE__, 39964026, __PRETTY_FUNCTION__).warning("QString::contains: invalid QRegularExpression object"); | - | ||||||||||||||||||||||||
| 1713 | return false; | - | ||||||||||||||||||||||||
| 1714 | } | - | ||||||||||||||||||||||||
| 1715 | QRegularExpressionMatch m = re.match(*this); | - | ||||||||||||||||||||||||
| 1716 | bool hasMatch = m.hasMatch(); | - | ||||||||||||||||||||||||
| 1717 | if (hasMatch && match) | - | ||||||||||||||||||||||||
| 1718 | *match = std::move(m); | - | ||||||||||||||||||||||||
| 1719 | return hasMatch; | - | ||||||||||||||||||||||||
| 1720 | } | - | ||||||||||||||||||||||||
| 1721 | int QString::count(const QRegularExpression &re) const | - | ||||||||||||||||||||||||
| 1722 | { | - | ||||||||||||||||||||||||
| 1723 | if (!re.isValid()) { | - | ||||||||||||||||||||||||
| 1724 | QMessageLogger(__FILE__, 40214051, __PRETTY_FUNCTION__).warning("QString::count: invalid QRegularExpression object"); | - | ||||||||||||||||||||||||
| 1725 | return 0; | - | ||||||||||||||||||||||||
| 1726 | } | - | ||||||||||||||||||||||||
| 1727 | int count = 0; | - | ||||||||||||||||||||||||
| 1728 | int index = -1; | - | ||||||||||||||||||||||||
| 1729 | int len = length(); | - | ||||||||||||||||||||||||
| 1730 | while (index < len - 1) { | - | ||||||||||||||||||||||||
| 1731 | QRegularExpressionMatch match = re.match(*this, index + 1); | - | ||||||||||||||||||||||||
| 1732 | if (!match.hasMatch()) | - | ||||||||||||||||||||||||
| 1733 | break; | - | ||||||||||||||||||||||||
| 1734 | index = match.capturedStart(); | - | ||||||||||||||||||||||||
| 1735 | count++; | - | ||||||||||||||||||||||||
| 1736 | } | - | ||||||||||||||||||||||||
| 1737 | return count; | - | ||||||||||||||||||||||||
| 1738 | } | - | ||||||||||||||||||||||||
| 1739 | QString QString::section(const QString &sep, int start, int end, SectionFlags flags) const | - | ||||||||||||||||||||||||
| 1740 | { | - | ||||||||||||||||||||||||
| 1741 | const QVector<QStringRef> sections = splitRef(sep, KeepEmptyParts, | - | ||||||||||||||||||||||||
| 1742 | (flags & SectionCaseInsensitiveSeps) ? Qt::CaseInsensitive : Qt::CaseSensitive); | - | ||||||||||||||||||||||||
| 1743 | const int sectionsSize = sections.size(); | - | ||||||||||||||||||||||||
| 1744 | if (!(flags & SectionSkipEmpty)) { | - | ||||||||||||||||||||||||
| 1745 | if (start < 0) | - | ||||||||||||||||||||||||
| 1746 | start += sectionsSize; | - | ||||||||||||||||||||||||
| 1747 | if (end < 0) | - | ||||||||||||||||||||||||
| 1748 | end += sectionsSize; | - | ||||||||||||||||||||||||
| 1749 | } else { | - | ||||||||||||||||||||||||
| 1750 | int skip = 0; | - | ||||||||||||||||||||||||
| 1751 | for (int k = 0; k < sectionsSize; ++k) { | - | ||||||||||||||||||||||||
| 1752 | if (sections.at(k).isEmpty()) | - | ||||||||||||||||||||||||
| 1753 | skip++; | - | ||||||||||||||||||||||||
| 1754 | } | - | ||||||||||||||||||||||||
| 1755 | if (start < 0) | - | ||||||||||||||||||||||||
| 1756 | start += sectionsSize - skip; | - | ||||||||||||||||||||||||
| 1757 | if (end < 0) | - | ||||||||||||||||||||||||
| 1758 | end += sectionsSize - skip; | - | ||||||||||||||||||||||||
| 1759 | } | - | ||||||||||||||||||||||||
| 1760 | if (start >= sectionsSize || end < 0 || start > end) | - | ||||||||||||||||||||||||
| 1761 | return QString(); | - | ||||||||||||||||||||||||
| 1762 | - | |||||||||||||||||||||||||
| 1763 | QString ret; | - | ||||||||||||||||||||||||
| 1764 | int first_i = start, last_i = end; | - | ||||||||||||||||||||||||
| 1765 | for (int x = 0, i = 0; x <= end && i < sectionsSize; ++i) { | - | ||||||||||||||||||||||||
| 1766 | const QStringRef §ion = sections.at(i); | - | ||||||||||||||||||||||||
| 1767 | const bool empty = section.isEmpty(); | - | ||||||||||||||||||||||||
| 1768 | if (x >= start) { | - | ||||||||||||||||||||||||
| 1769 | if(x == start) | - | ||||||||||||||||||||||||
| 1770 | first_i = i; | - | ||||||||||||||||||||||||
| 1771 | if(x == end) | - | ||||||||||||||||||||||||
| 1772 | last_i = i; | - | ||||||||||||||||||||||||
| 1773 | if (x > start && i > 0) | - | ||||||||||||||||||||||||
| 1774 | ret += sep; | - | ||||||||||||||||||||||||
| 1775 | ret += section; | - | ||||||||||||||||||||||||
| 1776 | } | - | ||||||||||||||||||||||||
| 1777 | if (!empty || !(flags & SectionSkipEmpty)) | - | ||||||||||||||||||||||||
| 1778 | x++; | - | ||||||||||||||||||||||||
| 1779 | } | - | ||||||||||||||||||||||||
| 1780 | if ((flags & SectionIncludeLeadingSep) && first_i > 0) | - | ||||||||||||||||||||||||
| 1781 | ret.prepend(sep); | - | ||||||||||||||||||||||||
| 1782 | if ((flags & SectionIncludeTrailingSep) && last_i < sectionsSize - 1) | - | ||||||||||||||||||||||||
| 1783 | ret += sep; | - | ||||||||||||||||||||||||
| 1784 | return ret; | - | ||||||||||||||||||||||||
| 1785 | } | - | ||||||||||||||||||||||||
| 1786 | - | |||||||||||||||||||||||||
| 1787 | - | |||||||||||||||||||||||||
| 1788 | class qt_section_chunk { | - | ||||||||||||||||||||||||
| 1789 | public: | - | ||||||||||||||||||||||||
| 1790 | qt_section_chunk() {} | - | ||||||||||||||||||||||||
| 1791 | qt_section_chunk(int l, QStringRef s) : length(l), string(std::move(s)) {} | - | ||||||||||||||||||||||||
| 1792 | int length; | - | ||||||||||||||||||||||||
| 1793 | QStringRef string; | - | ||||||||||||||||||||||||
| 1794 | }; | - | ||||||||||||||||||||||||
| 1795 | template<> class QTypeInfo<qt_section_chunk > { public: enum { isComplex = (((Q_MOVABLE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_MOVABLE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_MOVABLE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(qt_section_chunk)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< qt_section_chunk >::value, isDummy = (((Q_MOVABLE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(qt_section_chunk) }; static inline const char *name() { return "qt_section_chunk"; } }; | - | ||||||||||||||||||||||||
| 1796 | - | |||||||||||||||||||||||||
| 1797 | static QString extractSections(const QVector<qt_section_chunk> §ions, | - | ||||||||||||||||||||||||
| 1798 | int start, | - | ||||||||||||||||||||||||
| 1799 | int end, | - | ||||||||||||||||||||||||
| 1800 | QString::SectionFlags flags) | - | ||||||||||||||||||||||||
| 1801 | { | - | ||||||||||||||||||||||||
| 1802 | const int sectionsSize = sections.size(); | - | ||||||||||||||||||||||||
| 1803 | - | |||||||||||||||||||||||||
| 1804 | if (!(flags & QString::SectionSkipEmpty)) { | - | ||||||||||||||||||||||||
| 1805 | if (start < 0) | - | ||||||||||||||||||||||||
| 1806 | start += sectionsSize; | - | ||||||||||||||||||||||||
| 1807 | if (end < 0) | - | ||||||||||||||||||||||||
| 1808 | end += sectionsSize; | - | ||||||||||||||||||||||||
| 1809 | } else { | - | ||||||||||||||||||||||||
| 1810 | int skip = 0; | - | ||||||||||||||||||||||||
| 1811 | for (int k = 0; k < sectionsSize; ++k) { | - | ||||||||||||||||||||||||
| 1812 | const qt_section_chunk §ion = sections.at(k); | - | ||||||||||||||||||||||||
| 1813 | if (section.length == section.string.length()) | - | ||||||||||||||||||||||||
| 1814 | skip++; | - | ||||||||||||||||||||||||
| 1815 | } | - | ||||||||||||||||||||||||
| 1816 | if (start < 0) | - | ||||||||||||||||||||||||
| 1817 | start += sectionsSize - skip; | - | ||||||||||||||||||||||||
| 1818 | if (end < 0) | - | ||||||||||||||||||||||||
| 1819 | end += sectionsSize - skip; | - | ||||||||||||||||||||||||
| 1820 | } | - | ||||||||||||||||||||||||
| 1821 | if (start >= sectionsSize || end < 0 || start > end) | - | ||||||||||||||||||||||||
| 1822 | return QString(); | - | ||||||||||||||||||||||||
| 1823 | - | |||||||||||||||||||||||||
| 1824 | QString ret; | - | ||||||||||||||||||||||||
| 1825 | int x = 0; | - | ||||||||||||||||||||||||
| 1826 | int first_i = start, last_i = end; | - | ||||||||||||||||||||||||
| 1827 | for (int i = 0; x <= end && i < sectionsSize; ++i) { | - | ||||||||||||||||||||||||
| 1828 | const qt_section_chunk §ion = sections.at(i); | - | ||||||||||||||||||||||||
| 1829 | const bool empty = (section.length == section.string.length()); | - | ||||||||||||||||||||||||
| 1830 | if (x >= start) { | - | ||||||||||||||||||||||||
| 1831 | if (x == start) | - | ||||||||||||||||||||||||
| 1832 | first_i = i; | - | ||||||||||||||||||||||||
| 1833 | if (x == end) | - | ||||||||||||||||||||||||
| 1834 | last_i = i; | - | ||||||||||||||||||||||||
| 1835 | if (x != start) | - | ||||||||||||||||||||||||
| 1836 | ret += section.string; | - | ||||||||||||||||||||||||
| 1837 | else | - | ||||||||||||||||||||||||
| 1838 | ret += section.string.mid(section.length); | - | ||||||||||||||||||||||||
| 1839 | } | - | ||||||||||||||||||||||||
| 1840 | if (!empty || !(flags & QString::SectionSkipEmpty)) | - | ||||||||||||||||||||||||
| 1841 | x++; | - | ||||||||||||||||||||||||
| 1842 | } | - | ||||||||||||||||||||||||
| 1843 | - | |||||||||||||||||||||||||
| 1844 | if ((flags & QString::SectionIncludeLeadingSep) && first_i >= 0) { | - | ||||||||||||||||||||||||
| 1845 | const qt_section_chunk §ion = sections.at(first_i); | - | ||||||||||||||||||||||||
| 1846 | ret.prepend(section.string.left(section.length)); | - | ||||||||||||||||||||||||
| 1847 | } | - | ||||||||||||||||||||||||
| 1848 | - | |||||||||||||||||||||||||
| 1849 | if ((flags & QString::SectionIncludeTrailingSep) | - | ||||||||||||||||||||||||
| 1850 | && last_i < sectionsSize - 1) { | - | ||||||||||||||||||||||||
| 1851 | const qt_section_chunk §ion = sections.at(last_i+1); | - | ||||||||||||||||||||||||
| 1852 | ret += section.string.left(section.length); | - | ||||||||||||||||||||||||
| 1853 | } | - | ||||||||||||||||||||||||
| 1854 | - | |||||||||||||||||||||||||
| 1855 | return ret; | - | ||||||||||||||||||||||||
| 1856 | } | - | ||||||||||||||||||||||||
| 1857 | QString QString::section(const QRegExp ®, int start, int end, SectionFlags flags) const | - | ||||||||||||||||||||||||
| 1858 | { | - | ||||||||||||||||||||||||
| 1859 | const QChar *uc = unicode(); | - | ||||||||||||||||||||||||
| 1860 | if(!uc) | - | ||||||||||||||||||||||||
| 1861 | return QString(); | - | ||||||||||||||||||||||||
| 1862 | - | |||||||||||||||||||||||||
| 1863 | QRegExp sep(reg); | - | ||||||||||||||||||||||||
| 1864 | sep.setCaseSensitivity((flags & SectionCaseInsensitiveSeps) ? Qt::CaseInsensitive | - | ||||||||||||||||||||||||
| 1865 | : Qt::CaseSensitive); | - | ||||||||||||||||||||||||
| 1866 | - | |||||||||||||||||||||||||
| 1867 | QVector<qt_section_chunk> sections; | - | ||||||||||||||||||||||||
| 1868 | int n = length(), m = 0, last_m = 0, last_len = 0; | - | ||||||||||||||||||||||||
| 1869 | while ((m = sep.indexIn(*this, m)) != -1) { | - | ||||||||||||||||||||||||
| 1870 | sections.append(qt_section_chunk(last_len, QStringRef(this, last_m, m - last_m))); | - | ||||||||||||||||||||||||
| 1871 | last_m = m; | - | ||||||||||||||||||||||||
| 1872 | last_len = sep.matchedLength(); | - | ||||||||||||||||||||||||
| 1873 | m += qMax(sep.matchedLength(), 1); | - | ||||||||||||||||||||||||
| 1874 | } | - | ||||||||||||||||||||||||
| 1875 | sections.append(qt_section_chunk(last_len, QStringRef(this, last_m, n - last_m))); | - | ||||||||||||||||||||||||
| 1876 | - | |||||||||||||||||||||||||
| 1877 | return extractSections(sections, start, end, flags); | - | ||||||||||||||||||||||||
| 1878 | } | - | ||||||||||||||||||||||||
| 1879 | QString QString::section(const QRegularExpression &re, int start, int end, SectionFlags flags) const | - | ||||||||||||||||||||||||
| 1880 | { | - | ||||||||||||||||||||||||
| 1881 | if (!re.isValid()) { | - | ||||||||||||||||||||||||
| 1882 | QMessageLogger(__FILE__, 42884318, __PRETTY_FUNCTION__).warning("QString::section: invalid QRegularExpression object"); | - | ||||||||||||||||||||||||
| 1883 | return QString(); | - | ||||||||||||||||||||||||
| 1884 | } | - | ||||||||||||||||||||||||
| 1885 | - | |||||||||||||||||||||||||
| 1886 | const QChar *uc = unicode(); | - | ||||||||||||||||||||||||
| 1887 | if (!uc) | - | ||||||||||||||||||||||||
| 1888 | return QString(); | - | ||||||||||||||||||||||||
| 1889 | - | |||||||||||||||||||||||||
| 1890 | QRegularExpression sep(re); | - | ||||||||||||||||||||||||
| 1891 | if (flags & SectionCaseInsensitiveSeps) | - | ||||||||||||||||||||||||
| 1892 | sep.setPatternOptions(sep.patternOptions() | QRegularExpression::CaseInsensitiveOption); | - | ||||||||||||||||||||||||
| 1893 | - | |||||||||||||||||||||||||
| 1894 | QVector<qt_section_chunk> sections; | - | ||||||||||||||||||||||||
| 1895 | int n = length(), m = 0, last_m = 0, last_len = 0; | - | ||||||||||||||||||||||||
| 1896 | QRegularExpressionMatchIterator iterator = sep.globalMatch(*this); | - | ||||||||||||||||||||||||
| 1897 | while (iterator.hasNext()) { | - | ||||||||||||||||||||||||
| 1898 | QRegularExpressionMatch match = iterator.next(); | - | ||||||||||||||||||||||||
| 1899 | m = match.capturedStart(); | - | ||||||||||||||||||||||||
| 1900 | sections.append(qt_section_chunk(last_len, QStringRef(this, last_m, m - last_m))); | - | ||||||||||||||||||||||||
| 1901 | last_m = m; | - | ||||||||||||||||||||||||
| 1902 | last_len = match.capturedLength(); | - | ||||||||||||||||||||||||
| 1903 | } | - | ||||||||||||||||||||||||
| 1904 | sections.append(qt_section_chunk(last_len, QStringRef(this, last_m, n - last_m))); | - | ||||||||||||||||||||||||
| 1905 | - | |||||||||||||||||||||||||
| 1906 | return extractSections(sections, start, end, flags); | - | ||||||||||||||||||||||||
| 1907 | } | - | ||||||||||||||||||||||||
| 1908 | QString QString::left(int n) const | - | ||||||||||||||||||||||||
| 1909 | { | - | ||||||||||||||||||||||||
| 1910 | if (uint(n) >= uint(d->size)) | - | ||||||||||||||||||||||||
| 1911 | return *this; | - | ||||||||||||||||||||||||
| 1912 | return QString((const QChar*) d->data(), n); | - | ||||||||||||||||||||||||
| 1913 | } | - | ||||||||||||||||||||||||
| 1914 | QString QString::right(int n) const | - | ||||||||||||||||||||||||
| 1915 | { | - | ||||||||||||||||||||||||
| 1916 | if (uint(n) >= uint(d->size)) | - | ||||||||||||||||||||||||
| 1917 | return *this; | - | ||||||||||||||||||||||||
| 1918 | return QString((const QChar*) d->data() + d->size - n, n); | - | ||||||||||||||||||||||||
| 1919 | } | - | ||||||||||||||||||||||||
| 1920 | QString QString::mid(int position, int n) const | - | ||||||||||||||||||||||||
| 1921 | { | - | ||||||||||||||||||||||||
| 1922 | using namespace QtPrivate; | - | ||||||||||||||||||||||||
| 1923 | switch (QContainerImplHelper::mid(d->size, &position, &n)) { | - | ||||||||||||||||||||||||
| 1924 | case QContainerImplHelper::Null: | - | ||||||||||||||||||||||||
| 1925 | return QString(); | - | ||||||||||||||||||||||||
| 1926 | case QContainerImplHelper::Empty: | - | ||||||||||||||||||||||||
| 1927 | { | - | ||||||||||||||||||||||||
| 1928 | QStringDataPtr empty = { Data::allocate(0) }; | - | ||||||||||||||||||||||||
| 1929 | return QString(empty); | - | ||||||||||||||||||||||||
| 1930 | } | - | ||||||||||||||||||||||||
| 1931 | case QContainerImplHelper::Full: | - | ||||||||||||||||||||||||
| 1932 | return *this; | - | ||||||||||||||||||||||||
| 1933 | case QContainerImplHelper::Subset: | - | ||||||||||||||||||||||||
| 1934 | return QString((const QChar*)d->data() + position, n); | - | ||||||||||||||||||||||||
| 1935 | } | - | ||||||||||||||||||||||||
| 1936 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,43864416) : qt_noop()); __builtin_unreachable(); } while (0); | - | ||||||||||||||||||||||||
| 1937 | return QString(); | - | ||||||||||||||||||||||||
| 1938 | } | - | ||||||||||||||||||||||||
| 1939 | bool QString::startsWith(const QString& s, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1940 | { | - | ||||||||||||||||||||||||
| 1941 | return qt_starts_with(isNull() ? 0 : unicode(), size(), | - | ||||||||||||||||||||||||
| 1942 | s.isNull() ? 0 : s.unicode(), s.size(), cs); | - | ||||||||||||||||||||||||
| 1943 | } | - | ||||||||||||||||||||||||
| 1944 | - | |||||||||||||||||||||||||
| 1945 | - | |||||||||||||||||||||||||
| 1946 | - | |||||||||||||||||||||||||
| 1947 | - | |||||||||||||||||||||||||
| 1948 | bool QString::startsWith(QLatin1String s, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1949 | { | - | ||||||||||||||||||||||||
| 1950 | return qt_starts_with(isNull() ? 0 : unicode(), size(), s, cs); | - | ||||||||||||||||||||||||
| 1951 | } | - | ||||||||||||||||||||||||
| 1952 | - | |||||||||||||||||||||||||
| 1953 | - | |||||||||||||||||||||||||
| 1954 | - | |||||||||||||||||||||||||
| 1955 | - | |||||||||||||||||||||||||
| 1956 | - | |||||||||||||||||||||||||
| 1957 | - | |||||||||||||||||||||||||
| 1958 | - | |||||||||||||||||||||||||
| 1959 | bool QString::startsWith(QChar c, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1960 | { | - | ||||||||||||||||||||||||
| 1961 | return d->size | - | ||||||||||||||||||||||||
| 1962 | && (cs == Qt::CaseSensitive | - | ||||||||||||||||||||||||
| 1963 | ? d->data()[0] == c | - | ||||||||||||||||||||||||
| 1964 | : foldCase(d->data()[0]) == foldCase(c.unicode())); | - | ||||||||||||||||||||||||
| 1965 | } | - | ||||||||||||||||||||||||
| 1966 | bool QString::startsWith(const QStringRef &s, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1967 | { | - | ||||||||||||||||||||||||
| 1968 | return qt_starts_with(isNull() ? 0 : unicode(), size(), | - | ||||||||||||||||||||||||
| 1969 | s.isNull() ? 0 : s.unicode(), s.size(), cs); | - | ||||||||||||||||||||||||
| 1970 | } | - | ||||||||||||||||||||||||
| 1971 | bool QString::endsWith(const QString& s, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1972 | { | - | ||||||||||||||||||||||||
| 1973 | return qt_ends_with(isNull() ? 0 : unicode(), size(), | - | ||||||||||||||||||||||||
| 1974 | s.isNull() ? 0 : s.unicode(), s.size(), cs); | - | ||||||||||||||||||||||||
| 1975 | } | - | ||||||||||||||||||||||||
| 1976 | bool QString::endsWith(const QStringRef &s, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1977 | { | - | ||||||||||||||||||||||||
| 1978 | return qt_ends_with(isNull() ? 0 : unicode(), size(), | - | ||||||||||||||||||||||||
| 1979 | s.isNull() ? 0 : s.unicode(), s.size(), cs); | - | ||||||||||||||||||||||||
| 1980 | } | - | ||||||||||||||||||||||||
| 1981 | - | |||||||||||||||||||||||||
| 1982 | - | |||||||||||||||||||||||||
| 1983 | - | |||||||||||||||||||||||||
| 1984 | - | |||||||||||||||||||||||||
| 1985 | - | |||||||||||||||||||||||||
| 1986 | bool QString::endsWith(QLatin1String s, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1987 | { | - | ||||||||||||||||||||||||
| 1988 | return qt_ends_with(isNull() ? 0 : unicode(), size(), s, cs); | - | ||||||||||||||||||||||||
| 1989 | } | - | ||||||||||||||||||||||||
| 1990 | - | |||||||||||||||||||||||||
| 1991 | - | |||||||||||||||||||||||||
| 1992 | - | |||||||||||||||||||||||||
| 1993 | - | |||||||||||||||||||||||||
| 1994 | - | |||||||||||||||||||||||||
| 1995 | - | |||||||||||||||||||||||||
| 1996 | - | |||||||||||||||||||||||||
| 1997 | bool QString::endsWith(QChar c, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 1998 | { | - | ||||||||||||||||||||||||
| 1999 | return d->size | - | ||||||||||||||||||||||||
| 2000 | && (cs == Qt::CaseSensitive | - | ||||||||||||||||||||||||
| 2001 | ? d->data()[d->size - 1] == c | - | ||||||||||||||||||||||||
| 2002 | : foldCase(d->data()[d->size - 1]) == foldCase(c.unicode())); | - | ||||||||||||||||||||||||
| 2003 | } | - | ||||||||||||||||||||||||
| 2004 | - | |||||||||||||||||||||||||
| 2005 | QByteArray QString::toLatin1_helper(const QString &string) | - | ||||||||||||||||||||||||
| 2006 | { | - | ||||||||||||||||||||||||
| 2007 | if (__builtin_expect(!!(string.isNull()), false)) | - | ||||||||||||||||||||||||
| 2008 | return QByteArray(); | - | ||||||||||||||||||||||||
| 2009 | - | |||||||||||||||||||||||||
| 2010 | return toLatin1_helper(string.constData(), string.length()); | - | ||||||||||||||||||||||||
| 2011 | } | - | ||||||||||||||||||||||||
| 2012 | - | |||||||||||||||||||||||||
| 2013 | QByteArray QString::toLatin1_helper(const QChar *data, int length) | - | ||||||||||||||||||||||||
| 2014 | { | - | ||||||||||||||||||||||||
| 2015 | QByteArray ba(length, Qt::Uninitialized); | - | ||||||||||||||||||||||||
| 2016 | - | |||||||||||||||||||||||||
| 2017 | - | |||||||||||||||||||||||||
| 2018 | - | |||||||||||||||||||||||||
| 2019 | qt_to_latin1(reinterpret_cast<uchar *>(const_cast<char *>(ba.constData())), | - | ||||||||||||||||||||||||
| 2020 | reinterpret_cast<const ushort *>(data), length); | - | ||||||||||||||||||||||||
| 2021 | return ba; | - | ||||||||||||||||||||||||
| 2022 | } | - | ||||||||||||||||||||||||
| 2023 | - | |||||||||||||||||||||||||
| 2024 | QByteArray QString::toLatin1_helper_inplace(QString &s) | - | ||||||||||||||||||||||||
| 2025 | { | - | ||||||||||||||||||||||||
| 2026 | if (!s.isDetached()) | - | ||||||||||||||||||||||||
| 2027 | return s.toLatin1(); | - | ||||||||||||||||||||||||
| 2028 | - | |||||||||||||||||||||||||
| 2029 | - | |||||||||||||||||||||||||
| 2030 | - | |||||||||||||||||||||||||
| 2031 | const ushort *data = reinterpret_cast<const ushort *>(s.constData()); | - | ||||||||||||||||||||||||
| 2032 | uint length = s.size(); | - | ||||||||||||||||||||||||
| 2033 | - | |||||||||||||||||||||||||
| 2034 | - | |||||||||||||||||||||||||
| 2035 | - | |||||||||||||||||||||||||
| 2036 | QArrayData *ba_d = s.d; | - | ||||||||||||||||||||||||
| 2037 | - | |||||||||||||||||||||||||
| 2038 | - | |||||||||||||||||||||||||
| 2039 | ba_d->alloc *= sizeof(ushort); | - | ||||||||||||||||||||||||
| 2040 | - | |||||||||||||||||||||||||
| 2041 | - | |||||||||||||||||||||||||
| 2042 | s.d = QString().d; | - | ||||||||||||||||||||||||
| 2043 | - | |||||||||||||||||||||||||
| 2044 | - | |||||||||||||||||||||||||
| 2045 | uchar *dst = reinterpret_cast<uchar *>(ba_d->data()); | - | ||||||||||||||||||||||||
| 2046 | qt_to_latin1(dst, data, length); | - | ||||||||||||||||||||||||
| 2047 | dst[length] = '\0'; | - | ||||||||||||||||||||||||
| 2048 | - | |||||||||||||||||||||||||
| 2049 | QByteArrayDataPtr badptr = { ba_d }; | - | ||||||||||||||||||||||||
| 2050 | return QByteArray(badptr); | - | ||||||||||||||||||||||||
| 2051 | } | - | ||||||||||||||||||||||||
| 2052 | QByteArray QString::toLocal8Bit_helper(const QChar *data, int size) | - | ||||||||||||||||||||||||
| 2053 | { | - | ||||||||||||||||||||||||
| 2054 | - | |||||||||||||||||||||||||
| 2055 | QTextCodec *localeCodec = QTextCodec::codecForLocale(); | - | ||||||||||||||||||||||||
| 2056 | if (localeCodec) | - | ||||||||||||||||||||||||
| 2057 | return localeCodec->fromUnicode(data, size); | - | ||||||||||||||||||||||||
| 2058 | - | |||||||||||||||||||||||||
| 2059 | return toLatin1_helper(data, size); | - | ||||||||||||||||||||||||
| 2060 | } | - | ||||||||||||||||||||||||
| 2061 | QByteArray QString::toUtf8_helper(const QString &str) | - | ||||||||||||||||||||||||
| 2062 | { | - | ||||||||||||||||||||||||
| 2063 | if (str.isNull()) | - | ||||||||||||||||||||||||
| 2064 | return QByteArray(); | - | ||||||||||||||||||||||||
| 2065 | - | |||||||||||||||||||||||||
| 2066 | return QUtf8::convertFromUnicode(str.constData(), str.length()); | - | ||||||||||||||||||||||||
| 2067 | } | - | ||||||||||||||||||||||||
| 2068 | QVector<uint> QString::toUcs4() const | - | ||||||||||||||||||||||||
| 2069 | { | - | ||||||||||||||||||||||||
| 2070 | QVector<uint> v(length()); | - | ||||||||||||||||||||||||
| 2071 | uint *a = v.data(); | - | ||||||||||||||||||||||||
| 2072 | int len = toUcs4_helper(d->data(), length(), a); | - | ||||||||||||||||||||||||
| 2073 | v.resize(len); | - | ||||||||||||||||||||||||
| 2074 | return v; | - | ||||||||||||||||||||||||
| 2075 | } | - | ||||||||||||||||||||||||
| 2076 | - | |||||||||||||||||||||||||
| 2077 | QString::Data *QString::fromLatin1_helper(const char *str, int size) | - | ||||||||||||||||||||||||
| 2078 | { | - | ||||||||||||||||||||||||
| 2079 | Data *d; | - | ||||||||||||||||||||||||
| 2080 | if (!str) { | - | ||||||||||||||||||||||||
| 2081 | d = Data::sharedNull(); | - | ||||||||||||||||||||||||
| 2082 | } else if (size == 0 || (!*str && size < 0)) { | - | ||||||||||||||||||||||||
| 2083 | d = Data::allocate(0); | - | ||||||||||||||||||||||||
| 2084 | } else { | - | ||||||||||||||||||||||||
| 2085 | if (size < 0) | - | ||||||||||||||||||||||||
| 2086 | size = qstrlen(str); | - | ||||||||||||||||||||||||
| 2087 | d = Data::allocate(size + 1); | - | ||||||||||||||||||||||||
| 2088 | do { if (!(d)) qBadAlloc(); } while (0); | - | ||||||||||||||||||||||||
| 2089 | d->size = size; | - | ||||||||||||||||||||||||
| 2090 | d->data()[size] = '\0'; | - | ||||||||||||||||||||||||
| 2091 | ushort *dst = d->data(); | - | ||||||||||||||||||||||||
| 2092 | - | |||||||||||||||||||||||||
| 2093 | qt_from_latin1(dst, str, uint(size)); | - | ||||||||||||||||||||||||
| 2094 | } | - | ||||||||||||||||||||||||
| 2095 | return d; | - | ||||||||||||||||||||||||
| 2096 | } | - | ||||||||||||||||||||||||
| 2097 | - | |||||||||||||||||||||||||
| 2098 | QString::Data *QString::fromAscii_helper(const char *str, int size) | - | ||||||||||||||||||||||||
| 2099 | { | - | ||||||||||||||||||||||||
| 2100 | QString s = fromUtf8(str, size); | - | ||||||||||||||||||||||||
| 2101 | s.d->ref.ref(); | - | ||||||||||||||||||||||||
| 2102 | return s.d; | - | ||||||||||||||||||||||||
| 2103 | } | - | ||||||||||||||||||||||||
| 2104 | QString QString::fromLocal8Bit_helper(const char *str, int size) | - | ||||||||||||||||||||||||
| 2105 | { | - | ||||||||||||||||||||||||
| 2106 | if (!str) | - | ||||||||||||||||||||||||
| 2107 | return QString(); | - | ||||||||||||||||||||||||
| 2108 | if (size == 0 || (!*str && size < 0)) { | - | ||||||||||||||||||||||||
| 2109 | QStringDataPtr empty = { Data::allocate(0) }; | - | ||||||||||||||||||||||||
| 2110 | return QString(empty); | - | ||||||||||||||||||||||||
| 2111 | } | - | ||||||||||||||||||||||||
| 2112 | - | |||||||||||||||||||||||||
| 2113 | if (size < 0) | - | ||||||||||||||||||||||||
| 2114 | size = qstrlen(str); | - | ||||||||||||||||||||||||
| 2115 | QTextCodec *codec = QTextCodec::codecForLocale(); | - | ||||||||||||||||||||||||
| 2116 | if (codec) | - | ||||||||||||||||||||||||
| 2117 | return codec->toUnicode(str, size); | - | ||||||||||||||||||||||||
| 2118 | - | |||||||||||||||||||||||||
| 2119 | return fromLatin1(str, size); | - | ||||||||||||||||||||||||
| 2120 | } | - | ||||||||||||||||||||||||
| 2121 | QString QString::fromUtf8_helper(const char *str, int size) | - | ||||||||||||||||||||||||
| 2122 | { | - | ||||||||||||||||||||||||
| 2123 | if (!str) | - | ||||||||||||||||||||||||
| 2124 | return QString(); | - | ||||||||||||||||||||||||
| 2125 | - | |||||||||||||||||||||||||
| 2126 | ((!(size != -1)) ? qt_assert("size != -1",__FILE__,47884818) : qt_noop()); | - | ||||||||||||||||||||||||
| 2127 | return QUtf8::convertToUnicode(str, size); | - | ||||||||||||||||||||||||
| 2128 | } | - | ||||||||||||||||||||||||
| 2129 | QString QString::fromUtf16(const ushort *unicode, int size) | - | ||||||||||||||||||||||||
| 2130 | { | - | ||||||||||||||||||||||||
| 2131 | if (!unicode) | - | ||||||||||||||||||||||||
| 2132 | return QString(); | - | ||||||||||||||||||||||||
| 2133 | if (size < 0) { | - | ||||||||||||||||||||||||
| 2134 | size = 0; | - | ||||||||||||||||||||||||
| 2135 | while (unicode[size] != 0) | - | ||||||||||||||||||||||||
| 2136 | ++size; | - | ||||||||||||||||||||||||
| 2137 | } | - | ||||||||||||||||||||||||
| 2138 | return QUtf16::convertToUnicode((const char *)unicode, size*2, 0); | - | ||||||||||||||||||||||||
| 2139 | } | - | ||||||||||||||||||||||||
| 2140 | QString QString::fromUcs4(const uint *unicode, int size) | - | ||||||||||||||||||||||||
| 2141 | { | - | ||||||||||||||||||||||||
| 2142 | if (!unicode) | - | ||||||||||||||||||||||||
| 2143 | return QString(); | - | ||||||||||||||||||||||||
| 2144 | if (size < 0) { | - | ||||||||||||||||||||||||
| 2145 | size = 0; | - | ||||||||||||||||||||||||
| 2146 | while (unicode[size] != 0) | - | ||||||||||||||||||||||||
| 2147 | ++size; | - | ||||||||||||||||||||||||
| 2148 | } | - | ||||||||||||||||||||||||
| 2149 | return QUtf32::convertToUnicode((const char *)unicode, size*4, 0); | - | ||||||||||||||||||||||||
| 2150 | } | - | ||||||||||||||||||||||||
| 2151 | QString& QString::setUnicode(const QChar *unicode, int size) | - | ||||||||||||||||||||||||
| 2152 | { | - | ||||||||||||||||||||||||
| 2153 | resize(size); | - | ||||||||||||||||||||||||
| 2154 | if (unicode && size) | - | ||||||||||||||||||||||||
| 2155 | memcpy(d->data(), unicode, size * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 2156 | return *this; | - | ||||||||||||||||||||||||
| 2157 | } | - | ||||||||||||||||||||||||
| 2158 | QString QString::simplified_helper(const QString &str) | - | ||||||||||||||||||||||||
| 2159 | { | - | ||||||||||||||||||||||||
| 2160 | return QStringAlgorithms<const QString>::simplified_helper(str); | - | ||||||||||||||||||||||||
| 2161 | } | - | ||||||||||||||||||||||||
| 2162 | - | |||||||||||||||||||||||||
| 2163 | QString QString::simplified_helper(QString &str) | - | ||||||||||||||||||||||||
| 2164 | { | - | ||||||||||||||||||||||||
| 2165 | return QStringAlgorithms<QString>::simplified_helper(str); | - | ||||||||||||||||||||||||
| 2166 | } | - | ||||||||||||||||||||||||
| 2167 | QString QString::trimmed_helper(const QString &str) | - | ||||||||||||||||||||||||
| 2168 | { | - | ||||||||||||||||||||||||
| 2169 | return QStringAlgorithms<const QString>::trimmed_helper(str); | - | ||||||||||||||||||||||||
| 2170 | } | - | ||||||||||||||||||||||||
| 2171 | - | |||||||||||||||||||||||||
| 2172 | QString QString::trimmed_helper(QString &str) | - | ||||||||||||||||||||||||
| 2173 | { | - | ||||||||||||||||||||||||
| 2174 | return QStringAlgorithms<QString>::trimmed_helper(str); | - | ||||||||||||||||||||||||
| 2175 | } | - | ||||||||||||||||||||||||
| 2176 | void QString::truncate(int pos) | - | ||||||||||||||||||||||||
| 2177 | { | - | ||||||||||||||||||||||||
| 2178 | if (pos < d->size) | - | ||||||||||||||||||||||||
| 2179 | resize(pos); | - | ||||||||||||||||||||||||
| 2180 | } | - | ||||||||||||||||||||||||
| 2181 | void QString::chop(int n) | - | ||||||||||||||||||||||||
| 2182 | { | - | ||||||||||||||||||||||||
| 2183 | if (n > 0) | - | ||||||||||||||||||||||||
| 2184 | resize(d->size - n); | - | ||||||||||||||||||||||||
| 2185 | } | - | ||||||||||||||||||||||||
| 2186 | QString& QString::fill(QChar ch, int size) | - | ||||||||||||||||||||||||
| 2187 | { | - | ||||||||||||||||||||||||
| 2188 | resize(size < 0 ? d->size : size); | - | ||||||||||||||||||||||||
| 2189 | if (d->size) { | - | ||||||||||||||||||||||||
| 2190 | QChar *i = (QChar*)d->data() + d->size; | - | ||||||||||||||||||||||||
| 2191 | QChar *b = (QChar*)d->data(); | - | ||||||||||||||||||||||||
| 2192 | while (i != b) | - | ||||||||||||||||||||||||
| 2193 | *--i = ch; | - | ||||||||||||||||||||||||
| 2194 | } | - | ||||||||||||||||||||||||
| 2195 | return *this; | - | ||||||||||||||||||||||||
| 2196 | } | - | ||||||||||||||||||||||||
| 2197 | int QString::compare(const QString &other, Qt::CaseSensitivity cs) const noexcept | - | ||||||||||||||||||||||||
| 2198 | { | - | ||||||||||||||||||||||||
| 2199 | if (cs == Qt::CaseSensitive
| 240051-513982 | ||||||||||||||||||||||||
| 2200 | return executed 240051 times by 215 tests: ucstrcmp(constData(), length(), other.constData(), other.length());return ucstrcmp(constData(), length(), other.constData(), other.length());Executed by:
executed 240051 times by 215 tests: return ucstrcmp(constData(), length(), other.constData(), other.length());Executed by:
| 240051 | ||||||||||||||||||||||||
| 2201 | return executed 513982 times by 161 tests: ucstricmp(d->data(), d->data() + d->size, other.d->data(), other.d->data() + other.d->size);return ucstricmp(d->data(), d->data() + d->size, other.d->data(), other.d->data() + other.d->size);Executed by:
executed 513982 times by 161 tests: return ucstricmp(d->data(), d->data() + d->size, other.d->data(), other.d->data() + other.d->size);Executed by:
| 513982 | ||||||||||||||||||||||||
| 2202 | } | - | ||||||||||||||||||||||||
| 2203 | - | |||||||||||||||||||||||||
| 2204 | - | |||||||||||||||||||||||||
| 2205 | - | |||||||||||||||||||||||||
| 2206 | - | |||||||||||||||||||||||||
| 2207 | - | |||||||||||||||||||||||||
| 2208 | int QString::compare_helper(const QChar *data1, int length1, const QChar *data2, int length2, | - | ||||||||||||||||||||||||
| 2209 | Qt::CaseSensitivity cs) noexcept | - | ||||||||||||||||||||||||
| 2210 | { | - | ||||||||||||||||||||||||
| 2211 | if (cs == Qt::CaseSensitive
| 2594-552902 | ||||||||||||||||||||||||
| 2212 | return executed 552902 times by 47 tests: ucstrcmp(data1, length1, data2, length2);return ucstrcmp(data1, length1, data2, length2);Executed by:
executed 552902 times by 47 tests: return ucstrcmp(data1, length1, data2, length2);Executed by:
| 552902 | ||||||||||||||||||||||||
| 2213 | const ushort *s1 = reinterpret_cast<const ushort *>(data1); | - | ||||||||||||||||||||||||
| 2214 | const ushort *s2 = reinterpret_cast<const ushort *>(data2); | - | ||||||||||||||||||||||||
| 2215 | return executed 2594 times by 25 tests: ucstricmp(s1, s1 + length1, s2, s2 + length2);return ucstricmp(s1, s1 + length1, s2, s2 + length2);Executed by:
executed 2594 times by 25 tests: return ucstricmp(s1, s1 + length1, s2, s2 + length2);Executed by:
| 2594 | ||||||||||||||||||||||||
| 2216 | } | - | ||||||||||||||||||||||||
| 2217 | - | |||||||||||||||||||||||||
| 2218 | - | |||||||||||||||||||||||||
| 2219 | - | |||||||||||||||||||||||||
| 2220 | - | |||||||||||||||||||||||||
| 2221 | - | |||||||||||||||||||||||||
| 2222 | - | |||||||||||||||||||||||||
| 2223 | - | |||||||||||||||||||||||||
| 2224 | int QString::compare(QLatin1String other, Qt::CaseSensitivity cs) const noexcept | - | ||||||||||||||||||||||||
| 2225 | { | - | ||||||||||||||||||||||||
| 2226 | return executed 19282 times by 66 tests: compare_helper(unicode(), length(), other, cs);return compare_helper(unicode(), length(), other, cs);Executed by:
executed 19282 times by 66 tests: return compare_helper(unicode(), length(), other, cs);Executed by:
| 19282 | ||||||||||||||||||||||||
| 2227 | } | - | ||||||||||||||||||||||||
| 2228 | int QString::compare_helper(const QChar *data1, int length1, const char *data2, int length2, | - | ||||||||||||||||||||||||
| 2229 | Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 2230 | { | - | ||||||||||||||||||||||||
| 2231 | - | |||||||||||||||||||||||||
| 2232 | const QString s2 = QString::fromUtf8(data2, length2 == -1 ? (data2 ? int(strlen(data2)) : -1) : length2); | - | ||||||||||||||||||||||||
| 2233 | return compare_helper(data1, length1, s2.constData(), s2.size(), cs); | - | ||||||||||||||||||||||||
| 2234 | } | - | ||||||||||||||||||||||||
| 2235 | int QString::compare_helper(const QChar *data1, int length1, QLatin1String s2, | - | ||||||||||||||||||||||||
| 2236 | Qt::CaseSensitivity cs) noexcept | - | ||||||||||||||||||||||||
| 2237 | { | - | ||||||||||||||||||||||||
| 2238 | const ushort *uc = reinterpret_cast<const ushort *>(data1); | - | ||||||||||||||||||||||||
| 2239 | const ushort *uce = uc + length1; | - | ||||||||||||||||||||||||
| 2240 | const uchar *c = (const uchar *)s2.latin1(); | - | ||||||||||||||||||||||||
| 2241 | - | |||||||||||||||||||||||||
| 2242 | if (!c
| 0-235224 | ||||||||||||||||||||||||
| 2243 | return never executed: length1;return length1;never executed: return length1; | 0 | ||||||||||||||||||||||||
| 2244 | - | |||||||||||||||||||||||||
| 2245 | if (cs == Qt::CaseSensitive
| 17633-217591 | ||||||||||||||||||||||||
| 2246 | return executed 217591 times by 445 tests: ucstrcmp(data1, length1, c, s2.size());return ucstrcmp(data1, length1, c, s2.size());Executed by:
executed 217591 times by 445 tests: return ucstrcmp(data1, length1, c, s2.size());Executed by:
| 217591 | ||||||||||||||||||||||||
| 2247 | } else { | - | ||||||||||||||||||||||||
| 2248 | return executed 17633 times by 48 tests: ucstricmp(uc, uce, c, c + s2.size());return ucstricmp(uc, uce, c, c + s2.size());Executed by:
executed 17633 times by 48 tests: return ucstricmp(uc, uce, c, c + s2.size());Executed by:
| 17633 | ||||||||||||||||||||||||
| 2249 | } | - | ||||||||||||||||||||||||
| 2250 | } | - | ||||||||||||||||||||||||
| 2251 | int QString::localeAwareCompare(const QString &other) const | - | ||||||||||||||||||||||||
| 2252 | { | - | ||||||||||||||||||||||||
| 2253 | return localeAwareCompare_helper(constData(), length(), other.constData(), other.length()); | - | ||||||||||||||||||||||||
| 2254 | } | - | ||||||||||||||||||||||||
| 2255 | - | |||||||||||||||||||||||||
| 2256 | - | |||||||||||||||||||||||||
| 2257 | namespace { namespace Q_QGS_defaultCollator { typedef QThreadStorage<QCollator> Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<QThreadStorage<QCollator>, Q_QGS_defaultCollator::innerFunction, Q_QGS_defaultCollator::guard> defaultCollator; | - | ||||||||||||||||||||||||
| 2258 | - | |||||||||||||||||||||||||
| 2259 | - | |||||||||||||||||||||||||
| 2260 | - | |||||||||||||||||||||||||
| 2261 | - | |||||||||||||||||||||||||
| 2262 | - | |||||||||||||||||||||||||
| 2263 | - | |||||||||||||||||||||||||
| 2264 | int QString::localeAwareCompare_helper(const QChar *data1, int length1, | - | ||||||||||||||||||||||||
| 2265 | const QChar *data2, int length2) | - | ||||||||||||||||||||||||
| 2266 | { | - | ||||||||||||||||||||||||
| 2267 | - | |||||||||||||||||||||||||
| 2268 | if (length1 == 0 || length2 == 0) | - | ||||||||||||||||||||||||
| 2269 | return ucstrcmp(data1, length1, data2, length2); | - | ||||||||||||||||||||||||
| 2270 | if (!defaultCollator()->hasLocalData()) | - | ||||||||||||||||||||||||
| 2271 | defaultCollator()->setLocalData(QCollator()); | - | ||||||||||||||||||||||||
| 2272 | return defaultCollator()->localData().compare(data1, length1, data2, length2); | - | ||||||||||||||||||||||||
| 2273 | } | - | ||||||||||||||||||||||||
| 2274 | const ushort *QString::utf16() const | - | ||||||||||||||||||||||||
| 2275 | { | - | ||||||||||||||||||||||||
| 2276 | if (((d)->offset != sizeof(QStringData))) { | - | ||||||||||||||||||||||||
| 2277 | - | |||||||||||||||||||||||||
| 2278 | const_cast<QString*>(this)->reallocData(uint(d->size) + 1u); | - | ||||||||||||||||||||||||
| 2279 | } | - | ||||||||||||||||||||||||
| 2280 | return d->data(); | - | ||||||||||||||||||||||||
| 2281 | } | - | ||||||||||||||||||||||||
| 2282 | QString QString::leftJustified(int width, QChar fill, bool truncate) const | - | ||||||||||||||||||||||||
| 2283 | { | - | ||||||||||||||||||||||||
| 2284 | QString result; | - | ||||||||||||||||||||||||
| 2285 | int len = length(); | - | ||||||||||||||||||||||||
| 2286 | int padlen = width - len; | - | ||||||||||||||||||||||||
| 2287 | if (padlen > 0) { | - | ||||||||||||||||||||||||
| 2288 | result.resize(len+padlen); | - | ||||||||||||||||||||||||
| 2289 | if (len) | - | ||||||||||||||||||||||||
| 2290 | memcpy(result.d->data(), d->data(), sizeof(QChar)*len); | - | ||||||||||||||||||||||||
| 2291 | QChar *uc = (QChar*)result.d->data() + len; | - | ||||||||||||||||||||||||
| 2292 | while (padlen--) | - | ||||||||||||||||||||||||
| 2293 | * uc++ = fill; | - | ||||||||||||||||||||||||
| 2294 | } else { | - | ||||||||||||||||||||||||
| 2295 | if (truncate) | - | ||||||||||||||||||||||||
| 2296 | result = left(width); | - | ||||||||||||||||||||||||
| 2297 | else | - | ||||||||||||||||||||||||
| 2298 | result = *this; | - | ||||||||||||||||||||||||
| 2299 | } | - | ||||||||||||||||||||||||
| 2300 | return result; | - | ||||||||||||||||||||||||
| 2301 | } | - | ||||||||||||||||||||||||
| 2302 | QString QString::rightJustified(int width, QChar fill, bool truncate) const | - | ||||||||||||||||||||||||
| 2303 | { | - | ||||||||||||||||||||||||
| 2304 | QString result; | - | ||||||||||||||||||||||||
| 2305 | int len = length(); | - | ||||||||||||||||||||||||
| 2306 | int padlen = width - len; | - | ||||||||||||||||||||||||
| 2307 | if (padlen > 0) { | - | ||||||||||||||||||||||||
| 2308 | result.resize(len+padlen); | - | ||||||||||||||||||||||||
| 2309 | QChar *uc = (QChar*)result.d->data(); | - | ||||||||||||||||||||||||
| 2310 | while (padlen--) | - | ||||||||||||||||||||||||
| 2311 | * uc++ = fill; | - | ||||||||||||||||||||||||
| 2312 | if (len) | - | ||||||||||||||||||||||||
| 2313 | memcpy(uc, d->data(), sizeof(QChar)*len); | - | ||||||||||||||||||||||||
| 2314 | } else { | - | ||||||||||||||||||||||||
| 2315 | if (truncate) | - | ||||||||||||||||||||||||
| 2316 | result = left(width); | - | ||||||||||||||||||||||||
| 2317 | else | - | ||||||||||||||||||||||||
| 2318 | result = *this; | - | ||||||||||||||||||||||||
| 2319 | } | - | ||||||||||||||||||||||||
| 2320 | return result; | - | ||||||||||||||||||||||||
| 2321 | } | - | ||||||||||||||||||||||||
| 2322 | namespace QUnicodeTables { | - | ||||||||||||||||||||||||
| 2323 | template <typename Traits, typename T> | - | ||||||||||||||||||||||||
| 2324 | __attribute__((noinline)) | - | ||||||||||||||||||||||||
| 2325 | static QString detachAndConvertCase(T &str, QStringIterator it) | - | ||||||||||||||||||||||||
| 2326 | { | - | ||||||||||||||||||||||||
| 2327 | ((!(!str.isEmpty())) ? qt_assert("!str.isEmpty()",__FILE__,57725802) : qt_noop()); | - | ||||||||||||||||||||||||
| 2328 | QString s = std::move(str); | - | ||||||||||||||||||||||||
| 2329 | QChar *pp = s.begin() + it.index(); | - | ||||||||||||||||||||||||
| 2330 | - | |||||||||||||||||||||||||
| 2331 | do { | - | ||||||||||||||||||||||||
| 2332 | uint uc = it.nextUnchecked(); | - | ||||||||||||||||||||||||
| 2333 | - | |||||||||||||||||||||||||
| 2334 | const QUnicodeTables::Properties *prop = qGetProp(uc); | - | ||||||||||||||||||||||||
| 2335 | signed short caseDiff = Traits::caseDiff(prop); | - | ||||||||||||||||||||||||
| 2336 | - | |||||||||||||||||||||||||
| 2337 | if (__builtin_expect(!!(Traits::caseSpecial(prop)), false)) { | - | ||||||||||||||||||||||||
| 2338 | const ushort *specialCase = specialCaseMap + caseDiff; | - | ||||||||||||||||||||||||
| 2339 | ushort length = *specialCase++; | - | ||||||||||||||||||||||||
| 2340 | - | |||||||||||||||||||||||||
| 2341 | if (__builtin_expect(!!(length == 1), true)) { | - | ||||||||||||||||||||||||
| 2342 | *pp++ = QChar(*specialCase); | - | ||||||||||||||||||||||||
| 2343 | } else { | - | ||||||||||||||||||||||||
| 2344 | - | |||||||||||||||||||||||||
| 2345 | int inpos = it.index() - 1; | - | ||||||||||||||||||||||||
| 2346 | int outpos = pp - s.constBegin(); | - | ||||||||||||||||||||||||
| 2347 | - | |||||||||||||||||||||||||
| 2348 | s.replace(outpos, 1, reinterpret_cast<const QChar *>(specialCase), length); | - | ||||||||||||||||||||||||
| 2349 | pp = const_cast<QChar *>(s.constBegin()) + outpos + length; | - | ||||||||||||||||||||||||
| 2350 | - | |||||||||||||||||||||||||
| 2351 | - | |||||||||||||||||||||||||
| 2352 | - | |||||||||||||||||||||||||
| 2353 | if (str.isEmpty()) | - | ||||||||||||||||||||||||
| 2354 | it = QStringIterator(s.constBegin(), inpos + length, s.constEnd()); | - | ||||||||||||||||||||||||
| 2355 | } | - | ||||||||||||||||||||||||
| 2356 | } else if (__builtin_expect(!!(QChar::requiresSurrogates(uc)), false)) { | - | ||||||||||||||||||||||||
| 2357 | - | |||||||||||||||||||||||||
| 2358 | pp++; | - | ||||||||||||||||||||||||
| 2359 | *pp++ = QChar::lowSurrogate(uc + caseDiff); | - | ||||||||||||||||||||||||
| 2360 | } else { | - | ||||||||||||||||||||||||
| 2361 | *pp++ = QChar(uc + caseDiff); | - | ||||||||||||||||||||||||
| 2362 | } | - | ||||||||||||||||||||||||
| 2363 | } while (it.hasNext()); | - | ||||||||||||||||||||||||
| 2364 | - | |||||||||||||||||||||||||
| 2365 | return s; | - | ||||||||||||||||||||||||
| 2366 | } | - | ||||||||||||||||||||||||
| 2367 | - | |||||||||||||||||||||||||
| 2368 | template <typename Traits, typename T> | - | ||||||||||||||||||||||||
| 2369 | static QString convertCase(T &str) | - | ||||||||||||||||||||||||
| 2370 | { | - | ||||||||||||||||||||||||
| 2371 | const QChar *p = str.constBegin(); | - | ||||||||||||||||||||||||
| 2372 | const QChar *e = p + str.size(); | - | ||||||||||||||||||||||||
| 2373 | - | |||||||||||||||||||||||||
| 2374 | - | |||||||||||||||||||||||||
| 2375 | while (e != p && e[-1].isHighSurrogate()) | - | ||||||||||||||||||||||||
| 2376 | --e; | - | ||||||||||||||||||||||||
| 2377 | - | |||||||||||||||||||||||||
| 2378 | QStringIterator it(p, e); | - | ||||||||||||||||||||||||
| 2379 | while (it.hasNext()) { | - | ||||||||||||||||||||||||
| 2380 | uint uc = it.nextUnchecked(); | - | ||||||||||||||||||||||||
| 2381 | if (Traits::caseDiff(qGetProp(uc))) { | - | ||||||||||||||||||||||||
| 2382 | it.recedeUnchecked(); | - | ||||||||||||||||||||||||
| 2383 | return detachAndConvertCase<Traits>(str, it); | - | ||||||||||||||||||||||||
| 2384 | } | - | ||||||||||||||||||||||||
| 2385 | } | - | ||||||||||||||||||||||||
| 2386 | return std::move(str); | - | ||||||||||||||||||||||||
| 2387 | } | - | ||||||||||||||||||||||||
| 2388 | } | - | ||||||||||||||||||||||||
| 2389 | - | |||||||||||||||||||||||||
| 2390 | QString QString::toLower_helper(const QString &str) | - | ||||||||||||||||||||||||
| 2391 | { | - | ||||||||||||||||||||||||
| 2392 | return QUnicodeTables::convertCase<QUnicodeTables::LowercaseTraits>(str); | - | ||||||||||||||||||||||||
| 2393 | } | - | ||||||||||||||||||||||||
| 2394 | - | |||||||||||||||||||||||||
| 2395 | QString QString::toLower_helper(QString &str) | - | ||||||||||||||||||||||||
| 2396 | { | - | ||||||||||||||||||||||||
| 2397 | return QUnicodeTables::convertCase<QUnicodeTables::LowercaseTraits>(str); | - | ||||||||||||||||||||||||
| 2398 | } | - | ||||||||||||||||||||||||
| 2399 | QString QString::toCaseFolded_helper(const QString &str) | - | ||||||||||||||||||||||||
| 2400 | { | - | ||||||||||||||||||||||||
| 2401 | return QUnicodeTables::convertCase<QUnicodeTables::CasefoldTraits>(str); | - | ||||||||||||||||||||||||
| 2402 | } | - | ||||||||||||||||||||||||
| 2403 | - | |||||||||||||||||||||||||
| 2404 | QString QString::toCaseFolded_helper(QString &str) | - | ||||||||||||||||||||||||
| 2405 | { | - | ||||||||||||||||||||||||
| 2406 | return QUnicodeTables::convertCase<QUnicodeTables::CasefoldTraits>(str); | - | ||||||||||||||||||||||||
| 2407 | } | - | ||||||||||||||||||||||||
| 2408 | QString QString::toUpper_helper(const QString &str) | - | ||||||||||||||||||||||||
| 2409 | { | - | ||||||||||||||||||||||||
| 2410 | return QUnicodeTables::convertCase<QUnicodeTables::UppercaseTraits>(str); | - | ||||||||||||||||||||||||
| 2411 | } | - | ||||||||||||||||||||||||
| 2412 | - | |||||||||||||||||||||||||
| 2413 | QString QString::toUpper_helper(QString &str) | - | ||||||||||||||||||||||||
| 2414 | { | - | ||||||||||||||||||||||||
| 2415 | return QUnicodeTables::convertCase<QUnicodeTables::UppercaseTraits>(str); | - | ||||||||||||||||||||||||
| 2416 | } | - | ||||||||||||||||||||||||
| 2417 | - | |||||||||||||||||||||||||
| 2418 | - | |||||||||||||||||||||||||
| 2419 | - | |||||||||||||||||||||||||
| 2420 | - | |||||||||||||||||||||||||
| 2421 | - | |||||||||||||||||||||||||
| 2422 | - | |||||||||||||||||||||||||
| 2423 | QString &QString::sprintf(const char *cformat, ...) | - | ||||||||||||||||||||||||
| 2424 | { | - | ||||||||||||||||||||||||
| 2425 | va_list ap; | - | ||||||||||||||||||||||||
| 2426 | __builtin_va_start(ap,cformat); | - | ||||||||||||||||||||||||
| 2427 | *this = vasprintf(cformat, ap); | - | ||||||||||||||||||||||||
| 2428 | __builtin_va_end(ap); | - | ||||||||||||||||||||||||
| 2429 | return *this; | - | ||||||||||||||||||||||||
| 2430 | } | - | ||||||||||||||||||||||||
| 2431 | QString QString::asprintf(const char *cformat, ...) | - | ||||||||||||||||||||||||
| 2432 | { | - | ||||||||||||||||||||||||
| 2433 | va_list ap; | - | ||||||||||||||||||||||||
| 2434 | __builtin_va_start(ap,cformat); | - | ||||||||||||||||||||||||
| 2435 | const QString s = vasprintf(cformat, ap); | - | ||||||||||||||||||||||||
| 2436 | __builtin_va_end(ap); | - | ||||||||||||||||||||||||
| 2437 | return s; | - | ||||||||||||||||||||||||
| 2438 | } | - | ||||||||||||||||||||||||
| 2439 | - | |||||||||||||||||||||||||
| 2440 | - | |||||||||||||||||||||||||
| 2441 | - | |||||||||||||||||||||||||
| 2442 | - | |||||||||||||||||||||||||
| 2443 | - | |||||||||||||||||||||||||
| 2444 | - | |||||||||||||||||||||||||
| 2445 | QString &QString::vsprintf(const char *cformat, va_list ap) | - | ||||||||||||||||||||||||
| 2446 | { | - | ||||||||||||||||||||||||
| 2447 | return *this = vasprintf(cformat, ap); | - | ||||||||||||||||||||||||
| 2448 | } | - | ||||||||||||||||||||||||
| 2449 | - | |||||||||||||||||||||||||
| 2450 | static void append_utf8(QString &qs, const char *cs, int len) | - | ||||||||||||||||||||||||
| 2451 | { | - | ||||||||||||||||||||||||
| 2452 | const int oldSize = qs.size(); | - | ||||||||||||||||||||||||
| 2453 | qs.resize(oldSize + len); | - | ||||||||||||||||||||||||
| 2454 | const QChar *newEnd = QUtf8::convertToUnicode(qs.data() + oldSize, cs, len); | - | ||||||||||||||||||||||||
| 2455 | qs.resize(newEnd - qs.constData()); | - | ||||||||||||||||||||||||
| 2456 | } executed 683187 times by 161 tests: end of blockExecuted by:
| 683187 | ||||||||||||||||||||||||
| 2457 | - | |||||||||||||||||||||||||
| 2458 | static uint parse_flag_characters(const char * &c) noexcept | - | ||||||||||||||||||||||||
| 2459 | { | - | ||||||||||||||||||||||||
| 2460 | uint flags = QLocaleData::ZeroPadExponent; | - | ||||||||||||||||||||||||
| 2461 | while (true) { | - | ||||||||||||||||||||||||
| 2462 | switch (*c) { | - | ||||||||||||||||||||||||
| 2463 | case executed 4992 times by 1 test: '#':case '#':Executed by:
executed 4992 times by 1 test: flags |= QLocaleData::Alternate; break;case '#':Executed by:
executed 4992 times by 1 test: break;Executed by:
| 4992 | ||||||||||||||||||||||||
| 2464 | case executed 12678 times by 15 tests: '0':case '0':Executed by:
executed 12678 times by 15 tests: flags |= QLocaleData::ZeroPadded; break;case '0':Executed by:
executed 12678 times by 15 tests: break;Executed by:
| 12678 | ||||||||||||||||||||||||
| 2465 | case executed 5000 times by 1 test: '-':case '-':Executed by:
executed 5000 times by 1 test: flags |= QLocaleData::LeftAdjusted; break;case '-':Executed by:
executed 5000 times by 1 test: break;Executed by:
| 5000 | ||||||||||||||||||||||||
| 2466 | case executed 4992 times by 1 test: ' ':case ' ':Executed by:
executed 4992 times by 1 test: flags |= QLocaleData::BlankBeforePositive; break;case ' ':Executed by:
executed 4992 times by 1 test: break;Executed by:
| 4992 | ||||||||||||||||||||||||
| 2467 | case executed 4992 times by 1 test: '+':case '+':Executed by:
executed 4992 times by 1 test: flags |= QLocaleData::AlwaysShowSign; break;case '+':Executed by:
executed 4992 times by 1 test: break;Executed by:
| 4992 | ||||||||||||||||||||||||
| 2468 | case executed 9984 times by 1 test: '\'':case '\'':Executed by:
executed 9984 times by 1 test: flags |= QLocaleData::ThousandsGroup; break;case '\'':Executed by:
executed 9984 times by 1 test: break;Executed by:
| 9984 | ||||||||||||||||||||||||
| 2469 | default executed 394937 times by 110 tests: :default:Executed by:
executed 394937 times by 110 tests: returndefault:Executed by:
executed 394937 times by 110 tests: flags;return flags;Executed by:
executed 394937 times by 110 tests: return flags;Executed by:
| 394937 | ||||||||||||||||||||||||
| 2470 | } | - | ||||||||||||||||||||||||
| 2471 | ++c; | - | ||||||||||||||||||||||||
| 2472 | } executed 42638 times by 15 tests: end of blockExecuted by:
| 42638 | ||||||||||||||||||||||||
| 2473 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2474 | - | |||||||||||||||||||||||||
| 2475 | static int parse_field_width(const char * &c) | - | ||||||||||||||||||||||||
| 2476 | { | - | ||||||||||||||||||||||||
| 2477 | ((!(qIsDigit(*c))) ? qt_assert("qIsDigit(*c)",__FILE__,6010) : qt_noop()); | - | ||||||||||||||||||||||||
| 2478 | - | |||||||||||||||||||||||||
| 2479 | - | |||||||||||||||||||||||||
| 2480 | - | |||||||||||||||||||||||||
| 2481 | const char *endp; | - | ||||||||||||||||||||||||
| 2482 | bool ok; | - | ||||||||||||||||||||||||
| 2483 | const qulonglong result = qstrtoull(c, &endp, 10, &ok); | - | ||||||||||||||||||||||||
| 2484 | c = endp; | - | ||||||||||||||||||||||||
| 2485 | while (qIsDigit(*c)
| 0-24569 | ||||||||||||||||||||||||
| 2486 | ++ never executed: c;++c;never executed: ++c; | 0 | ||||||||||||||||||||||||
| 2487 | return executed 24569 times by 22 tests: ok && result < qulonglong(std::numeric_limits<int>::max()) ? int(result) : 0;return ok && result < qulonglong(std::numeric_limits<int>::max()) ? int(result) : 0;Executed by:
executed 24569 times by 22 tests: return ok && result < qulonglong(std::numeric_limits<int>::max()) ? int(result) : 0;Executed by:
| 24569 | ||||||||||||||||||||||||
| 2488 | } | - | ||||||||||||||||||||||||
| 2489 | - | |||||||||||||||||||||||||
| 2490 | enum LengthMod { lm_none, lm_hh, lm_h, lm_l, lm_ll, lm_L, lm_j, lm_z, lm_t }; | - | ||||||||||||||||||||||||
| 2491 | - | |||||||||||||||||||||||||
| 2492 | static inline bool can_consume(const char * &c, char ch) noexcept | - | ||||||||||||||||||||||||
| 2493 | { | - | ||||||||||||||||||||||||
| 2494 | if (*
| 42-2022 | ||||||||||||||||||||||||
| 2495 | ++c; | - | ||||||||||||||||||||||||
| 2496 | return executed 2022 times by 3 tests: true;return true;Executed by:
executed 2022 times by 3 tests: return true;Executed by:
| 2022 | ||||||||||||||||||||||||
| 2497 | } | - | ||||||||||||||||||||||||
| 2498 | return executed 42 times by 7 tests: false;return false;Executed by:
executed 42 times by 7 tests: return false;Executed by:
| 42 | ||||||||||||||||||||||||
| 2499 | } | - | ||||||||||||||||||||||||
| 2500 | - | |||||||||||||||||||||||||
| 2501 | static LengthMod parse_length_modifier(const char * &c) noexcept | - | ||||||||||||||||||||||||
| 2502 | { | - | ||||||||||||||||||||||||
| 2503 | switch (*c++) { | - | ||||||||||||||||||||||||
| 2504 | case never executed: 'h':case 'h':never executed: returncase 'h':never executed: can_consume(c, 'h') ? lm_hh : lm_h;return can_consume(c, 'h') ? lm_hh : lm_h;never executed: return can_consume(c, 'h') ? lm_hh : lm_h; | 0 | ||||||||||||||||||||||||
| 2505 | case executed 2064 times by 9 tests: 'l':case 'l':Executed by:
executed 2064 times by 9 tests: returncase 'l':Executed by:
executed 2064 times by 9 tests: can_consume(c, 'l') ? lm_ll : lm_l;return can_consume(c, 'l') ? lm_ll : lm_l;Executed by:
executed 2064 times by 9 tests: return can_consume(c, 'l') ? lm_ll : lm_l;Executed by:
| 2064 | ||||||||||||||||||||||||
| 2506 | case never executed: 'L':case 'L':never executed: returncase 'L':never executed: lm_L;return lm_L;never executed: return lm_L; | 0 | ||||||||||||||||||||||||
| 2507 | case never executed: 'j':case 'j':never executed: returncase 'j':never executed: lm_j;return lm_j;never executed: return lm_j; | 0 | ||||||||||||||||||||||||
| 2508 | case executed 3 times by 1 test: 'z':case 'z':Executed by:
executed 3 times by 1 test: case 'z':Executed by:
| 3 | ||||||||||||||||||||||||
| 2509 | case never executed: 'Z':case 'Z':never executed: returncase 'Z':executed 3 times by 1 test: lm_z;return lm_z;Executed by:
executed 3 times by 1 test: return lm_z;Executed by:
| 0-3 | ||||||||||||||||||||||||
| 2510 | case never executed: 't':case 't':never executed: returncase 't':never executed: lm_t;return lm_t;never executed: return lm_t; | 0 | ||||||||||||||||||||||||
| 2511 | } | - | ||||||||||||||||||||||||
| 2512 | --c; | - | ||||||||||||||||||||||||
| 2513 | return executed 392870 times by 110 tests: lm_none;return lm_none;Executed by:
executed 392870 times by 110 tests: return lm_none;Executed by:
| 392870 | ||||||||||||||||||||||||
| 2514 | } | - | ||||||||||||||||||||||||
| 2515 | QString QString::vasprintf(const char *cformat, va_list ap) | - | ||||||||||||||||||||||||
| 2516 | { | - | ||||||||||||||||||||||||
| 2517 | if (!cformat
| 0-288236 | ||||||||||||||||||||||||
| 2518 | - | |||||||||||||||||||||||||
| 2519 | return executed 1 time by 1 test: fromLatin1("");return fromLatin1("");Executed by:
executed 1 time by 1 test: return fromLatin1("");Executed by:
| 1 | ||||||||||||||||||||||||
| 2520 | } | - | ||||||||||||||||||||||||
| 2521 | - | |||||||||||||||||||||||||
| 2522 | - | |||||||||||||||||||||||||
| 2523 | - | |||||||||||||||||||||||||
| 2524 | QString result; | - | ||||||||||||||||||||||||
| 2525 | const char *c = cformat; | - | ||||||||||||||||||||||||
| 2526 | for (;;) { | - | ||||||||||||||||||||||||
| 2527 | - | |||||||||||||||||||||||||
| 2528 | const char *cb = c; | - | ||||||||||||||||||||||||
| 2529 | while (*
| 214564-609515 | ||||||||||||||||||||||||
| 2530 | c++; executed 214564 times by 161 tests: c++;Executed by:
| 214564 | ||||||||||||||||||||||||
| 2531 | result.append(QString::fromUtf8append_utf8(result, cb, (int)((c - cb)));)); | - | ||||||||||||||||||||||||
| 2532 | - | |||||||||||||||||||||||||
| 2533 | if (*
| 288236-394951 | ||||||||||||||||||||||||
| 2534 | break; executed 288236 times by 161 tests: break;Executed by:
| 288236 | ||||||||||||||||||||||||
| 2535 | - | |||||||||||||||||||||||||
| 2536 | - | |||||||||||||||||||||||||
| 2537 | const char *escape_start = c; | - | ||||||||||||||||||||||||
| 2538 | ++c; | - | ||||||||||||||||||||||||
| 2539 | - | |||||||||||||||||||||||||
| 2540 | if (*
| 0-394951 | ||||||||||||||||||||||||
| 2541 | result.append(QLatin1Char('%')); | - | ||||||||||||||||||||||||
| 2542 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2543 | } | - | ||||||||||||||||||||||||
| 2544 | if (*
| 14-394937 | ||||||||||||||||||||||||
| 2545 | result.append(QLatin1Char('%')); | - | ||||||||||||||||||||||||
| 2546 | ++c; | - | ||||||||||||||||||||||||
| 2547 | continue; executed 14 times by 2 tests: continue;Executed by:
| 14 | ||||||||||||||||||||||||
| 2548 | } | - | ||||||||||||||||||||||||
| 2549 | - | |||||||||||||||||||||||||
| 2550 | uint flags = 0; | - | ||||||||||||||||||||||||
| bool no_more_flags = false; | ||||||||||||||||||||||||||
| do { | ||||||||||||||||||||||||||
| switch (*c) { | ||||||||||||||||||||||||||
| case '#': flags |= QLocaleData::Alternate; break; | ||||||||||||||||||||||||||
| case '0': flags |= QLocaleData::ZeroPadded; break; | ||||||||||||||||||||||||||
| case '-': flags |= QLocaleData::LeftAdjusted; break; | ||||||||||||||||||||||||||
| case ' ': flags |= QLocaleData::BlankBeforePositive; break; | ||||||||||||||||||||||||||
| case '+': flags |= QLocaleData::AlwaysShowSign; break; | ||||||||||||||||||||||||||
| case '\'':flags |= QLocaleData::ThousandsGroup; break; | ||||||||||||||||||||||||||
| default: no_more_flags= true; break; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| if (!no_more_flags) | ||||||||||||||||||||||||||
| ++parse_flag_characters(c; | ||||||||||||||||||||||||||
| } while (!no_more_flags); | ||||||||||||||||||||||||||
| 2551 | - | |||||||||||||||||||||||||
| 2552 | if (*
| 0-394937 | ||||||||||||||||||||||||
| 2553 | result.append(QLatin1String(escape_start)); | - | ||||||||||||||||||||||||
| 2554 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2555 | } | - | ||||||||||||||||||||||||
| 2556 | - | |||||||||||||||||||||||||
| 2557 | - | |||||||||||||||||||||||||
| 2558 | int width = -1; | - | ||||||||||||||||||||||||
| 2559 | if (qIsDigit(*c)
| 15195-379742 | ||||||||||||||||||||||||
| 2560 | QString width_str; | - | ||||||||||||||||||||||||
| while (*c != '\0' && qIsDigit(*c)) | ||||||||||||||||||||||||||
| width_str.append(QLatin1Char(*c++));width = width_str.toInt();parse_field_width(c); | ||||||||||||||||||||||||||
| 2561 | } executed 15195 times by 15 tests: else if (*end of blockExecuted by:
| 1-379741 | ||||||||||||||||||||||||
| 2562 | width = __builtin_va_arg(ap,int); | - | ||||||||||||||||||||||||
| 2563 | if (width < 0
| 0-1 | ||||||||||||||||||||||||
| 2564 | width = -1; never executed: width = -1; | 0 | ||||||||||||||||||||||||
| 2565 | ++c; | - | ||||||||||||||||||||||||
| 2566 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 2567 | - | |||||||||||||||||||||||||
| 2568 | if (*
| 0-394937 | ||||||||||||||||||||||||
| 2569 | result.append(QLatin1String(escape_start)); | - | ||||||||||||||||||||||||
| 2570 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2571 | } | - | ||||||||||||||||||||||||
| 2572 | - | |||||||||||||||||||||||||
| 2573 | - | |||||||||||||||||||||||||
| 2574 | int precision = -1; | - | ||||||||||||||||||||||||
| 2575 | if (*
| 9375-385562 | ||||||||||||||||||||||||
| 2576 | ++c; | - | ||||||||||||||||||||||||
| 2577 | if (qIsDigit(*c)
| 1-9374 | ||||||||||||||||||||||||
| 2578 | QString precision_str; | - | ||||||||||||||||||||||||
| while (*c != '\0' && qIsDigit(*c)) | ||||||||||||||||||||||||||
| precision_str.append(QLatin1Char(*c++));precision = precision_str.toInt();parse_field_width(c); | ||||||||||||||||||||||||||
| 2579 | } executed 9374 times by 8 tests: else if (*end of blockExecuted by:
| 0-9374 | ||||||||||||||||||||||||
| 2580 | precision = __builtin_va_arg(ap,int); | - | ||||||||||||||||||||||||
| 2581 | if (precision < 0
| 0-1 | ||||||||||||||||||||||||
| 2582 | precision = -1; never executed: precision = -1; | 0 | ||||||||||||||||||||||||
| 2583 | ++c; | - | ||||||||||||||||||||||||
| 2584 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 2585 | } executed 9375 times by 9 tests: end of blockExecuted by:
| 9375 | ||||||||||||||||||||||||
| 2586 | - | |||||||||||||||||||||||||
| 2587 | if (*
| 0-394937 | ||||||||||||||||||||||||
| 2588 | result.append(QLatin1String(escape_start)); | - | ||||||||||||||||||||||||
| 2589 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2590 | } | - | ||||||||||||||||||||||||
| 2591 | - | |||||||||||||||||||||||||
| 2592 | enum LengthMod { lm_none, lm_hh, lm_h, lm_l, lm_ll, lm_L, lm_j, lm_z, lm_t };const LengthMod length_mod = lm_none; | - | ||||||||||||||||||||||||
| switch (*c) { | ||||||||||||||||||||||||||
| case 'h': | ||||||||||||||||||||||||||
| ++c; | ||||||||||||||||||||||||||
| if (*c == 'h') { | ||||||||||||||||||||||||||
| length_mod = lm_hh; | ||||||||||||||||||||||||||
| ++c; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||
| length_mod = lm_h; | ||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||
| case 'l': | ||||||||||||||||||||||||||
| ++c; | ||||||||||||||||||||||||||
| if (*c == 'l') { | ||||||||||||||||||||||||||
| length_mod = lm_ll; | ||||||||||||||||||||||||||
| ++c; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||
| length_mod = lm_l; | ||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||
| case 'L': | ||||||||||||||||||||||||||
| ++c; | ||||||||||||||||||||||||||
| length_mod = lm_L; | ||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||
| case 'j': | ||||||||||||||||||||||||||
| ++c; | ||||||||||||||||||||||||||
| length_mod = lm_j; | ||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||
| case 'z': | ||||||||||||||||||||||||||
| case 'Z': | ||||||||||||||||||||||||||
| ++c;length_mod = lm_z; | ||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||
| case 't': | ||||||||||||||||||||||||||
| ++parse_length_modifier(c; | ||||||||||||||||||||||||||
| length_mod = lm_t; | ||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||
| default: break; | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
| 2593 | - | |||||||||||||||||||||||||
| 2594 | if (*
| 0-394937 | ||||||||||||||||||||||||
| 2595 | result.append(QLatin1String(escape_start)); | - | ||||||||||||||||||||||||
| 2596 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2597 | } | - | ||||||||||||||||||||||||
| 2598 | - | |||||||||||||||||||||||||
| 2599 | - | |||||||||||||||||||||||||
| 2600 | QString subst; | - | ||||||||||||||||||||||||
| 2601 | switch (*c) { | - | ||||||||||||||||||||||||
| 2602 | case executed 288080 times by 46 tests: 'd':case 'd':Executed by:
executed 288080 times by 46 tests: case 'd':Executed by:
| 288080 | ||||||||||||||||||||||||
| 2603 | case executed 750 times by 7 tests: 'i':case 'i':Executed by:
executed 750 times by 7 tests: {case 'i':Executed by:
| 750 | ||||||||||||||||||||||||
| 2604 | qint64 i; | - | ||||||||||||||||||||||||
| 2605 | switch (length_mod) { | - | ||||||||||||||||||||||||
| 2606 | case executed 288827 times by 50 tests: lm_none:case lm_none:Executed by:
executed 288827 times by 50 tests: i = __builtin_va_arg(ap,int); break;case lm_none:Executed by:
executed 288827 times by 50 tests: break;Executed by:
| 288827 | ||||||||||||||||||||||||
| 2607 | case never executed: lm_hh:case lm_hh:never executed: i = __builtin_va_arg(ap,int); break;case lm_hh:never executed: break; | 0 | ||||||||||||||||||||||||
| 2608 | case never executed: lm_h:case lm_h:never executed: i = __builtin_va_arg(ap,int); break;case lm_h:never executed: break; | 0 | ||||||||||||||||||||||||
| 2609 | case executed 2 times by 2 tests: lm_l:case lm_l:Executed by:
executed 2 times by 2 tests: i = __builtin_va_arg(ap,long int); break;case lm_l:Executed by:
executed 2 times by 2 tests: break;Executed by:
| 2 | ||||||||||||||||||||||||
| 2610 | case executed 1 time by 1 test: lm_ll:case lm_ll:Executed by:
executed 1 time by 1 test: i = __builtin_va_arg(ap,qint64); break;case lm_ll:Executed by:
executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||
| 2611 | case never executed: lm_j:case lm_j:never executed: i = __builtin_va_arg(ap,long int); break;case lm_j:never executed: break; | 0 | ||||||||||||||||||||||||
| 2612 | case never executed: lm_z:case lm_z:never executed: i = __builtin_va_arg(ap,size_t); break;case lm_z:never executed: break; | 0 | ||||||||||||||||||||||||
| 2613 | case never executed: lm_t:case lm_t:never executed: i = __builtin_va_arg(ap,int); break;case lm_t:never executed: break; | 0 | ||||||||||||||||||||||||
| 2614 | default never executed: :default:never executed: i = 0; break;default:never executed: break; | 0 | ||||||||||||||||||||||||
| 2615 | } | - | ||||||||||||||||||||||||
| 2616 | subst = QLocaleData::c()->longLongToString(i, precision, 10, width, flags); | - | ||||||||||||||||||||||||
| 2617 | ++c; | - | ||||||||||||||||||||||||
| 2618 | break; executed 288830 times by 50 tests: break;Executed by:
| 288830 | ||||||||||||||||||||||||
| 2619 | } | - | ||||||||||||||||||||||||
| 2620 | case never executed: 'o':case 'o':never executed: case 'o': | 0 | ||||||||||||||||||||||||
| 2621 | case executed 6 times by 2 tests: 'u':case 'u':Executed by:
executed 6 times by 2 tests: case 'u':Executed by:
| 6 | ||||||||||||||||||||||||
| 2622 | case executed 6044 times by 5 tests: 'x':case 'x':Executed by:
executed 6044 times by 5 tests: case 'x':Executed by:
| 6044 | ||||||||||||||||||||||||
| 2623 | case never executed: 'X':case 'X':never executed: {case 'X': | 0 | ||||||||||||||||||||||||
| 2624 | quint64 u; | - | ||||||||||||||||||||||||
| 2625 | switch (length_mod) { | - | ||||||||||||||||||||||||
| 2626 | case executed 4027 times by 6 tests: lm_none:case lm_none:Executed by:
executed 4027 times by 6 tests: u = __builtin_va_arg(ap,uint); break;case lm_none:Executed by:
executed 4027 times by 6 tests: break;Executed by:
| 4027 | ||||||||||||||||||||||||
| 2627 | case never executed: lm_hh:case lm_hh:never executed: u = __builtin_va_arg(ap,uint); break;case lm_hh:never executed: break; | 0 | ||||||||||||||||||||||||
| 2628 | case never executed: lm_h:case lm_h:never executed: u = __builtin_va_arg(ap,uint); break;case lm_h:never executed: break; | 0 | ||||||||||||||||||||||||
| 2629 | case never executed: lm_l:case lm_l:never executed: u = __builtin_va_arg(ap,ulong); break;case lm_l:never executed: break; | 0 | ||||||||||||||||||||||||
| 2630 | case executed 2020 times by 1 test: lm_ll:case lm_ll:Executed by:
executed 2020 times by 1 test: u = __builtin_va_arg(ap,quint64); break;case lm_ll:Executed by:
executed 2020 times by 1 test: break;Executed by:
| 2020 | ||||||||||||||||||||||||
| 2631 | case executed 3 times by 1 test: lm_z:case lm_z:Executed by:
executed 3 times by 1 test: u = __builtin_va_arg(ap,size_t); break;case lm_z:Executed by:
executed 3 times by 1 test: break;Executed by:
| 3 | ||||||||||||||||||||||||
| 2632 | default never executed: :default:never executed: u = 0; break;default:never executed: break; | 0 | ||||||||||||||||||||||||
| 2633 | } | - | ||||||||||||||||||||||||
| 2634 | - | |||||||||||||||||||||||||
| 2635 | if (qIsUpper(*c)
| 0-6050 | ||||||||||||||||||||||||
| 2636 | flags |= QLocaleData::CapitalEorX; never executed: flags |= QLocaleData::CapitalEorX; | 0 | ||||||||||||||||||||||||
| 2637 | - | |||||||||||||||||||||||||
| 2638 | int base = 10; | - | ||||||||||||||||||||||||
| 2639 | switch (qToLower(*c)) { | - | ||||||||||||||||||||||||
| 2640 | case never executed: 'o':case 'o':never executed: case 'o': | 0 | ||||||||||||||||||||||||
| 2641 | base = 8; break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2642 | case executed 6 times by 2 tests: 'u':case 'u':Executed by:
executed 6 times by 2 tests: case 'u':Executed by:
| 6 | ||||||||||||||||||||||||
| 2643 | base = 10; break; executed 6 times by 2 tests: break;Executed by:
| 6 | ||||||||||||||||||||||||
| 2644 | case executed 6044 times by 5 tests: 'x':case 'x':Executed by:
executed 6044 times by 5 tests: case 'x':Executed by:
| 6044 | ||||||||||||||||||||||||
| 2645 | base = 16; break; executed 6044 times by 5 tests: break;Executed by:
| 6044 | ||||||||||||||||||||||||
| 2646 | default never executed: :default:never executed: break;default:never executed: break; | 0 | ||||||||||||||||||||||||
| 2647 | } | - | ||||||||||||||||||||||||
| 2648 | subst = QLocaleData::c()->unsLongLongToString(u, precision, base, width, flags); | - | ||||||||||||||||||||||||
| 2649 | ++c; | - | ||||||||||||||||||||||||
| 2650 | break; executed 6050 times by 7 tests: break;Executed by:
| 6050 | ||||||||||||||||||||||||
| 2651 | } | - | ||||||||||||||||||||||||
| 2652 | case never executed: 'E':case 'E':never executed: case 'E': | 0 | ||||||||||||||||||||||||
| 2653 | case never executed: 'e':case 'e':never executed: case 'e': | 0 | ||||||||||||||||||||||||
| 2654 | case never executed: 'F':case 'F':never executed: case 'F': | 0 | ||||||||||||||||||||||||
| 2655 | case executed 55 times by 8 tests: 'f':case 'f':Executed by:
executed 55 times by 8 tests: case 'f':Executed by:
| 55 | ||||||||||||||||||||||||
| 2656 | case executed 4992 times by 1 test: 'G':case 'G':Executed by:
executed 4992 times by 1 test: case 'G':Executed by:
| 4992 | ||||||||||||||||||||||||
| 2657 | case executed 5001 times by 3 tests: 'g':case 'g':Executed by:
executed 5001 times by 3 tests: case 'g':Executed by:
| 5001 | ||||||||||||||||||||||||
| 2658 | case never executed: 'A':case 'A':never executed: case 'A': | 0 | ||||||||||||||||||||||||
| 2659 | case never executed: 'a':case 'a':never executed: {case 'a': | 0 | ||||||||||||||||||||||||
| 2660 | double d; | - | ||||||||||||||||||||||||
| 2661 | if (length_mod == lm_L
| 0-10048 | ||||||||||||||||||||||||
| 2662 | d = __builtin_va_arg(ap,long double); never executed: d = __builtin_va_arg(ap,long double); | 0 | ||||||||||||||||||||||||
| 2663 | else | - | ||||||||||||||||||||||||
| 2664 | d = __builtin_va_arg(ap,double); executed 10048 times by 10 tests: d = __builtin_va_arg(ap,double);Executed by:
| 10048 | ||||||||||||||||||||||||
| 2665 | - | |||||||||||||||||||||||||
| 2666 | if (qIsUpper(*c)
| 4992-5056 | ||||||||||||||||||||||||
| 2667 | flags |= QLocaleData::CapitalEorX; executed 4992 times by 1 test: flags |= QLocaleData::CapitalEorX;Executed by:
| 4992 | ||||||||||||||||||||||||
| 2668 | - | |||||||||||||||||||||||||
| 2669 | QLocaleData::DoubleForm form = QLocaleData::DFDecimal; | - | ||||||||||||||||||||||||
| 2670 | switch (qToLower(*c)) { | - | ||||||||||||||||||||||||
| 2671 | case never executed: 'e':case 'e':never executed: form = QLocaleData::DFExponent; break;case 'e':never executed: break; | 0 | ||||||||||||||||||||||||
| 2672 | case never executed: 'a':case 'a':never executed: case 'a': | 0 | ||||||||||||||||||||||||
| 2673 | case executed 55 times by 8 tests: 'f':case 'f':Executed by:
executed 55 times by 8 tests: form = QLocaleData::DFDecimal; break;case 'f':Executed by:
executed 55 times by 8 tests: break;Executed by:
| 55 | ||||||||||||||||||||||||
| 2674 | case executed 9993 times by 3 tests: 'g':case 'g':Executed by:
executed 9993 times by 3 tests: form = QLocaleData::DFSignificantDigits; break;case 'g':Executed by:
executed 9993 times by 3 tests: break;Executed by:
| 9993 | ||||||||||||||||||||||||
| 2675 | default never executed: :default:never executed: break;default:never executed: break; | 0 | ||||||||||||||||||||||||
| 2676 | } | - | ||||||||||||||||||||||||
| 2677 | subst = QLocaleData::c()->doubleToString(d, precision, form, width, flags); | - | ||||||||||||||||||||||||
| 2678 | ++c; | - | ||||||||||||||||||||||||
| 2679 | break; executed 10048 times by 10 tests: break;Executed by:
| 10048 | ||||||||||||||||||||||||
| 2680 | } | - | ||||||||||||||||||||||||
| 2681 | case executed 218 times by 3 tests: 'c':case 'c':Executed by:
executed 218 times by 3 tests: {case 'c':Executed by:
| 218 | ||||||||||||||||||||||||
| 2682 | if (length_mod == lm_l
| 0-218 | ||||||||||||||||||||||||
| 2683 | subst = QChar((ushort) __builtin_va_arg(ap,int)); never executed: subst = QChar((ushort) __builtin_va_arg(ap,int)); | 0 | ||||||||||||||||||||||||
| 2684 | else | - | ||||||||||||||||||||||||
| 2685 | subst = QLatin1Char((uchar) __builtin_va_arg(ap,int)); executed 218 times by 3 tests: subst = QLatin1Char((uchar) __builtin_va_arg(ap,int));Executed by:
| 218 | ||||||||||||||||||||||||
| 2686 | ++c; | - | ||||||||||||||||||||||||
| 2687 | break; executed 218 times by 3 tests: break;Executed by:
| 218 | ||||||||||||||||||||||||
| 2688 | } | - | ||||||||||||||||||||||||
| 2689 | case executed 87840 times by 49 tests: 's':case 's':Executed by:
executed 87840 times by 49 tests: {case 's':Executed by:
| 87840 | ||||||||||||||||||||||||
| 2690 | if (length_mod == lm_l
| 38-87802 | ||||||||||||||||||||||||
| 2691 | const ushort *buff = __builtin_va_arg(ap,const ushort*); | - | ||||||||||||||||||||||||
| 2692 | const ushort *ch = buff; | - | ||||||||||||||||||||||||
| 2693 | while (*
| 38-906 | ||||||||||||||||||||||||
| 2694 | ++ executed 906 times by 5 tests: ch;++ch;Executed by:
executed 906 times by 5 tests: ++ch;Executed by:
| 906 | ||||||||||||||||||||||||
| 2695 | subst.setUtf16(buff, ch - buff); | - | ||||||||||||||||||||||||
| 2696 | } executed 38 times by 6 tests: elseend of blockExecuted by:
| 38 | ||||||||||||||||||||||||
| 2697 | subst = QString::fromUtf8(__builtin_va_arg(ap,const char*)); executed 87802 times by 49 tests: subst = QString::fromUtf8(__builtin_va_arg(ap,const char*));Executed by:
| 87802 | ||||||||||||||||||||||||
| 2698 | if (precision != -1
| 14-87826 | ||||||||||||||||||||||||
| 2699 | subst.truncate(precision); executed 14 times by 1 test: subst.truncate(precision);Executed by:
| 14 | ||||||||||||||||||||||||
| 2700 | ++c; | - | ||||||||||||||||||||||||
| 2701 | break; executed 87840 times by 49 tests: break;Executed by:
| 87840 | ||||||||||||||||||||||||
| 2702 | } | - | ||||||||||||||||||||||||
| 2703 | case executed 1948 times by 33 tests: 'p':case 'p':Executed by:
executed 1948 times by 33 tests: {case 'p':Executed by:
| 1948 | ||||||||||||||||||||||||
| 2704 | void *arg = __builtin_va_arg(ap,void*); | - | ||||||||||||||||||||||||
| 2705 | const quint64 i = reinterpret_cast<quintptr>(arg); | - | ||||||||||||||||||||||||
| 2706 | flags |= QLocaleData::Alternate; | - | ||||||||||||||||||||||||
| 2707 | subst = QLocaleData::c()->unsLongLongToString(i, precision, 16, width, flags); | - | ||||||||||||||||||||||||
| 2708 | ++c; | - | ||||||||||||||||||||||||
| 2709 | break; executed 1948 times by 33 tests: break;Executed by:
| 1948 | ||||||||||||||||||||||||
| 2710 | } | - | ||||||||||||||||||||||||
| 2711 | case executed 3 times by 1 test: 'n':case 'n':Executed by:
executed 3 times by 1 test: case 'n':Executed by:
| 3 | ||||||||||||||||||||||||
| 2712 | switch (length_mod) { | - | ||||||||||||||||||||||||
| 2713 | case never executed: lm_hh:case lm_hh:never executed: {case lm_hh: | 0 | ||||||||||||||||||||||||
| 2714 | signed char *n = __builtin_va_arg(ap,signed char*); | - | ||||||||||||||||||||||||
| 2715 | *n = result.length(); | - | ||||||||||||||||||||||||
| 2716 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2717 | } | - | ||||||||||||||||||||||||
| 2718 | case never executed: lm_h:case lm_h:never executed: {case lm_h: | 0 | ||||||||||||||||||||||||
| 2719 | short int *n = __builtin_va_arg(ap,short int*); | - | ||||||||||||||||||||||||
| 2720 | *n = result.length(); | - | ||||||||||||||||||||||||
| 2721 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2722 | } | - | ||||||||||||||||||||||||
| 2723 | case never executed: lm_l:case lm_l:never executed: {case lm_l: | 0 | ||||||||||||||||||||||||
| 2724 | long int *n = __builtin_va_arg(ap,long int*); | - | ||||||||||||||||||||||||
| 2725 | *n = result.length(); | - | ||||||||||||||||||||||||
| 2726 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2727 | } | - | ||||||||||||||||||||||||
| 2728 | case executed 1 time by 1 test: lm_ll:case lm_ll:Executed by:
executed 1 time by 1 test: {case lm_ll:Executed by:
| 1 | ||||||||||||||||||||||||
| 2729 | qint64 *n = __builtin_va_arg(ap,qint64*); | - | ||||||||||||||||||||||||
| 2730 | volatile uint tmp*n = result.length(); | - | ||||||||||||||||||||||||
| 2731 | *n = tmp;break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||
| 2732 | } | - | ||||||||||||||||||||||||
| 2733 | default executed 2 times by 1 test: :default:Executed by:
executed 2 times by 1 test: {default:Executed by:
| 2 | ||||||||||||||||||||||||
| 2734 | int *n = __builtin_va_arg(ap,int*); | - | ||||||||||||||||||||||||
| 2735 | *n = result.length(); | - | ||||||||||||||||||||||||
| 2736 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||
| 2737 | } | - | ||||||||||||||||||||||||
| 2738 | } | - | ||||||||||||||||||||||||
| 2739 | ++c; | - | ||||||||||||||||||||||||
| 2740 | break; executed 3 times by 1 test: break;Executed by:
| 3 | ||||||||||||||||||||||||
| 2741 | - | |||||||||||||||||||||||||
| 2742 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 2743 | for (const char *cc = escape_start; cc != c
| 0 | ||||||||||||||||||||||||
| 2744 | result.append(QLatin1Char(*cc)); never executed: result.append(QLatin1Char(*cc)); | 0 | ||||||||||||||||||||||||
| 2745 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2746 | } | - | ||||||||||||||||||||||||
| 2747 | - | |||||||||||||||||||||||||
| 2748 | if (flags & QLocaleData::LeftAdjusted
| 5000-389937 | ||||||||||||||||||||||||
| 2749 | result.append(subst.leftJustified(width)); executed 5000 times by 1 test: result.append(subst.leftJustified(width));Executed by:
| 5000 | ||||||||||||||||||||||||
| 2750 | else | - | ||||||||||||||||||||||||
| 2751 | result.append(subst.rightJustified(width)); executed 389937 times by 110 tests: result.append(subst.rightJustified(width));Executed by:
| 389937 | ||||||||||||||||||||||||
| 2752 | } | - | ||||||||||||||||||||||||
| 2753 | - | |||||||||||||||||||||||||
| 2754 | return executed 288236 times by 161 tests: result;return result;Executed by:
executed 288236 times by 161 tests: return result;Executed by:
| 288236 | ||||||||||||||||||||||||
| 2755 | } | - | ||||||||||||||||||||||||
| 2756 | qint64 QString::toLongLong(bool *ok, int base) const | - | ||||||||||||||||||||||||
| 2757 | { | - | ||||||||||||||||||||||||
| 2758 | return toIntegral_helper<qlonglong>(constData(), size(), ok, base); | - | ||||||||||||||||||||||||
| 2759 | } | - | ||||||||||||||||||||||||
| 2760 | - | |||||||||||||||||||||||||
| 2761 | qlonglong QString::toIntegral_helper(const QChar *data, int len, bool *ok, int base) | - | ||||||||||||||||||||||||
| 2762 | { | - | ||||||||||||||||||||||||
| 2763 | - | |||||||||||||||||||||||||
| 2764 | - | |||||||||||||||||||||||||
| 2765 | - | |||||||||||||||||||||||||
| 2766 | - | |||||||||||||||||||||||||
| 2767 | - | |||||||||||||||||||||||||
| 2768 | - | |||||||||||||||||||||||||
| 2769 | - | |||||||||||||||||||||||||
| 2770 | return executed 156190 times by 67 tests: QLocaleData::c()->stringToLongLong(data, len, base, ok, QLocaleDataQLocale::FailOnGroupSeparatorsRejectGroupSeparator);return QLocaleData::c()->stringToLongLong(data, len, base, ok, QLocale::RejectGroupSeparator);Executed by:
executed 156190 times by 67 tests: return QLocaleData::c()->stringToLongLong(data, len, base, ok, QLocale::RejectGroupSeparator);Executed by:
| 156190 | ||||||||||||||||||||||||
| 2771 | } | - | ||||||||||||||||||||||||
| 2772 | quint64 QString::toULongLong(bool *ok, int base) const | - | ||||||||||||||||||||||||
| 2773 | { | - | ||||||||||||||||||||||||
| 2774 | return toIntegral_helper<qulonglong>(constData(), size(), ok, base); | - | ||||||||||||||||||||||||
| 2775 | } | - | ||||||||||||||||||||||||
| 2776 | - | |||||||||||||||||||||||||
| 2777 | qulonglong QString::toIntegral_helper(const QChar *data, uint len, bool *ok, int base) | - | ||||||||||||||||||||||||
| 2778 | { | - | ||||||||||||||||||||||||
| 2779 | - | |||||||||||||||||||||||||
| 2780 | - | |||||||||||||||||||||||||
| 2781 | - | |||||||||||||||||||||||||
| 2782 | - | |||||||||||||||||||||||||
| 2783 | - | |||||||||||||||||||||||||
| 2784 | - | |||||||||||||||||||||||||
| 2785 | - | |||||||||||||||||||||||||
| 2786 | return executed 3900 times by 20 tests: QLocaleData::c()->stringToUnsLongLong(data, len, base, ok,return QLocaleData::c()->stringToUnsLongLong(data, len, base, ok, QLocale::RejectGroupSeparator);Executed by:
executed 3900 times by 20 tests: return QLocaleData::c()->stringToUnsLongLong(data, len, base, ok, QLocale::RejectGroupSeparator);Executed by:
| 3900 | ||||||||||||||||||||||||
| 2787 | QLocaleDataQLocale::FailOnGroupSeparatorsRejectGroupSeparator); executed 3900 times by 20 tests: return QLocaleData::c()->stringToUnsLongLong(data, len, base, ok, QLocale::RejectGroupSeparator);Executed by:
| 3900 | ||||||||||||||||||||||||
| 2788 | } | - | ||||||||||||||||||||||||
| 2789 | long QString::toLong(bool *ok, int base) const | - | ||||||||||||||||||||||||
| 2790 | { | - | ||||||||||||||||||||||||
| 2791 | return toIntegral_helper<long>(constData(), size(), ok, base); | - | ||||||||||||||||||||||||
| 2792 | } | - | ||||||||||||||||||||||||
| 2793 | ulong QString::toULong(bool *ok, int base) const | - | ||||||||||||||||||||||||
| 2794 | { | - | ||||||||||||||||||||||||
| 2795 | return toIntegral_helper<ulong>(constData(), size(), ok, base); | - | ||||||||||||||||||||||||
| 2796 | } | - | ||||||||||||||||||||||||
| 2797 | int QString::toInt(bool *ok, int base) const | - | ||||||||||||||||||||||||
| 2798 | { | - | ||||||||||||||||||||||||
| 2799 | return toIntegral_helper<int>(constData(), size(), ok, base); | - | ||||||||||||||||||||||||
| 2800 | } | - | ||||||||||||||||||||||||
| 2801 | uint QString::toUInt(bool *ok, int base) const | - | ||||||||||||||||||||||||
| 2802 | { | - | ||||||||||||||||||||||||
| 2803 | return toIntegral_helper<uint>(constData(), size(), ok, base); | - | ||||||||||||||||||||||||
| 2804 | } | - | ||||||||||||||||||||||||
| 2805 | short QString::toShort(bool *ok, int base) const | - | ||||||||||||||||||||||||
| 2806 | { | - | ||||||||||||||||||||||||
| 2807 | return toIntegral_helper<short>(constData(), size(), ok, base); | - | ||||||||||||||||||||||||
| 2808 | } | - | ||||||||||||||||||||||||
| 2809 | ushort QString::toUShort(bool *ok, int base) const | - | ||||||||||||||||||||||||
| 2810 | { | - | ||||||||||||||||||||||||
| 2811 | return toIntegral_helper<ushort>(constData(), size(), ok, base); | - | ||||||||||||||||||||||||
| 2812 | } | - | ||||||||||||||||||||||||
| 2813 | double QString::toDouble(bool *ok) const | - | ||||||||||||||||||||||||
| 2814 | { | - | ||||||||||||||||||||||||
| 2815 | return executed 2767 times by 24 tests: QLocaleData::c()->stringToDouble(constData(), size(), ok, QLocaleDataQLocale::FailOnGroupSeparatorsRejectGroupSeparator);return QLocaleData::c()->stringToDouble(constData(), size(), ok, QLocale::RejectGroupSeparator);Executed by:
executed 2767 times by 24 tests: return QLocaleData::c()->stringToDouble(constData(), size(), ok, QLocale::RejectGroupSeparator);Executed by:
| 2767 | ||||||||||||||||||||||||
| 2816 | } | - | ||||||||||||||||||||||||
| 2817 | float QString::toFloat(bool *ok) const | - | ||||||||||||||||||||||||
| 2818 | { | - | ||||||||||||||||||||||||
| 2819 | return QLocaleData::convertDoubleToFloat(toDouble(ok), ok); | - | ||||||||||||||||||||||||
| 2820 | } | - | ||||||||||||||||||||||||
| 2821 | QString &QString::setNum(qlonglong n, int base) | - | ||||||||||||||||||||||||
| 2822 | { | - | ||||||||||||||||||||||||
| 2823 | return *this = number(n, base); | - | ||||||||||||||||||||||||
| 2824 | } | - | ||||||||||||||||||||||||
| 2825 | - | |||||||||||||||||||||||||
| 2826 | - | |||||||||||||||||||||||||
| 2827 | - | |||||||||||||||||||||||||
| 2828 | - | |||||||||||||||||||||||||
| 2829 | QString &QString::setNum(qulonglong n, int base) | - | ||||||||||||||||||||||||
| 2830 | { | - | ||||||||||||||||||||||||
| 2831 | return *this = number(n, base); | - | ||||||||||||||||||||||||
| 2832 | } | - | ||||||||||||||||||||||||
| 2833 | QString &QString::setNum(double n, char f, int prec) | - | ||||||||||||||||||||||||
| 2834 | { | - | ||||||||||||||||||||||||
| 2835 | return *this = number(n, f, prec); | - | ||||||||||||||||||||||||
| 2836 | } | - | ||||||||||||||||||||||||
| 2837 | QString QString::number(long n, int base) | - | ||||||||||||||||||||||||
| 2838 | { | - | ||||||||||||||||||||||||
| 2839 | return number(qlonglong(n), base); | - | ||||||||||||||||||||||||
| 2840 | } | - | ||||||||||||||||||||||||
| 2841 | - | |||||||||||||||||||||||||
| 2842 | - | |||||||||||||||||||||||||
| 2843 | - | |||||||||||||||||||||||||
| 2844 | - | |||||||||||||||||||||||||
| 2845 | - | |||||||||||||||||||||||||
| 2846 | - | |||||||||||||||||||||||||
| 2847 | QString QString::number(ulong n, int base) | - | ||||||||||||||||||||||||
| 2848 | { | - | ||||||||||||||||||||||||
| 2849 | return number(qulonglong(n), base); | - | ||||||||||||||||||||||||
| 2850 | } | - | ||||||||||||||||||||||||
| 2851 | - | |||||||||||||||||||||||||
| 2852 | - | |||||||||||||||||||||||||
| 2853 | - | |||||||||||||||||||||||||
| 2854 | - | |||||||||||||||||||||||||
| 2855 | QString QString::number(int n, int base) | - | ||||||||||||||||||||||||
| 2856 | { | - | ||||||||||||||||||||||||
| 2857 | return number(qlonglong(n), base); | - | ||||||||||||||||||||||||
| 2858 | } | - | ||||||||||||||||||||||||
| 2859 | - | |||||||||||||||||||||||||
| 2860 | - | |||||||||||||||||||||||||
| 2861 | - | |||||||||||||||||||||||||
| 2862 | - | |||||||||||||||||||||||||
| 2863 | QString QString::number(uint n, int base) | - | ||||||||||||||||||||||||
| 2864 | { | - | ||||||||||||||||||||||||
| 2865 | return number(qulonglong(n), base); | - | ||||||||||||||||||||||||
| 2866 | } | - | ||||||||||||||||||||||||
| 2867 | - | |||||||||||||||||||||||||
| 2868 | - | |||||||||||||||||||||||||
| 2869 | - | |||||||||||||||||||||||||
| 2870 | - | |||||||||||||||||||||||||
| 2871 | QString QString::number(qlonglong n, int base) | - | ||||||||||||||||||||||||
| 2872 | { | - | ||||||||||||||||||||||||
| 2873 | - | |||||||||||||||||||||||||
| 2874 | - | |||||||||||||||||||||||||
| 2875 | - | |||||||||||||||||||||||||
| 2876 | - | |||||||||||||||||||||||||
| 2877 | - | |||||||||||||||||||||||||
| 2878 | - | |||||||||||||||||||||||||
| 2879 | return QLocaleData::c()->longLongToString(n, -1, base); | - | ||||||||||||||||||||||||
| 2880 | } | - | ||||||||||||||||||||||||
| 2881 | - | |||||||||||||||||||||||||
| 2882 | - | |||||||||||||||||||||||||
| 2883 | - | |||||||||||||||||||||||||
| 2884 | - | |||||||||||||||||||||||||
| 2885 | QString QString::number(qulonglong n, int base) | - | ||||||||||||||||||||||||
| 2886 | { | - | ||||||||||||||||||||||||
| 2887 | - | |||||||||||||||||||||||||
| 2888 | - | |||||||||||||||||||||||||
| 2889 | - | |||||||||||||||||||||||||
| 2890 | - | |||||||||||||||||||||||||
| 2891 | - | |||||||||||||||||||||||||
| 2892 | - | |||||||||||||||||||||||||
| 2893 | return QLocaleData::c()->unsLongLongToString(n, -1, base); | - | ||||||||||||||||||||||||
| 2894 | } | - | ||||||||||||||||||||||||
| 2895 | QString QString::number(double n, char f, int prec) | - | ||||||||||||||||||||||||
| 2896 | { | - | ||||||||||||||||||||||||
| 2897 | QLocaleData::DoubleForm form = QLocaleData::DFDecimal; | - | ||||||||||||||||||||||||
| 2898 | uint flags = 0; | - | ||||||||||||||||||||||||
| 2899 | - | |||||||||||||||||||||||||
| 2900 | if (qIsUpper(f)) | - | ||||||||||||||||||||||||
| 2901 | flags = QLocaleData::CapitalEorX; | - | ||||||||||||||||||||||||
| 2902 | f = qToLower(f); | - | ||||||||||||||||||||||||
| 2903 | - | |||||||||||||||||||||||||
| 2904 | switch (f) { | - | ||||||||||||||||||||||||
| 2905 | case 'f': | - | ||||||||||||||||||||||||
| 2906 | form = QLocaleData::DFDecimal; | - | ||||||||||||||||||||||||
| 2907 | break; | - | ||||||||||||||||||||||||
| 2908 | case 'e': | - | ||||||||||||||||||||||||
| 2909 | form = QLocaleData::DFExponent; | - | ||||||||||||||||||||||||
| 2910 | break; | - | ||||||||||||||||||||||||
| 2911 | case 'g': | - | ||||||||||||||||||||||||
| 2912 | form = QLocaleData::DFSignificantDigits; | - | ||||||||||||||||||||||||
| 2913 | break; | - | ||||||||||||||||||||||||
| 2914 | default: | - | ||||||||||||||||||||||||
| 2915 | - | |||||||||||||||||||||||||
| 2916 | - | |||||||||||||||||||||||||
| 2917 | - | |||||||||||||||||||||||||
| 2918 | break; | - | ||||||||||||||||||||||||
| 2919 | } | - | ||||||||||||||||||||||||
| 2920 | - | |||||||||||||||||||||||||
| 2921 | return QLocaleData::c()->doubleToString(n, prec, form, -1, flags); | - | ||||||||||||||||||||||||
| 2922 | } | - | ||||||||||||||||||||||||
| 2923 | - | |||||||||||||||||||||||||
| 2924 | namespace { | - | ||||||||||||||||||||||||
| 2925 | template<class ResultList, class StringSource> | - | ||||||||||||||||||||||||
| 2926 | static ResultList splitString(const StringSource &source, const QChar *sep, | - | ||||||||||||||||||||||||
| 2927 | QString::SplitBehavior behavior, Qt::CaseSensitivity cs, const int separatorSize) | - | ||||||||||||||||||||||||
| 2928 | { | - | ||||||||||||||||||||||||
| 2929 | ResultList list; | - | ||||||||||||||||||||||||
| 2930 | int start = 0; | - | ||||||||||||||||||||||||
| 2931 | int end; | - | ||||||||||||||||||||||||
| 2932 | int extra = 0; | - | ||||||||||||||||||||||||
| 2933 | while ((end = qFindString(source.constData(), source.size(), start + extra, sep, separatorSize, cs)) != -1) { | - | ||||||||||||||||||||||||
| 2934 | if (start != end || behavior == QString::KeepEmptyParts) | - | ||||||||||||||||||||||||
| 2935 | list.append(source.mid(start, end - start)); | - | ||||||||||||||||||||||||
| 2936 | start = end + separatorSize; | - | ||||||||||||||||||||||||
| 2937 | extra = (separatorSize == 0 ? 1 : 0); | - | ||||||||||||||||||||||||
| 2938 | } | - | ||||||||||||||||||||||||
| 2939 | if (start != source.size() || behavior == QString::KeepEmptyParts) | - | ||||||||||||||||||||||||
| 2940 | list.append(source.mid(start, -1)); | - | ||||||||||||||||||||||||
| 2941 | return list; | - | ||||||||||||||||||||||||
| 2942 | } | - | ||||||||||||||||||||||||
| 2943 | - | |||||||||||||||||||||||||
| 2944 | } | - | ||||||||||||||||||||||||
| 2945 | QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 2946 | { | - | ||||||||||||||||||||||||
| 2947 | return splitString<QStringList>(*this, sep.constData(), behavior, cs, sep.size()); | - | ||||||||||||||||||||||||
| 2948 | } | - | ||||||||||||||||||||||||
| 2949 | QVector<QStringRef> QString::splitRef(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 2950 | { | - | ||||||||||||||||||||||||
| 2951 | return splitString<QVector<QStringRef> >(QStringRef(this), sep.constData(), behavior, cs, sep.size()); | - | ||||||||||||||||||||||||
| 2952 | } | - | ||||||||||||||||||||||||
| 2953 | - | |||||||||||||||||||||||||
| 2954 | - | |||||||||||||||||||||||||
| 2955 | - | |||||||||||||||||||||||||
| 2956 | QStringList QString::split(QChar sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 2957 | { | - | ||||||||||||||||||||||||
| 2958 | return splitString<QStringList>(*this, &sep, behavior, cs, 1); | - | ||||||||||||||||||||||||
| 2959 | } | - | ||||||||||||||||||||||||
| 2960 | - | |||||||||||||||||||||||||
| 2961 | - | |||||||||||||||||||||||||
| 2962 | - | |||||||||||||||||||||||||
| 2963 | - | |||||||||||||||||||||||||
| 2964 | - | |||||||||||||||||||||||||
| 2965 | QVector<QStringRef> QString::splitRef(QChar sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 2966 | { | - | ||||||||||||||||||||||||
| 2967 | return splitString<QVector<QStringRef> >(QStringRef(this), &sep, behavior, cs, 1); | - | ||||||||||||||||||||||||
| 2968 | } | - | ||||||||||||||||||||||||
| 2969 | QVector<QStringRef> QStringRef::split(const QString &sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 2970 | { | - | ||||||||||||||||||||||||
| 2971 | return splitString<QVector<QStringRef> >(*this, sep.constData(), behavior, cs, sep.size()); | - | ||||||||||||||||||||||||
| 2972 | } | - | ||||||||||||||||||||||||
| 2973 | - | |||||||||||||||||||||||||
| 2974 | - | |||||||||||||||||||||||||
| 2975 | - | |||||||||||||||||||||||||
| 2976 | - | |||||||||||||||||||||||||
| 2977 | - | |||||||||||||||||||||||||
| 2978 | QVector<QStringRef> QStringRef::split(QChar sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 2979 | { | - | ||||||||||||||||||||||||
| 2980 | return splitString<QVector<QStringRef> >(*this, &sep, behavior, cs, 1); | - | ||||||||||||||||||||||||
| 2981 | } | - | ||||||||||||||||||||||||
| 2982 | - | |||||||||||||||||||||||||
| 2983 | - | |||||||||||||||||||||||||
| 2984 | namespace { | - | ||||||||||||||||||||||||
| 2985 | template<class ResultList, typename MidMethod> | - | ||||||||||||||||||||||||
| 2986 | static ResultList splitString(const QString &source, MidMethod mid, const QRegExp &rx, QString::SplitBehavior behavior) | - | ||||||||||||||||||||||||
| 2987 | { | - | ||||||||||||||||||||||||
| 2988 | QRegExp rx2(rx); | - | ||||||||||||||||||||||||
| 2989 | ResultList list; | - | ||||||||||||||||||||||||
| 2990 | int start = 0; | - | ||||||||||||||||||||||||
| 2991 | int extra = 0; | - | ||||||||||||||||||||||||
| 2992 | int end; | - | ||||||||||||||||||||||||
| 2993 | while ((end = rx2.indexIn(source, start + extra)) != -1) { | - | ||||||||||||||||||||||||
| 2994 | int matchedLen = rx2.matchedLength(); | - | ||||||||||||||||||||||||
| 2995 | if (start != end || behavior == QString::KeepEmptyParts) | - | ||||||||||||||||||||||||
| 2996 | list.append((source.*mid)(start, end - start)); | - | ||||||||||||||||||||||||
| 2997 | start = end + matchedLen; | - | ||||||||||||||||||||||||
| 2998 | extra = (matchedLen == 0) ? 1 : 0; | - | ||||||||||||||||||||||||
| 2999 | } | - | ||||||||||||||||||||||||
| 3000 | if (start != source.size() || behavior == QString::KeepEmptyParts) | - | ||||||||||||||||||||||||
| 3001 | list.append((source.*mid)(start, -1)); | - | ||||||||||||||||||||||||
| 3002 | return list; | - | ||||||||||||||||||||||||
| 3003 | } | - | ||||||||||||||||||||||||
| 3004 | } | - | ||||||||||||||||||||||||
| 3005 | QStringList QString::split(const QRegExp &rx, SplitBehavior behavior) const | - | ||||||||||||||||||||||||
| 3006 | { | - | ||||||||||||||||||||||||
| 3007 | return splitString<QStringList>(*this, &QString::mid, rx, behavior); | - | ||||||||||||||||||||||||
| 3008 | } | - | ||||||||||||||||||||||||
| 3009 | QVector<QStringRef> QString::splitRef(const QRegExp &rx, SplitBehavior behavior) const | - | ||||||||||||||||||||||||
| 3010 | { | - | ||||||||||||||||||||||||
| 3011 | return splitString<QVector<QStringRef> >(*this, &QString::midRef, rx, behavior); | - | ||||||||||||||||||||||||
| 3012 | } | - | ||||||||||||||||||||||||
| 3013 | - | |||||||||||||||||||||||||
| 3014 | - | |||||||||||||||||||||||||
| 3015 | - | |||||||||||||||||||||||||
| 3016 | - | |||||||||||||||||||||||||
| 3017 | namespace { | - | ||||||||||||||||||||||||
| 3018 | template<class ResultList, typename MidMethod> | - | ||||||||||||||||||||||||
| 3019 | static ResultList splitString(const QString &source, MidMethod mid, const QRegularExpression &re, | - | ||||||||||||||||||||||||
| 3020 | QString::SplitBehavior behavior) | - | ||||||||||||||||||||||||
| 3021 | { | - | ||||||||||||||||||||||||
| 3022 | ResultList list; | - | ||||||||||||||||||||||||
| 3023 | if (!re.isValid()) { | - | ||||||||||||||||||||||||
| 3024 | QMessageLogger(__FILE__, 69967016, __PRETTY_FUNCTION__).warning("QString::split: invalid QRegularExpression object"); | - | ||||||||||||||||||||||||
| 3025 | return list; | - | ||||||||||||||||||||||||
| 3026 | } | - | ||||||||||||||||||||||||
| 3027 | - | |||||||||||||||||||||||||
| 3028 | int start = 0; | - | ||||||||||||||||||||||||
| 3029 | int end = 0; | - | ||||||||||||||||||||||||
| 3030 | QRegularExpressionMatchIterator iterator = re.globalMatch(source); | - | ||||||||||||||||||||||||
| 3031 | while (iterator.hasNext()) { | - | ||||||||||||||||||||||||
| 3032 | QRegularExpressionMatch match = iterator.next(); | - | ||||||||||||||||||||||||
| 3033 | end = match.capturedStart(); | - | ||||||||||||||||||||||||
| 3034 | if (start != end || behavior == QString::KeepEmptyParts) | - | ||||||||||||||||||||||||
| 3035 | list.append((source.*mid)(start, end - start)); | - | ||||||||||||||||||||||||
| 3036 | start = match.capturedEnd(); | - | ||||||||||||||||||||||||
| 3037 | } | - | ||||||||||||||||||||||||
| 3038 | - | |||||||||||||||||||||||||
| 3039 | if (start != source.size() || behavior == QString::KeepEmptyParts) | - | ||||||||||||||||||||||||
| 3040 | list.append((source.*mid)(start, -1)); | - | ||||||||||||||||||||||||
| 3041 | - | |||||||||||||||||||||||||
| 3042 | return list; | - | ||||||||||||||||||||||||
| 3043 | } | - | ||||||||||||||||||||||||
| 3044 | } | - | ||||||||||||||||||||||||
| 3045 | QStringList QString::split(const QRegularExpression &re, SplitBehavior behavior) const | - | ||||||||||||||||||||||||
| 3046 | { | - | ||||||||||||||||||||||||
| 3047 | return splitString<QStringList>(*this, &QString::mid, re, behavior); | - | ||||||||||||||||||||||||
| 3048 | } | - | ||||||||||||||||||||||||
| 3049 | QVector<QStringRef> QString::splitRef(const QRegularExpression &re, SplitBehavior behavior) const | - | ||||||||||||||||||||||||
| 3050 | { | - | ||||||||||||||||||||||||
| 3051 | return splitString<QVector<QStringRef> >(*this, &QString::midRef, re, behavior); | - | ||||||||||||||||||||||||
| 3052 | } | - | ||||||||||||||||||||||||
| 3053 | QString QString::repeated(int times) const | - | ||||||||||||||||||||||||
| 3054 | { | - | ||||||||||||||||||||||||
| 3055 | if (d->size == 0) | - | ||||||||||||||||||||||||
| 3056 | return *this; | - | ||||||||||||||||||||||||
| 3057 | - | |||||||||||||||||||||||||
| 3058 | if (times <= 1) { | - | ||||||||||||||||||||||||
| 3059 | if (times == 1) | - | ||||||||||||||||||||||||
| 3060 | return *this; | - | ||||||||||||||||||||||||
| 3061 | return QString(); | - | ||||||||||||||||||||||||
| 3062 | } | - | ||||||||||||||||||||||||
| 3063 | - | |||||||||||||||||||||||||
| 3064 | const int resultSize = times * d->size; | - | ||||||||||||||||||||||||
| 3065 | - | |||||||||||||||||||||||||
| 3066 | QString result; | - | ||||||||||||||||||||||||
| 3067 | result.reserve(resultSize); | - | ||||||||||||||||||||||||
| 3068 | if (result.d->alloc != uint(resultSize) + 1u) | - | ||||||||||||||||||||||||
| 3069 | return QString(); | - | ||||||||||||||||||||||||
| 3070 | - | |||||||||||||||||||||||||
| 3071 | memcpy(result.d->data(), d->data(), d->size * sizeof(ushort)); | - | ||||||||||||||||||||||||
| 3072 | - | |||||||||||||||||||||||||
| 3073 | int sizeSoFar = d->size; | - | ||||||||||||||||||||||||
| 3074 | ushort *end = result.d->data() + sizeSoFar; | - | ||||||||||||||||||||||||
| 3075 | - | |||||||||||||||||||||||||
| 3076 | const int halfResultSize = resultSize >> 1; | - | ||||||||||||||||||||||||
| 3077 | while (sizeSoFar <= halfResultSize) { | - | ||||||||||||||||||||||||
| 3078 | memcpy(end, result.d->data(), sizeSoFar * sizeof(ushort)); | - | ||||||||||||||||||||||||
| 3079 | end += sizeSoFar; | - | ||||||||||||||||||||||||
| 3080 | sizeSoFar <<= 1; | - | ||||||||||||||||||||||||
| 3081 | } | - | ||||||||||||||||||||||||
| 3082 | memcpy(end, result.d->data(), (resultSize - sizeSoFar) * sizeof(ushort)); | - | ||||||||||||||||||||||||
| 3083 | result.d->data()[resultSize] = '\0'; | - | ||||||||||||||||||||||||
| 3084 | result.d->size = resultSize; | - | ||||||||||||||||||||||||
| 3085 | return result; | - | ||||||||||||||||||||||||
| 3086 | } | - | ||||||||||||||||||||||||
| 3087 | - | |||||||||||||||||||||||||
| 3088 | void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar::UnicodeVersion version, int from) | - | ||||||||||||||||||||||||
| 3089 | { | - | ||||||||||||||||||||||||
| 3090 | bool simple = true; | - | ||||||||||||||||||||||||
| 3091 | const QChar *p = data->constData(); | - | ||||||||||||||||||||||||
| 3092 | int len = data->length(); | - | ||||||||||||||||||||||||
| 3093 | for (int i = from; i < len; ++i) { | - | ||||||||||||||||||||||||
| 3094 | if (p[i].unicode() >= 0x80) { | - | ||||||||||||||||||||||||
| 3095 | simple = false; | - | ||||||||||||||||||||||||
| 3096 | if (i > from) | - | ||||||||||||||||||||||||
| 3097 | from = i - 1; | - | ||||||||||||||||||||||||
| 3098 | break; | - | ||||||||||||||||||||||||
| 3099 | } | - | ||||||||||||||||||||||||
| 3100 | } | - | ||||||||||||||||||||||||
| 3101 | if (simple) | - | ||||||||||||||||||||||||
| 3102 | return; | - | ||||||||||||||||||||||||
| 3103 | - | |||||||||||||||||||||||||
| 3104 | if (version == QChar::Unicode_Unassigned) { | - | ||||||||||||||||||||||||
| 3105 | version = QChar::currentUnicodeVersion(); | - | ||||||||||||||||||||||||
| 3106 | } else if (int(version) <= NormalizationCorrectionsVersionMax) { | - | ||||||||||||||||||||||||
| 3107 | const QString &s = *data; | - | ||||||||||||||||||||||||
| 3108 | QChar *d = 0; | - | ||||||||||||||||||||||||
| 3109 | for (int i = 0; i < NumNormalizationCorrections; ++i) { | - | ||||||||||||||||||||||||
| 3110 | const NormalizationCorrection &n = uc_normalization_corrections[i]; | - | ||||||||||||||||||||||||
| 3111 | if (n.version > version) { | - | ||||||||||||||||||||||||
| 3112 | int pos = from; | - | ||||||||||||||||||||||||
| 3113 | if (QChar::requiresSurrogates(n.ucs4)) { | - | ||||||||||||||||||||||||
| 3114 | ushort ucs4High = QChar::highSurrogate(n.ucs4); | - | ||||||||||||||||||||||||
| 3115 | ushort ucs4Low = QChar::lowSurrogate(n.ucs4); | - | ||||||||||||||||||||||||
| 3116 | ushort oldHigh = QChar::highSurrogate(n.old_mapping); | - | ||||||||||||||||||||||||
| 3117 | ushort oldLow = QChar::lowSurrogate(n.old_mapping); | - | ||||||||||||||||||||||||
| 3118 | while (pos < s.length() - 1) { | - | ||||||||||||||||||||||||
| 3119 | if (s.at(pos).unicode() == ucs4High && s.at(pos + 1).unicode() == ucs4Low) { | - | ||||||||||||||||||||||||
| 3120 | if (!d) | - | ||||||||||||||||||||||||
| 3121 | d = data->data(); | - | ||||||||||||||||||||||||
| 3122 | d[pos] = QChar(oldHigh); | - | ||||||||||||||||||||||||
| 3123 | d[++pos] = QChar(oldLow); | - | ||||||||||||||||||||||||
| 3124 | } | - | ||||||||||||||||||||||||
| 3125 | ++pos; | - | ||||||||||||||||||||||||
| 3126 | } | - | ||||||||||||||||||||||||
| 3127 | } else { | - | ||||||||||||||||||||||||
| 3128 | while (pos < s.length()) { | - | ||||||||||||||||||||||||
| 3129 | if (s.at(pos).unicode() == n.ucs4) { | - | ||||||||||||||||||||||||
| 3130 | if (!d) | - | ||||||||||||||||||||||||
| 3131 | d = data->data(); | - | ||||||||||||||||||||||||
| 3132 | d[pos] = QChar(n.old_mapping); | - | ||||||||||||||||||||||||
| 3133 | } | - | ||||||||||||||||||||||||
| 3134 | ++pos; | - | ||||||||||||||||||||||||
| 3135 | } | - | ||||||||||||||||||||||||
| 3136 | } | - | ||||||||||||||||||||||||
| 3137 | } | - | ||||||||||||||||||||||||
| 3138 | } | - | ||||||||||||||||||||||||
| 3139 | } | - | ||||||||||||||||||||||||
| 3140 | - | |||||||||||||||||||||||||
| 3141 | if (normalizationQuickCheckHelper(data, mode, from, &from)) | - | ||||||||||||||||||||||||
| 3142 | return; | - | ||||||||||||||||||||||||
| 3143 | - | |||||||||||||||||||||||||
| 3144 | decomposeHelper(data, mode < QString::NormalizationForm_KD, version, from); | - | ||||||||||||||||||||||||
| 3145 | - | |||||||||||||||||||||||||
| 3146 | canonicalOrderHelper(data, version, from); | - | ||||||||||||||||||||||||
| 3147 | - | |||||||||||||||||||||||||
| 3148 | if (mode == QString::NormalizationForm_D || mode == QString::NormalizationForm_KD) | - | ||||||||||||||||||||||||
| 3149 | return; | - | ||||||||||||||||||||||||
| 3150 | - | |||||||||||||||||||||||||
| 3151 | composeHelper(data, version, from); | - | ||||||||||||||||||||||||
| 3152 | } | - | ||||||||||||||||||||||||
| 3153 | - | |||||||||||||||||||||||||
| 3154 | - | |||||||||||||||||||||||||
| 3155 | - | |||||||||||||||||||||||||
| 3156 | - | |||||||||||||||||||||||||
| 3157 | - | |||||||||||||||||||||||||
| 3158 | QString QString::normalized(QString::NormalizationForm mode, QChar::UnicodeVersion version) const | - | ||||||||||||||||||||||||
| 3159 | { | - | ||||||||||||||||||||||||
| 3160 | QString copy = *this; | - | ||||||||||||||||||||||||
| 3161 | qt_string_normalize(©, mode, version, 0); | - | ||||||||||||||||||||||||
| 3162 | return copy; | - | ||||||||||||||||||||||||
| 3163 | } | - | ||||||||||||||||||||||||
| 3164 | - | |||||||||||||||||||||||||
| 3165 | - | |||||||||||||||||||||||||
| 3166 | struct ArgEscapeData | - | ||||||||||||||||||||||||
| 3167 | { | - | ||||||||||||||||||||||||
| 3168 | int min_escape; | - | ||||||||||||||||||||||||
| 3169 | int occurrences; | - | ||||||||||||||||||||||||
| 3170 | int locale_occurrences; | - | ||||||||||||||||||||||||
| 3171 | - | |||||||||||||||||||||||||
| 3172 | int escape_len; | - | ||||||||||||||||||||||||
| 3173 | }; | - | ||||||||||||||||||||||||
| 3174 | - | |||||||||||||||||||||||||
| 3175 | static ArgEscapeData findArgEscapes(const QString &s) | - | ||||||||||||||||||||||||
| 3176 | { | - | ||||||||||||||||||||||||
| 3177 | const QChar *uc_begin = s.unicode(); | - | ||||||||||||||||||||||||
| 3178 | const QChar *uc_end = uc_begin + s.length(); | - | ||||||||||||||||||||||||
| 3179 | - | |||||||||||||||||||||||||
| 3180 | ArgEscapeData d; | - | ||||||||||||||||||||||||
| 3181 | - | |||||||||||||||||||||||||
| 3182 | d.min_escape = 2147483647; | - | ||||||||||||||||||||||||
| 3183 | d.occurrences = 0; | - | ||||||||||||||||||||||||
| 3184 | d.escape_len = 0; | - | ||||||||||||||||||||||||
| 3185 | d.locale_occurrences = 0; | - | ||||||||||||||||||||||||
| 3186 | - | |||||||||||||||||||||||||
| 3187 | const QChar *c = uc_begin; | - | ||||||||||||||||||||||||
| 3188 | while (c != uc_end) { | - | ||||||||||||||||||||||||
| 3189 | while (c != uc_end && c->unicode() != '%') | - | ||||||||||||||||||||||||
| 3190 | ++c; | - | ||||||||||||||||||||||||
| 3191 | - | |||||||||||||||||||||||||
| 3192 | if (c == uc_end) | - | ||||||||||||||||||||||||
| 3193 | break; | - | ||||||||||||||||||||||||
| 3194 | const QChar *escape_start = c; | - | ||||||||||||||||||||||||
| 3195 | if (++c == uc_end) | - | ||||||||||||||||||||||||
| 3196 | break; | - | ||||||||||||||||||||||||
| 3197 | - | |||||||||||||||||||||||||
| 3198 | bool locale_arg = false; | - | ||||||||||||||||||||||||
| 3199 | if (c->unicode() == 'L') { | - | ||||||||||||||||||||||||
| 3200 | locale_arg = true; | - | ||||||||||||||||||||||||
| 3201 | if (++c == uc_end) | - | ||||||||||||||||||||||||
| 3202 | break; | - | ||||||||||||||||||||||||
| 3203 | } | - | ||||||||||||||||||||||||
| 3204 | - | |||||||||||||||||||||||||
| 3205 | int escape = c->digitValue(); | - | ||||||||||||||||||||||||
| 3206 | if (escape == -1) | - | ||||||||||||||||||||||||
| 3207 | continue; | - | ||||||||||||||||||||||||
| 3208 | - | |||||||||||||||||||||||||
| 3209 | ++c; | - | ||||||||||||||||||||||||
| 3210 | - | |||||||||||||||||||||||||
| 3211 | if (c != uc_end) { | - | ||||||||||||||||||||||||
| 3212 | int next_escape = c->digitValue(); | - | ||||||||||||||||||||||||
| 3213 | if (next_escape != -1) { | - | ||||||||||||||||||||||||
| 3214 | escape = (10 * escape) + next_escape; | - | ||||||||||||||||||||||||
| 3215 | ++c; | - | ||||||||||||||||||||||||
| 3216 | } | - | ||||||||||||||||||||||||
| 3217 | } | - | ||||||||||||||||||||||||
| 3218 | - | |||||||||||||||||||||||||
| 3219 | if (escape > d.min_escape) | - | ||||||||||||||||||||||||
| 3220 | continue; | - | ||||||||||||||||||||||||
| 3221 | - | |||||||||||||||||||||||||
| 3222 | if (escape < d.min_escape) { | - | ||||||||||||||||||||||||
| 3223 | d.min_escape = escape; | - | ||||||||||||||||||||||||
| 3224 | d.occurrences = 0; | - | ||||||||||||||||||||||||
| 3225 | d.escape_len = 0; | - | ||||||||||||||||||||||||
| 3226 | d.locale_occurrences = 0; | - | ||||||||||||||||||||||||
| 3227 | } | - | ||||||||||||||||||||||||
| 3228 | - | |||||||||||||||||||||||||
| 3229 | ++d.occurrences; | - | ||||||||||||||||||||||||
| 3230 | if (locale_arg) | - | ||||||||||||||||||||||||
| 3231 | ++d.locale_occurrences; | - | ||||||||||||||||||||||||
| 3232 | d.escape_len += c - escape_start; | - | ||||||||||||||||||||||||
| 3233 | } | - | ||||||||||||||||||||||||
| 3234 | return d; | - | ||||||||||||||||||||||||
| 3235 | } | - | ||||||||||||||||||||||||
| 3236 | - | |||||||||||||||||||||||||
| 3237 | static QString replaceArgEscapes(const QString &s, const ArgEscapeData &d, int field_width, | - | ||||||||||||||||||||||||
| 3238 | const QString &arg, const QString &larg, QChar fillChar = QLatin1Char(' ')) | - | ||||||||||||||||||||||||
| 3239 | { | - | ||||||||||||||||||||||||
| 3240 | const QChar *uc_begin = s.unicode(); | - | ||||||||||||||||||||||||
| 3241 | const QChar *uc_end = uc_begin + s.length(); | - | ||||||||||||||||||||||||
| 3242 | - | |||||||||||||||||||||||||
| 3243 | int abs_field_width = qAbs(field_width); | - | ||||||||||||||||||||||||
| 3244 | int result_len = s.length() | - | ||||||||||||||||||||||||
| 3245 | - d.escape_len | - | ||||||||||||||||||||||||
| 3246 | + (d.occurrences - d.locale_occurrences) | - | ||||||||||||||||||||||||
| 3247 | *qMax(abs_field_width, arg.length()) | - | ||||||||||||||||||||||||
| 3248 | + d.locale_occurrences | - | ||||||||||||||||||||||||
| 3249 | *qMax(abs_field_width, larg.length()); | - | ||||||||||||||||||||||||
| 3250 | - | |||||||||||||||||||||||||
| 3251 | QString result(result_len, Qt::Uninitialized); | - | ||||||||||||||||||||||||
| 3252 | QChar *result_buff = (QChar*) result.unicode(); | - | ||||||||||||||||||||||||
| 3253 | - | |||||||||||||||||||||||||
| 3254 | QChar *rc = result_buff; | - | ||||||||||||||||||||||||
| 3255 | const QChar *c = uc_begin; | - | ||||||||||||||||||||||||
| 3256 | int repl_cnt = 0; | - | ||||||||||||||||||||||||
| 3257 | while (c != uc_end) { | - | ||||||||||||||||||||||||
| 3258 | - | |||||||||||||||||||||||||
| 3259 | - | |||||||||||||||||||||||||
| 3260 | - | |||||||||||||||||||||||||
| 3261 | - | |||||||||||||||||||||||||
| 3262 | const QChar *text_start = c; | - | ||||||||||||||||||||||||
| 3263 | - | |||||||||||||||||||||||||
| 3264 | while (c->unicode() != '%') | - | ||||||||||||||||||||||||
| 3265 | ++c; | - | ||||||||||||||||||||||||
| 3266 | - | |||||||||||||||||||||||||
| 3267 | const QChar *escape_start = c++; | - | ||||||||||||||||||||||||
| 3268 | - | |||||||||||||||||||||||||
| 3269 | bool locale_arg = false; | - | ||||||||||||||||||||||||
| 3270 | if (c->unicode() == 'L') { | - | ||||||||||||||||||||||||
| 3271 | locale_arg = true; | - | ||||||||||||||||||||||||
| 3272 | ++c; | - | ||||||||||||||||||||||||
| 3273 | } | - | ||||||||||||||||||||||||
| 3274 | - | |||||||||||||||||||||||||
| 3275 | int escape = c->digitValue(); | - | ||||||||||||||||||||||||
| 3276 | if (escape != -1) { | - | ||||||||||||||||||||||||
| 3277 | if (c + 1 != uc_end && (c + 1)->digitValue() != -1) { | - | ||||||||||||||||||||||||
| 3278 | escape = (10 * escape) + (c + 1)->digitValue(); | - | ||||||||||||||||||||||||
| 3279 | ++c; | - | ||||||||||||||||||||||||
| 3280 | } | - | ||||||||||||||||||||||||
| 3281 | } | - | ||||||||||||||||||||||||
| 3282 | - | |||||||||||||||||||||||||
| 3283 | if (escape != d.min_escape) { | - | ||||||||||||||||||||||||
| 3284 | memcpy(rc, text_start, (c - text_start)*sizeof(QChar)); | - | ||||||||||||||||||||||||
| 3285 | rc += c - text_start; | - | ||||||||||||||||||||||||
| 3286 | } | - | ||||||||||||||||||||||||
| 3287 | else { | - | ||||||||||||||||||||||||
| 3288 | ++c; | - | ||||||||||||||||||||||||
| 3289 | - | |||||||||||||||||||||||||
| 3290 | memcpy(rc, text_start, (escape_start - text_start)*sizeof(QChar)); | - | ||||||||||||||||||||||||
| 3291 | rc += escape_start - text_start; | - | ||||||||||||||||||||||||
| 3292 | - | |||||||||||||||||||||||||
| 3293 | uint pad_chars; | - | ||||||||||||||||||||||||
| 3294 | if (locale_arg) | - | ||||||||||||||||||||||||
| 3295 | pad_chars = qMax(abs_field_width, larg.length()) - larg.length(); | - | ||||||||||||||||||||||||
| 3296 | else | - | ||||||||||||||||||||||||
| 3297 | pad_chars = qMax(abs_field_width, arg.length()) - arg.length(); | - | ||||||||||||||||||||||||
| 3298 | - | |||||||||||||||||||||||||
| 3299 | if (field_width > 0) { | - | ||||||||||||||||||||||||
| 3300 | for (uint i = 0; i < pad_chars; ++i) | - | ||||||||||||||||||||||||
| 3301 | (rc++)->unicode() = fillChar.unicode(); | - | ||||||||||||||||||||||||
| 3302 | } | - | ||||||||||||||||||||||||
| 3303 | - | |||||||||||||||||||||||||
| 3304 | if (locale_arg) { | - | ||||||||||||||||||||||||
| 3305 | memcpy(rc, larg.unicode(), larg.length()*sizeof(QChar)); | - | ||||||||||||||||||||||||
| 3306 | rc += larg.length(); | - | ||||||||||||||||||||||||
| 3307 | } | - | ||||||||||||||||||||||||
| 3308 | else { | - | ||||||||||||||||||||||||
| 3309 | memcpy(rc, arg.unicode(), arg.length()*sizeof(QChar)); | - | ||||||||||||||||||||||||
| 3310 | rc += arg.length(); | - | ||||||||||||||||||||||||
| 3311 | } | - | ||||||||||||||||||||||||
| 3312 | - | |||||||||||||||||||||||||
| 3313 | if (field_width < 0) { | - | ||||||||||||||||||||||||
| 3314 | for (uint i = 0; i < pad_chars; ++i) | - | ||||||||||||||||||||||||
| 3315 | (rc++)->unicode() = fillChar.unicode(); | - | ||||||||||||||||||||||||
| 3316 | } | - | ||||||||||||||||||||||||
| 3317 | - | |||||||||||||||||||||||||
| 3318 | if (++repl_cnt == d.occurrences) { | - | ||||||||||||||||||||||||
| 3319 | memcpy(rc, c, (uc_end - c)*sizeof(QChar)); | - | ||||||||||||||||||||||||
| 3320 | rc += uc_end - c; | - | ||||||||||||||||||||||||
| 3321 | ((!(rc - result_buff == result_len)) ? qt_assert("rc - result_buff == result_len",__FILE__,73677387) : qt_noop()); | - | ||||||||||||||||||||||||
| 3322 | c = uc_end; | - | ||||||||||||||||||||||||
| 3323 | } | - | ||||||||||||||||||||||||
| 3324 | } | - | ||||||||||||||||||||||||
| 3325 | } | - | ||||||||||||||||||||||||
| 3326 | ((!(rc == result_buff + result_len)) ? qt_assert("rc == result_buff + result_len",__FILE__,73727392) : qt_noop()); | - | ||||||||||||||||||||||||
| 3327 | - | |||||||||||||||||||||||||
| 3328 | return result; | - | ||||||||||||||||||||||||
| 3329 | } | - | ||||||||||||||||||||||||
| 3330 | QString QString::arg(const QString &a, int fieldWidth, QChar fillChar) const | - | ||||||||||||||||||||||||
| 3331 | { | - | ||||||||||||||||||||||||
| 3332 | ArgEscapeData d = findArgEscapes(*this); | - | ||||||||||||||||||||||||
| 3333 | - | |||||||||||||||||||||||||
| 3334 | if (d.occurrences == 0) { | - | ||||||||||||||||||||||||
| 3335 | QMessageLogger(__FILE__, 74117431, __PRETTY_FUNCTION__).warning("QString::arg: Argument missing: %s, %s", toLocal8Bit().data(), | - | ||||||||||||||||||||||||
| 3336 | a.toLocal8Bit().data()); | - | ||||||||||||||||||||||||
| 3337 | return *this; | - | ||||||||||||||||||||||||
| 3338 | } | - | ||||||||||||||||||||||||
| 3339 | return replaceArgEscapes(*this, d, fieldWidth, a, a, fillChar); | - | ||||||||||||||||||||||||
| 3340 | } | - | ||||||||||||||||||||||||
| 3341 | QString QString::arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const | - | ||||||||||||||||||||||||
| 3342 | { | - | ||||||||||||||||||||||||
| 3343 | ArgEscapeData d = findArgEscapes(*this); | - | ||||||||||||||||||||||||
| 3344 | - | |||||||||||||||||||||||||
| 3345 | if (d.occurrences == 0) { | - | ||||||||||||||||||||||||
| 3346 | QMessageLogger(__FILE__, 76157635, __PRETTY_FUNCTION__).warning() << "QString::arg: Argument missing:" << *this << ',' << a; | - | ||||||||||||||||||||||||
| 3347 | return *this; | - | ||||||||||||||||||||||||
| 3348 | } | - | ||||||||||||||||||||||||
| 3349 | - | |||||||||||||||||||||||||
| 3350 | unsigned flags = QLocaleData::NoFlags; | - | ||||||||||||||||||||||||
| 3351 | if (fillChar == QLatin1Char('0')) | - | ||||||||||||||||||||||||
| 3352 | flags = QLocaleData::ZeroPadded; | - | ||||||||||||||||||||||||
| 3353 | - | |||||||||||||||||||||||||
| 3354 | QString arg; | - | ||||||||||||||||||||||||
| 3355 | if (d.occurrences > d.locale_occurrences) | - | ||||||||||||||||||||||||
| 3356 | arg = QLocaleData::c()->longLongToString(a, -1, base, fieldWidth, flags); | - | ||||||||||||||||||||||||
| 3357 | - | |||||||||||||||||||||||||
| 3358 | QString locale_arg; | - | ||||||||||||||||||||||||
| 3359 | if (d.locale_occurrences > 0) { | - | ||||||||||||||||||||||||
| 3360 | QLocale locale; | - | ||||||||||||||||||||||||
| 3361 | if (!(locale.numberOptions() & QLocale::OmitGroupSeparator)) | - | ||||||||||||||||||||||||
| 3362 | flags |= QLocaleData::ThousandsGroup; | - | ||||||||||||||||||||||||
| 3363 | locale_arg = locale.d->m_data->longLongToString(a, -1, base, fieldWidth, flags); | - | ||||||||||||||||||||||||
| 3364 | } | - | ||||||||||||||||||||||||
| 3365 | - | |||||||||||||||||||||||||
| 3366 | return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar); | - | ||||||||||||||||||||||||
| 3367 | } | - | ||||||||||||||||||||||||
| 3368 | QString QString::arg(qulonglong a, int fieldWidth, int base, QChar fillChar) const | - | ||||||||||||||||||||||||
| 3369 | { | - | ||||||||||||||||||||||||
| 3370 | ArgEscapeData d = findArgEscapes(*this); | - | ||||||||||||||||||||||||
| 3371 | - | |||||||||||||||||||||||||
| 3372 | if (d.occurrences == 0) { | - | ||||||||||||||||||||||||
| 3373 | QMessageLogger(__FILE__, 76597679, __PRETTY_FUNCTION__).warning() << "QString::arg: Argument missing:" << *this << ',' << a; | - | ||||||||||||||||||||||||
| 3374 | return *this; | - | ||||||||||||||||||||||||
| 3375 | } | - | ||||||||||||||||||||||||
| 3376 | - | |||||||||||||||||||||||||
| 3377 | unsigned flags = QLocaleData::NoFlags; | - | ||||||||||||||||||||||||
| 3378 | if (fillChar == QLatin1Char('0')) | - | ||||||||||||||||||||||||
| 3379 | flags = QLocaleData::ZeroPadded; | - | ||||||||||||||||||||||||
| 3380 | - | |||||||||||||||||||||||||
| 3381 | QString arg; | - | ||||||||||||||||||||||||
| 3382 | if (d.occurrences > d.locale_occurrences) | - | ||||||||||||||||||||||||
| 3383 | arg = QLocaleData::c()->unsLongLongToString(a, -1, base, fieldWidth, flags); | - | ||||||||||||||||||||||||
| 3384 | - | |||||||||||||||||||||||||
| 3385 | QString locale_arg; | - | ||||||||||||||||||||||||
| 3386 | if (d.locale_occurrences > 0) { | - | ||||||||||||||||||||||||
| 3387 | QLocale locale; | - | ||||||||||||||||||||||||
| 3388 | if (!(locale.numberOptions() & QLocale::OmitGroupSeparator)) | - | ||||||||||||||||||||||||
| 3389 | flags |= QLocaleData::ThousandsGroup; | - | ||||||||||||||||||||||||
| 3390 | locale_arg = locale.d->m_data->unsLongLongToString(a, -1, base, fieldWidth, flags); | - | ||||||||||||||||||||||||
| 3391 | } | - | ||||||||||||||||||||||||
| 3392 | - | |||||||||||||||||||||||||
| 3393 | return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar); | - | ||||||||||||||||||||||||
| 3394 | } | - | ||||||||||||||||||||||||
| 3395 | QString QString::arg(QChar a, int fieldWidth, QChar fillChar) const | - | ||||||||||||||||||||||||
| 3396 | { | - | ||||||||||||||||||||||||
| 3397 | QString c; | - | ||||||||||||||||||||||||
| 3398 | c += a; | - | ||||||||||||||||||||||||
| 3399 | return arg(c, fieldWidth, fillChar); | - | ||||||||||||||||||||||||
| 3400 | } | - | ||||||||||||||||||||||||
| 3401 | - | |||||||||||||||||||||||||
| 3402 | - | |||||||||||||||||||||||||
| 3403 | - | |||||||||||||||||||||||||
| 3404 | - | |||||||||||||||||||||||||
| 3405 | - | |||||||||||||||||||||||||
| 3406 | - | |||||||||||||||||||||||||
| 3407 | QString QString::arg(char a, int fieldWidth, QChar fillChar) const | - | ||||||||||||||||||||||||
| 3408 | { | - | ||||||||||||||||||||||||
| 3409 | QString c; | - | ||||||||||||||||||||||||
| 3410 | c += QLatin1Char(a); | - | ||||||||||||||||||||||||
| 3411 | return arg(c, fieldWidth, fillChar); | - | ||||||||||||||||||||||||
| 3412 | } | - | ||||||||||||||||||||||||
| 3413 | QString QString::arg(double a, int fieldWidth, char fmt, int prec, QChar fillChar) const | - | ||||||||||||||||||||||||
| 3414 | { | - | ||||||||||||||||||||||||
| 3415 | ArgEscapeData d = findArgEscapes(*this); | - | ||||||||||||||||||||||||
| 3416 | - | |||||||||||||||||||||||||
| 3417 | if (d.occurrences == 0
| 0-95812 | ||||||||||||||||||||||||
| 3418 | QMessageLogger(__FILE__, 77717791, __PRETTY_FUNCTION__).warning("QString::arg: Argument missing: %s, %g", toLocal8Bit().data(), a); | - | ||||||||||||||||||||||||
| 3419 | return never executed: *this;return *this;never executed: return *this; | 0 | ||||||||||||||||||||||||
| 3420 | } | - | ||||||||||||||||||||||||
| 3421 | - | |||||||||||||||||||||||||
| 3422 | unsigned flags = QLocaleData::NoFlags; | - | ||||||||||||||||||||||||
| 3423 | if (fillChar == QLatin1Char('0')
| 5-95807 | ||||||||||||||||||||||||
| 3424 | flags = QLocaleData::ZeroPadded; executed 5 times by 1 test: flags = QLocaleData::ZeroPadded;Executed by:
| 5 | ||||||||||||||||||||||||
| 3425 | - | |||||||||||||||||||||||||
| 3426 | if (qIsUpper(fmt)
| 0-95812 | ||||||||||||||||||||||||
| 3427 | flags |= QLocaleData::CapitalEorX; never executed: flags |= QLocaleData::CapitalEorX; | 0 | ||||||||||||||||||||||||
| 3428 | fmt = qToLower(fmt); | - | ||||||||||||||||||||||||
| 3429 | - | |||||||||||||||||||||||||
| 3430 | QLocaleData::DoubleForm form = QLocaleData::DFDecimal; | - | ||||||||||||||||||||||||
| 3431 | switch (fmt) { | - | ||||||||||||||||||||||||
| 3432 | case never executed: 'f':case 'f':never executed: case 'f': | 0 | ||||||||||||||||||||||||
| 3433 | form = QLocaleData::DFDecimal; | - | ||||||||||||||||||||||||
| 3434 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3435 | case never executed: 'e':case 'e':never executed: case 'e': | 0 | ||||||||||||||||||||||||
| 3436 | form = QLocaleData::DFExponent; | - | ||||||||||||||||||||||||
| 3437 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3438 | case executed 95812 times by 7 tests: 'g':case 'g':Executed by:
executed 95812 times by 7 tests: case 'g':Executed by:
| 95812 | ||||||||||||||||||||||||
| 3439 | form = QLocaleData::DFSignificantDigits; | - | ||||||||||||||||||||||||
| 3440 | break; executed 95812 times by 7 tests: break;Executed by:
| 95812 | ||||||||||||||||||||||||
| 3441 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 3442 | - | |||||||||||||||||||||||||
| 3443 | - | |||||||||||||||||||||||||
| 3444 | - | |||||||||||||||||||||||||
| 3445 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3446 | } | - | ||||||||||||||||||||||||
| 3447 | - | |||||||||||||||||||||||||
| 3448 | QString arg; | - | ||||||||||||||||||||||||
| 3449 | if (d.occurrences > d.locale_occurrences
| 9-95803 | ||||||||||||||||||||||||
| 3450 | arg = QLocaleData::c()->doubleToString(a, prec, form, fieldWidth, flags); executed 95803 times by 7 tests: arg = QLocaleData::c()->doubleToString(a, prec, form, fieldWidth, flags);Executed by:
| 95803 | ||||||||||||||||||||||||
| 3451 | - | |||||||||||||||||||||||||
| 3452 | QString locale_arg; | - | ||||||||||||||||||||||||
| 3453 | if (d.locale_occurrences > 0
| 9-95803 | ||||||||||||||||||||||||
| 3454 | QLocale locale; | - | ||||||||||||||||||||||||
| 3455 | - | |||||||||||||||||||||||||
| 3456 | if (!(locale.numberOptions() & QLocale::OmitGroupSeparator)
| 2-7 | ||||||||||||||||||||||||
| 3457 | flags |= QLocaleData::ThousandsGroup; executed 7 times by 1 test: flags |= QLocaleData::ThousandsGroup;Executed by:
| 7 | ||||||||||||||||||||||||
| 3458 | if (!(locale.numberOptions() & QLocale::OmitLeadingZeroInExponent)
| 0-9 | ||||||||||||||||||||||||
| 3459 | flags |= QLocaleData::ZeroPadExponent executed 9 times by 1 test: flags |= QLocaleData::ZeroPadExponent;Executed by:
executed 9 times by 1 test: ;flags |= QLocaleData::ZeroPadExponent;Executed by:
executed 9 times by 1 test: flags |= QLocaleData::ZeroPadExponent;Executed by:
| 9 | ||||||||||||||||||||||||
| 3460 | locale_arg = locale.d->m_data->doubleToString(a, prec, form, fieldWidth, flags); | - | ||||||||||||||||||||||||
| 3461 | } executed 9 times by 1 test: end of blockExecuted by:
| 9 | ||||||||||||||||||||||||
| 3462 | - | |||||||||||||||||||||||||
| 3463 | return executed 95812 times by 7 tests: replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar);return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar);Executed by:
executed 95812 times by 7 tests: return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar);Executed by:
| 95812 | ||||||||||||||||||||||||
| 3464 | } | - | ||||||||||||||||||||||||
| 3465 | - | |||||||||||||||||||||||||
| 3466 | static int getEscape(const QChar *uc, int *pos, int len, int maxNumber = 999) | - | ||||||||||||||||||||||||
| 3467 | { | - | ||||||||||||||||||||||||
| 3468 | int i = *pos; | - | ||||||||||||||||||||||||
| 3469 | ++i; | - | ||||||||||||||||||||||||
| 3470 | if (i < len && uc[i] == QLatin1Char('L')) | - | ||||||||||||||||||||||||
| 3471 | ++i; | - | ||||||||||||||||||||||||
| 3472 | if (i < len) { | - | ||||||||||||||||||||||||
| 3473 | int escape = uc[i].unicode() - '0'; | - | ||||||||||||||||||||||||
| 3474 | if (uint(escape) >= 10U) | - | ||||||||||||||||||||||||
| 3475 | return -1; | - | ||||||||||||||||||||||||
| 3476 | ++i; | - | ||||||||||||||||||||||||
| 3477 | while (i < len) { | - | ||||||||||||||||||||||||
| 3478 | int digit = uc[i].unicode() - '0'; | - | ||||||||||||||||||||||||
| 3479 | if (uint(digit) >= 10U) | - | ||||||||||||||||||||||||
| 3480 | break; | - | ||||||||||||||||||||||||
| 3481 | escape = (escape * 10) + digit; | - | ||||||||||||||||||||||||
| 3482 | ++i; | - | ||||||||||||||||||||||||
| 3483 | } | - | ||||||||||||||||||||||||
| 3484 | if (escape <= maxNumber) { | - | ||||||||||||||||||||||||
| 3485 | *pos = i; | - | ||||||||||||||||||||||||
| 3486 | return escape; | - | ||||||||||||||||||||||||
| 3487 | } | - | ||||||||||||||||||||||||
| 3488 | } | - | ||||||||||||||||||||||||
| 3489 | return -1; | - | ||||||||||||||||||||||||
| 3490 | } | - | ||||||||||||||||||||||||
| 3491 | namespace { | - | ||||||||||||||||||||||||
| 3492 | struct Part | - | ||||||||||||||||||||||||
| 3493 | { | - | ||||||||||||||||||||||||
| 3494 | Part() : stringRef(), number(0) {} | - | ||||||||||||||||||||||||
| 3495 | Part(const QString &s, int pos, int len, int num = -1) noexcept | - | ||||||||||||||||||||||||
| 3496 | : stringRef(&s, pos, len), number(num) {} executed 1547777 times by 331 tests: end of blockExecuted by:
| 1547777 | ||||||||||||||||||||||||
| 3497 | - | |||||||||||||||||||||||||
| 3498 | QStringRef stringRef; | - | ||||||||||||||||||||||||
| 3499 | int number; | - | ||||||||||||||||||||||||
| 3500 | }; | - | ||||||||||||||||||||||||
| 3501 | } | - | ||||||||||||||||||||||||
| 3502 | - | |||||||||||||||||||||||||
| 3503 | template <> | - | ||||||||||||||||||||||||
| 3504 | class QTypeInfo<Part> : public QTypeInfoMerger<Part, QStringRef, int> {}; | - | ||||||||||||||||||||||||
| 3505 | - | |||||||||||||||||||||||||
| 3506 | - | |||||||||||||||||||||||||
| 3507 | namespace { | - | ||||||||||||||||||||||||
| 3508 | - | |||||||||||||||||||||||||
| 3509 | enum { ExpectedParts = 32 }; | - | ||||||||||||||||||||||||
| 3510 | - | |||||||||||||||||||||||||
| 3511 | typedef QVarLengthArray<Part, ExpectedParts> ParseResult; | - | ||||||||||||||||||||||||
| 3512 | typedef QVarLengthArray<int, ExpectedParts/2> ArgIndexToPlaceholderMap; | - | ||||||||||||||||||||||||
| 3513 | - | |||||||||||||||||||||||||
| 3514 | static ParseResult parseMultiArgFormatString(const QString &s) | - | ||||||||||||||||||||||||
| 3515 | { | - | ||||||||||||||||||||||||
| 3516 | ParseResult result; | - | ||||||||||||||||||||||||
| 3517 | - | |||||||||||||||||||||||||
| 3518 | const QChar *uc = s.constData(); | - | ||||||||||||||||||||||||
| 3519 | const int len = s.size(); | - | ||||||||||||||||||||||||
| 3520 | const int end = len - 1; | - | ||||||||||||||||||||||||
| 3521 | int i = 0; | - | ||||||||||||||||||||||||
| 3522 | int last = 0; | - | ||||||||||||||||||||||||
| 3523 | - | |||||||||||||||||||||||||
| 3524 | while (i < end) { | - | ||||||||||||||||||||||||
| 3525 | if (uc[i] == QLatin1Char('%')) { | - | ||||||||||||||||||||||||
| 3526 | int percent = i; | - | ||||||||||||||||||||||||
| 3527 | int number = getEscape(uc, &i, len); | - | ||||||||||||||||||||||||
| 3528 | if (number != -1) { | - | ||||||||||||||||||||||||
| 3529 | if (last != percent) | - | ||||||||||||||||||||||||
| 3530 | result.push_back(Part(s, last, percent - last)); | - | ||||||||||||||||||||||||
| 3531 | result.push_back(Part(s, percent, i - percent, number)); | - | ||||||||||||||||||||||||
| 3532 | last = i; | - | ||||||||||||||||||||||||
| 3533 | continue; | - | ||||||||||||||||||||||||
| 3534 | } | - | ||||||||||||||||||||||||
| 3535 | } | - | ||||||||||||||||||||||||
| 3536 | ++i; | - | ||||||||||||||||||||||||
| 3537 | } | - | ||||||||||||||||||||||||
| 3538 | - | |||||||||||||||||||||||||
| 3539 | if (last < len) | - | ||||||||||||||||||||||||
| 3540 | result.push_back(Part(s, last, len - last)); | - | ||||||||||||||||||||||||
| 3541 | - | |||||||||||||||||||||||||
| 3542 | return result; | - | ||||||||||||||||||||||||
| 3543 | } | - | ||||||||||||||||||||||||
| 3544 | - | |||||||||||||||||||||||||
| 3545 | static ArgIndexToPlaceholderMap makeArgIndexToPlaceholderMap(const ParseResult &parts) | - | ||||||||||||||||||||||||
| 3546 | { | - | ||||||||||||||||||||||||
| 3547 | ArgIndexToPlaceholderMap result; | - | ||||||||||||||||||||||||
| 3548 | - | |||||||||||||||||||||||||
| 3549 | for (ParseResult::const_iterator it = parts.begin(), end = parts.end(); it != end; ++it) { | - | ||||||||||||||||||||||||
| 3550 | if (it->number >= 0) | - | ||||||||||||||||||||||||
| 3551 | result.push_back(it->number); | - | ||||||||||||||||||||||||
| 3552 | } | - | ||||||||||||||||||||||||
| 3553 | - | |||||||||||||||||||||||||
| 3554 | std::sort(result.begin(), result.end()); | - | ||||||||||||||||||||||||
| 3555 | result.erase(std::unique(result.begin(), result.end()), | - | ||||||||||||||||||||||||
| 3556 | result.end()); | - | ||||||||||||||||||||||||
| 3557 | - | |||||||||||||||||||||||||
| 3558 | return result; | - | ||||||||||||||||||||||||
| 3559 | } | - | ||||||||||||||||||||||||
| 3560 | - | |||||||||||||||||||||||||
| 3561 | static int resolveStringRefsAndReturnTotalSize(ParseResult &parts, const ArgIndexToPlaceholderMap &argIndexToPlaceholderMap, const QString *args[]) | - | ||||||||||||||||||||||||
| 3562 | { | - | ||||||||||||||||||||||||
| 3563 | int totalSize = 0; | - | ||||||||||||||||||||||||
| 3564 | for (ParseResult::iterator pit = parts.begin(), end = parts.end(); pit != end; ++pit) { | - | ||||||||||||||||||||||||
| 3565 | if (pit->number != -1) { | - | ||||||||||||||||||||||||
| 3566 | const ArgIndexToPlaceholderMap::const_iterator ait | - | ||||||||||||||||||||||||
| 3567 | = std::find(argIndexToPlaceholderMap.begin(), argIndexToPlaceholderMap.end(), pit->number); | - | ||||||||||||||||||||||||
| 3568 | if (ait != argIndexToPlaceholderMap.end()) | - | ||||||||||||||||||||||||
| 3569 | pit->stringRef = QStringRef(args[ait - argIndexToPlaceholderMap.begin()]); | - | ||||||||||||||||||||||||
| 3570 | } | - | ||||||||||||||||||||||||
| 3571 | totalSize += pit->stringRef.size(); | - | ||||||||||||||||||||||||
| 3572 | } | - | ||||||||||||||||||||||||
| 3573 | return totalSize; | - | ||||||||||||||||||||||||
| 3574 | } | - | ||||||||||||||||||||||||
| 3575 | - | |||||||||||||||||||||||||
| 3576 | } | - | ||||||||||||||||||||||||
| 3577 | - | |||||||||||||||||||||||||
| 3578 | QString QString::multiArg(int numArgs, const QString **args) const | - | ||||||||||||||||||||||||
| 3579 | { | - | ||||||||||||||||||||||||
| 3580 | - | |||||||||||||||||||||||||
| 3581 | ParseResult parts = parseMultiArgFormatString(*this); | - | ||||||||||||||||||||||||
| 3582 | - | |||||||||||||||||||||||||
| 3583 | - | |||||||||||||||||||||||||
| 3584 | ArgIndexToPlaceholderMap argIndexToPlaceholderMap = makeArgIndexToPlaceholderMap(parts); | - | ||||||||||||||||||||||||
| 3585 | - | |||||||||||||||||||||||||
| 3586 | if (argIndexToPlaceholderMap.size() > numArgs) | - | ||||||||||||||||||||||||
| 3587 | argIndexToPlaceholderMap.resize(numArgs); | - | ||||||||||||||||||||||||
| 3588 | else if (argIndexToPlaceholderMap.size() < numArgs) | - | ||||||||||||||||||||||||
| 3589 | QMessageLogger(__FILE__, 79757997, __PRETTY_FUNCTION__).warning("QString::arg: %d argument(s) missing in %s", | - | ||||||||||||||||||||||||
| 3590 | numArgs - argIndexToPlaceholderMap.size(), toLocal8Bit().data()); | - | ||||||||||||||||||||||||
| 3591 | - | |||||||||||||||||||||||||
| 3592 | - | |||||||||||||||||||||||||
| 3593 | const int totalSize = resolveStringRefsAndReturnTotalSize(parts, argIndexToPlaceholderMap, args); | - | ||||||||||||||||||||||||
| 3594 | - | |||||||||||||||||||||||||
| 3595 | - | |||||||||||||||||||||||||
| 3596 | QString result(totalSize, Qt::Uninitialized); | - | ||||||||||||||||||||||||
| 3597 | QChar *out = result.data(); | - | ||||||||||||||||||||||||
| 3598 | - | |||||||||||||||||||||||||
| 3599 | for (ParseResult::const_iterator it = parts.begin(), end = parts.end(); it != end; ++it) { | - | ||||||||||||||||||||||||
| 3600 | if (const int sz = it->stringRef.size()) { | - | ||||||||||||||||||||||||
| 3601 | memcpy(out, it->stringRef.constData(), sz * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 3602 | out += sz; | - | ||||||||||||||||||||||||
| 3603 | } | - | ||||||||||||||||||||||||
| 3604 | } | - | ||||||||||||||||||||||||
| 3605 | - | |||||||||||||||||||||||||
| 3606 | return result; | - | ||||||||||||||||||||||||
| 3607 | } | - | ||||||||||||||||||||||||
| 3608 | bool QString::isSimpleText() const | - | ||||||||||||||||||||||||
| 3609 | { | - | ||||||||||||||||||||||||
| 3610 | const ushort *p = d->data(); | - | ||||||||||||||||||||||||
| 3611 | const ushort * const end = p + d->size; | - | ||||||||||||||||||||||||
| 3612 | while (p < end) { | - | ||||||||||||||||||||||||
| 3613 | ushort uc = *p; | - | ||||||||||||||||||||||||
| 3614 | - | |||||||||||||||||||||||||
| 3615 | if (uc > 0x058f && (uc < 0x1100 || uc > 0xfb0f)) { | - | ||||||||||||||||||||||||
| 3616 | return false; | - | ||||||||||||||||||||||||
| 3617 | } | - | ||||||||||||||||||||||||
| 3618 | p++; | - | ||||||||||||||||||||||||
| 3619 | } | - | ||||||||||||||||||||||||
| 3620 | - | |||||||||||||||||||||||||
| 3621 | return true; | - | ||||||||||||||||||||||||
| 3622 | } | - | ||||||||||||||||||||||||
| 3623 | - | |||||||||||||||||||||||||
| 3624 | - | |||||||||||||||||||||||||
| 3625 | - | |||||||||||||||||||||||||
| 3626 | - | |||||||||||||||||||||||||
| 3627 | - | |||||||||||||||||||||||||
| 3628 | bool QString::isRightToLeft() const | - | ||||||||||||||||||||||||
| 3629 | { | - | ||||||||||||||||||||||||
| 3630 | const ushort *p = d->data(); | - | ||||||||||||||||||||||||
| 3631 | const ushort * const end = p + d->size; | - | ||||||||||||||||||||||||
| 3632 | while (p < end) { | - | ||||||||||||||||||||||||
| 3633 | uint ucs4 = *p; | - | ||||||||||||||||||||||||
| 3634 | if (QChar::isHighSurrogate(ucs4) && p < end - 1) { | - | ||||||||||||||||||||||||
| 3635 | ushort low = p[1]; | - | ||||||||||||||||||||||||
| 3636 | if (QChar::isLowSurrogate(low)) { | - | ||||||||||||||||||||||||
| 3637 | ucs4 = QChar::surrogateToUcs4(ucs4, low); | - | ||||||||||||||||||||||||
| 3638 | ++p; | - | ||||||||||||||||||||||||
| 3639 | } | - | ||||||||||||||||||||||||
| 3640 | } | - | ||||||||||||||||||||||||
| 3641 | switch (QChar::direction(ucs4)) | - | ||||||||||||||||||||||||
| 3642 | { | - | ||||||||||||||||||||||||
| 3643 | case QChar::DirL: | - | ||||||||||||||||||||||||
| 3644 | return false; | - | ||||||||||||||||||||||||
| 3645 | case QChar::DirR: | - | ||||||||||||||||||||||||
| 3646 | case QChar::DirAL: | - | ||||||||||||||||||||||||
| 3647 | return true; | - | ||||||||||||||||||||||||
| 3648 | default: | - | ||||||||||||||||||||||||
| 3649 | break; | - | ||||||||||||||||||||||||
| 3650 | } | - | ||||||||||||||||||||||||
| 3651 | ++p; | - | ||||||||||||||||||||||||
| 3652 | } | - | ||||||||||||||||||||||||
| 3653 | return false; | - | ||||||||||||||||||||||||
| 3654 | } | - | ||||||||||||||||||||||||
| 3655 | QString QString::fromRawData(const QChar *unicode, int size) | - | ||||||||||||||||||||||||
| 3656 | { | - | ||||||||||||||||||||||||
| 3657 | Data *x; | - | ||||||||||||||||||||||||
| 3658 | if (!unicode) { | - | ||||||||||||||||||||||||
| 3659 | x = Data::sharedNull(); | - | ||||||||||||||||||||||||
| 3660 | } else if (!size) { | - | ||||||||||||||||||||||||
| 3661 | x = Data::allocate(0); | - | ||||||||||||||||||||||||
| 3662 | } else { | - | ||||||||||||||||||||||||
| 3663 | x = Data::fromRawData(reinterpret_cast<const ushort *>(unicode), size); | - | ||||||||||||||||||||||||
| 3664 | do { if (!(x)) qBadAlloc(); } while (0); | - | ||||||||||||||||||||||||
| 3665 | } | - | ||||||||||||||||||||||||
| 3666 | QStringDataPtr dataPtr = { x }; | - | ||||||||||||||||||||||||
| 3667 | return QString(dataPtr); | - | ||||||||||||||||||||||||
| 3668 | } | - | ||||||||||||||||||||||||
| 3669 | QString &QString::setRawData(const QChar *unicode, int size) | - | ||||||||||||||||||||||||
| 3670 | { | - | ||||||||||||||||||||||||
| 3671 | if (d->ref.isShared() || d->alloc) { | - | ||||||||||||||||||||||||
| 3672 | *this = fromRawData(unicode, size); | - | ||||||||||||||||||||||||
| 3673 | } else { | - | ||||||||||||||||||||||||
| 3674 | if (unicode) { | - | ||||||||||||||||||||||||
| 3675 | d->size = size; | - | ||||||||||||||||||||||||
| 3676 | d->offset = reinterpret_cast<const char *>(unicode) - reinterpret_cast<char *>(d); | - | ||||||||||||||||||||||||
| 3677 | } else { | - | ||||||||||||||||||||||||
| 3678 | d->offset = sizeof(QStringData); | - | ||||||||||||||||||||||||
| 3679 | d->size = 0; | - | ||||||||||||||||||||||||
| 3680 | } | - | ||||||||||||||||||||||||
| 3681 | } | - | ||||||||||||||||||||||||
| 3682 | return *this; | - | ||||||||||||||||||||||||
| 3683 | } | - | ||||||||||||||||||||||||
| 3684 | QDataStream &operator<<(QDataStream &out, const QString &str) | - | ||||||||||||||||||||||||
| 3685 | { | - | ||||||||||||||||||||||||
| 3686 | if (out.version() == 1) { | - | ||||||||||||||||||||||||
| 3687 | out << str.toLatin1(); | - | ||||||||||||||||||||||||
| 3688 | } else { | - | ||||||||||||||||||||||||
| 3689 | if (!str.isNull() || out.version() < 3) { | - | ||||||||||||||||||||||||
| 3690 | if ((out.byteOrder() == QDataStream::BigEndian) == (QSysInfo::ByteOrder == QSysInfo::BigEndian)) { | - | ||||||||||||||||||||||||
| 3691 | out.writeBytes(reinterpret_cast<const char *>(str.unicode()), sizeof(QChar) * str.length()); | - | ||||||||||||||||||||||||
| 3692 | } else { | - | ||||||||||||||||||||||||
| 3693 | QVarLengthArray<ushort> buffer(str.length()); | - | ||||||||||||||||||||||||
| 3694 | const ushort *data = reinterpret_cast<const ushort *>(str.constData()); | - | ||||||||||||||||||||||||
| 3695 | for (int i = 0; i < str.length(); i++) { | - | ||||||||||||||||||||||||
| 3696 | buffer[i] = qbswap(*data); | - | ||||||||||||||||||||||||
| 3697 | ++data; | - | ||||||||||||||||||||||||
| 3698 | } | - | ||||||||||||||||||||||||
| 3699 | out.writeBytes(reinterpret_cast<const char *>(buffer.data()), sizeof(ushort) * buffer.size()); | - | ||||||||||||||||||||||||
| 3700 | } | - | ||||||||||||||||||||||||
| 3701 | } else { | - | ||||||||||||||||||||||||
| 3702 | - | |||||||||||||||||||||||||
| 3703 | out << (quint32)0xffffffff; | - | ||||||||||||||||||||||||
| 3704 | } | - | ||||||||||||||||||||||||
| 3705 | } | - | ||||||||||||||||||||||||
| 3706 | return out; | - | ||||||||||||||||||||||||
| 3707 | } | - | ||||||||||||||||||||||||
| 3708 | QDataStream &operator>>(QDataStream &in, QString &str) | - | ||||||||||||||||||||||||
| 3709 | { | - | ||||||||||||||||||||||||
| 3710 | if (in.version() == 1) { | - | ||||||||||||||||||||||||
| 3711 | QByteArray l; | - | ||||||||||||||||||||||||
| 3712 | in >> l; | - | ||||||||||||||||||||||||
| 3713 | str = QString::fromLatin1(l); | - | ||||||||||||||||||||||||
| 3714 | } else { | - | ||||||||||||||||||||||||
| 3715 | quint32 bytes = 0; | - | ||||||||||||||||||||||||
| 3716 | in >> bytes; | - | ||||||||||||||||||||||||
| 3717 | if (bytes == 0xffffffff) { | - | ||||||||||||||||||||||||
| 3718 | str.clear(); | - | ||||||||||||||||||||||||
| 3719 | } else if (bytes > 0) { | - | ||||||||||||||||||||||||
| 3720 | if (bytes & 0x1) { | - | ||||||||||||||||||||||||
| 3721 | str.clear(); | - | ||||||||||||||||||||||||
| 3722 | in.setStatus(QDataStream::ReadCorruptData); | - | ||||||||||||||||||||||||
| 3723 | return in; | - | ||||||||||||||||||||||||
| 3724 | } | - | ||||||||||||||||||||||||
| 3725 | - | |||||||||||||||||||||||||
| 3726 | const quint32 Step = 1024 * 1024; | - | ||||||||||||||||||||||||
| 3727 | quint32 len = bytes / 2; | - | ||||||||||||||||||||||||
| 3728 | quint32 allocated = 0; | - | ||||||||||||||||||||||||
| 3729 | - | |||||||||||||||||||||||||
| 3730 | while (allocated < len) { | - | ||||||||||||||||||||||||
| 3731 | int blockSize = qMin(Step, len - allocated); | - | ||||||||||||||||||||||||
| 3732 | str.resize(allocated + blockSize); | - | ||||||||||||||||||||||||
| 3733 | if (in.readRawData(reinterpret_cast<char *>(str.data()) + allocated * 2, | - | ||||||||||||||||||||||||
| 3734 | blockSize * 2) != blockSize * 2) { | - | ||||||||||||||||||||||||
| 3735 | str.clear(); | - | ||||||||||||||||||||||||
| 3736 | in.setStatus(QDataStream::ReadPastEnd); | - | ||||||||||||||||||||||||
| 3737 | return in; | - | ||||||||||||||||||||||||
| 3738 | } | - | ||||||||||||||||||||||||
| 3739 | allocated += blockSize; | - | ||||||||||||||||||||||||
| 3740 | } | - | ||||||||||||||||||||||||
| 3741 | - | |||||||||||||||||||||||||
| 3742 | if ((in.byteOrder() == QDataStream::BigEndian) | - | ||||||||||||||||||||||||
| 3743 | != (QSysInfo::ByteOrder == QSysInfo::BigEndian)) { | - | ||||||||||||||||||||||||
| 3744 | ushort *data = reinterpret_cast<ushort *>(str.data()); | - | ||||||||||||||||||||||||
| 3745 | while (len--) { | - | ||||||||||||||||||||||||
| 3746 | *data = qbswap(*data); | - | ||||||||||||||||||||||||
| 3747 | ++data; | - | ||||||||||||||||||||||||
| 3748 | } | - | ||||||||||||||||||||||||
| 3749 | } | - | ||||||||||||||||||||||||
| 3750 | } else { | - | ||||||||||||||||||||||||
| 3751 | str = QString(QLatin1String("")); | - | ||||||||||||||||||||||||
| 3752 | } | - | ||||||||||||||||||||||||
| 3753 | } | - | ||||||||||||||||||||||||
| 3754 | return in; | - | ||||||||||||||||||||||||
| 3755 | } | - | ||||||||||||||||||||||||
| 3756 | QString QStringRef::toString() const { | - | ||||||||||||||||||||||||
| 3757 | if (!m_string) | - | ||||||||||||||||||||||||
| 3758 | return QString(); | - | ||||||||||||||||||||||||
| 3759 | if (m_size && m_position == 0 && m_size == m_string->size()) | - | ||||||||||||||||||||||||
| 3760 | return *m_string; | - | ||||||||||||||||||||||||
| 3761 | return QString(m_string->unicode() + m_position, m_size); | - | ||||||||||||||||||||||||
| 3762 | } | - | ||||||||||||||||||||||||
| 3763 | - | |||||||||||||||||||||||||
| 3764 | - | |||||||||||||||||||||||||
| 3765 | - | |||||||||||||||||||||||||
| 3766 | - | |||||||||||||||||||||||||
| 3767 | - | |||||||||||||||||||||||||
| 3768 | - | |||||||||||||||||||||||||
| 3769 | - | |||||||||||||||||||||||||
| 3770 | bool operator==(const QStringRef &s1,const QStringRef &s2) noexcept | - | ||||||||||||||||||||||||
| 3771 | { return executed 2511992 times by 48 tests: (s1.size() == s2.size() &&return (s1.size() == s2.size() && qMemEquals((const ushort *)s1.unicode(), (const ushort *)s2.unicode(), s1.size()));Executed by:
executed 2511992 times by 48 tests: return (s1.size() == s2.size() && qMemEquals((const ushort *)s1.unicode(), (const ushort *)s2.unicode(), s1.size()));Executed by:
| 2511992 | ||||||||||||||||||||||||
| 3772 | qMemEquals((const ushort *)s1.unicode(), (const ushort *)s2.unicode(), s1.size())); executed 2511992 times by 48 tests: return (s1.size() == s2.size() && qMemEquals((const ushort *)s1.unicode(), (const ushort *)s2.unicode(), s1.size()));Executed by:
| 2511992 | ||||||||||||||||||||||||
| 3773 | } | - | ||||||||||||||||||||||||
| 3774 | - | |||||||||||||||||||||||||
| 3775 | - | |||||||||||||||||||||||||
| 3776 | - | |||||||||||||||||||||||||
| 3777 | - | |||||||||||||||||||||||||
| 3778 | - | |||||||||||||||||||||||||
| 3779 | - | |||||||||||||||||||||||||
| 3780 | bool operator==(const QString &s1,const QStringRef &s2) noexcept | - | ||||||||||||||||||||||||
| 3781 | { return executed 280789 times by 121 tests: (s1.size() == s2.size() &&return (s1.size() == s2.size() && qMemEquals((const ushort *)s1.unicode(), (const ushort *)s2.unicode(), s1.size()));Executed by:
executed 280789 times by 121 tests: return (s1.size() == s2.size() && qMemEquals((const ushort *)s1.unicode(), (const ushort *)s2.unicode(), s1.size()));Executed by:
| 280789 | ||||||||||||||||||||||||
| 3782 | qMemEquals((const ushort *)s1.unicode(), (const ushort *)s2.unicode(), s1.size())); executed 280789 times by 121 tests: return (s1.size() == s2.size() && qMemEquals((const ushort *)s1.unicode(), (const ushort *)s2.unicode(), s1.size()));Executed by:
| 280789 | ||||||||||||||||||||||||
| 3783 | } | - | ||||||||||||||||||||||||
| 3784 | - | |||||||||||||||||||||||||
| 3785 | - | |||||||||||||||||||||||||
| 3786 | - | |||||||||||||||||||||||||
| 3787 | - | |||||||||||||||||||||||||
| 3788 | - | |||||||||||||||||||||||||
| 3789 | - | |||||||||||||||||||||||||
| 3790 | bool operator==(QLatin1String s1, const QStringRef &s2) noexcept | - | ||||||||||||||||||||||||
| 3791 | { | - | ||||||||||||||||||||||||
| 3792 | if (s1.size() != s2.size()
| 656355-840026 | ||||||||||||||||||||||||
| 3793 | return executed 840026 times by 66 tests: false;return false;Executed by:
executed 840026 times by 66 tests: return false;Executed by:
| 840026 | ||||||||||||||||||||||||
| 3794 | - | |||||||||||||||||||||||||
| 3795 | const uchar *c = reinterpret_cast<const uchar *>(s1.latin1()); | - | ||||||||||||||||||||||||
| 3796 | if (!c
| 0-656355 | ||||||||||||||||||||||||
| 3797 | return never executed: s2.isEmpty();return s2.isEmpty();never executed: return s2.isEmpty(); | 0 | ||||||||||||||||||||||||
| 3798 | return executed 656355 times by 53 tests: ucstrncmp(s2.unicode(), c, s2.size()) == 0;return ucstrncmp(s2.unicode(), c, s2.size()) == 0;Executed by:
executed 656355 times by 53 tests: return ucstrncmp(s2.unicode(), c, s2.size()) == 0;Executed by:
| 656355 | ||||||||||||||||||||||||
| 3799 | } | - | ||||||||||||||||||||||||
| 3800 | bool operator<(const QStringRef &s1,const QStringRef &s2) noexcept | - | ||||||||||||||||||||||||
| 3801 | { | - | ||||||||||||||||||||||||
| 3802 | return executed 3346 times by 14 tests: ucstrcmp(s1.constData(), s1.length(), s2.constData(), s2.length()) < 0;return ucstrcmp(s1.constData(), s1.length(), s2.constData(), s2.length()) < 0;Executed by:
executed 3346 times by 14 tests: return ucstrcmp(s1.constData(), s1.length(), s2.constData(), s2.length()) < 0;Executed by:
| 3346 | ||||||||||||||||||||||||
| 3803 | } | - | ||||||||||||||||||||||||
| 3804 | QStringRef QStringRef::appendTo(QString *string) const | - | ||||||||||||||||||||||||
| 3805 | { | - | ||||||||||||||||||||||||
| 3806 | if (!string) | - | ||||||||||||||||||||||||
| 3807 | return QStringRef(); | - | ||||||||||||||||||||||||
| 3808 | int pos = string->size(); | - | ||||||||||||||||||||||||
| 3809 | string->insert(pos, unicode(), size()); | - | ||||||||||||||||||||||||
| 3810 | return QStringRef(string, pos, size()); | - | ||||||||||||||||||||||||
| 3811 | } | - | ||||||||||||||||||||||||
| 3812 | QString &QString::append(const QStringRef &str) | - | ||||||||||||||||||||||||
| 3813 | { | - | ||||||||||||||||||||||||
| 3814 | if (str.string() == this) { | - | ||||||||||||||||||||||||
| 3815 | str.appendTo(this); | - | ||||||||||||||||||||||||
| 3816 | } else if (!str.isNull()) { | - | ||||||||||||||||||||||||
| 3817 | int oldSize = size(); | - | ||||||||||||||||||||||||
| 3818 | resize(oldSize + str.size()); | - | ||||||||||||||||||||||||
| 3819 | memcpy(data() + oldSize, str.unicode(), str.size() * sizeof(QChar)); | - | ||||||||||||||||||||||||
| 3820 | } | - | ||||||||||||||||||||||||
| 3821 | return *this; | - | ||||||||||||||||||||||||
| 3822 | } | - | ||||||||||||||||||||||||
| 3823 | QStringRef QStringRef::left(int n) const | - | ||||||||||||||||||||||||
| 3824 | { | - | ||||||||||||||||||||||||
| 3825 | if (uint(n) >= uint(m_size)) | - | ||||||||||||||||||||||||
| 3826 | return *this; | - | ||||||||||||||||||||||||
| 3827 | return QStringRef(m_string, m_position, n); | - | ||||||||||||||||||||||||
| 3828 | } | - | ||||||||||||||||||||||||
| 3829 | QStringRef QString::leftRef(int n) const | - | ||||||||||||||||||||||||
| 3830 | { | - | ||||||||||||||||||||||||
| 3831 | if (uint(n) >= uint(d->size)) | - | ||||||||||||||||||||||||
| 3832 | n = d->size; | - | ||||||||||||||||||||||||
| 3833 | return QStringRef(this, 0, n); | - | ||||||||||||||||||||||||
| 3834 | } | - | ||||||||||||||||||||||||
| 3835 | QStringRef QStringRef::right(int n) const | - | ||||||||||||||||||||||||
| 3836 | { | - | ||||||||||||||||||||||||
| 3837 | if (uint(n) >= uint(m_size)) | - | ||||||||||||||||||||||||
| 3838 | return *this; | - | ||||||||||||||||||||||||
| 3839 | return QStringRef(m_string, m_size - n + m_position, n); | - | ||||||||||||||||||||||||
| 3840 | } | - | ||||||||||||||||||||||||
| 3841 | QStringRef QString::rightRef(int n) const | - | ||||||||||||||||||||||||
| 3842 | { | - | ||||||||||||||||||||||||
| 3843 | if (uint(n) >= uint(d->size)) | - | ||||||||||||||||||||||||
| 3844 | n = d->size; | - | ||||||||||||||||||||||||
| 3845 | return QStringRef(this, d->size - n, n); | - | ||||||||||||||||||||||||
| 3846 | } | - | ||||||||||||||||||||||||
| 3847 | QStringRef QStringRef::mid(int pos, int n) const | - | ||||||||||||||||||||||||
| 3848 | { | - | ||||||||||||||||||||||||
| 3849 | using namespace QtPrivate; | - | ||||||||||||||||||||||||
| 3850 | switch (QContainerImplHelper::mid(m_size, &pos, &n)) { | - | ||||||||||||||||||||||||
| 3851 | case QContainerImplHelper::Null: | - | ||||||||||||||||||||||||
| 3852 | return QStringRef(); | - | ||||||||||||||||||||||||
| 3853 | case QContainerImplHelper::Empty: | - | ||||||||||||||||||||||||
| 3854 | return QStringRef(m_string, 0, 0); | - | ||||||||||||||||||||||||
| 3855 | case QContainerImplHelper::Full: | - | ||||||||||||||||||||||||
| 3856 | return *this; | - | ||||||||||||||||||||||||
| 3857 | case QContainerImplHelper::Subset: | - | ||||||||||||||||||||||||
| 3858 | return QStringRef(m_string, pos + m_position, n); | - | ||||||||||||||||||||||||
| 3859 | } | - | ||||||||||||||||||||||||
| 3860 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,95259618) : qt_noop()); __builtin_unreachable(); } while (0); | - | ||||||||||||||||||||||||
| 3861 | return QStringRef(); | - | ||||||||||||||||||||||||
| 3862 | } | - | ||||||||||||||||||||||||
| 3863 | QStringRef QString::midRef(int position, int n) const | - | ||||||||||||||||||||||||
| 3864 | { | - | ||||||||||||||||||||||||
| 3865 | using namespace QtPrivate; | - | ||||||||||||||||||||||||
| 3866 | switch (QContainerImplHelper::mid(d->size, &position, &n)) { | - | ||||||||||||||||||||||||
| 3867 | case QContainerImplHelper::Null: | - | ||||||||||||||||||||||||
| 3868 | return QStringRef(); | - | ||||||||||||||||||||||||
| 3869 | case QContainerImplHelper::Empty: | - | ||||||||||||||||||||||||
| 3870 | return QStringRef(this, 0, 0); | - | ||||||||||||||||||||||||
| 3871 | case QContainerImplHelper::Full: | - | ||||||||||||||||||||||||
| 3872 | return QStringRef(this, 0, d->size); | - | ||||||||||||||||||||||||
| 3873 | case QContainerImplHelper::Subset: | - | ||||||||||||||||||||||||
| 3874 | return QStringRef(this, position, n); | - | ||||||||||||||||||||||||
| 3875 | } | - | ||||||||||||||||||||||||
| 3876 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,95629655) : qt_noop()); __builtin_unreachable(); } while (0); | - | ||||||||||||||||||||||||
| 3877 | return QStringRef(); | - | ||||||||||||||||||||||||
| 3878 | } | - | ||||||||||||||||||||||||
| 3879 | int QStringRef::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 3880 | { | - | ||||||||||||||||||||||||
| 3881 | return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs); | - | ||||||||||||||||||||||||
| 3882 | } | - | ||||||||||||||||||||||||
| 3883 | int QStringRef::indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 3884 | { | - | ||||||||||||||||||||||||
| 3885 | return findChar(unicode(), length(), ch, from, cs); | - | ||||||||||||||||||||||||
| 3886 | } | - | ||||||||||||||||||||||||
| 3887 | int QStringRef::indexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 3888 | { | - | ||||||||||||||||||||||||
| 3889 | return qt_find_latin1_string(unicode(), size(), str, from, cs); | - | ||||||||||||||||||||||||
| 3890 | } | - | ||||||||||||||||||||||||
| 3891 | int QStringRef::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 3892 | { | - | ||||||||||||||||||||||||
| 3893 | return qFindString(unicode(), size(), from, str.unicode(), str.size(), cs); | - | ||||||||||||||||||||||||
| 3894 | } | - | ||||||||||||||||||||||||
| 3895 | int QStringRef::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 3896 | { | - | ||||||||||||||||||||||||
| 3897 | const int sl = str.size(); | - | ||||||||||||||||||||||||
| 3898 | if (sl == 1) | - | ||||||||||||||||||||||||
| 3899 | return lastIndexOf(str.at(0), from, cs); | - | ||||||||||||||||||||||||
| 3900 | - | |||||||||||||||||||||||||
| 3901 | const int l = size();; | - | ||||||||||||||||||||||||
| 3902 | if (from < 0) | - | ||||||||||||||||||||||||
| 3903 | from += l; | - | ||||||||||||||||||||||||
| 3904 | int delta = l - sl; | - | ||||||||||||||||||||||||
| 3905 | if (from == l && sl == 0) | - | ||||||||||||||||||||||||
| 3906 | return from; | - | ||||||||||||||||||||||||
| 3907 | if (uint(from) >= uint(l) || delta < 0) | - | ||||||||||||||||||||||||
| 3908 | return -1; | - | ||||||||||||||||||||||||
| 3909 | if (from > delta) | - | ||||||||||||||||||||||||
| 3910 | from = delta; | - | ||||||||||||||||||||||||
| 3911 | - | |||||||||||||||||||||||||
| 3912 | return lastIndexOfHelper(reinterpret_cast<const ushort*>(unicode()), from, | - | ||||||||||||||||||||||||
| 3913 | reinterpret_cast<const ushort*>(str.unicode()), str.size(), cs); | - | ||||||||||||||||||||||||
| 3914 | } | - | ||||||||||||||||||||||||
| 3915 | int QStringRef::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 3916 | { | - | ||||||||||||||||||||||||
| 3917 | return qt_last_index_of(unicode(), size(), ch, from, cs); | - | ||||||||||||||||||||||||
| 3918 | } | - | ||||||||||||||||||||||||
| 3919 | int QStringRef::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 3920 | { | - | ||||||||||||||||||||||||
| 3921 | const int sl = str.size(); | - | ||||||||||||||||||||||||
| 3922 | if (sl == 1) | - | ||||||||||||||||||||||||
| 3923 | return lastIndexOf(QLatin1Char(str.latin1()[0]), from, cs); | - | ||||||||||||||||||||||||
| 3924 | - | |||||||||||||||||||||||||
| 3925 | const int l = size(); | - | ||||||||||||||||||||||||
| 3926 | if (from < 0) | - | ||||||||||||||||||||||||
| 3927 | from += l; | - | ||||||||||||||||||||||||
| 3928 | int delta = l - sl; | - | ||||||||||||||||||||||||
| 3929 | if (from == l && sl == 0) | - | ||||||||||||||||||||||||
| 3930 | return from; | - | ||||||||||||||||||||||||
| 3931 | if (uint(from) >= uint(l) || delta < 0) | - | ||||||||||||||||||||||||
| 3932 | return -1; | - | ||||||||||||||||||||||||
| 3933 | if (from > delta) | - | ||||||||||||||||||||||||
| 3934 | from = delta; | - | ||||||||||||||||||||||||
| 3935 | - | |||||||||||||||||||||||||
| 3936 | QVarLengthArray<ushort> s(sl); | - | ||||||||||||||||||||||||
| 3937 | qt_from_latin1(s.data(), str.latin1(), sl); | - | ||||||||||||||||||||||||
| 3938 | - | |||||||||||||||||||||||||
| 3939 | return lastIndexOfHelper(reinterpret_cast<const ushort*>(unicode()), from, s.data(), sl, cs); | - | ||||||||||||||||||||||||
| 3940 | } | - | ||||||||||||||||||||||||
| 3941 | int QStringRef::lastIndexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 3942 | { | - | ||||||||||||||||||||||||
| 3943 | const int sl = str.size(); | - | ||||||||||||||||||||||||
| 3944 | if (sl == 1) | - | ||||||||||||||||||||||||
| 3945 | return lastIndexOf(str.at(0), from, cs); | - | ||||||||||||||||||||||||
| 3946 | - | |||||||||||||||||||||||||
| 3947 | const int l = size(); | - | ||||||||||||||||||||||||
| 3948 | if (from < 0) | - | ||||||||||||||||||||||||
| 3949 | from += l; | - | ||||||||||||||||||||||||
| 3950 | int delta = l - sl; | - | ||||||||||||||||||||||||
| 3951 | if (from == l && sl == 0) | - | ||||||||||||||||||||||||
| 3952 | return from; | - | ||||||||||||||||||||||||
| 3953 | if (uint(from) >= uint(l) || delta < 0) | - | ||||||||||||||||||||||||
| 3954 | return -1; | - | ||||||||||||||||||||||||
| 3955 | if (from > delta) | - | ||||||||||||||||||||||||
| 3956 | from = delta; | - | ||||||||||||||||||||||||
| 3957 | - | |||||||||||||||||||||||||
| 3958 | return lastIndexOfHelper(reinterpret_cast<const ushort*>(unicode()), from, | - | ||||||||||||||||||||||||
| 3959 | reinterpret_cast<const ushort*>(str.unicode()), | - | ||||||||||||||||||||||||
| 3960 | str.size(), cs); | - | ||||||||||||||||||||||||
| 3961 | } | - | ||||||||||||||||||||||||
| 3962 | int QStringRef::count(const QString &str, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 3963 | { | - | ||||||||||||||||||||||||
| 3964 | return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs); | - | ||||||||||||||||||||||||
| 3965 | } | - | ||||||||||||||||||||||||
| 3966 | int QStringRef::count(QChar ch, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 3967 | { | - | ||||||||||||||||||||||||
| 3968 | return qt_string_count(unicode(), size(), ch, cs); | - | ||||||||||||||||||||||||
| 3969 | } | - | ||||||||||||||||||||||||
| 3970 | int QStringRef::count(const QStringRef &str, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 3971 | { | - | ||||||||||||||||||||||||
| 3972 | return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs); | - | ||||||||||||||||||||||||
| 3973 | } | - | ||||||||||||||||||||||||
| 3974 | bool QStringRef::startsWith(const QString &str, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 3975 | { | - | ||||||||||||||||||||||||
| 3976 | return qt_starts_with(isNull() ? 0 : unicode(), size(), | - | ||||||||||||||||||||||||
| 3977 | str.isNull() ? 0 : str.unicode(), str.size(), cs); | - | ||||||||||||||||||||||||
| 3978 | } | - | ||||||||||||||||||||||||
| 3979 | - | |||||||||||||||||||||||||
| 3980 | - | |||||||||||||||||||||||||
| 3981 | - | |||||||||||||||||||||||||
| 3982 | - | |||||||||||||||||||||||||
| 3983 | - | |||||||||||||||||||||||||
| 3984 | - | |||||||||||||||||||||||||
| 3985 | bool QStringRef::startsWith(QLatin1String str, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 3986 | { | - | ||||||||||||||||||||||||
| 3987 | return qt_starts_with(isNull() ? 0 : unicode(), size(), str, cs); | - | ||||||||||||||||||||||||
| 3988 | } | - | ||||||||||||||||||||||||
| 3989 | - | |||||||||||||||||||||||||
| 3990 | - | |||||||||||||||||||||||||
| 3991 | - | |||||||||||||||||||||||||
| 3992 | - | |||||||||||||||||||||||||
| 3993 | - | |||||||||||||||||||||||||
| 3994 | - | |||||||||||||||||||||||||
| 3995 | bool QStringRef::startsWith(const QStringRef &str, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 3996 | { | - | ||||||||||||||||||||||||
| 3997 | return qt_starts_with(isNull() ? 0 : unicode(), size(), | - | ||||||||||||||||||||||||
| 3998 | str.isNull() ? 0 : str.unicode(), str.size(), cs); | - | ||||||||||||||||||||||||
| 3999 | } | - | ||||||||||||||||||||||||
| 4000 | bool QStringRef::startsWith(QChar ch, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 4001 | { | - | ||||||||||||||||||||||||
| 4002 | if (!isEmpty()) { | - | ||||||||||||||||||||||||
| 4003 | const ushort *data = reinterpret_cast<const ushort*>(unicode()); | - | ||||||||||||||||||||||||
| 4004 | return (cs == Qt::CaseSensitive | - | ||||||||||||||||||||||||
| 4005 | ? data[0] == ch | - | ||||||||||||||||||||||||
| 4006 | : foldCase(data[0]) == foldCase(ch.unicode())); | - | ||||||||||||||||||||||||
| 4007 | } else { | - | ||||||||||||||||||||||||
| 4008 | return false; | - | ||||||||||||||||||||||||
| 4009 | } | - | ||||||||||||||||||||||||
| 4010 | } | - | ||||||||||||||||||||||||
| 4011 | bool QStringRef::endsWith(const QString &str, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 4012 | { | - | ||||||||||||||||||||||||
| 4013 | return qt_ends_with(isNull() ? 0 : unicode(), size(), | - | ||||||||||||||||||||||||
| 4014 | str.isNull() ? 0 : str.unicode(), str.size(), cs); | - | ||||||||||||||||||||||||
| 4015 | } | - | ||||||||||||||||||||||||
| 4016 | bool QStringRef::endsWith(QChar ch, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 4017 | { | - | ||||||||||||||||||||||||
| 4018 | if (!isEmpty()) { | - | ||||||||||||||||||||||||
| 4019 | const ushort *data = reinterpret_cast<const ushort*>(unicode()); | - | ||||||||||||||||||||||||
| 4020 | const int size = length(); | - | ||||||||||||||||||||||||
| 4021 | return (cs == Qt::CaseSensitive | - | ||||||||||||||||||||||||
| 4022 | ? data[size - 1] == ch | - | ||||||||||||||||||||||||
| 4023 | : foldCase(data[size - 1]) == foldCase(ch.unicode())); | - | ||||||||||||||||||||||||
| 4024 | } else { | - | ||||||||||||||||||||||||
| 4025 | return false; | - | ||||||||||||||||||||||||
| 4026 | } | - | ||||||||||||||||||||||||
| 4027 | } | - | ||||||||||||||||||||||||
| 4028 | - | |||||||||||||||||||||||||
| 4029 | - | |||||||||||||||||||||||||
| 4030 | - | |||||||||||||||||||||||||
| 4031 | - | |||||||||||||||||||||||||
| 4032 | - | |||||||||||||||||||||||||
| 4033 | - | |||||||||||||||||||||||||
| 4034 | bool QStringRef::endsWith(QLatin1String str, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 4035 | { | - | ||||||||||||||||||||||||
| 4036 | return qt_ends_with(isNull() ? 0 : unicode(), size(), str, cs); | - | ||||||||||||||||||||||||
| 4037 | } | - | ||||||||||||||||||||||||
| 4038 | - | |||||||||||||||||||||||||
| 4039 | - | |||||||||||||||||||||||||
| 4040 | - | |||||||||||||||||||||||||
| 4041 | - | |||||||||||||||||||||||||
| 4042 | - | |||||||||||||||||||||||||
| 4043 | - | |||||||||||||||||||||||||
| 4044 | bool QStringRef::endsWith(const QStringRef &str, Qt::CaseSensitivity cs) const | - | ||||||||||||||||||||||||
| 4045 | { | - | ||||||||||||||||||||||||
| 4046 | return qt_ends_with(isNull() ? 0 : unicode(), size(), | - | ||||||||||||||||||||||||
| 4047 | str.isNull() ? 0 : str.unicode(), str.size(), cs); | - | ||||||||||||||||||||||||
| 4048 | } | - | ||||||||||||||||||||||||
| 4049 | static inline int qt_last_index_of(const QChar *haystack, int haystackLen, QChar needle, | - | ||||||||||||||||||||||||
| 4050 | int from, Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 4051 | { | - | ||||||||||||||||||||||||
| 4052 | ushort c = needle.unicode(); | - | ||||||||||||||||||||||||
| 4053 | if (from < 0) | - | ||||||||||||||||||||||||
| 4054 | from += haystackLen; | - | ||||||||||||||||||||||||
| 4055 | if (uint(from) >= uint(haystackLen)) | - | ||||||||||||||||||||||||
| 4056 | return -1; | - | ||||||||||||||||||||||||
| 4057 | if (from >= 0) { | - | ||||||||||||||||||||||||
| 4058 | const ushort *b = reinterpret_cast<const ushort*>(haystack); | - | ||||||||||||||||||||||||
| 4059 | const ushort *n = b + from; | - | ||||||||||||||||||||||||
| 4060 | if (cs == Qt::CaseSensitive) { | - | ||||||||||||||||||||||||
| 4061 | for (; n >= b; --n) | - | ||||||||||||||||||||||||
| 4062 | if (*n == c) | - | ||||||||||||||||||||||||
| 4063 | return n - b; | - | ||||||||||||||||||||||||
| 4064 | } else { | - | ||||||||||||||||||||||||
| 4065 | c = foldCase(c); | - | ||||||||||||||||||||||||
| 4066 | for (; n >= b; --n) | - | ||||||||||||||||||||||||
| 4067 | if (foldCase(*n) == c) | - | ||||||||||||||||||||||||
| 4068 | return n - b; | - | ||||||||||||||||||||||||
| 4069 | } | - | ||||||||||||||||||||||||
| 4070 | } | - | ||||||||||||||||||||||||
| 4071 | return -1; | - | ||||||||||||||||||||||||
| 4072 | - | |||||||||||||||||||||||||
| 4073 | - | |||||||||||||||||||||||||
| 4074 | } | - | ||||||||||||||||||||||||
| 4075 | - | |||||||||||||||||||||||||
| 4076 | static inline int qt_string_count(const QChar *haystack, int haystackLen, | - | ||||||||||||||||||||||||
| 4077 | const QChar *needle, int needleLen, | - | ||||||||||||||||||||||||
| 4078 | Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 4079 | { | - | ||||||||||||||||||||||||
| 4080 | int num = 0; | - | ||||||||||||||||||||||||
| 4081 | int i = -1; | - | ||||||||||||||||||||||||
| 4082 | if (haystackLen > 500 && needleLen > 5) { | - | ||||||||||||||||||||||||
| 4083 | QStringMatcher matcher(needle, needleLen, cs); | - | ||||||||||||||||||||||||
| 4084 | while ((i = matcher.indexIn(haystack, haystackLen, i + 1)) != -1) | - | ||||||||||||||||||||||||
| 4085 | ++num; | - | ||||||||||||||||||||||||
| 4086 | } else { | - | ||||||||||||||||||||||||
| 4087 | while ((i = qFindString(haystack, haystackLen, i + 1, needle, needleLen, cs)) != -1) | - | ||||||||||||||||||||||||
| 4088 | ++num; | - | ||||||||||||||||||||||||
| 4089 | } | - | ||||||||||||||||||||||||
| 4090 | return num; | - | ||||||||||||||||||||||||
| 4091 | } | - | ||||||||||||||||||||||||
| 4092 | - | |||||||||||||||||||||||||
| 4093 | static inline int qt_string_count(const QChar *unicode, int size, QChar ch, | - | ||||||||||||||||||||||||
| 4094 | Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 4095 | { | - | ||||||||||||||||||||||||
| 4096 | ushort c = ch.unicode(); | - | ||||||||||||||||||||||||
| 4097 | int num = 0; | - | ||||||||||||||||||||||||
| 4098 | const ushort *b = reinterpret_cast<const ushort*>(unicode); | - | ||||||||||||||||||||||||
| 4099 | const ushort *i = b + size; | - | ||||||||||||||||||||||||
| 4100 | if (cs == Qt::CaseSensitive) { | - | ||||||||||||||||||||||||
| 4101 | while (i != b) | - | ||||||||||||||||||||||||
| 4102 | if (*--i == c) | - | ||||||||||||||||||||||||
| 4103 | ++num; | - | ||||||||||||||||||||||||
| 4104 | } else { | - | ||||||||||||||||||||||||
| 4105 | c = foldCase(c); | - | ||||||||||||||||||||||||
| 4106 | while (i != b) | - | ||||||||||||||||||||||||
| 4107 | if (foldCase(*(--i)) == c) | - | ||||||||||||||||||||||||
| 4108 | ++num; | - | ||||||||||||||||||||||||
| 4109 | } | - | ||||||||||||||||||||||||
| 4110 | return num; | - | ||||||||||||||||||||||||
| 4111 | } | - | ||||||||||||||||||||||||
| 4112 | - | |||||||||||||||||||||||||
| 4113 | static inline int qt_find_latin1_string(const QChar *haystack, int size, | - | ||||||||||||||||||||||||
| 4114 | QLatin1String needle, | - | ||||||||||||||||||||||||
| 4115 | int from, Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 4116 | { | - | ||||||||||||||||||||||||
| 4117 | if (size < needle.size()) | - | ||||||||||||||||||||||||
| 4118 | return -1; | - | ||||||||||||||||||||||||
| 4119 | - | |||||||||||||||||||||||||
| 4120 | const char *latin1 = needle.latin1(); | - | ||||||||||||||||||||||||
| 4121 | int len = needle.size(); | - | ||||||||||||||||||||||||
| 4122 | QVarLengthArray<ushort> s(len); | - | ||||||||||||||||||||||||
| 4123 | qt_from_latin1(s.data(), latin1, len); | - | ||||||||||||||||||||||||
| 4124 | - | |||||||||||||||||||||||||
| 4125 | return qFindString(haystack, size, from, | - | ||||||||||||||||||||||||
| 4126 | reinterpret_cast<const QChar*>(s.constData()), len, cs); | - | ||||||||||||||||||||||||
| 4127 | } | - | ||||||||||||||||||||||||
| 4128 | - | |||||||||||||||||||||||||
| 4129 | static inline bool qt_starts_with(const QChar *haystack, int haystackLen, | - | ||||||||||||||||||||||||
| 4130 | const QChar *needle, int needleLen, Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 4131 | { | - | ||||||||||||||||||||||||
| 4132 | if (!haystack) | - | ||||||||||||||||||||||||
| 4133 | return !needle; | - | ||||||||||||||||||||||||
| 4134 | if (haystackLen == 0) | - | ||||||||||||||||||||||||
| 4135 | return needleLen == 0; | - | ||||||||||||||||||||||||
| 4136 | if (needleLen > haystackLen) | - | ||||||||||||||||||||||||
| 4137 | return false; | - | ||||||||||||||||||||||||
| 4138 | - | |||||||||||||||||||||||||
| 4139 | const ushort *h = reinterpret_cast<const ushort*>(haystack); | - | ||||||||||||||||||||||||
| 4140 | const ushort *n = reinterpret_cast<const ushort*>(needle); | - | ||||||||||||||||||||||||
| 4141 | - | |||||||||||||||||||||||||
| 4142 | if (cs == Qt::CaseSensitive) { | - | ||||||||||||||||||||||||
| 4143 | return qMemEquals(h, n, needleLen); | - | ||||||||||||||||||||||||
| 4144 | } else { | - | ||||||||||||||||||||||||
| 4145 | uint last = 0; | - | ||||||||||||||||||||||||
| 4146 | uint olast = 0; | - | ||||||||||||||||||||||||
| 4147 | for (int i = 0; i < needleLen; ++i) | - | ||||||||||||||||||||||||
| 4148 | if (foldCase(h[i], last) != foldCase(n[i], olast)) | - | ||||||||||||||||||||||||
| 4149 | return false; | - | ||||||||||||||||||||||||
| 4150 | } | - | ||||||||||||||||||||||||
| 4151 | return true; | - | ||||||||||||||||||||||||
| 4152 | } | - | ||||||||||||||||||||||||
| 4153 | - | |||||||||||||||||||||||||
| 4154 | static inline bool qt_starts_with(const QChar *haystack, int haystackLen, | - | ||||||||||||||||||||||||
| 4155 | QLatin1String needle, Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 4156 | { | - | ||||||||||||||||||||||||
| 4157 | if (!haystack) | - | ||||||||||||||||||||||||
| 4158 | return !needle.latin1(); | - | ||||||||||||||||||||||||
| 4159 | if (haystackLen == 0) | - | ||||||||||||||||||||||||
| 4160 | return !needle.latin1() || *needle.latin1() == 0; | - | ||||||||||||||||||||||||
| 4161 | const int slen = needle.size(); | - | ||||||||||||||||||||||||
| 4162 | if (slen > haystackLen) | - | ||||||||||||||||||||||||
| 4163 | return false; | - | ||||||||||||||||||||||||
| 4164 | const ushort *data = reinterpret_cast<const ushort*>(haystack); | - | ||||||||||||||||||||||||
| 4165 | const uchar *latin = reinterpret_cast<const uchar*>(needle.latin1()); | - | ||||||||||||||||||||||||
| 4166 | if (cs == Qt::CaseSensitive) { | - | ||||||||||||||||||||||||
| 4167 | return ucstrncmp(haystack, latin, slen) == 0; | - | ||||||||||||||||||||||||
| 4168 | } else { | - | ||||||||||||||||||||||||
| 4169 | for (int i = 0; i < slen; ++i) | - | ||||||||||||||||||||||||
| 4170 | if (foldCase(data[i]) != foldCase((ushort)latin[i])) | - | ||||||||||||||||||||||||
| 4171 | return false; | - | ||||||||||||||||||||||||
| 4172 | } | - | ||||||||||||||||||||||||
| 4173 | return true; | - | ||||||||||||||||||||||||
| 4174 | } | - | ||||||||||||||||||||||||
| 4175 | - | |||||||||||||||||||||||||
| 4176 | static inline bool qt_ends_with(const QChar *haystack, int haystackLen, | - | ||||||||||||||||||||||||
| 4177 | const QChar *needle, int needleLen, Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 4178 | { | - | ||||||||||||||||||||||||
| 4179 | if (!haystack) | - | ||||||||||||||||||||||||
| 4180 | return !needle; | - | ||||||||||||||||||||||||
| 4181 | if (haystackLen == 0) | - | ||||||||||||||||||||||||
| 4182 | return needleLen == 0; | - | ||||||||||||||||||||||||
| 4183 | const int pos = haystackLen - needleLen; | - | ||||||||||||||||||||||||
| 4184 | if (pos < 0) | - | ||||||||||||||||||||||||
| 4185 | return false; | - | ||||||||||||||||||||||||
| 4186 | - | |||||||||||||||||||||||||
| 4187 | const ushort *h = reinterpret_cast<const ushort*>(haystack); | - | ||||||||||||||||||||||||
| 4188 | const ushort *n = reinterpret_cast<const ushort*>(needle); | - | ||||||||||||||||||||||||
| 4189 | - | |||||||||||||||||||||||||
| 4190 | if (cs == Qt::CaseSensitive) { | - | ||||||||||||||||||||||||
| 4191 | return qMemEquals(h + pos, n, needleLen); | - | ||||||||||||||||||||||||
| 4192 | } else { | - | ||||||||||||||||||||||||
| 4193 | uint last = 0; | - | ||||||||||||||||||||||||
| 4194 | uint olast = 0; | - | ||||||||||||||||||||||||
| 4195 | for (int i = 0; i < needleLen; i++) | - | ||||||||||||||||||||||||
| 4196 | if (foldCase(h[pos+i], last) != foldCase(n[i], olast)) | - | ||||||||||||||||||||||||
| 4197 | return false; | - | ||||||||||||||||||||||||
| 4198 | } | - | ||||||||||||||||||||||||
| 4199 | return true; | - | ||||||||||||||||||||||||
| 4200 | } | - | ||||||||||||||||||||||||
| 4201 | - | |||||||||||||||||||||||||
| 4202 | - | |||||||||||||||||||||||||
| 4203 | static inline bool qt_ends_with(const QChar *haystack, int haystackLen, | - | ||||||||||||||||||||||||
| 4204 | QLatin1String needle, Qt::CaseSensitivity cs) | - | ||||||||||||||||||||||||
| 4205 | { | - | ||||||||||||||||||||||||
| 4206 | if (!haystack) | - | ||||||||||||||||||||||||
| 4207 | return !needle.latin1(); | - | ||||||||||||||||||||||||
| 4208 | if (haystackLen == 0) | - | ||||||||||||||||||||||||
| 4209 | return !needle.latin1() || *needle.latin1() == 0; | - | ||||||||||||||||||||||||
| 4210 | const int slen = needle.size(); | - | ||||||||||||||||||||||||
| 4211 | int pos = haystackLen - slen; | - | ||||||||||||||||||||||||
| 4212 | if (pos < 0) | - | ||||||||||||||||||||||||
| 4213 | return false; | - | ||||||||||||||||||||||||
| 4214 | const uchar *latin = reinterpret_cast<const uchar*>(needle.latin1()); | - | ||||||||||||||||||||||||
| 4215 | const ushort *data = reinterpret_cast<const ushort*>(haystack); | - | ||||||||||||||||||||||||
| 4216 | if (cs == Qt::CaseSensitive) { | - | ||||||||||||||||||||||||
| 4217 | return ucstrncmp(haystack + pos, latin, slen) == 0; | - | ||||||||||||||||||||||||
| 4218 | } else { | - | ||||||||||||||||||||||||
| 4219 | for (int i = 0; i < slen; i++) | - | ||||||||||||||||||||||||
| 4220 | if (foldCase(data[pos+i]) != foldCase((ushort)latin[i])) | - | ||||||||||||||||||||||||
| 4221 | return false; | - | ||||||||||||||||||||||||
| 4222 | } | - | ||||||||||||||||||||||||
| 4223 | return true; | - | ||||||||||||||||||||||||
| 4224 | } | - | ||||||||||||||||||||||||
| 4225 | QByteArray QStringRef::toLatin1() const | - | ||||||||||||||||||||||||
| 4226 | { | - | ||||||||||||||||||||||||
| 4227 | return QString::toLatin1_helper(unicode(), length()); | - | ||||||||||||||||||||||||
| 4228 | } | - | ||||||||||||||||||||||||
| 4229 | QByteArray QStringRef::toLocal8Bit() const | - | ||||||||||||||||||||||||
| 4230 | { | - | ||||||||||||||||||||||||
| 4231 | - | |||||||||||||||||||||||||
| 4232 | QTextCodec *localeCodec = QTextCodec::codecForLocale(); | - | ||||||||||||||||||||||||
| 4233 | if (localeCodec) | - | ||||||||||||||||||||||||
| 4234 | return localeCodec->fromUnicode(unicode(), length()); | - | ||||||||||||||||||||||||
| 4235 | - | |||||||||||||||||||||||||
| 4236 | return toLatin1(); | - | ||||||||||||||||||||||||
| 4237 | } | - | ||||||||||||||||||||||||
| 4238 | QByteArray QStringRef::toUtf8() const | - | ||||||||||||||||||||||||
| 4239 | { | - | ||||||||||||||||||||||||
| 4240 | if (isNull()) | - | ||||||||||||||||||||||||
| 4241 | return QByteArray(); | - | ||||||||||||||||||||||||
| 4242 | - | |||||||||||||||||||||||||
| 4243 | return QUtf8::convertFromUnicode(constData(), length()); | - | ||||||||||||||||||||||||
| 4244 | } | - | ||||||||||||||||||||||||
| 4245 | QVector<uint> QStringRef::toUcs4() const | - | ||||||||||||||||||||||||
| 4246 | { | - | ||||||||||||||||||||||||
| 4247 | QVector<uint> v(length()); | - | ||||||||||||||||||||||||
| 4248 | uint *a = v.data(); | - | ||||||||||||||||||||||||
| 4249 | int len = QString::toUcs4_helper(reinterpret_cast<const ushort *>(unicode()), length(), a); | - | ||||||||||||||||||||||||
| 4250 | v.resize(len); | - | ||||||||||||||||||||||||
| 4251 | return v; | - | ||||||||||||||||||||||||
| 4252 | } | - | ||||||||||||||||||||||||
| 4253 | QStringRef QStringRef::trimmed() const | - | ||||||||||||||||||||||||
| 4254 | { | - | ||||||||||||||||||||||||
| 4255 | const QChar *begin = cbegin(); | - | ||||||||||||||||||||||||
| 4256 | const QChar *end = cend(); | - | ||||||||||||||||||||||||
| 4257 | QStringAlgorithms<const QStringRef>::trimmed_helper_positions(begin, end); | - | ||||||||||||||||||||||||
| 4258 | if (begin == cbegin() && end == cend()) | - | ||||||||||||||||||||||||
| 4259 | return *this; | - | ||||||||||||||||||||||||
| 4260 | if (begin == end) | - | ||||||||||||||||||||||||
| 4261 | return QStringRef(); | - | ||||||||||||||||||||||||
| 4262 | int position = m_position + (begin - cbegin()); | - | ||||||||||||||||||||||||
| 4263 | return QStringRef(m_string, position, end - begin); | - | ||||||||||||||||||||||||
| 4264 | } | - | ||||||||||||||||||||||||
| 4265 | qint64 QStringRef::toLongLong(bool *ok, int base) const | - | ||||||||||||||||||||||||
| 4266 | { | - | ||||||||||||||||||||||||
| 4267 | return QString::toIntegral_helper<qint64>(constData(), size(), ok, base); | - | ||||||||||||||||||||||||
| 4268 | } | - | ||||||||||||||||||||||||
| 4269 | quint64 QStringRef::toULongLong(bool *ok, int base) const | - | ||||||||||||||||||||||||
| 4270 | { | - | ||||||||||||||||||||||||
| 4271 | return QString::toIntegral_helper<quint64>(constData(), size(), ok, base); | - | ||||||||||||||||||||||||
| 4272 | } | - | ||||||||||||||||||||||||
| 4273 | long QStringRef::toLong(bool *ok, int base) const | - | ||||||||||||||||||||||||
| 4274 | { | - | ||||||||||||||||||||||||
| 4275 | return QString::toIntegral_helper<long>(constData(), size(), ok, base); | - | ||||||||||||||||||||||||
| 4276 | } | - | ||||||||||||||||||||||||
| 4277 | ulong QStringRef::toULong(bool *ok, int base) const | - | ||||||||||||||||||||||||
| 4278 | { | - | ||||||||||||||||||||||||
| 4279 | return QString::toIntegral_helper<ulong>(constData(), size(), ok, base); | - | ||||||||||||||||||||||||
| 4280 | } | - | ||||||||||||||||||||||||
| 4281 | int QStringRef::toInt(bool *ok, int base) const | - | ||||||||||||||||||||||||
| 4282 | { | - | ||||||||||||||||||||||||
| 4283 | return QString::toIntegral_helper<int>(constData(), size(), ok, base); | - | ||||||||||||||||||||||||
| 4284 | } | - | ||||||||||||||||||||||||
| 4285 | uint QStringRef::toUInt(bool *ok, int base) const | - | ||||||||||||||||||||||||
| 4286 | { | - | ||||||||||||||||||||||||
| 4287 | return QString::toIntegral_helper<uint>(constData(), size(), ok, base); | - | ||||||||||||||||||||||||
| 4288 | } | - | ||||||||||||||||||||||||
| 4289 | short QStringRef::toShort(bool *ok, int base) const | - | ||||||||||||||||||||||||
| 4290 | { | - | ||||||||||||||||||||||||
| 4291 | return QString::toIntegral_helper<short>(constData(), size(), ok, base); | - | ||||||||||||||||||||||||
| 4292 | } | - | ||||||||||||||||||||||||
| 4293 | ushort QStringRef::toUShort(bool *ok, int base) const | - | ||||||||||||||||||||||||
| 4294 | { | - | ||||||||||||||||||||||||
| 4295 | return QString::toIntegral_helper<ushort>(constData(), size(), ok, base); | - | ||||||||||||||||||||||||
| 4296 | } | - | ||||||||||||||||||||||||
| 4297 | double QStringRef::toDouble(bool *ok) const | - | ||||||||||||||||||||||||
| 4298 | { | - | ||||||||||||||||||||||||
| 4299 | return executed 84 times by 4 tests: QLocaleData::c()->stringToDouble(constData(), size(), ok, QLocaleDataQLocale::FailOnGroupSeparatorsRejectGroupSeparator);return QLocaleData::c()->stringToDouble(constData(), size(), ok, QLocale::RejectGroupSeparator);Executed by:
executed 84 times by 4 tests: return QLocaleData::c()->stringToDouble(constData(), size(), ok, QLocale::RejectGroupSeparator);Executed by:
| 84 | ||||||||||||||||||||||||
| 4300 | } | - | ||||||||||||||||||||||||
| 4301 | float QStringRef::toFloat(bool *ok) const | - | ||||||||||||||||||||||||
| 4302 | { | - | ||||||||||||||||||||||||
| 4303 | return QLocaleData::convertDoubleToFloat(toDouble(ok), ok); | - | ||||||||||||||||||||||||
| 4304 | } | - | ||||||||||||||||||||||||
| 4305 | QString QString::toHtmlEscaped() const | - | ||||||||||||||||||||||||
| 4306 | { | - | ||||||||||||||||||||||||
| 4307 | QString rich; | - | ||||||||||||||||||||||||
| 4308 | const int len = length(); | - | ||||||||||||||||||||||||
| 4309 | rich.reserve(int(len * 1.1)); | - | ||||||||||||||||||||||||
| 4310 | for (int i = 0; i < len; ++i) { | - | ||||||||||||||||||||||||
| 4311 | if (at(i) == QLatin1Char('<')) | - | ||||||||||||||||||||||||
| 4312 | rich += QLatin1String("<"); | - | ||||||||||||||||||||||||
| 4313 | else if (at(i) == QLatin1Char('>')) | - | ||||||||||||||||||||||||
| 4314 | rich += QLatin1String(">"); | - | ||||||||||||||||||||||||
| 4315 | else if (at(i) == QLatin1Char('&')) | - | ||||||||||||||||||||||||
| 4316 | rich += QLatin1String("&"); | - | ||||||||||||||||||||||||
| 4317 | else if (at(i) == QLatin1Char('"')) | - | ||||||||||||||||||||||||
| 4318 | rich += QLatin1String("""); | - | ||||||||||||||||||||||||
| 4319 | else | - | ||||||||||||||||||||||||
| 4320 | rich += at(i); | - | ||||||||||||||||||||||||
| 4321 | } | - | ||||||||||||||||||||||||
| 4322 | rich.squeeze(); | - | ||||||||||||||||||||||||
| 4323 | return rich; | - | ||||||||||||||||||||||||
| 4324 | } | - | ||||||||||||||||||||||||
| 4325 | void QAbstractConcatenable::appendLatin1To(const char *a, int len, QChar *out) noexcept | - | ||||||||||||||||||||||||
| 4326 | { | - | ||||||||||||||||||||||||
| 4327 | qt_from_latin1(reinterpret_cast<ushort *>(out), a, uint(len)); | - | ||||||||||||||||||||||||
| 4328 | } executed 130482 times by 513 tests: end of blockExecuted by:
| 130482 | ||||||||||||||||||||||||
| 4329 | - | |||||||||||||||||||||||||
| 4330 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |