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:3197318
yes
Evaluation Count:197519
197519-3197318
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:3197318
never evaluated: i + 1 != len
0-3197318
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:2991307
yes
Evaluation Count:206011
206011-2991307
50 attributes[pos].graphemeBoundary = true;
executed: attributes[pos].graphemeBoundary = true;
Execution Count:2991307
2991307
51 -
52 lcls = cls; -
53 }
executed: }
Execution Count:3197318
3197318
54 -
55 attributes[len].graphemeBoundary = true; -
56}
executed: }
Execution Count:197519
197519
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:1774
yes
Evaluation Count:62
62-1774
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:1774
never evaluated: i + 1 != len
0-1774
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:1741
33-1741
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:1621
executed: }
Execution Count:33
33-1621
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:783
yes
Evaluation Count:889
783-889
137 attributes[pos].wordBreak = true; -
138 if (currentWordType != WordTypeNone)
evaluated: currentWordType != WordTypeNone
TRUEFALSE
yes
Evaluation Count:305
yes
Evaluation Count:478
305-478
139 attributes[pos].wordEnd = true;
executed: attributes[pos].wordEnd = true;
Execution Count:305
305
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:349
349
150 default: -
151 currentWordType = WordTypeNone; -
152 break;
executed: break;
Execution Count:434
434
153 } -
154 }
executed: }
Execution Count:783
783
155 }
executed: }
Execution Count:1672
1672
156 -
157 if (currentWordType != WordTypeNone)
evaluated: currentWordType != WordTypeNone
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:18
18-44
158 attributes[len].wordEnd = true;
executed: attributes[len].wordEnd = true;
Execution Count:44
44
159 attributes[len].wordBreak = true; -
160}
executed: }
Execution Count:62
62
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:555
yes
Evaluation Count:18
18-555
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:555
never evaluated: i + 1 != len
0-555
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:555
0-555
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:42
yes
Evaluation Count:513
42-513
252 attributes[pos].sentenceBoundary = true; -
253 state = SB::breakTable[SB::Initial][ncls]; -
254 }
executed: }
Execution Count:42
42
255 }
executed: }
Execution Count:555
555
256 -
257 attributes[len].sentenceBoundary = true; -
258}
executed: }
Execution Count:18
18
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:612
yes
Evaluation Count:2071155
612-2071155
299 return SYIS;
executed: return SYIS;
Execution Count:612
612
300 break;
executed: break;
Execution Count:2071155
2071155
301 case QUnicodeTables::LineBreak_PR: case QUnicodeTables::LineBreak_PO: -
302 return PRPO;
executed: return PRPO;
Execution Count:652
652
303 case QUnicodeTables::LineBreak_OP: case QUnicodeTables::LineBreak_HY: -
304 return OPHY;
executed: return OPHY;
Execution Count:18432
18432
305 case QUnicodeTables::LineBreak_NU: -
306 return NU;
executed: return NU;
Execution Count:456784
456784
307 case QUnicodeTables::LineBreak_SY: case QUnicodeTables::LineBreak_IS: -
308 return SYIS;
executed: return SYIS;
Execution Count:67444
67444
309 case QUnicodeTables::LineBreak_CL: case QUnicodeTables::LineBreak_CP: -
310 return CLCP;
executed: return CLCP;
Execution Count:11280
11280
311 default: -
312 break;
executed: break;
Execution Count:364641
364641
313 } -
314 return XX;
executed: return XX;
Execution Count:2435796
2435796
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:3197072
yes
Evaluation Count:197540
197540-3197072
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:3197072
never evaluated: i + 1 != len
0-3197072
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:2990204
206868-2990204
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:2990951
206121-2990951
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:2991000
yes
Evaluation Count:206072
206072-2991000
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:97498
yes
Evaluation Count:153014
97498-153014
402 attributes[j].lineBreak = false;
executed: attributes[j].lineBreak = false;
Execution Count:97498
97498
403 -
404 case LB::NS::None:
code before this statement executed: case LB::NS::None:
Execution Count:153014
153014
405 nelast = LB::NS::XX; -
406 break;
executed: break;
Execution Count:2467096
2467096
407 case LB::NS::Start: -
408 nestart = i; -
409 -
410 default:
code before this statement executed: default:
Execution Count:300113
300113
411 nelast = necur; -
412 break;
executed: break;
Execution Count:523904
523904
413 } -
414 }
executed: }
Execution Count:2991000
2991000
415 -
416 if (__builtin_expect(!!(lcls >= QUnicodeTables::LineBreak_CR), false)) {
evaluated: __builtin_expect(!!(lcls >= QUnicodeTables::LineBreak_CR), false)
TRUEFALSE
yes
Evaluation Count:207541
yes
Evaluation Count:2989531
207541-2989531
417 -
418 if (lcls > QUnicodeTables::LineBreak_CR || ncls != QUnicodeTables::LineBreak_LF)
evaluated: lcls > QUnicodeTables::LineBreak_CR
TRUEFALSE
yes
Evaluation Count:207533
yes
Evaluation Count:8
evaluated: ncls != QUnicodeTables::LineBreak_LF
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
4-207533
419 attributes[pos].lineBreak = attributes[pos].mandatoryBreak = true;
executed: attributes[pos].lineBreak = attributes[pos].mandatoryBreak = true;
Execution Count:207537
207537
420 goto next;
executed: goto next;
Execution Count:207541
207541
421 } -
422 -
423 if (__builtin_expect(!!(ncls >= QUnicodeTables::LineBreak_SP), false)) {
evaluated: __builtin_expect(!!(ncls >= QUnicodeTables::LineBreak_SP), false)
TRUEFALSE
yes
Evaluation Count:360706
yes
Evaluation Count:2628825
360706-2628825
424 if (ncls > QUnicodeTables::LineBreak_SP)
evaluated: ncls > QUnicodeTables::LineBreak_SP
TRUEFALSE
yes
Evaluation Count:10102
yes
Evaluation Count:350604
10102-350604
425 goto next;
executed: goto next;
Execution Count:10102
10102
426 goto next_no_cls_update;
executed: goto next_no_cls_update;
Execution Count:350604
350604
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:1941
yes
Evaluation Count:2626884
1941-2626884
432 cls = QUnicodeTables::LineBreak_AL;
executed: cls = QUnicodeTables::LineBreak_AL;
Execution Count:1941
1941
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:35794
35794
438 case LB::IndirectBreak: -
439 if (lcls == QUnicodeTables::LineBreak_SP)
evaluated: lcls == QUnicodeTables::LineBreak_SP
TRUEFALSE
yes
Evaluation Count:345761
yes
Evaluation Count:1951497
345761-1951497
440 attributes[pos].lineBreak = true;
executed: attributes[pos].lineBreak = true;
Execution Count:345761
345761
441 break;
executed: break;
Execution Count:2297258
2297258
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:89701
89701
455 } -
456 -
457 next:
code before this statement executed: next:
Execution Count:2422753
2422753
458 cls = ncls; -
459 next_no_cls_update:
code before this statement executed: next_no_cls_update:
Execution Count:2640396
2640396
460 lcls = ncls; -
461 }
executed: }
Execution Count:3197072
3197072
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:140428
yes
Evaluation Count:57112
57112-140428
464 -
465 for (quint32 j = nestart + 1; j < len; ++j)
evaluated: j < len
TRUEFALSE
yes
Evaluation Count:126257
yes
Evaluation Count:140428
126257-140428
466 attributes[j].lineBreak = false;
executed: attributes[j].lineBreak = false;
Execution Count:126257
126257
467 }
executed: }
Execution Count:140428
140428
468 -
469 attributes[0].lineBreak = attributes[0].mandatoryBreak = false; -
470 attributes[len].lineBreak = attributes[len].mandatoryBreak = true; -
471}
executed: }
Execution Count:197540
197540
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:3196739
yes
Evaluation Count:197513
197513-3196739
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:3196739
never evaluated: i + 1 != len
0-3196739
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:360892
yes
Evaluation Count:2835847
360892-2835847
487 attributes[i].whiteSpace = true;
executed: attributes[i].whiteSpace = true;
Execution Count:360892
360892
488 }
executed: }
Execution Count:3196739
3196739
489}
executed: }
Execution Count:197513
197513
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:59
yes
Evaluation Count:197626
59-197626
497 return;
executed: return;
Execution Count:59
59
498 -
499 if (!(options & DontClearAttributes))
partially evaluated: !(options & DontClearAttributes)
TRUEFALSE
yes
Evaluation Count:197626
no
Evaluation Count:0
0-197626
500 ::memset(attributes, 0, (length + 1) * sizeof(QCharAttributes));
executed: ::memset(attributes, 0, (length + 1) * sizeof(QCharAttributes));
Execution Count:197626
197626
501 -
502 if (options & GraphemeBreaks)
evaluated: options & GraphemeBreaks
TRUEFALSE
yes
Evaluation Count:197519
yes
Evaluation Count:107
107-197519
503 getGraphemeBreaks(string, length, attributes);
executed: getGraphemeBreaks(string, length, attributes);
Execution Count:197519
197519
504 if (options & WordBreaks)
evaluated: options & WordBreaks
TRUEFALSE
yes
Evaluation Count:62
yes
Evaluation Count:197564
62-197564
505 getWordBreaks(string, length, attributes);
executed: getWordBreaks(string, length, attributes);
Execution Count:62
62
506 if (options & SentenceBreaks)
evaluated: options & SentenceBreaks
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:197608
18-197608
507 getSentenceBreaks(string, length, attributes);
executed: getSentenceBreaks(string, length, attributes);
Execution Count:18
18
508 if (options & LineBreaks)
evaluated: options & LineBreaks
TRUEFALSE
yes
Evaluation Count:197540
yes
Evaluation Count:86
86-197540
509 getLineBreaks(string, length, attributes);
executed: getLineBreaks(string, length, attributes);
Execution Count:197540
197540
510 if (options & WhiteSpaces)
evaluated: options & WhiteSpaces
TRUEFALSE
yes
Evaluation Count:197513
yes
Evaluation Count:113
113-197513
511 getWhiteSpaces(string, length, attributes);
executed: getWhiteSpaces(string, length, attributes);
Execution Count:197513
197513
512 -
513 if (!items || numItems <= 0)
partially evaluated: !items
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:197626
partially evaluated: numItems <= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:197626
0-197626
514 return;
never executed: return;
0
515 if (!qt_initcharattributes_default_algorithm_only) {
partially evaluated: !qt_initcharattributes_default_algorithm_only
TRUEFALSE
yes
Evaluation Count:197626
no
Evaluation Count:0
0-197626
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:21776
yes
Evaluation Count:197626
21776-197626
520 if (items[i].script == items[start].script)
evaluated: items[i].script == items[start].script
TRUEFALSE
yes
Evaluation Count:21170
yes
Evaluation Count:606
606-21170
521 continue;
executed: continue;
Execution Count:21170
21170
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:606
606
530 if (items[start].position + 1 < length) {
evaluated: items[start].position + 1 < length
TRUEFALSE
yes
Evaluation Count:176027
yes
Evaluation Count:21599
21599-176027
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:176027
176027
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:197626
197626
543}
executed: }
Execution Count:197626
197626
544 -
545} -
546 -
547 -
548 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial