Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qchar.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | bool QChar::isPrint(uint ucs4) noexcept | - | ||||||||||||
9 | { | - | ||||||||||||
10 | if (ucs4 > LastValidCodePoint
| 0-206544 | ||||||||||||
11 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
12 | const int test = (1 << (Other_Control)) | | - | ||||||||||||
13 | (1 << (Other_Format)) | | - | ||||||||||||
14 | (1 << (Other_Surrogate)) | | - | ||||||||||||
15 | (1 << (Other_PrivateUse)) | | - | ||||||||||||
16 | (1 << (Other_NotAssigned)); | - | ||||||||||||
17 | return executed 206544 times by 79 tests: !((1 << (qGetProp(ucs4)->category)) & test);return !((1 << (qGetProp(ucs4)->category)) & test); Executed by:
executed 206544 times by 79 tests: return !((1 << (qGetProp(ucs4)->category)) & test); Executed by:
| 206544 | ||||||||||||
18 | } | - | ||||||||||||
19 | bool QChar::isSpace_helper(uint ucs4) noexcept | - | ||||||||||||
20 | { | - | ||||||||||||
21 | if (ucs4 > LastValidCodePoint
| 0-315775 | ||||||||||||
22 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
23 | const int test = (1 << (Separator_Space)) | | - | ||||||||||||
24 | (1 << (Separator_Line)) | | - | ||||||||||||
25 | (1 << (Separator_Paragraph)); | - | ||||||||||||
26 | return executed 315775 times by 44 tests: (1 << (qGetProp(ucs4)->category)) & test;return (1 << (qGetProp(ucs4)->category)) & test; Executed by:
executed 315775 times by 44 tests: return (1 << (qGetProp(ucs4)->category)) & test; Executed by:
| 315775 | ||||||||||||
27 | } | - | ||||||||||||
28 | bool QChar::isMark(uint ucs4) noexcept | - | ||||||||||||
29 | { | - | ||||||||||||
30 | if (ucs4 > LastValidCodePoint
| 0-16148 | ||||||||||||
31 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
32 | const int test = (1 << (Mark_NonSpacing)) | | - | ||||||||||||
33 | (1 << (Mark_SpacingCombining)) | | - | ||||||||||||
34 | (1 << (Mark_Enclosing)); | - | ||||||||||||
35 | return executed 16148 times by 3 tests: (1 << (qGetProp(ucs4)->category)) & test;return (1 << (qGetProp(ucs4)->category)) & test; Executed by:
executed 16148 times by 3 tests: return (1 << (qGetProp(ucs4)->category)) & test; Executed by:
| 16148 | ||||||||||||
36 | } | - | ||||||||||||
37 | bool QChar::isPunct(uint ucs4) noexcept | - | ||||||||||||
38 | { | - | ||||||||||||
39 | if (ucs4 > LastValidCodePoint
| 0 | ||||||||||||
40 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
41 | const int test = (1 << (Punctuation_Connector)) | | - | ||||||||||||
42 | (1 << (Punctuation_Dash)) | | - | ||||||||||||
43 | (1 << (Punctuation_Open)) | | - | ||||||||||||
44 | (1 << (Punctuation_Close)) | | - | ||||||||||||
45 | (1 << (Punctuation_InitialQuote)) | | - | ||||||||||||
46 | (1 << (Punctuation_FinalQuote)) | | - | ||||||||||||
47 | (1 << (Punctuation_Other)); | - | ||||||||||||
48 | return never executed: (1 << (qGetProp(ucs4)->category)) & test;return (1 << (qGetProp(ucs4)->category)) & test; never executed: return (1 << (qGetProp(ucs4)->category)) & test; | 0 | ||||||||||||
49 | } | - | ||||||||||||
50 | bool QChar::isSymbol(uint ucs4) noexcept | - | ||||||||||||
51 | { | - | ||||||||||||
52 | if (ucs4 > LastValidCodePoint
| 0 | ||||||||||||
53 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
54 | const int test = (1 << (Symbol_Math)) | | - | ||||||||||||
55 | (1 << (Symbol_Currency)) | | - | ||||||||||||
56 | (1 << (Symbol_Modifier)) | | - | ||||||||||||
57 | (1 << (Symbol_Other)); | - | ||||||||||||
58 | return never executed: (1 << (qGetProp(ucs4)->category)) & test;return (1 << (qGetProp(ucs4)->category)) & test; never executed: return (1 << (qGetProp(ucs4)->category)) & test; | 0 | ||||||||||||
59 | } | - | ||||||||||||
60 | bool QChar::isLetter_helper(uint ucs4) noexcept | - | ||||||||||||
61 | { | - | ||||||||||||
62 | if (ucs4 > LastValidCodePoint
| 0-128 | ||||||||||||
63 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
64 | const int test = (1 << (Letter_Uppercase)) | | - | ||||||||||||
65 | (1 << (Letter_Lowercase)) | | - | ||||||||||||
66 | (1 << (Letter_Titlecase)) | | - | ||||||||||||
67 | (1 << (Letter_Modifier)) | | - | ||||||||||||
68 | (1 << (Letter_Other)); | - | ||||||||||||
69 | return executed 128 times by 1 test: (1 << (qGetProp(ucs4)->category)) & test;return (1 << (qGetProp(ucs4)->category)) & test; Executed by:
executed 128 times by 1 test: return (1 << (qGetProp(ucs4)->category)) & test; Executed by:
| 128 | ||||||||||||
70 | } | - | ||||||||||||
71 | bool QChar::isNumber_helper(uint ucs4) noexcept | - | ||||||||||||
72 | { | - | ||||||||||||
73 | if (ucs4 > LastValidCodePoint
| 0 | ||||||||||||
74 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
75 | const int test = (1 << (Number_DecimalDigit)) | | - | ||||||||||||
76 | (1 << (Number_Letter)) | | - | ||||||||||||
77 | (1 << (Number_Other)); | - | ||||||||||||
78 | return never executed: (1 << (qGetProp(ucs4)->category)) & test;return (1 << (qGetProp(ucs4)->category)) & test; never executed: return (1 << (qGetProp(ucs4)->category)) & test; | 0 | ||||||||||||
79 | } | - | ||||||||||||
80 | bool QChar::isLetterOrNumber_helper(uint ucs4) noexcept | - | ||||||||||||
81 | { | - | ||||||||||||
82 | if (ucs4 > LastValidCodePoint
| 0-81818 | ||||||||||||
83 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
84 | const int test = (1 << (Letter_Uppercase)) | | - | ||||||||||||
85 | (1 << (Letter_Lowercase)) | | - | ||||||||||||
86 | (1 << (Letter_Titlecase)) | | - | ||||||||||||
87 | (1 << (Letter_Modifier)) | | - | ||||||||||||
88 | (1 << (Letter_Other)) | | - | ||||||||||||
89 | (1 << (Number_DecimalDigit)) | | - | ||||||||||||
90 | (1 << (Number_Letter)) | | - | ||||||||||||
91 | (1 << (Number_Other)); | - | ||||||||||||
92 | return executed 81818 times by 36 tests: (1 << (qGetProp(ucs4)->category)) & test;return (1 << (qGetProp(ucs4)->category)) & test; Executed by:
executed 81818 times by 36 tests: return (1 << (qGetProp(ucs4)->category)) & test; Executed by:
| 81818 | ||||||||||||
93 | } | - | ||||||||||||
94 | int QChar::digitValue(uint ucs4) noexcept | - | ||||||||||||
95 | { | - | ||||||||||||
96 | if (ucs4 > LastValidCodePoint
| 1-5797012 | ||||||||||||
97 | return executed 1 time by 1 test: -1;return -1; Executed by:
executed 1 time by 1 test: return -1; Executed by:
| 1 | ||||||||||||
98 | return executed 5797012 times by 430 tests: qGetProp(ucs4)->digitValue;return qGetProp(ucs4)->digitValue; Executed by:
executed 5797012 times by 430 tests: return qGetProp(ucs4)->digitValue; Executed by:
| 5797012 | ||||||||||||
99 | } | - | ||||||||||||
100 | QChar::Category QChar::category(uint ucs4) noexcept | - | ||||||||||||
101 | { | - | ||||||||||||
102 | if (ucs4 > LastValidCodePoint
| 1-9539049 | ||||||||||||
103 | return executed 1 time by 1 test: QChar::Other_NotAssigned;return QChar::Other_NotAssigned; Executed by:
executed 1 time by 1 test: return QChar::Other_NotAssigned; Executed by:
| 1 | ||||||||||||
104 | return executed 9539049 times by 132 tests: (QChar::Category) qGetProp(ucs4)->category;return (QChar::Category) qGetProp(ucs4)->category; Executed by:
executed 9539049 times by 132 tests: return (QChar::Category) qGetProp(ucs4)->category; Executed by:
| 9539049 | ||||||||||||
105 | } | - | ||||||||||||
106 | QChar::Direction QChar::direction(uint ucs4) noexcept | - | ||||||||||||
107 | { | - | ||||||||||||
108 | if (ucs4 > LastValidCodePoint
| 0-1879525 | ||||||||||||
109 | return never executed: QChar::DirL;return QChar::DirL; never executed: return QChar::DirL; | 0 | ||||||||||||
110 | return executed 1879525 times by 104 tests: (QChar::Direction) qGetProp(ucs4)->direction;return (QChar::Direction) qGetProp(ucs4)->direction; Executed by:
executed 1879525 times by 104 tests: return (QChar::Direction) qGetProp(ucs4)->direction; Executed by:
| 1879525 | ||||||||||||
111 | } | - | ||||||||||||
112 | QChar::JoiningType QChar::joiningType(uint ucs4) noexcept | - | ||||||||||||
113 | { | - | ||||||||||||
114 | if (ucs4 > LastValidCodePoint
| 0-2169 | ||||||||||||
115 | return never executed: QChar::Joining_None;return QChar::Joining_None; never executed: return QChar::Joining_None; | 0 | ||||||||||||
116 | return executed 2169 times by 14 tests: QChar::JoiningType(qGetProp(ucs4)->joining);return QChar::JoiningType(qGetProp(ucs4)->joining); Executed by:
executed 2169 times by 14 tests: return QChar::JoiningType(qGetProp(ucs4)->joining); Executed by:
| 2169 | ||||||||||||
117 | } | - | ||||||||||||
118 | QChar::Joining QChar::joining(uint ucs4) noexcept | - | ||||||||||||
119 | { | - | ||||||||||||
120 | if (ucs4 > LastValidCodePoint
| 0 | ||||||||||||
121 | return never executed: QChar::OtherJoining;return QChar::OtherJoining; never executed: return QChar::OtherJoining; | 0 | ||||||||||||
122 | switch (qGetProp(ucs4)->joining) { | - | ||||||||||||
123 | case never executed: QChar::Joining_Causing:case QChar::Joining_Causing: never executed: returncase QChar::Joining_Causing: never executed: QChar::Center;return QChar::Center; never executed: return QChar::Center; | 0 | ||||||||||||
124 | case never executed: QChar::Joining_Dual:case QChar::Joining_Dual: never executed: returncase QChar::Joining_Dual: never executed: QChar::Dual;return QChar::Dual; never executed: return QChar::Dual; | 0 | ||||||||||||
125 | case never executed: QChar::Joining_Right:case QChar::Joining_Right: never executed: returncase QChar::Joining_Right: never executed: QChar::Right;return QChar::Right; never executed: return QChar::Right; | 0 | ||||||||||||
126 | default never executed: :default: never executed: break;default: never executed: break; | 0 | ||||||||||||
127 | } | - | ||||||||||||
128 | return never executed: QChar::OtherJoining;return QChar::OtherJoining; never executed: return QChar::OtherJoining; | 0 | ||||||||||||
129 | } | - | ||||||||||||
130 | bool QChar::hasMirrored(uint ucs4) noexcept | - | ||||||||||||
131 | { | - | ||||||||||||
132 | if (ucs4 > LastValidCodePoint
| 0-4 | ||||||||||||
133 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
134 | return executed 4 times by 1 test: qGetProp(ucs4)->mirrorDiff != 0;return qGetProp(ucs4)->mirrorDiff != 0; Executed by:
executed 4 times by 1 test: return qGetProp(ucs4)->mirrorDiff != 0; Executed by:
| 4 | ||||||||||||
135 | } | - | ||||||||||||
136 | uint QChar::mirroredChar(uint ucs4) noexcept | - | ||||||||||||
137 | { | - | ||||||||||||
138 | if (ucs4 > LastValidCodePoint
| 0-129532 | ||||||||||||
139 | return never executed: ucs4;return ucs4; never executed: return ucs4; | 0 | ||||||||||||
140 | return executed 129532 times by 12 tests: ucs4 + qGetProp(ucs4)->mirrorDiff;return ucs4 + qGetProp(ucs4)->mirrorDiff; Executed by:
executed 129532 times by 12 tests: return ucs4 + qGetProp(ucs4)->mirrorDiff; Executed by:
| 129532 | ||||||||||||
141 | } | - | ||||||||||||
142 | - | |||||||||||||
143 | - | |||||||||||||
144 | - | |||||||||||||
145 | enum { | - | ||||||||||||
146 | Hangul_SBase = 0xac00, | - | ||||||||||||
147 | Hangul_LBase = 0x1100, | - | ||||||||||||
148 | Hangul_VBase = 0x1161, | - | ||||||||||||
149 | Hangul_TBase = 0x11a7, | - | ||||||||||||
150 | Hangul_LCount = 19, | - | ||||||||||||
151 | Hangul_VCount = 21, | - | ||||||||||||
152 | Hangul_TCount = 28, | - | ||||||||||||
153 | Hangul_NCount = Hangul_VCount * Hangul_TCount, | - | ||||||||||||
154 | Hangul_SCount = Hangul_LCount * Hangul_NCount | - | ||||||||||||
155 | }; | - | ||||||||||||
156 | - | |||||||||||||
157 | - | |||||||||||||
158 | static const unsigned short * decompositionHelper | - | ||||||||||||
159 | (uint ucs4, int *length, int *tag, unsigned short *buffer) | - | ||||||||||||
160 | { | - | ||||||||||||
161 | if (ucs4 >= Hangul_SBase && ucs4 < Hangul_SBase + Hangul_SCount) { | - | ||||||||||||
162 | - | |||||||||||||
163 | const uint SIndex = ucs4 - Hangul_SBase; | - | ||||||||||||
164 | buffer[0] = Hangul_LBase + SIndex / Hangul_NCount; | - | ||||||||||||
165 | buffer[1] = Hangul_VBase + (SIndex % Hangul_NCount) / Hangul_TCount; | - | ||||||||||||
166 | buffer[2] = Hangul_TBase + SIndex % Hangul_TCount; | - | ||||||||||||
167 | *length = buffer[2] == Hangul_TBase ? 2 : 3; | - | ||||||||||||
168 | *tag = QChar::Canonical; | - | ||||||||||||
169 | return buffer; | - | ||||||||||||
170 | } | - | ||||||||||||
171 | - | |||||||||||||
172 | const unsigned short index = (ucs4 < 0x3400 ? (uc_decomposition_trie[uc_decomposition_trie[ucs4>>4] + (ucs4 & 0xf)]) : (ucs4 < 0x30000 ? uc_decomposition_trie[uc_decomposition_trie[((ucs4 - 0x3400)>>8) + 0x340] + (ucs4 & 0xff)] : 0xffff)); | - | ||||||||||||
173 | if (index == 0xffff) { | - | ||||||||||||
174 | *length = 0; | - | ||||||||||||
175 | *tag = QChar::NoDecomposition; | - | ||||||||||||
176 | return 0; | - | ||||||||||||
177 | } | - | ||||||||||||
178 | - | |||||||||||||
179 | const unsigned short *decomposition = uc_decomposition_map+index; | - | ||||||||||||
180 | *tag = (*decomposition) & 0xff; | - | ||||||||||||
181 | *length = (*decomposition) >> 8; | - | ||||||||||||
182 | return decomposition+1; | - | ||||||||||||
183 | } | - | ||||||||||||
184 | - | |||||||||||||
185 | - | |||||||||||||
186 | - | |||||||||||||
187 | - | |||||||||||||
188 | - | |||||||||||||
189 | QString QChar::decomposition() const | - | ||||||||||||
190 | { | - | ||||||||||||
191 | return QChar::decomposition(ucs); | - | ||||||||||||
192 | } | - | ||||||||||||
193 | - | |||||||||||||
194 | - | |||||||||||||
195 | - | |||||||||||||
196 | - | |||||||||||||
197 | - | |||||||||||||
198 | - | |||||||||||||
199 | QString QChar::decomposition(uint ucs4) | - | ||||||||||||
200 | { | - | ||||||||||||
201 | unsigned short buffer[3]; | - | ||||||||||||
202 | int length; | - | ||||||||||||
203 | int tag; | - | ||||||||||||
204 | const unsigned short *d = decompositionHelper(ucs4, &length, &tag, buffer); | - | ||||||||||||
205 | return QString(reinterpret_cast<const QChar *>(d), length); | - | ||||||||||||
206 | } | - | ||||||||||||
207 | QChar::Decomposition QChar::decompositionTag(uint ucs4) noexcept | - | ||||||||||||
208 | { | - | ||||||||||||
209 | if (ucs4 >= Hangul_SBase
| 24-1275746 | ||||||||||||
210 | return executed 22344 times by 1 test: QChar::Canonical;return QChar::Canonical; Executed by:
executed 22344 times by 1 test: return QChar::Canonical; Executed by:
| 22344 | ||||||||||||
211 | const unsigned short index = (ucs4 < 0x3400
| 0-1275746 | ||||||||||||
212 | if (index == 0xffff
| 55674-1220096 | ||||||||||||
213 | return executed 1220096 times by 85 tests: QChar::NoDecomposition;return QChar::NoDecomposition; Executed by:
executed 1220096 times by 85 tests: return QChar::NoDecomposition; Executed by:
| 1220096 | ||||||||||||
214 | return executed 55674 times by 7 tests: (QChar::Decomposition)(uc_decomposition_map[index] & 0xff);return (QChar::Decomposition)(uc_decomposition_map[index] & 0xff); Executed by:
executed 55674 times by 7 tests: return (QChar::Decomposition)(uc_decomposition_map[index] & 0xff); Executed by:
| 55674 | ||||||||||||
215 | } | - | ||||||||||||
216 | unsigned char QChar::combiningClass(uint ucs4) noexcept | - | ||||||||||||
217 | { | - | ||||||||||||
218 | if (ucs4 > LastValidCodePoint
| 0-5518214 | ||||||||||||
219 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
220 | return executed 5518214 times by 112 tests: (unsigned char) qGetProp(ucs4)->combiningClass;return (unsigned char) qGetProp(ucs4)->combiningClass; Executed by:
executed 5518214 times by 112 tests: return (unsigned char) qGetProp(ucs4)->combiningClass; Executed by:
| 5518214 | ||||||||||||
221 | } | - | ||||||||||||
222 | QChar::Script QChar::script(uint ucs4) noexcept | - | ||||||||||||
223 | { | - | ||||||||||||
224 | if (ucs4 > LastValidCodePoint
| 0-2639 | ||||||||||||
225 | return never executed: QChar::Script_Unknown;return QChar::Script_Unknown; never executed: return QChar::Script_Unknown; | 0 | ||||||||||||
226 | return executed 2639 times by 62 tests: (QChar::Script) qGetProp(ucs4)->script;return (QChar::Script) qGetProp(ucs4)->script; Executed by:
executed 2639 times by 62 tests: return (QChar::Script) qGetProp(ucs4)->script; Executed by:
| 2639 | ||||||||||||
227 | } | - | ||||||||||||
228 | QChar::UnicodeVersion QChar::unicodeVersion(uint ucs4) noexcept | - | ||||||||||||
229 | { | - | ||||||||||||
230 | if (ucs4 > LastValidCodePoint
| 1-609469 | ||||||||||||
231 | return executed 1 time by 1 test: QChar::Unicode_Unassigned;return QChar::Unicode_Unassigned; Executed by:
executed 1 time by 1 test: return QChar::Unicode_Unassigned; Executed by:
| 1 | ||||||||||||
232 | return executed 609469 times by 6 tests: (QChar::UnicodeVersion) qGetProp(ucs4)->unicodeVersion;return (QChar::UnicodeVersion) qGetProp(ucs4)->unicodeVersion; Executed by:
executed 609469 times by 6 tests: return (QChar::UnicodeVersion) qGetProp(ucs4)->unicodeVersion; Executed by:
| 609469 | ||||||||||||
233 | } | - | ||||||||||||
234 | - | |||||||||||||
235 | - | |||||||||||||
236 | - | |||||||||||||
237 | - | |||||||||||||
238 | QChar::UnicodeVersion QChar::currentUnicodeVersion() noexcept | - | ||||||||||||
239 | { | - | ||||||||||||
240 | return executed 565704 times by 4 tests: QChar::Unicode_8_0;return QChar::Unicode_8_0; Executed by:
executed 565704 times by 4 tests: return QChar::Unicode_8_0; Executed by:
| 565704 | ||||||||||||
241 | } | - | ||||||||||||
242 | - | |||||||||||||
243 | - | |||||||||||||
244 | template <typename Traits, typename T> | - | ||||||||||||
245 | __attribute__((const)) static inline T convertCase_helper(T uc) noexcept | - | ||||||||||||
246 | { | - | ||||||||||||
247 | const QUnicodeTables::Properties *prop = qGetProp(uc); | - | ||||||||||||
248 | - | |||||||||||||
249 | if (__builtin_expect(!!(Traits::caseSpecial(prop)), false)
| 347-11269411 | ||||||||||||
250 | const ushort *specialCase = specialCaseMap + Traits::caseDiff(prop); | - | ||||||||||||
251 | - | |||||||||||||
252 | return executed 347 times by 5 tests: *specialCase == 1 ? specialCase[1] : uc;return *specialCase == 1 ? specialCase[1] : uc; Executed by:
executed 347 times by 5 tests: return *specialCase == 1 ? specialCase[1] : uc; Executed by:
| 347 | ||||||||||||
253 | } | - | ||||||||||||
254 | - | |||||||||||||
255 | return executed 11269411 times by 226 tests: uc + Traits::caseDiff(prop);return uc + Traits::caseDiff(prop); Executed by:
executed 11269411 times by 226 tests: return uc + Traits::caseDiff(prop); Executed by:
| 11269411 | ||||||||||||
256 | } | - | ||||||||||||
257 | uint QChar::toLower(uint ucs4) noexcept | - | ||||||||||||
258 | { | - | ||||||||||||
259 | if (ucs4 > LastValidCodePoint
| 0-5516452 | ||||||||||||
260 | return never executed: ucs4;return ucs4; never executed: return ucs4; | 0 | ||||||||||||
261 | return executed 5516452 times by 94 tests: convertCase_helper<QUnicodeTables::LowercaseTraits>(ucs4);return convertCase_helper<QUnicodeTables::LowercaseTraits>(ucs4); Executed by:
executed 5516452 times by 94 tests: return convertCase_helper<QUnicodeTables::LowercaseTraits>(ucs4); Executed by:
| 5516452 | ||||||||||||
262 | } | - | ||||||||||||
263 | uint QChar::toUpper(uint ucs4) noexcept | - | ||||||||||||
264 | { | - | ||||||||||||
265 | if (ucs4 > LastValidCodePoint
| 0-2026370 | ||||||||||||
266 | return never executed: ucs4;return ucs4; never executed: return ucs4; | 0 | ||||||||||||
267 | return executed 2026370 times by 187 tests: convertCase_helper<QUnicodeTables::UppercaseTraits>(ucs4);return convertCase_helper<QUnicodeTables::UppercaseTraits>(ucs4); Executed by:
executed 2026370 times by 187 tests: return convertCase_helper<QUnicodeTables::UppercaseTraits>(ucs4); Executed by:
| 2026370 | ||||||||||||
268 | } | - | ||||||||||||
269 | uint QChar::toTitleCase(uint ucs4) noexcept | - | ||||||||||||
270 | { | - | ||||||||||||
271 | if (ucs4 > LastValidCodePoint
| 0-50 | ||||||||||||
272 | return never executed: ucs4;return ucs4; never executed: return ucs4; | 0 | ||||||||||||
273 | return executed 50 times by 2 tests: convertCase_helper<QUnicodeTables::TitlecaseTraits>(ucs4);return convertCase_helper<QUnicodeTables::TitlecaseTraits>(ucs4); Executed by:
executed 50 times by 2 tests: return convertCase_helper<QUnicodeTables::TitlecaseTraits>(ucs4); Executed by:
| 50 | ||||||||||||
274 | } | - | ||||||||||||
275 | - | |||||||||||||
276 | static inline uint foldCase(const ushort *ch, const ushort *start) | - | ||||||||||||
277 | { | - | ||||||||||||
278 | uint ucs4 = *ch; | - | ||||||||||||
279 | if (QChar::isLowSurrogate(ucs4) && ch > start && QChar::isHighSurrogate(*(ch - 1))) | - | ||||||||||||
280 | ucs4 = QChar::surrogateToUcs4(*(ch - 1), ucs4); | - | ||||||||||||
281 | return convertCase_helper<QUnicodeTables::CasefoldTraits>(ucs4); | - | ||||||||||||
282 | } | - | ||||||||||||
283 | - | |||||||||||||
284 | static inline uint foldCase(uint ch, uint &last) noexcept | - | ||||||||||||
285 | { | - | ||||||||||||
286 | uint ucs4 = ch; | - | ||||||||||||
287 | if (QChar::isLowSurrogate(ucs4)
| 0-3463562 | ||||||||||||
288 | ucs4 = QChar::surrogateToUcs4(last, ucs4); executed 28 times by 2 tests: ucs4 = QChar::surrogateToUcs4(last, ucs4); Executed by:
| 28 | ||||||||||||
289 | last = ch; | - | ||||||||||||
290 | return executed 3463590 times by 170 tests: convertCase_helper<QUnicodeTables::CasefoldTraits>(ucs4);return convertCase_helper<QUnicodeTables::CasefoldTraits>(ucs4); Executed by:
executed 3463590 times by 170 tests: return convertCase_helper<QUnicodeTables::CasefoldTraits>(ucs4); Executed by:
| 3463590 | ||||||||||||
291 | } | - | ||||||||||||
292 | - | |||||||||||||
293 | static inline ushort foldCase(ushort ch) noexcept | - | ||||||||||||
294 | { | - | ||||||||||||
295 | return executed 151362 times by 53 tests: convertCase_helper<QUnicodeTables::CasefoldTraits>(ch);return convertCase_helper<QUnicodeTables::CasefoldTraits>(ch); Executed by:
executed 151362 times by 53 tests: return convertCase_helper<QUnicodeTables::CasefoldTraits>(ch); Executed by:
| 151362 | ||||||||||||
296 | } | - | ||||||||||||
297 | uint QChar::toCaseFolded(uint ucs4) noexcept | - | ||||||||||||
298 | { | - | ||||||||||||
299 | if (ucs4 > LastValidCodePoint
| 0-65583 | ||||||||||||
300 | return never executed: ucs4;return ucs4; never executed: return ucs4; | 0 | ||||||||||||
301 | return executed 65583 times by 2 tests: convertCase_helper<QUnicodeTables::CasefoldTraits>(ucs4);return convertCase_helper<QUnicodeTables::CasefoldTraits>(ucs4); Executed by:
executed 65583 times by 2 tests: return convertCase_helper<QUnicodeTables::CasefoldTraits>(ucs4); Executed by:
| 65583 | ||||||||||||
302 | } | - | ||||||||||||
303 | QDataStream &operator<<(QDataStream &out, QChar chr) | - | ||||||||||||
304 | { | - | ||||||||||||
305 | out << quint16(chr.unicode()); | - | ||||||||||||
306 | return out; | - | ||||||||||||
307 | } | - | ||||||||||||
308 | QDataStream &operator>>(QDataStream &in, QChar &chr) | - | ||||||||||||
309 | { | - | ||||||||||||
310 | quint16 u; | - | ||||||||||||
311 | in >> u; | - | ||||||||||||
312 | chr.unicode() = ushort(u); | - | ||||||||||||
313 | return in; | - | ||||||||||||
314 | } | - | ||||||||||||
315 | static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion version, int from) | - | ||||||||||||
316 | { | - | ||||||||||||
317 | int length; | - | ||||||||||||
318 | int tag; | - | ||||||||||||
319 | unsigned short buffer[3]; | - | ||||||||||||
320 | - | |||||||||||||
321 | QString &s = *str; | - | ||||||||||||
322 | - | |||||||||||||
323 | const unsigned short *utf16 = reinterpret_cast<unsigned short *>(s.data()); | - | ||||||||||||
324 | const unsigned short *uc = utf16 + s.length(); | - | ||||||||||||
325 | while (uc != utf16 + from) { | - | ||||||||||||
326 | uint ucs4 = *(--uc); | - | ||||||||||||
327 | if (QChar(ucs4).isLowSurrogate() && uc != utf16) { | - | ||||||||||||
328 | ushort high = *(uc - 1); | - | ||||||||||||
329 | if (QChar(high).isHighSurrogate()) { | - | ||||||||||||
330 | --uc; | - | ||||||||||||
331 | ucs4 = QChar::surrogateToUcs4(high, ucs4); | - | ||||||||||||
332 | } | - | ||||||||||||
333 | } | - | ||||||||||||
334 | - | |||||||||||||
335 | if (QChar::unicodeVersion(ucs4) > version) | - | ||||||||||||
336 | continue; | - | ||||||||||||
337 | - | |||||||||||||
338 | const unsigned short *d = decompositionHelper(ucs4, &length, &tag, buffer); | - | ||||||||||||
339 | if (!d || (canonical && tag != QChar::Canonical)) | - | ||||||||||||
340 | continue; | - | ||||||||||||
341 | - | |||||||||||||
342 | int pos = uc - utf16; | - | ||||||||||||
343 | s.replace(pos, QChar::requiresSurrogates(ucs4) ? 2 : 1, reinterpret_cast<const QChar *>(d), length); | - | ||||||||||||
344 | - | |||||||||||||
345 | utf16 = reinterpret_cast<unsigned short *>(s.data()); | - | ||||||||||||
346 | uc = utf16 + pos + length; | - | ||||||||||||
347 | } | - | ||||||||||||
348 | } | - | ||||||||||||
349 | - | |||||||||||||
350 | - | |||||||||||||
351 | struct UCS2Pair { | - | ||||||||||||
352 | ushort u1; | - | ||||||||||||
353 | ushort u2; | - | ||||||||||||
354 | }; | - | ||||||||||||
355 | - | |||||||||||||
356 | inline bool operator<(const UCS2Pair &ligature1, const UCS2Pair &ligature2) | - | ||||||||||||
357 | { return ligature1.u1 < ligature2.u1; } | - | ||||||||||||
358 | inline bool operator<(ushort u1, const UCS2Pair &ligature) | - | ||||||||||||
359 | { return u1 < ligature.u1; } | - | ||||||||||||
360 | inline bool operator<(const UCS2Pair &ligature, ushort u1) | - | ||||||||||||
361 | { return ligature.u1 < u1; } | - | ||||||||||||
362 | - | |||||||||||||
363 | struct UCS2SurrogatePair { | - | ||||||||||||
364 | UCS2Pair p1; | - | ||||||||||||
365 | UCS2Pair p2; | - | ||||||||||||
366 | }; | - | ||||||||||||
367 | - | |||||||||||||
368 | inline bool operator<(const UCS2SurrogatePair &ligature1, const UCS2SurrogatePair &ligature2) | - | ||||||||||||
369 | { return QChar::surrogateToUcs4(ligature1.p1.u1, ligature1.p1.u2) < QChar::surrogateToUcs4(ligature2.p1.u1, ligature2.p1.u2); } | - | ||||||||||||
370 | inline bool operator<(uint u1, const UCS2SurrogatePair &ligature) | - | ||||||||||||
371 | { return u1 < QChar::surrogateToUcs4(ligature.p1.u1, ligature.p1.u2); } | - | ||||||||||||
372 | inline bool operator<(const UCS2SurrogatePair &ligature, uint u1) | - | ||||||||||||
373 | { return QChar::surrogateToUcs4(ligature.p1.u1, ligature.p1.u2) < u1; } | - | ||||||||||||
374 | - | |||||||||||||
375 | static uint inline ligatureHelper(uint u1, uint u2) | - | ||||||||||||
376 | { | - | ||||||||||||
377 | if (u1 >= Hangul_LBase && u1 <= Hangul_SBase + Hangul_SCount) { | - | ||||||||||||
378 | - | |||||||||||||
379 | - | |||||||||||||
380 | const uint LIndex = u1 - Hangul_LBase; | - | ||||||||||||
381 | if (LIndex < Hangul_LCount) { | - | ||||||||||||
382 | const uint VIndex = u2 - Hangul_VBase; | - | ||||||||||||
383 | if (VIndex < Hangul_VCount) | - | ||||||||||||
384 | return Hangul_SBase + (LIndex * Hangul_VCount + VIndex) * Hangul_TCount; | - | ||||||||||||
385 | } | - | ||||||||||||
386 | - | |||||||||||||
387 | const uint SIndex = u1 - Hangul_SBase; | - | ||||||||||||
388 | if (SIndex < Hangul_SCount && (SIndex % Hangul_TCount) == 0) { | - | ||||||||||||
389 | const uint TIndex = u2 - Hangul_TBase; | - | ||||||||||||
390 | if (TIndex <= Hangul_TCount) | - | ||||||||||||
391 | return u1 + TIndex; | - | ||||||||||||
392 | } | - | ||||||||||||
393 | } | - | ||||||||||||
394 | - | |||||||||||||
395 | const unsigned short index = (u2 < 0x3100 ? (uc_ligature_trie[uc_ligature_trie[u2>>5] + (u2 & 0x1f)]) : (u2 < 0x12000 ? uc_ligature_trie[uc_ligature_trie[((u2 - 0x3100)>>8) + 0x188] + (u2 & 0xff)] : 0xffff)); | - | ||||||||||||
396 | if (index == 0xffff) | - | ||||||||||||
397 | return 0; | - | ||||||||||||
398 | const unsigned short *ligatures = uc_ligature_map+index; | - | ||||||||||||
399 | ushort length = *ligatures++; | - | ||||||||||||
400 | if (QChar::requiresSurrogates(u1)) { | - | ||||||||||||
401 | const UCS2SurrogatePair *data = reinterpret_cast<const UCS2SurrogatePair *>(ligatures); | - | ||||||||||||
402 | const UCS2SurrogatePair *r = std::lower_bound(data, data + length, u1); | - | ||||||||||||
403 | if (r != data + length && QChar::surrogateToUcs4(r->p1.u1, r->p1.u2) == u1) | - | ||||||||||||
404 | return QChar::surrogateToUcs4(r->p2.u1, r->p2.u2); | - | ||||||||||||
405 | } else { | - | ||||||||||||
406 | const UCS2Pair *data = reinterpret_cast<const UCS2Pair *>(ligatures); | - | ||||||||||||
407 | const UCS2Pair *r = std::lower_bound(data, data + length, ushort(u1)); | - | ||||||||||||
408 | if (r != data + length && r->u1 == ushort(u1)) | - | ||||||||||||
409 | return r->u2; | - | ||||||||||||
410 | } | - | ||||||||||||
411 | - | |||||||||||||
412 | return 0; | - | ||||||||||||
413 | } | - | ||||||||||||
414 | - | |||||||||||||
415 | static void composeHelper(QString *str, QChar::UnicodeVersion version, int from) | - | ||||||||||||
416 | { | - | ||||||||||||
417 | QString &s = *str; | - | ||||||||||||
418 | - | |||||||||||||
419 | if (from < 0 || s.length() - from < 2) | - | ||||||||||||
420 | return; | - | ||||||||||||
421 | - | |||||||||||||
422 | uint stcode = 0; | - | ||||||||||||
423 | int starter = -1; | - | ||||||||||||
424 | int next = -1; | - | ||||||||||||
425 | int lastCombining = 255; | - | ||||||||||||
426 | - | |||||||||||||
427 | int pos = from; | - | ||||||||||||
428 | while (pos < s.length()) { | - | ||||||||||||
429 | int i = pos; | - | ||||||||||||
430 | uint uc = s.at(pos).unicode(); | - | ||||||||||||
431 | if (QChar(uc).isHighSurrogate() && pos < s.length()-1) { | - | ||||||||||||
432 | ushort low = s.at(pos+1).unicode(); | - | ||||||||||||
433 | if (QChar(low).isLowSurrogate()) { | - | ||||||||||||
434 | uc = QChar::surrogateToUcs4(uc, low); | - | ||||||||||||
435 | ++pos; | - | ||||||||||||
436 | } | - | ||||||||||||
437 | } | - | ||||||||||||
438 | - | |||||||||||||
439 | const QUnicodeTables::Properties *p = qGetProp(uc); | - | ||||||||||||
440 | if (p->unicodeVersion > version) { | - | ||||||||||||
441 | starter = -1; | - | ||||||||||||
442 | next = -1; | - | ||||||||||||
443 | lastCombining = 255; | - | ||||||||||||
444 | ++pos; | - | ||||||||||||
445 | continue; | - | ||||||||||||
446 | } | - | ||||||||||||
447 | - | |||||||||||||
448 | int combining = p->combiningClass; | - | ||||||||||||
449 | if ((i == next || combining > lastCombining) && starter >= from) { | - | ||||||||||||
450 | - | |||||||||||||
451 | uint ligature = ligatureHelper(stcode, uc); | - | ||||||||||||
452 | if (ligature) { | - | ||||||||||||
453 | stcode = ligature; | - | ||||||||||||
454 | QChar *d = s.data(); | - | ||||||||||||
455 | - | |||||||||||||
456 | if (QChar::requiresSurrogates(ligature)) { | - | ||||||||||||
457 | d[starter] = QChar::highSurrogate(ligature); | - | ||||||||||||
458 | d[starter + 1] = QChar::lowSurrogate(ligature); | - | ||||||||||||
459 | s.remove(i, 2); | - | ||||||||||||
460 | } else { | - | ||||||||||||
461 | d[starter] = ligature; | - | ||||||||||||
462 | s.remove(i, 1); | - | ||||||||||||
463 | } | - | ||||||||||||
464 | continue; | - | ||||||||||||
465 | } | - | ||||||||||||
466 | } | - | ||||||||||||
467 | if (combining == 0) { | - | ||||||||||||
468 | starter = i; | - | ||||||||||||
469 | stcode = uc; | - | ||||||||||||
470 | next = pos + 1; | - | ||||||||||||
471 | } | - | ||||||||||||
472 | lastCombining = combining; | - | ||||||||||||
473 | - | |||||||||||||
474 | ++pos; | - | ||||||||||||
475 | } | - | ||||||||||||
476 | } | - | ||||||||||||
477 | - | |||||||||||||
478 | - | |||||||||||||
479 | static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, int from) | - | ||||||||||||
480 | { | - | ||||||||||||
481 | QString &s = *str; | - | ||||||||||||
482 | const int l = s.length()-1; | - | ||||||||||||
483 | - | |||||||||||||
484 | uint u1, u2; | - | ||||||||||||
485 | ushort c1, c2; | - | ||||||||||||
486 | - | |||||||||||||
487 | int pos = from; | - | ||||||||||||
488 | while (pos < l) { | - | ||||||||||||
489 | int p2 = pos+1; | - | ||||||||||||
490 | u1 = s.at(pos).unicode(); | - | ||||||||||||
491 | if (QChar(u1).isHighSurrogate()) { | - | ||||||||||||
492 | ushort low = s.at(p2).unicode(); | - | ||||||||||||
493 | if (QChar(low).isLowSurrogate()) { | - | ||||||||||||
494 | u1 = QChar::surrogateToUcs4(u1, low); | - | ||||||||||||
495 | if (p2 >= l) | - | ||||||||||||
496 | break; | - | ||||||||||||
497 | ++p2; | - | ||||||||||||
498 | } | - | ||||||||||||
499 | } | - | ||||||||||||
500 | c1 = 0; | - | ||||||||||||
501 | - | |||||||||||||
502 | advance: | - | ||||||||||||
503 | u2 = s.at(p2).unicode(); | - | ||||||||||||
504 | if (QChar(u2).isHighSurrogate() && p2 < l) { | - | ||||||||||||
505 | ushort low = s.at(p2+1).unicode(); | - | ||||||||||||
506 | if (QChar(low).isLowSurrogate()) { | - | ||||||||||||
507 | u2 = QChar::surrogateToUcs4(u2, low); | - | ||||||||||||
508 | ++p2; | - | ||||||||||||
509 | } | - | ||||||||||||
510 | } | - | ||||||||||||
511 | - | |||||||||||||
512 | c2 = 0; | - | ||||||||||||
513 | { | - | ||||||||||||
514 | const QUnicodeTables::Properties *p = qGetProp(u2); | - | ||||||||||||
515 | if (p->unicodeVersion <= version) | - | ||||||||||||
516 | c2 = p->combiningClass; | - | ||||||||||||
517 | } | - | ||||||||||||
518 | if (c2 == 0) { | - | ||||||||||||
519 | pos = p2+1; | - | ||||||||||||
520 | continue; | - | ||||||||||||
521 | } | - | ||||||||||||
522 | - | |||||||||||||
523 | if (c1 == 0) { | - | ||||||||||||
524 | const QUnicodeTables::Properties *p = qGetProp(u1); | - | ||||||||||||
525 | if (p->unicodeVersion <= version) | - | ||||||||||||
526 | c1 = p->combiningClass; | - | ||||||||||||
527 | } | - | ||||||||||||
528 | - | |||||||||||||
529 | if (c1 > c2) { | - | ||||||||||||
530 | QChar *uc = s.data(); | - | ||||||||||||
531 | int p = pos; | - | ||||||||||||
532 | - | |||||||||||||
533 | if (!QChar::requiresSurrogates(u2)) { | - | ||||||||||||
534 | uc[p++] = u2; | - | ||||||||||||
535 | } else { | - | ||||||||||||
536 | uc[p++] = QChar::highSurrogate(u2); | - | ||||||||||||
537 | uc[p++] = QChar::lowSurrogate(u2); | - | ||||||||||||
538 | } | - | ||||||||||||
539 | if (!QChar::requiresSurrogates(u1)) { | - | ||||||||||||
540 | uc[p++] = u1; | - | ||||||||||||
541 | } else { | - | ||||||||||||
542 | uc[p++] = QChar::highSurrogate(u1); | - | ||||||||||||
543 | uc[p++] = QChar::lowSurrogate(u1); | - | ||||||||||||
544 | } | - | ||||||||||||
545 | if (pos > 0) | - | ||||||||||||
546 | --pos; | - | ||||||||||||
547 | if (pos > 0 && s.at(pos).isLowSurrogate()) | - | ||||||||||||
548 | --pos; | - | ||||||||||||
549 | } else { | - | ||||||||||||
550 | ++pos; | - | ||||||||||||
551 | if (QChar::requiresSurrogates(u1)) | - | ||||||||||||
552 | ++pos; | - | ||||||||||||
553 | - | |||||||||||||
554 | u1 = u2; | - | ||||||||||||
555 | c1 = c2; | - | ||||||||||||
556 | p2 = pos + 1; | - | ||||||||||||
557 | if (QChar::requiresSurrogates(u1)) | - | ||||||||||||
558 | ++p2; | - | ||||||||||||
559 | if (p2 > l) | - | ||||||||||||
560 | break; | - | ||||||||||||
561 | - | |||||||||||||
562 | goto advance; | - | ||||||||||||
563 | } | - | ||||||||||||
564 | } | - | ||||||||||||
565 | } | - | ||||||||||||
566 | - | |||||||||||||
567 | - | |||||||||||||
568 | - | |||||||||||||
569 | static bool normalizationQuickCheckHelper(QString *str, QString::NormalizationForm mode, int from, int *lastStable) | - | ||||||||||||
570 | { | - | ||||||||||||
571 | static_assert(bool(QString::NormalizationForm_D == 0), "QString::NormalizationForm_D == 0"); | - | ||||||||||||
572 | static_assert(bool(QString::NormalizationForm_C == 1), "QString::NormalizationForm_C == 1"); | - | ||||||||||||
573 | static_assert(bool(QString::NormalizationForm_KD == 2), "QString::NormalizationForm_KD == 2"); | - | ||||||||||||
574 | static_assert(bool(QString::NormalizationForm_KC == 3), "QString::NormalizationForm_KC == 3"); | - | ||||||||||||
575 | - | |||||||||||||
576 | enum { NFQC_YES = 0, NFQC_NO = 1, NFQC_MAYBE = 3 }; | - | ||||||||||||
577 | - | |||||||||||||
578 | const ushort *string = reinterpret_cast<const ushort *>(str->constData()); | - | ||||||||||||
579 | int length = str->length(); | - | ||||||||||||
580 | - | |||||||||||||
581 | - | |||||||||||||
582 | while (length > from && QChar::isHighSurrogate(string[length - 1])) | - | ||||||||||||
583 | --length; | - | ||||||||||||
584 | - | |||||||||||||
585 | uchar lastCombining = 0; | - | ||||||||||||
586 | for (int i = from; i < length; ++i) { | - | ||||||||||||
587 | int pos = i; | - | ||||||||||||
588 | uint uc = string[i]; | - | ||||||||||||
589 | if (uc < 0x80) { | - | ||||||||||||
590 | - | |||||||||||||
591 | lastCombining = 0; | - | ||||||||||||
592 | *lastStable = pos; | - | ||||||||||||
593 | continue; | - | ||||||||||||
594 | } | - | ||||||||||||
595 | - | |||||||||||||
596 | if (QChar::isHighSurrogate(uc)) { | - | ||||||||||||
597 | ushort low = string[i + 1]; | - | ||||||||||||
598 | if (!QChar::isLowSurrogate(low)) { | - | ||||||||||||
599 | - | |||||||||||||
600 | lastCombining = 0; | - | ||||||||||||
601 | *lastStable = pos; | - | ||||||||||||
602 | continue; | - | ||||||||||||
603 | } | - | ||||||||||||
604 | ++i; | - | ||||||||||||
605 | uc = QChar::surrogateToUcs4(uc, low); | - | ||||||||||||
606 | } | - | ||||||||||||
607 | - | |||||||||||||
608 | const QUnicodeTables::Properties *p = qGetProp(uc); | - | ||||||||||||
609 | - | |||||||||||||
610 | if (p->combiningClass < lastCombining && p->combiningClass > 0) | - | ||||||||||||
611 | return false; | - | ||||||||||||
612 | - | |||||||||||||
613 | const uchar check = (p->nfQuickCheck >> (mode << 1)) & 0x03; | - | ||||||||||||
614 | if (check != NFQC_YES) | - | ||||||||||||
615 | return false; | - | ||||||||||||
616 | - | |||||||||||||
617 | lastCombining = p->combiningClass; | - | ||||||||||||
618 | if (lastCombining == 0) | - | ||||||||||||
619 | *lastStable = pos; | - | ||||||||||||
620 | } | - | ||||||||||||
621 | - | |||||||||||||
622 | if (length != str->length()) | - | ||||||||||||
623 | *lastStable = str->length() - 1; | - | ||||||||||||
624 | - | |||||||||||||
625 | return true; | - | ||||||||||||
626 | } | - | ||||||||||||
627 | - | |||||||||||||
628 | - | |||||||||||||
Switch to Source code | Preprocessed file |