tools/qunicodetools.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 int qt_initcharattributes_default_algorithm_only = 0; -
9 -
10namespace QUnicodeTools { -
11namespace GB { -
12 -
13static const uchar breakTable[QUnicodeTables::GraphemeBreak_LVT + 1][QUnicodeTables::GraphemeBreak_LVT + 1] = { -
14 -
15 { true , true , true , true , false, true , true , false, true , true , true , true , true }, -
16 { true , true , false, true , true , true , true , true , true , true , true , true , true }, -
17 { true , true , true , true , true , true , true , true , true , true , true , true , true }, -
18 { true , true , true , true , true , true , true , true , true , true , true , true , true }, -
19 { true , true , true , true , false, true , true , false, true , true , true , true , true }, -
20 { true , true , true , true , false, false, true , false, true , true , true , true , true }, -
21 { false, true , true , true , false, false, false, false, false, false, false, false, false }, -
22 { true , true , true , true , false, true , true , false, true , true , true , true , true }, -
23 { true , true , true , true , false, true , true , false, false, false, true , false, false }, -
24 { true , true , true , true , false, true , true , false, true , false, false, true , true }, -
25 { true , true , true , true , false, true , true , false, true , true , false, true , true }, -
26 { true , true , true , true , false, true , true , false, true , false, false, true , true }, -
27 { true , true , true , true , false, true , true , false, true , true , false, true , true }, -
28}; -
29 -
30} -
31 -
32static void getGraphemeBreaks(const ushort *string, quint32 len, QCharAttributes *attributes) -
33{ -
34 QUnicodeTables::GraphemeBreakClass lcls = QUnicodeTables::GraphemeBreak_LF; -
35 for (quint32 i = 0; i != len; ++i) {
evaluated: i != len
TRUEFALSE
yes
Evaluation Count:1181420
yes
Evaluation Count:112425
112425-1181420
36 quint32 pos = i; -
37 uint ucs4 = string[i]; -
38 if (QChar::isHighSurrogate(ucs4) && i + 1 != len) {
partially evaluated: QChar::isHighSurrogate(ucs4)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1181420
never evaluated: i + 1 != len
0-1181420
39 ushort low = string[i + 1]; -
40 if (QChar::isLowSurrogate(low)) {
never evaluated: QChar::isLowSurrogate(low)
0
41 ucs4 = QChar::surrogateToUcs4(ucs4, low); -
42 ++i; -
43 }
never executed: }
0
44 }
never executed: }
0
45 -
46 const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ucs4); -
47 QUnicodeTables::GraphemeBreakClass cls = (QUnicodeTables::GraphemeBreakClass) prop->graphemeBreakClass; -
48 -
49 if (__builtin_expect(!!(GB::breakTable[lcls][cls]), true))
evaluated: __builtin_expect(!!(GB::breakTable[lcls][cls]), true)
TRUEFALSE
yes
Evaluation Count:975409
yes
Evaluation Count:206011
206011-975409
50 attributes[pos].graphemeBoundary = true;
executed: attributes[pos].graphemeBoundary = true;
Execution Count:975409
975409
51 -
52 lcls = cls; -
53 }
executed: }
Execution Count:1181420
1181420
54 -
55 attributes[len].graphemeBoundary = true; -
56}
executed: }
Execution Count:112425
112425
57 -
58 -
59namespace WB { -
60 -
61enum Action { -
62 NoBreak = 0, -
63 Break = 1, -
64 Lookup = 2 -
65}; -
66 -
67static const uchar breakTable[QUnicodeTables::WordBreak_ExtendNumLet + 1][QUnicodeTables::WordBreak_ExtendNumLet + 1] = { -
68 -
69 { Break , Break , Break , Break , NoBreak, Break , Break , Break , Break , Break , Break , Break , Break }, -
70 { Break , Break , NoBreak, Break , Break , Break , Break , Break , Break , Break , Break , Break , Break }, -
71 { Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break }, -
72 { Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break }, -
73 { Break , Break , Break , Break , NoBreak, Break , Break , Break , Break , Break , Break , Break , Break }, -
74 { Break , Break , Break , Break , NoBreak, NoBreak, Break , Break , Break , Break , Break , Break , Break }, -
75 { Break , Break , Break , Break , NoBreak, Break , NoBreak, Break , Break , Break , Break , Break , NoBreak }, -
76 { Break , Break , Break , Break , NoBreak, Break , Break , NoBreak, Lookup , Lookup , Break , NoBreak, NoBreak }, -
77 { Break , Break , Break , Break , NoBreak, Break , Break , Break , Break , Break , Break , Break , Break }, -
78 { Break , Break , Break , Break , NoBreak, Break , Break , Break , Break , Break , Break , Break , Break }, -
79 { Break , Break , Break , Break , NoBreak, Break , Break , Break , Break , Break , Break , Break , Break }, -
80 { Break , Break , Break , Break , NoBreak, Break , Break , NoBreak, Lookup , Break , Lookup , NoBreak, NoBreak }, -
81 { Break , Break , Break , Break , NoBreak, Break , NoBreak, NoBreak, Break , Break , Break , NoBreak, NoBreak }, -
82}; -
83 -
84} -
85 -
86static void getWordBreaks(const ushort *string, quint32 len, QCharAttributes *attributes) -
87{ -
88 enum WordType { -
89 WordTypeNone, WordTypeAlphaNumeric, WordTypeHiraganaKatakana -
90 } currentWordType = WordTypeNone; -
91 -
92 QUnicodeTables::WordBreakClass cls = QUnicodeTables::WordBreak_LF; -
93 for (quint32 i = 0; i != len; ++i) {
evaluated: i != len
TRUEFALSE
yes
Evaluation Count:748
yes
Evaluation Count:53
53-748
94 quint32 pos = i; -
95 uint ucs4 = string[i]; -
96 if (QChar::isHighSurrogate(ucs4) && i + 1 != len) {
partially evaluated: QChar::isHighSurrogate(ucs4)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:748
never evaluated: i + 1 != len
0-748
97 ushort low = string[i + 1]; -
98 if (QChar::isLowSurrogate(low)) {
never evaluated: QChar::isLowSurrogate(low)
0
99 ucs4 = QChar::surrogateToUcs4(ucs4, low); -
100 ++i; -
101 }
never executed: }
0
102 }
never executed: }
0
103 -
104 const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ucs4); -
105 QUnicodeTables::WordBreakClass ncls = (QUnicodeTables::WordBreakClass) prop->wordBreakClass; -
106 uchar action = WB::breakTable[cls][ncls]; -
107 if (__builtin_expect(!!(action == WB::Lookup), false)) {
evaluated: __builtin_expect(!!(action == WB::Lookup), false)
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:715
33-715
108 action = WB::Break; -
109 for (quint32 lookahead = i + 1; lookahead < len; ++lookahead) {
partially evaluated: lookahead < len
TRUEFALSE
yes
Evaluation Count:45
no
Evaluation Count:0
0-45
110 ucs4 = string[lookahead]; -
111 if (QChar::isHighSurrogate(ucs4) && lookahead + 1 != len) {
partially evaluated: QChar::isHighSurrogate(ucs4)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:45
never evaluated: lookahead + 1 != len
0-45
112 ushort low = string[lookahead + 1]; -
113 if (QChar::isLowSurrogate(low)) {
never evaluated: QChar::isLowSurrogate(low)
0
114 ucs4 = QChar::surrogateToUcs4(ucs4, low); -
115 ++lookahead; -
116 }
never executed: }
0
117 }
never executed: }
0
118 -
119 prop = QUnicodeTables::properties(ucs4); -
120 QUnicodeTables::WordBreakClass tcls = (QUnicodeTables::WordBreakClass) prop->wordBreakClass; -
121 if (__builtin_expect(!!(tcls == QUnicodeTables::WordBreak_Extend), false))
evaluated: __builtin_expect(!!(tcls == QUnicodeTables::WordBreak_Extend), false)
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:33
12-33
122 continue;
executed: continue;
Execution Count:12
12
123 if (__builtin_expect(!!(tcls == cls), true)) {
partially evaluated: __builtin_expect(!!(tcls == cls), true)
TRUEFALSE
yes
Evaluation Count:33
no
Evaluation Count:0
0-33
124 i = lookahead; -
125 ncls = tcls; -
126 action = WB::NoBreak; -
127 }
executed: }
Execution Count:33
33
128 break;
executed: break;
Execution Count:33
33
129 } -
130 } else if (__builtin_expect(!!(ncls == QUnicodeTables::WordBreak_Extend), false)) {
evaluated: __builtin_expect(!!(ncls == QUnicodeTables::WordBreak_Extend), false)
TRUEFALSE
yes
Evaluation Count:120
yes
Evaluation Count:595
executed: }
Execution Count:33
33-595
131 -
132 if (__builtin_expect(!!(action != WB::Break), true))
evaluated: __builtin_expect(!!(action != WB::Break), true)
TRUEFALSE
yes
Evaluation Count:102
yes
Evaluation Count:18
18-102
133 continue;
executed: continue;
Execution Count:102
102
134 }
executed: }
Execution Count:18
18
135 cls = ncls; -
136 if (action == WB::Break) {
evaluated: action == WB::Break
TRUEFALSE
yes
Evaluation Count:297
yes
Evaluation Count:349
297-349
137 attributes[pos].wordBreak = true; -
138 if (currentWordType != WordTypeNone)
evaluated: currentWordType != WordTypeNone
TRUEFALSE
yes
Evaluation Count:89
yes
Evaluation Count:208
89-208
139 attributes[pos].wordEnd = true;
executed: attributes[pos].wordEnd = true;
Execution Count:89
89
140 switch (cls) { -
141 case QUnicodeTables::WordBreak_Katakana: -
142 currentWordType = WordTypeHiraganaKatakana; -
143 attributes[pos].wordStart = true; -
144 break;
never executed: break;
0
145 case QUnicodeTables::WordBreak_ALetter: -
146 case QUnicodeTables::WordBreak_Numeric: -
147 currentWordType = WordTypeAlphaNumeric; -
148 attributes[pos].wordStart = true; -
149 break;
executed: break;
Execution Count:124
124
150 default: -
151 currentWordType = WordTypeNone; -
152 break;
executed: break;
Execution Count:173
173
153 } -
154 }
executed: }
Execution Count:297
297
155 }
executed: }
Execution Count:646
646
156 -
157 if (currentWordType != WordTypeNone)
evaluated: currentWordType != WordTypeNone
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:18
18-35
158 attributes[len].wordEnd = true;
executed: attributes[len].wordEnd = true;
Execution Count:35
35
159 attributes[len].wordBreak = true; -
160}
executed: }
Execution Count:53
53
161 -
162 -
163namespace SB { -
164 -
165enum State { -
166 Initial, -
167 Upper, -
168 UpATerm, -
169 ATerm, -
170 ATermC, -
171 ACS, -
172 STerm, -
173 STermC, -
174 SCS, -
175 BAfterC, -
176 BAfter, -
177 Break, -
178 Lookup -
179}; -
180 -
181static const uchar breakTable[BAfter + 1][QUnicodeTables::SentenceBreak_Close + 1] = { -
182 -
183 { Initial, BAfterC, BAfter , BAfter , Initial, Initial, Initial, Upper , Initial, Initial, ATerm , Initial, STerm , Initial }, -
184 { Initial, BAfterC, BAfter , BAfter , Upper , Initial, Initial, Upper , Initial, Initial, UpATerm, STerm , STerm , Initial }, -
185 -
186 { Lookup , BAfterC, BAfter , BAfter , UpATerm, ACS , Initial, Upper , Break , Initial, ATerm , STerm , STerm , ATermC }, -
187 { Lookup , BAfterC, BAfter , BAfter , ATerm , ACS , Initial, Break , Break , Initial, ATerm , STerm , STerm , ATermC }, -
188 { Lookup , BAfterC, BAfter , BAfter , ATermC , ACS , Initial, Break , Break , Lookup , ATerm , STerm , STerm , ATermC }, -
189 { Lookup , BAfterC, BAfter , BAfter , ACS , ACS , Initial, Break , Break , Lookup , ATerm , STerm , STerm , Lookup }, -
190 -
191 { Break , BAfterC, BAfter , BAfter , STerm , SCS , Break , Break , Break , Break , ATerm , STerm , STerm , STermC }, -
192 { Break , BAfterC, BAfter , BAfter , STermC , SCS , Break , Break , Break , Break , ATerm , STerm , STerm , STermC }, -
193 { Break , BAfterC, BAfter , BAfter , SCS , SCS , Break , Break , Break , Break , ATerm , STerm , STerm , Break }, -
194 { Break , Break , BAfter , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break }, -
195 { Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break }, -
196}; -
197 -
198} -
199 -
200static void getSentenceBreaks(const ushort *string, quint32 len, QCharAttributes *attributes) -
201{ -
202 uchar state = SB::BAfter; -
203 for (quint32 i = 0; i != len; ++i) {
evaluated: i != len
TRUEFALSE
yes
Evaluation Count:213
yes
Evaluation Count:15
15-213
204 quint32 pos = i; -
205 uint ucs4 = string[i]; -
206 if (QChar::isHighSurrogate(ucs4) && i + 1 != len) {
partially evaluated: QChar::isHighSurrogate(ucs4)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:213
never evaluated: i + 1 != len
0-213
207 ushort low = string[i + 1]; -
208 if (QChar::isLowSurrogate(low)) {
never evaluated: QChar::isLowSurrogate(low)
0
209 ucs4 = QChar::surrogateToUcs4(ucs4, low); -
210 ++i; -
211 }
never executed: }
0
212 }
never executed: }
0
213 -
214 const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ucs4); -
215 QUnicodeTables::SentenceBreakClass ncls = (QUnicodeTables::SentenceBreakClass) prop->sentenceBreakClass; -
216 -
217 qt_noop(); -
218 state = SB::breakTable[state][ncls]; -
219 if (__builtin_expect(!!(state == SB::Lookup), false)) {
partially evaluated: __builtin_expect(!!(state == SB::Lookup), false)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:213
0-213
220 state = SB::Break; -
221 for (quint32 lookahead = i + 1; lookahead < len; ++lookahead) {
never evaluated: lookahead < len
0
222 ucs4 = string[lookahead]; -
223 if (QChar::isHighSurrogate(ucs4) && lookahead + 1 != len) {
never evaluated: QChar::isHighSurrogate(ucs4)
never evaluated: lookahead + 1 != len
0
224 ushort low = string[lookahead + 1]; -
225 if (QChar::isLowSurrogate(low)) {
never evaluated: QChar::isLowSurrogate(low)
0
226 ucs4 = QChar::surrogateToUcs4(ucs4, low); -
227 ++lookahead; -
228 }
never executed: }
0
229 }
never executed: }
0
230 -
231 prop = QUnicodeTables::properties(ucs4); -
232 QUnicodeTables::SentenceBreakClass tcls = (QUnicodeTables::SentenceBreakClass) prop->sentenceBreakClass; -
233 switch (tcls) { -
234 case QUnicodeTables::SentenceBreak_Other: -
235 case QUnicodeTables::SentenceBreak_Extend: -
236 case QUnicodeTables::SentenceBreak_Sp: -
237 case QUnicodeTables::SentenceBreak_Numeric: -
238 case QUnicodeTables::SentenceBreak_SContinue: -
239 case QUnicodeTables::SentenceBreak_Close: -
240 continue;
never executed: continue;
0
241 case QUnicodeTables::SentenceBreak_Lower: -
242 i = lookahead; -
243 state = SB::Initial; -
244 break;
never executed: break;
0
245 default: -
246 break;
never executed: break;
0
247 } -
248 break;
never executed: break;
0
249 } -
250 }
never executed: }
0
251 if (__builtin_expect(!!(state == SB::Break), false)) {
evaluated: __builtin_expect(!!(state == SB::Break), false)
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:183
30-183
252 attributes[pos].sentenceBoundary = true; -
253 state = SB::breakTable[SB::Initial][ncls]; -
254 }
executed: }
Execution Count:30
30
255 }
executed: }
Execution Count:213
213
256 -
257 attributes[len].sentenceBoundary = true; -
258}
executed: }
Execution Count:15
15
259namespace LB { -
260 -
261namespace NS { -
262 -
263 -
264 -
265 -
266 -
267enum Action { -
268 None, -
269 Start, -
270 Continue, -
271 Break -
272}; -
273 -
274enum Class { -
275 XX, -
276 PRPO, -
277 OPHY, -
278 NU, -
279 SYIS, -
280 CLCP -
281}; -
282 -
283static const uchar actionTable[CLCP + 1][CLCP + 1] = { -
284 -
285 { None , Start , Start , Start , None , None }, -
286 { None , Start , Continue, Continue, None , None }, -
287 { None , Start , Start , Continue, None , None }, -
288 { Break , Break , Break , Continue, Continue, Continue }, -
289 { Break , Break , Break , Continue, Continue, Continue }, -
290 { Break , Continue, Break , Break , Break , Break }, -
291}; -
292 -
293inline Class toClass(QUnicodeTables::LineBreakClass lbc, QChar::Category category) -
294{ -
295 switch (lbc) { -
296 case QUnicodeTables::LineBreak_AL: -
297 -
298 if (category == QChar::Symbol_Math)
evaluated: category == QChar::Symbol_Math
TRUEFALSE
yes
Evaluation Count:478
yes
Evaluation Count:565024
478-565024
299 return SYIS;
executed: return SYIS;
Execution Count:478
478
300 break;
executed: break;
Execution Count:565024
565024
301 case QUnicodeTables::LineBreak_PR: case QUnicodeTables::LineBreak_PO: -
302 return PRPO;
executed: return PRPO;
Execution Count:535
535
303 case QUnicodeTables::LineBreak_OP: case QUnicodeTables::LineBreak_HY: -
304 return OPHY;
executed: return OPHY;
Execution Count:17407
17407
305 case QUnicodeTables::LineBreak_NU: -
306 return NU;
executed: return NU;
Execution Count:223249
223249
307 case QUnicodeTables::LineBreak_SY: case QUnicodeTables::LineBreak_IS: -
308 return SYIS;
executed: return SYIS;
Execution Count:42633
42633
309 case QUnicodeTables::LineBreak_CL: case QUnicodeTables::LineBreak_CP: -
310 return CLCP;
executed: return CLCP;
Execution Count:11113
11113
311 default: -
312 break;
executed: break;
Execution Count:115233
115233
313 } -
314 return XX;
executed: return XX;
Execution Count:680257
680257
315} -
316 -
317} -
318enum Action { -
319 ProhibitedBreak, PB = ProhibitedBreak, -
320 DirectBreak, DB = DirectBreak, -
321 IndirectBreak, IB = IndirectBreak, -
322 CombiningIndirectBreak, CI = CombiningIndirectBreak, -
323 CombiningProhibitedBreak, CP = CombiningProhibitedBreak -
324}; -
325 -
326static const uchar breakTable[QUnicodeTables::LineBreak_CB + 1][QUnicodeTables::LineBreak_CB + 1] = { -
327 -
328 { PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, CP, PB, PB, PB, PB, PB, PB, PB, PB }, -
329 { DB, PB, PB, IB, IB, PB, PB, PB, PB, DB, DB, DB, DB, DB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB, DB, DB }, -
330 { DB, PB, PB, IB, IB, PB, PB, PB, PB, DB, DB, IB, IB, IB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB, DB, DB }, -
331 { PB, PB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, IB, IB, IB, IB, IB, IB, IB, PB, CI, PB, IB, IB, IB, IB, IB, IB, IB }, -
332 { IB, PB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, IB, IB, IB, IB, IB, IB, IB, PB, CI, PB, IB, IB, IB, IB, IB, IB, IB }, -
333 { DB, PB, PB, IB, IB, IB, PB, PB, PB, DB, DB, DB, DB, DB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB, DB, DB }, -
334 { DB, PB, PB, IB, IB, IB, PB, PB, PB, DB, DB, DB, DB, DB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB, DB, DB }, -
335 { DB, PB, PB, IB, IB, IB, PB, PB, PB, DB, DB, DB, DB, DB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB, DB, DB }, -
336 { DB, PB, PB, IB, IB, IB, PB, PB, PB, DB, DB, DB, IB, IB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB, DB, DB }, -
337 { DB, PB, PB, IB, IB, IB, PB, PB, PB, DB, DB, IB, IB, IB, IB, DB, IB, IB, DB, DB, PB, CI, PB, IB, IB, IB, IB, IB, DB, DB }, -
338 { DB, PB, PB, IB, IB, IB, PB, PB, PB, DB, DB, IB, IB, IB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB, DB, DB }, -
339 { IB, PB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, IB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB, DB, DB }, -
340 { IB, PB, PB, IB, IB, IB, PB, PB, PB, DB, DB, IB, IB, IB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB, DB, DB }, -
341 { IB, PB, PB, IB, IB, IB, PB, PB, PB, DB, DB, IB, IB, IB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB, DB, DB }, -
342 { DB, PB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB, DB, DB }, -
343 { DB, PB, PB, IB, IB, IB, PB, PB, PB, DB, DB, DB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB, DB, DB }, -
344 { DB, PB, PB, IB, DB, IB, PB, PB, PB, DB, DB, IB, DB, DB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB, DB, DB }, -
345 { DB, PB, PB, IB, DB, IB, PB, PB, PB, DB, DB, DB, DB, DB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB, DB, DB }, -
346 { IB, PB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, IB, IB, IB, IB, IB, IB, IB, PB, CI, PB, IB, IB, IB, IB, IB, IB, DB }, -
347 { DB, PB, PB, IB, IB, IB, PB, PB, PB, DB, DB, DB, DB, DB, DB, DB, IB, IB, DB, PB, PB, CI, PB, DB, DB, DB, DB, DB, DB, DB }, -
348 { DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, PB, DB, DB, DB, DB, DB, DB, DB, DB, DB }, -
349 { IB, PB, PB, IB, IB, IB, PB, PB, PB, DB, DB, IB, IB, IB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB, DB, DB }, -
350 { IB, PB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, IB, IB, IB, IB, IB, IB, IB, PB, CI, PB, IB, IB, IB, IB, IB, IB, IB }, -
351 { DB, PB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, IB, IB, DB, DB }, -
352 { DB, PB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, IB, DB, DB }, -
353 { DB, PB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, IB, IB, IB, IB, DB, DB, DB }, -
354 { DB, PB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, IB, IB, DB, DB }, -
355 { DB, PB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, IB, DB, DB }, -
356 { DB, PB, PB, IB, IB, IB, PB, PB, PB, DB, DB, DB, DB, DB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB, IB, DB }, -
357 { DB, PB, PB, IB, IB, DB, PB, PB, PB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB, DB, DB } -
358}; -
359 -
360} -
361 -
362static void getLineBreaks(const ushort *string, quint32 len, QCharAttributes *attributes) -
363{ -
364 quint32 nestart = 0; -
365 LB::NS::Class nelast = LB::NS::XX; -
366 -
367 QUnicodeTables::LineBreakClass lcls = QUnicodeTables::LineBreak_LF; -
368 QUnicodeTables::LineBreakClass cls = lcls; -
369 for (quint32 i = 0; i != len; ++i) {
evaluated: i != len
TRUEFALSE
yes
Evaluation Count:1181744
yes
Evaluation Count:112451
112451-1181744
370 quint32 pos = i; -
371 uint ucs4 = string[i]; -
372 if (QChar::isHighSurrogate(ucs4) && i + 1 != len) {
partially evaluated: QChar::isHighSurrogate(ucs4)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1181744
never evaluated: i + 1 != len
0-1181744
373 ushort low = string[i + 1]; -
374 if (QChar::isLowSurrogate(low)) {
never evaluated: QChar::isLowSurrogate(low)
0
375 ucs4 = QChar::surrogateToUcs4(ucs4, low); -
376 ++i; -
377 }
never executed: }
0
378 }
never executed: }
0
379 -
380 const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ucs4); -
381 QUnicodeTables::LineBreakClass ncls = (QUnicodeTables::LineBreakClass) prop->lineBreakClass; -
382 -
383 if (__builtin_expect(!!(ncls == QUnicodeTables::LineBreak_SA), false)) {
evaluated: __builtin_expect(!!(ncls == QUnicodeTables::LineBreak_SA), false)
TRUEFALSE
yes
Evaluation Count:206868
yes
Evaluation Count:974876
206868-974876
384 -
385 static const int test = (1 << (QChar::Mark_NonSpacing)) | (1 << (QChar::Mark_SpacingCombining)); -
386 if ((1 << (prop->category)) & test)
evaluated: (1 << (prop->category)) & test
TRUEFALSE
yes
Evaluation Count:204984
yes
Evaluation Count:1884
1884-204984
387 ncls = QUnicodeTables::LineBreak_CM;
executed: ncls = QUnicodeTables::LineBreak_CM;
Execution Count:204984
204984
388 }
executed: }
Execution Count:206868
206868
389 if (__builtin_expect(!!(ncls == QUnicodeTables::LineBreak_CM), false)) {
evaluated: __builtin_expect(!!(ncls == QUnicodeTables::LineBreak_CM), false)
TRUEFALSE
yes
Evaluation Count:206121
yes
Evaluation Count:975623
206121-975623
390 -
391 if (lcls == QUnicodeTables::LineBreak_ZW || lcls >= QUnicodeTables::LineBreak_SP)
partially evaluated: lcls == QUnicodeTables::LineBreak_ZW
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:206121
evaluated: lcls >= QUnicodeTables::LineBreak_SP
TRUEFALSE
yes
Evaluation Count:49
yes
Evaluation Count:206072
0-206121
392 ncls = QUnicodeTables::LineBreak_AL;
executed: ncls = QUnicodeTables::LineBreak_AL;
Execution Count:49
49
393 }
executed: }
Execution Count:206121
206121
394 -
395 if (__builtin_expect(!!(ncls != QUnicodeTables::LineBreak_CM), true)) {
evaluated: __builtin_expect(!!(ncls != QUnicodeTables::LineBreak_CM), true)
TRUEFALSE
yes
Evaluation Count:975672
yes
Evaluation Count:206072
206072-975672
396 -
397 LB::NS::Class necur = LB::NS::toClass(ncls, (QChar::Category)prop->category); -
398 switch (LB::NS::actionTable[nelast][necur]) { -
399 case LB::NS::Break: -
400 -
401 for (quint32 j = nestart + 1; j < pos; ++j)
evaluated: j < pos
TRUEFALSE
yes
Evaluation Count:51486
yes
Evaluation Count:25520
25520-51486
402 attributes[j].lineBreak = false;
executed: attributes[j].lineBreak = false;
Execution Count:51486
51486
403 -
404 case LB::NS::None:
code before this statement executed: case LB::NS::None:
Execution Count:25520
25520
405 nelast = LB::NS::XX; -
406 break;
executed: break;
Execution Count:691594
691594
407 case LB::NS::Start: -
408 nestart = i; -
409 -
410 default:
code before this statement executed: default:
Execution Count:112168
112168
411 nelast = necur; -
412 break;
executed: break;
Execution Count:284078
284078
413 } -
414 }
executed: }
Execution Count:975672
975672
415 -
416 if (__builtin_expect(!!(lcls >= QUnicodeTables::LineBreak_CR), false)) {
evaluated: __builtin_expect(!!(lcls >= QUnicodeTables::LineBreak_CR), false)
TRUEFALSE
yes
Evaluation Count:121264
yes
Evaluation Count:1060480
121264-1060480
417 -
418 if (lcls > QUnicodeTables::LineBreak_CR || ncls != QUnicodeTables::LineBreak_LF)
evaluated: lcls > QUnicodeTables::LineBreak_CR
TRUEFALSE
yes
Evaluation Count:121256
yes
Evaluation Count:8
evaluated: ncls != QUnicodeTables::LineBreak_LF
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
4-121256
419 attributes[pos].lineBreak = attributes[pos].mandatoryBreak = true;
executed: attributes[pos].lineBreak = attributes[pos].mandatoryBreak = true;
Execution Count:121260
121260
420 goto next;
executed: goto next;
Execution Count:121264
121264
421 } -
422 -
423 if (__builtin_expect(!!(ncls >= QUnicodeTables::LineBreak_SP), false)) {
evaluated: __builtin_expect(!!(ncls >= QUnicodeTables::LineBreak_SP), false)
TRUEFALSE
yes
Evaluation Count:111731
yes
Evaluation Count:948749
111731-948749
424 if (ncls > QUnicodeTables::LineBreak_SP)
evaluated: ncls > QUnicodeTables::LineBreak_SP
TRUEFALSE
yes
Evaluation Count:8897
yes
Evaluation Count:102834
8897-102834
425 goto next;
executed: goto next;
Execution Count:8897
8897
426 goto next_no_cls_update;
executed: goto next_no_cls_update;
Execution Count:102834
102834
427 } -
428 -
429 -
430 -
431 if (__builtin_expect(!!(cls >= QUnicodeTables::LineBreak_SA), false))
evaluated: __builtin_expect(!!(cls >= QUnicodeTables::LineBreak_SA), false)
TRUEFALSE
yes
Evaluation Count:1897
yes
Evaluation Count:946852
1897-946852
432 cls = QUnicodeTables::LineBreak_AL;
executed: cls = QUnicodeTables::LineBreak_AL;
Execution Count:1897
1897
433 -
434 switch (LB::breakTable[cls][ncls < QUnicodeTables::LineBreak_SA ? ncls : QUnicodeTables::LineBreak_AL]) { -
435 case LB::DirectBreak: -
436 attributes[pos].lineBreak = true; -
437 break;
executed: break;
Execution Count:33775
33775
438 case LB::IndirectBreak: -
439 if (lcls == QUnicodeTables::LineBreak_SP)
evaluated: lcls == QUnicodeTables::LineBreak_SP
TRUEFALSE
yes
Evaluation Count:99604
yes
Evaluation Count:544874
99604-544874
440 attributes[pos].lineBreak = true;
executed: attributes[pos].lineBreak = true;
Execution Count:99604
99604
441 break;
executed: break;
Execution Count:644478
644478
442 case LB::CombiningIndirectBreak: -
443 if (lcls != QUnicodeTables::LineBreak_SP)
partially evaluated: lcls != QUnicodeTables::LineBreak_SP
TRUEFALSE
yes
Evaluation Count:206072
no
Evaluation Count:0
0-206072
444 goto next_no_cls_update;
executed: goto next_no_cls_update;
Execution Count:206072
206072
445 attributes[pos].lineBreak = true; -
446 break;
never executed: break;
0
447 case LB::CombiningProhibitedBreak: -
448 if (lcls != QUnicodeTables::LineBreak_SP)
never evaluated: lcls != QUnicodeTables::LineBreak_SP
0
449 goto next_no_cls_update;
never executed: goto next_no_cls_update;
0
450 break;
never executed: break;
0
451 case LB::ProhibitedBreak: -
452 -
453 default: -
454 break;
executed: break;
Execution Count:64424
64424
455 } -
456 -
457 next:
code before this statement executed: next:
Execution Count:742677
742677
458 cls = ncls; -
459 next_no_cls_update:
code before this statement executed: next_no_cls_update:
Execution Count:872838
872838
460 lcls = ncls; -
461 }
executed: }
Execution Count:1181744
1181744
462 -
463 if (__builtin_expect(!!(LB::NS::actionTable[nelast][LB::NS::XX] == LB::NS::Break), false)) {
evaluated: __builtin_expect(!!(LB::NS::actionTable[nelast][LB::NS::XX] == LB::NS::Break), false)
TRUEFALSE
yes
Evaluation Count:81016
yes
Evaluation Count:31435
31435-81016
464 -
465 for (quint32 j = nestart + 1; j < len; ++j)
evaluated: j < len
TRUEFALSE
yes
Evaluation Count:120405
yes
Evaluation Count:81016
81016-120405
466 attributes[j].lineBreak = false;
executed: attributes[j].lineBreak = false;
Execution Count:120405
120405
467 }
executed: }
Execution Count:81016
81016
468 -
469 attributes[0].lineBreak = attributes[0].mandatoryBreak = false; -
470 attributes[len].lineBreak = attributes[len].mandatoryBreak = true; -
471}
executed: }
Execution Count:112451
112451
472 -
473 -
474static void getWhiteSpaces(const ushort *string, quint32 len, QCharAttributes *attributes) -
475{ -
476 for (quint32 i = 0; i != len; ++i) {
evaluated: i != len
TRUEFALSE
yes
Evaluation Count:1181411
yes
Evaluation Count:112424
112424-1181411
477 uint ucs4 = string[i]; -
478 if (QChar::isHighSurrogate(ucs4) && i + 1 != len) {
partially evaluated: QChar::isHighSurrogate(ucs4)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1181411
never evaluated: i + 1 != len
0-1181411
479 ushort low = string[i + 1]; -
480 if (QChar::isLowSurrogate(low)) {
never evaluated: QChar::isLowSurrogate(low)
0
481 ucs4 = QChar::surrogateToUcs4(ucs4, low); -
482 ++i; -
483 }
never executed: }
0
484 }
never executed: }
0
485 -
486 if (__builtin_expect(!!(QChar::isSpace(ucs4)), false))
evaluated: __builtin_expect(!!(QChar::isSpace(ucs4)), false)
TRUEFALSE
yes
Evaluation Count:111747
yes
Evaluation Count:1069664
111747-1069664
487 attributes[i].whiteSpace = true;
executed: attributes[i].whiteSpace = true;
Execution Count:111747
111747
488 }
executed: }
Execution Count:1181411
1181411
489}
executed: }
Execution Count:112424
112424
490 -
491 -
492__attribute__((visibility("default"))) void initCharAttributes(const ushort *string, int length, -
493 const ScriptItem *items, int numItems, -
494 QCharAttributes *attributes, CharAttributeOptions options) -
495{ -
496 if (length <= 0)
evaluated: length <= 0
TRUEFALSE
yes
Evaluation Count:61
yes
Evaluation Count:112520
61-112520
497 return;
executed: return;
Execution Count:61
61
498 -
499 if (!(options & DontClearAttributes))
partially evaluated: !(options & DontClearAttributes)
TRUEFALSE
yes
Evaluation Count:112520
no
Evaluation Count:0
0-112520
500 ::memset(attributes, 0, (length + 1) * sizeof(QCharAttributes));
executed: ::memset(attributes, 0, (length + 1) * sizeof(QCharAttributes));
Execution Count:112520
112520
501 -
502 if (options & GraphemeBreaks)
evaluated: options & GraphemeBreaks
TRUEFALSE
yes
Evaluation Count:112425
yes
Evaluation Count:95
95-112425
503 getGraphemeBreaks(string, length, attributes);
executed: getGraphemeBreaks(string, length, attributes);
Execution Count:112425
112425
504 if (options & WordBreaks)
evaluated: options & WordBreaks
TRUEFALSE
yes
Evaluation Count:53
yes
Evaluation Count:112467
53-112467
505 getWordBreaks(string, length, attributes);
executed: getWordBreaks(string, length, attributes);
Execution Count:53
53
506 if (options & SentenceBreaks)
evaluated: options & SentenceBreaks
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:112505
15-112505
507 getSentenceBreaks(string, length, attributes);
executed: getSentenceBreaks(string, length, attributes);
Execution Count:15
15
508 if (options & LineBreaks)
evaluated: options & LineBreaks
TRUEFALSE
yes
Evaluation Count:112451
yes
Evaluation Count:69
69-112451
509 getLineBreaks(string, length, attributes);
executed: getLineBreaks(string, length, attributes);
Execution Count:112451
112451
510 if (options & WhiteSpaces)
evaluated: options & WhiteSpaces
TRUEFALSE
yes
Evaluation Count:112424
yes
Evaluation Count:96
96-112424
511 getWhiteSpaces(string, length, attributes);
executed: getWhiteSpaces(string, length, attributes);
Execution Count:112424
112424
512 -
513 if (!items || numItems <= 0)
partially evaluated: !items
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:112520
partially evaluated: numItems <= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:112520
0-112520
514 return;
never executed: return;
0
515 if (!qt_initcharattributes_default_algorithm_only) {
partially evaluated: !qt_initcharattributes_default_algorithm_only
TRUEFALSE
yes
Evaluation Count:112520
no
Evaluation Count:0
0-112520
516 QVarLengthArray<HB_ScriptItem, 64> scriptItems; -
517 scriptItems.reserve(numItems); -
518 int start = 0; -
519 for (int i = start + 1; i < numItems; ++i) {
evaluated: i < numItems
TRUEFALSE
yes
Evaluation Count:18959
yes
Evaluation Count:112520
18959-112520
520 if (items[i].script == items[start].script)
evaluated: items[i].script == items[start].script
TRUEFALSE
yes
Evaluation Count:18377
yes
Evaluation Count:582
582-18377
521 continue;
executed: continue;
Execution Count:18377
18377
522 HB_ScriptItem item; -
523 item.pos = items[start].position; -
524 item.length = items[i].position - items[start].position; -
525 item.script = (HB_Script)items[start].script; -
526 item.bidiLevel = 0; -
527 scriptItems.append(item); -
528 start = i; -
529 }
executed: }
Execution Count:582
582
530 if (items[start].position + 1 < length) {
evaluated: items[start].position + 1 < length
TRUEFALSE
yes
Evaluation Count:93234
yes
Evaluation Count:19286
19286-93234
531 HB_ScriptItem item; -
532 item.pos = items[start].position; -
533 item.length = length - items[start].position; -
534 item.script = (HB_Script)items[start].script; -
535 item.bidiLevel = 0; -
536 scriptItems.append(item); -
537 }
executed: }
Execution Count:93234
93234
538 static_assert(bool(sizeof(QCharAttributes) == sizeof(HB_CharAttributes)), "sizeof(QCharAttributes) == sizeof(HB_CharAttributes)"); -
539 HB_GetTailoredCharAttributes(string, length, -
540 scriptItems.constData(), scriptItems.size(), -
541 reinterpret_cast<HB_CharAttributes *>(attributes)); -
542 }
executed: }
Execution Count:112520
112520
543}
executed: }
Execution Count:112520
112520
544 -
545} -
546 -
547 -
548 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial