tools/qunicodetools.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtCore module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qunicodetools_p.h" -
43 -
44#include "qunicodetables_p.h" -
45#include "qvarlengtharray.h" -
46 -
47#include <private/harfbuzz-shaper.h> -
48 -
49#define FLAG(x) (1 << (x)) -
50 -
51QT_BEGIN_NAMESPACE -
52 -
53Q_AUTOTEST_EXPORT int qt_initcharattributes_default_algorithm_only = 0; -
54 -
55namespace QUnicodeTools { -
56 -
57// ----------------------------------------------------------------------------------------------------- -
58// -
59// The text boundaries determination algorithm. -
60// See http://www.unicode.org/reports/tr29/tr29-21.html -
61// -
62// ----------------------------------------------------------------------------------------------------- -
63 -
64namespace GB { -
65 -
66static const uchar breakTable[QUnicodeTables::GraphemeBreak_LVT + 1][QUnicodeTables::GraphemeBreak_LVT + 1] = { -
67// Other CR LF Control Extend RI Prepend S-Mark L V T LV LVT -
68 { true , true , true , true , false, true , true , false, true , true , true , true , true }, // Other -
69 { true , true , false, true , true , true , true , true , true , true , true , true , true }, // CR -
70 { true , true , true , true , true , true , true , true , true , true , true , true , true }, // LF -
71 { true , true , true , true , true , true , true , true , true , true , true , true , true }, // Control -
72 { true , true , true , true , false, true , true , false, true , true , true , true , true }, // Extend -
73 { true , true , true , true , false, false, true , false, true , true , true , true , true }, // RegionalIndicator -
74 { false, true , true , true , false, false, false, false, false, false, false, false, false }, // Prepend -
75 { true , true , true , true , false, true , true , false, true , true , true , true , true }, // SpacingMark -
76 { true , true , true , true , false, true , true , false, false, false, true , false, false }, // L -
77 { true , true , true , true , false, true , true , false, true , false, false, true , true }, // V -
78 { true , true , true , true , false, true , true , false, true , true , false, true , true }, // T -
79 { true , true , true , true , false, true , true , false, true , false, false, true , true }, // LV -
80 { true , true , true , true , false, true , true , false, true , true , false, true , true }, // LVT -
81}; -
82 -
83} // namespace GB -
84 -
85static void getGraphemeBreaks(const ushort *string, quint32 len, QCharAttributes *attributes) -
86{ -
87 QUnicodeTables::GraphemeBreakClass lcls = QUnicodeTables::GraphemeBreak_LF; // to meet GB1
executed (the execution status of this line is deduced): QUnicodeTables::GraphemeBreakClass lcls = QUnicodeTables::GraphemeBreak_LF;
-
88 for (quint32 i = 0; i != len; ++i) {
evaluated: i != len
TRUEFALSE
yes
Evaluation Count:3197318
yes
Evaluation Count:197519
197519-3197318
89 quint32 pos = i;
executed (the execution status of this line is deduced): quint32 pos = i;
-
90 uint ucs4 = string[i];
executed (the execution status of this line is deduced): uint ucs4 = string[i];
-
91 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
92 ushort low = string[i + 1];
never executed (the execution status of this line is deduced): ushort low = string[i + 1];
-
93 if (QChar::isLowSurrogate(low)) {
never evaluated: QChar::isLowSurrogate(low)
0
94 ucs4 = QChar::surrogateToUcs4(ucs4, low);
never executed (the execution status of this line is deduced): ucs4 = QChar::surrogateToUcs4(ucs4, low);
-
95 ++i;
never executed (the execution status of this line is deduced): ++i;
-
96 }
never executed: }
0
97 }
never executed: }
0
98 -
99 const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ucs4);
executed (the execution status of this line is deduced): const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ucs4);
-
100 QUnicodeTables::GraphemeBreakClass cls = (QUnicodeTables::GraphemeBreakClass) prop->graphemeBreakClass;
executed (the execution status of this line is deduced): QUnicodeTables::GraphemeBreakClass cls = (QUnicodeTables::GraphemeBreakClass) prop->graphemeBreakClass;
-
101 -
102 if (Q_LIKELY(GB::breakTable[lcls][cls]))
evaluated: __builtin_expect(!!(GB::breakTable[lcls][cls]), true)
TRUEFALSE
yes
Evaluation Count:2991307
yes
Evaluation Count:206011
206011-2991307
103 attributes[pos].graphemeBoundary = true;
executed: attributes[pos].graphemeBoundary = true;
Execution Count:2991307
2991307
104 -
105 lcls = cls;
executed (the execution status of this line is deduced): lcls = cls;
-
106 }
executed: }
Execution Count:3197318
3197318
107 -
108 attributes[len].graphemeBoundary = true; // GB2
executed (the execution status of this line is deduced): attributes[len].graphemeBoundary = true;
-
109}
executed: }
Execution Count:197519
197519
110 -
111 -
112namespace WB { -
113 -
114enum Action { -
115 NoBreak = 0, -
116 Break = 1, -
117 Lookup = 2 -
118}; -
119 -
120static const uchar breakTable[QUnicodeTables::WordBreak_ExtendNumLet + 1][QUnicodeTables::WordBreak_ExtendNumLet + 1] = { -
121// Other CR LF Newline Extend RI Katakana ALetter MidNumLet MidLetter MidNum Numeric ExtendNumLet -
122 { Break , Break , Break , Break , NoBreak, Break , Break , Break , Break , Break , Break , Break , Break }, // Other -
123 { Break , Break , NoBreak, Break , Break , Break , Break , Break , Break , Break , Break , Break , Break }, // CR -
124 { Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break }, // LF -
125 { Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break }, // Newline -
126 { Break , Break , Break , Break , NoBreak, Break , Break , Break , Break , Break , Break , Break , Break }, // Extend -
127 { Break , Break , Break , Break , NoBreak, NoBreak, Break , Break , Break , Break , Break , Break , Break }, // RegionalIndicator -
128 { Break , Break , Break , Break , NoBreak, Break , NoBreak, Break , Break , Break , Break , Break , NoBreak }, // Katakana -
129 { Break , Break , Break , Break , NoBreak, Break , Break , NoBreak, Lookup , Lookup , Break , NoBreak, NoBreak }, // ALetter -
130 { Break , Break , Break , Break , NoBreak, Break , Break , Break , Break , Break , Break , Break , Break }, // MidNumLet -
131 { Break , Break , Break , Break , NoBreak, Break , Break , Break , Break , Break , Break , Break , Break }, // MidLetter -
132 { Break , Break , Break , Break , NoBreak, Break , Break , Break , Break , Break , Break , Break , Break }, // MidNum -
133 { Break , Break , Break , Break , NoBreak, Break , Break , NoBreak, Lookup , Break , Lookup , NoBreak, NoBreak }, // Numeric -
134 { Break , Break , Break , Break , NoBreak, Break , NoBreak, NoBreak, Break , Break , Break , NoBreak, NoBreak }, // ExtendNumLet -
135}; -
136 -
137} // namespace WB -
138 -
139static void getWordBreaks(const ushort *string, quint32 len, QCharAttributes *attributes) -
140{ -
141 enum WordType {
executed (the execution status of this line is deduced): enum WordType {
-
142 WordTypeNone, WordTypeAlphaNumeric, WordTypeHiraganaKatakana
executed (the execution status of this line is deduced): WordTypeNone, WordTypeAlphaNumeric, WordTypeHiraganaKatakana
-
143 } currentWordType = WordTypeNone;
executed (the execution status of this line is deduced): } currentWordType = WordTypeNone;
-
144 -
145 QUnicodeTables::WordBreakClass cls = QUnicodeTables::WordBreak_LF; // to meet WB1
executed (the execution status of this line is deduced): QUnicodeTables::WordBreakClass cls = QUnicodeTables::WordBreak_LF;
-
146 for (quint32 i = 0; i != len; ++i) {
evaluated: i != len
TRUEFALSE
yes
Evaluation Count:1774
yes
Evaluation Count:62
62-1774
147 quint32 pos = i;
executed (the execution status of this line is deduced): quint32 pos = i;
-
148 uint ucs4 = string[i];
executed (the execution status of this line is deduced): uint ucs4 = string[i];
-
149 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
150 ushort low = string[i + 1];
never executed (the execution status of this line is deduced): ushort low = string[i + 1];
-
151 if (QChar::isLowSurrogate(low)) {
never evaluated: QChar::isLowSurrogate(low)
0
152 ucs4 = QChar::surrogateToUcs4(ucs4, low);
never executed (the execution status of this line is deduced): ucs4 = QChar::surrogateToUcs4(ucs4, low);
-
153 ++i;
never executed (the execution status of this line is deduced): ++i;
-
154 }
never executed: }
0
155 }
never executed: }
0
156 -
157 const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ucs4);
executed (the execution status of this line is deduced): const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ucs4);
-
158 QUnicodeTables::WordBreakClass ncls = (QUnicodeTables::WordBreakClass) prop->wordBreakClass;
executed (the execution status of this line is deduced): QUnicodeTables::WordBreakClass ncls = (QUnicodeTables::WordBreakClass) prop->wordBreakClass;
-
159#ifdef QT_BUILD_INTERNAL -
160 if (qt_initcharattributes_default_algorithm_only) { -
161 // as of Unicode 5.1, some punctuation marks were mapped to MidLetter and MidNumLet -
162 // which caused "hi.there" to be treated like if it were just a single word; -
163 // by remapping those characters in the Unicode tables generator. -
164 // this code is needed to pass the coverage tests; remove once the issue is fixed. -
165 if (ucs4 == 0x002E) // FULL STOP -
166 ncls = QUnicodeTables::WordBreak_MidNumLet; -
167 else if (ucs4 == 0x003A) // COLON -
168 ncls = QUnicodeTables::WordBreak_MidLetter; -
169 } -
170#endif -
171 -
172 uchar action = WB::breakTable[cls][ncls];
executed (the execution status of this line is deduced): uchar action = WB::breakTable[cls][ncls];
-
173 if (Q_UNLIKELY(action == WB::Lookup)) {
evaluated: __builtin_expect(!!(action == WB::Lookup), false)
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:1741
33-1741
174 action = WB::Break;
executed (the execution status of this line is deduced): action = WB::Break;
-
175 for (quint32 lookahead = i + 1; lookahead < len; ++lookahead) {
partially evaluated: lookahead < len
TRUEFALSE
yes
Evaluation Count:45
no
Evaluation Count:0
0-45
176 ucs4 = string[lookahead];
executed (the execution status of this line is deduced): ucs4 = string[lookahead];
-
177 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
178 ushort low = string[lookahead + 1];
never executed (the execution status of this line is deduced): ushort low = string[lookahead + 1];
-
179 if (QChar::isLowSurrogate(low)) {
never evaluated: QChar::isLowSurrogate(low)
0
180 ucs4 = QChar::surrogateToUcs4(ucs4, low);
never executed (the execution status of this line is deduced): ucs4 = QChar::surrogateToUcs4(ucs4, low);
-
181 ++lookahead;
never executed (the execution status of this line is deduced): ++lookahead;
-
182 }
never executed: }
0
183 }
never executed: }
0
184 -
185 prop = QUnicodeTables::properties(ucs4);
executed (the execution status of this line is deduced): prop = QUnicodeTables::properties(ucs4);
-
186 QUnicodeTables::WordBreakClass tcls = (QUnicodeTables::WordBreakClass) prop->wordBreakClass;
executed (the execution status of this line is deduced): QUnicodeTables::WordBreakClass tcls = (QUnicodeTables::WordBreakClass) prop->wordBreakClass;
-
187 if (Q_UNLIKELY(tcls == QUnicodeTables::WordBreak_Extend))
evaluated: __builtin_expect(!!(tcls == QUnicodeTables::WordBreak_Extend), false)
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:33
12-33
188 continue;
executed: continue;
Execution Count:12
12
189 if (Q_LIKELY(tcls == cls)) {
partially evaluated: __builtin_expect(!!(tcls == cls), true)
TRUEFALSE
yes
Evaluation Count:33
no
Evaluation Count:0
0-33
190 i = lookahead;
executed (the execution status of this line is deduced): i = lookahead;
-
191 ncls = tcls;
executed (the execution status of this line is deduced): ncls = tcls;
-
192 action = WB::NoBreak;
executed (the execution status of this line is deduced): action = WB::NoBreak;
-
193 }
executed: }
Execution Count:33
33
194 break;
executed: break;
Execution Count:33
33
195 } -
196 } else if (Q_UNLIKELY(ncls == QUnicodeTables::WordBreak_Extend)) {
executed: }
Execution Count:33
evaluated: __builtin_expect(!!(ncls == QUnicodeTables::WordBreak_Extend), false)
TRUEFALSE
yes
Evaluation Count:120
yes
Evaluation Count:1621
33-1621
197 // WB4: X(Extend|Format)* -> X -
198 if (Q_LIKELY(action != WB::Break))
evaluated: __builtin_expect(!!(action != WB::Break), true)
TRUEFALSE
yes
Evaluation Count:102
yes
Evaluation Count:18
18-102
199 continue;
executed: continue;
Execution Count:102
102
200 }
executed: }
Execution Count:18
18
201 cls = ncls;
executed (the execution status of this line is deduced): cls = ncls;
-
202 if (action == WB::Break) {
evaluated: action == WB::Break
TRUEFALSE
yes
Evaluation Count:783
yes
Evaluation Count:889
783-889
203 attributes[pos].wordBreak = true;
executed (the execution status of this line is deduced): attributes[pos].wordBreak = true;
-
204 if (currentWordType != WordTypeNone)
evaluated: currentWordType != WordTypeNone
TRUEFALSE
yes
Evaluation Count:305
yes
Evaluation Count:478
305-478
205 attributes[pos].wordEnd = true;
executed: attributes[pos].wordEnd = true;
Execution Count:305
305
206 switch (cls) { -
207 case QUnicodeTables::WordBreak_Katakana: -
208 currentWordType = WordTypeHiraganaKatakana;
never executed (the execution status of this line is deduced): currentWordType = WordTypeHiraganaKatakana;
-
209 attributes[pos].wordStart = true;
never executed (the execution status of this line is deduced): attributes[pos].wordStart = true;
-
210 break;
never executed: break;
0
211 case QUnicodeTables::WordBreak_ALetter: -
212 case QUnicodeTables::WordBreak_Numeric: -
213 currentWordType = WordTypeAlphaNumeric;
executed (the execution status of this line is deduced): currentWordType = WordTypeAlphaNumeric;
-
214 attributes[pos].wordStart = true;
executed (the execution status of this line is deduced): attributes[pos].wordStart = true;
-
215 break;
executed: break;
Execution Count:349
349
216 default: -
217 currentWordType = WordTypeNone;
executed (the execution status of this line is deduced): currentWordType = WordTypeNone;
-
218 break;
executed: break;
Execution Count:434
434
219 } -
220 }
executed: }
Execution Count:783
783
221 }
executed: }
Execution Count:1672
1672
222 -
223 if (currentWordType != WordTypeNone)
evaluated: currentWordType != WordTypeNone
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:18
18-44
224 attributes[len].wordEnd = true;
executed: attributes[len].wordEnd = true;
Execution Count:44
44
225 attributes[len].wordBreak = true; // WB2
executed (the execution status of this line is deduced): attributes[len].wordBreak = true;
-
226}
executed: }
Execution Count:62
62
227 -
228 -
229namespace SB { -
230 -
231enum State { -
232 Initial, -
233 Upper, -
234 UpATerm, -
235 ATerm, -
236 ATermC, -
237 ACS, -
238 STerm, -
239 STermC, -
240 SCS, -
241 BAfterC, -
242 BAfter, -
243 Break, -
244 Lookup -
245}; -
246 -
247static const uchar breakTable[BAfter + 1][QUnicodeTables::SentenceBreak_Close + 1] = { -
248// Other CR LF Sep Extend Sp Lower Upper OLetter Numeric ATerm SContinue STerm Close -
249 { Initial, BAfterC, BAfter , BAfter , Initial, Initial, Initial, Upper , Initial, Initial, ATerm , Initial, STerm , Initial }, // Initial -
250 { Initial, BAfterC, BAfter , BAfter , Upper , Initial, Initial, Upper , Initial, Initial, UpATerm, STerm , STerm , Initial }, // Upper -
251 -
252 { Lookup , BAfterC, BAfter , BAfter , UpATerm, ACS , Initial, Upper , Break , Initial, ATerm , STerm , STerm , ATermC }, // UpATerm -
253 { Lookup , BAfterC, BAfter , BAfter , ATerm , ACS , Initial, Break , Break , Initial, ATerm , STerm , STerm , ATermC }, // ATerm -
254 { Lookup , BAfterC, BAfter , BAfter , ATermC , ACS , Initial, Break , Break , Lookup , ATerm , STerm , STerm , ATermC }, // ATermC -
255 { Lookup , BAfterC, BAfter , BAfter , ACS , ACS , Initial, Break , Break , Lookup , ATerm , STerm , STerm , Lookup }, // ACS -
256 -
257 { Break , BAfterC, BAfter , BAfter , STerm , SCS , Break , Break , Break , Break , ATerm , STerm , STerm , STermC }, // STerm, -
258 { Break , BAfterC, BAfter , BAfter , STermC , SCS , Break , Break , Break , Break , ATerm , STerm , STerm , STermC }, // STermC -
259 { Break , BAfterC, BAfter , BAfter , SCS , SCS , Break , Break , Break , Break , ATerm , STerm , STerm , Break }, // SCS -
260 { Break , Break , BAfter , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break }, // BAfterC -
261 { Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break , Break }, // BAfter -
262}; -
263 -
264} // namespace SB -
265 -
266static void getSentenceBreaks(const ushort *string, quint32 len, QCharAttributes *attributes) -
267{ -
268 uchar state = SB::BAfter; // to meet SB1
executed (the execution status of this line is deduced): uchar state = SB::BAfter;
-
269 for (quint32 i = 0; i != len; ++i) {
evaluated: i != len
TRUEFALSE
yes
Evaluation Count:555
yes
Evaluation Count:18
18-555
270 quint32 pos = i;
executed (the execution status of this line is deduced): quint32 pos = i;
-
271 uint ucs4 = string[i];
executed (the execution status of this line is deduced): uint ucs4 = string[i];
-
272 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
273 ushort low = string[i + 1];
never executed (the execution status of this line is deduced): ushort low = string[i + 1];
-
274 if (QChar::isLowSurrogate(low)) {
never evaluated: QChar::isLowSurrogate(low)
0
275 ucs4 = QChar::surrogateToUcs4(ucs4, low);
never executed (the execution status of this line is deduced): ucs4 = QChar::surrogateToUcs4(ucs4, low);
-
276 ++i;
never executed (the execution status of this line is deduced): ++i;
-
277 }
never executed: }
0
278 }
never executed: }
0
279 -
280 const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ucs4);
executed (the execution status of this line is deduced): const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ucs4);
-
281 QUnicodeTables::SentenceBreakClass ncls = (QUnicodeTables::SentenceBreakClass) prop->sentenceBreakClass;
executed (the execution status of this line is deduced): QUnicodeTables::SentenceBreakClass ncls = (QUnicodeTables::SentenceBreakClass) prop->sentenceBreakClass;
-
282 -
283 Q_ASSERT(state <= SB::BAfter);
executed (the execution status of this line is deduced): qt_noop();
-
284 state = SB::breakTable[state][ncls];
executed (the execution status of this line is deduced): state = SB::breakTable[state][ncls];
-
285 if (Q_UNLIKELY(state == SB::Lookup)) { // SB8
partially evaluated: __builtin_expect(!!(state == SB::Lookup), false)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:555
0-555
286 state = SB::Break;
never executed (the execution status of this line is deduced): state = SB::Break;
-
287 for (quint32 lookahead = i + 1; lookahead < len; ++lookahead) {
never evaluated: lookahead < len
0
288 ucs4 = string[lookahead];
never executed (the execution status of this line is deduced): ucs4 = string[lookahead];
-
289 if (QChar::isHighSurrogate(ucs4) && lookahead + 1 != len) {
never evaluated: QChar::isHighSurrogate(ucs4)
never evaluated: lookahead + 1 != len
0
290 ushort low = string[lookahead + 1];
never executed (the execution status of this line is deduced): ushort low = string[lookahead + 1];
-
291 if (QChar::isLowSurrogate(low)) {
never evaluated: QChar::isLowSurrogate(low)
0
292 ucs4 = QChar::surrogateToUcs4(ucs4, low);
never executed (the execution status of this line is deduced): ucs4 = QChar::surrogateToUcs4(ucs4, low);
-
293 ++lookahead;
never executed (the execution status of this line is deduced): ++lookahead;
-
294 }
never executed: }
0
295 }
never executed: }
0
296 -
297 prop = QUnicodeTables::properties(ucs4);
never executed (the execution status of this line is deduced): prop = QUnicodeTables::properties(ucs4);
-
298 QUnicodeTables::SentenceBreakClass tcls = (QUnicodeTables::SentenceBreakClass) prop->sentenceBreakClass;
never executed (the execution status of this line is deduced): QUnicodeTables::SentenceBreakClass tcls = (QUnicodeTables::SentenceBreakClass) prop->sentenceBreakClass;
-
299 switch (tcls) { -
300 case QUnicodeTables::SentenceBreak_Other: -
301 case QUnicodeTables::SentenceBreak_Extend: -
302 case QUnicodeTables::SentenceBreak_Sp: -
303 case QUnicodeTables::SentenceBreak_Numeric: -
304 case QUnicodeTables::SentenceBreak_SContinue: -
305 case QUnicodeTables::SentenceBreak_Close: -
306 continue;
never executed: continue;
0
307 case QUnicodeTables::SentenceBreak_Lower: -
308 i = lookahead;
never executed (the execution status of this line is deduced): i = lookahead;
-
309 state = SB::Initial;
never executed (the execution status of this line is deduced): state = SB::Initial;
-
310 break;
never executed: break;
0
311 default: -
312 break;
never executed: break;
0
313 } -
314 break;
never executed: break;
0
315 } -
316 }
never executed: }
0
317 if (Q_UNLIKELY(state == SB::Break)) {
evaluated: __builtin_expect(!!(state == SB::Break), false)
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:513
42-513
318 attributes[pos].sentenceBoundary = true;
executed (the execution status of this line is deduced): attributes[pos].sentenceBoundary = true;
-
319 state = SB::breakTable[SB::Initial][ncls];
executed (the execution status of this line is deduced): state = SB::breakTable[SB::Initial][ncls];
-
320 }
executed: }
Execution Count:42
42
321 }
executed: }
Execution Count:555
555
322 -
323 attributes[len].sentenceBoundary = true; // SB2
executed (the execution status of this line is deduced): attributes[len].sentenceBoundary = true;
-
324}
executed: }
Execution Count:18
18
325 -
326 -
327// ----------------------------------------------------------------------------------------------------- -
328// -
329// The line breaking algorithm. -
330// See http://www.unicode.org/reports/tr14/tr14-30.html -
331// -
332// ----------------------------------------------------------------------------------------------------- -
333 -
334namespace LB { -
335 -
336namespace NS { // Number Sequence -
337 -
338// LB25 recommends to not break lines inside numbers of the form -
339// described by the following regular expression: -
340// (PR|PO)?(OP|HY)?NU(NU|SY|IS)*(CL|CP)?(PR|PO)? -
341 -
342enum Action { -
343 None, -
344 Start, -
345 Continue, -
346 Break -
347}; -
348 -
349enum Class { -
350 XX, -
351 PRPO, -
352 OPHY, -
353 NU, -
354 SYIS, -
355 CLCP -
356}; -
357 -
358static const uchar actionTable[CLCP + 1][CLCP + 1] = { -
359// XX PRPO OPHY NU SYIS CLCP -
360 { None , Start , Start , Start , None , None }, // XX -
361 { None , Start , Continue, Continue, None , None }, // PRPO -
362 { None , Start , Start , Continue, None , None }, // OPHY -
363 { Break , Break , Break , Continue, Continue, Continue }, // NU -
364 { Break , Break , Break , Continue, Continue, Continue }, // SYIS -
365 { Break , Continue, Break , Break , Break , Break }, // CLCP -
366}; -
367 -
368inline Class toClass(QUnicodeTables::LineBreakClass lbc, QChar::Category category) -
369{ -
370 switch (lbc) { -
371 case QUnicodeTables::LineBreak_AL:// case QUnicodeTables::LineBreak_AI: -
372 // resolve AI math symbols in numerical context to IS -
373 if (category == QChar::Symbol_Math)
evaluated: category == QChar::Symbol_Math
TRUEFALSE
yes
Evaluation Count:612
yes
Evaluation Count:2071155
612-2071155
374 return SYIS;
executed: return SYIS;
Execution Count:612
612
375 break;
executed: break;
Execution Count:2071155
2071155
376 case QUnicodeTables::LineBreak_PR: case QUnicodeTables::LineBreak_PO: -
377 return PRPO;
executed: return PRPO;
Execution Count:652
652
378 case QUnicodeTables::LineBreak_OP: case QUnicodeTables::LineBreak_HY: -
379 return OPHY;
executed: return OPHY;
Execution Count:18432
18432
380 case QUnicodeTables::LineBreak_NU: -
381 return NU;
executed: return NU;
Execution Count:456784
456784
382 case QUnicodeTables::LineBreak_SY: case QUnicodeTables::LineBreak_IS: -
383 return SYIS;
executed: return SYIS;
Execution Count:67444
67444
384 case QUnicodeTables::LineBreak_CL: case QUnicodeTables::LineBreak_CP: -
385 return CLCP;
executed: return CLCP;
Execution Count:11280
11280
386 default: -
387 break;
executed: break;
Execution Count:364641
364641
388 } -
389 return XX;
executed: return XX;
Execution Count:2435796
2435796
390} -
391 -
392} // namespace NS -
393 -
394/* In order to support the tailored implementation of LB25 properly -
395 the following changes were made in the pair table to allow breaks -
396 where the numeric expression doesn't match the template (i.e. [^NU](IS|SY)NU): -
397 CL->PO from IB to DB -
398 CP->PO from IB to DB -
399 CL->PR from IB to DB -
400 CP->PR from IB to DB -
401 PO->OP from IB to DB -
402 PR->OP from IB to DB -
403 IS->NU from IB to DB -
404 SY->NU from IB to DB -
405*/ -
406 -
407// The following line break classes are not treated by the pair table -
408// and must be resolved outside: -
409// AI, BK, CB, CJ, CR, LF, NL, SA, SG, SP, XX -
410 -
411enum Action { -
412 ProhibitedBreak, PB = ProhibitedBreak, -
413 DirectBreak, DB = DirectBreak, -
414 IndirectBreak, IB = IndirectBreak, -
415 CombiningIndirectBreak, CI = CombiningIndirectBreak, -
416 CombiningProhibitedBreak, CP = CombiningProhibitedBreak -
417}; -
418 -
419static const uchar breakTable[QUnicodeTables::LineBreak_CB + 1][QUnicodeTables::LineBreak_CB + 1] = { -
420/* OP CL CP QU GL NS EX SY IS PR PO NU AL HL ID IN HY BA BB B2 ZW CM WJ H2 H3 JL JV JT RI CB */ -
421/* OP */ { 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 }, -
422/* CL */ { 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 }, -
423/* CP */ { 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 }, -
424/* QU */ { 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 }, -
425/* GL */ { 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 }, -
426/* NS */ { 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 }, -
427/* EX */ { 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 }, -
428/* SY */ { 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 }, -
429/* IS */ { 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 }, -
430/* PR */ { 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 }, -
431/* PO */ { 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 }, -
432/* NU */ { 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 }, -
433/* AL */ { 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 }, -
434/* HL */ { 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 }, -
435/* ID */ { 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 }, -
436/* IN */ { 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 }, -
437/* HY */ { 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 }, -
438/* BA */ { 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 }, -
439/* BB */ { 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 }, -
440/* B2 */ { 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 }, -
441/* ZW */ { 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 }, -
442/* CM */ { 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 }, -
443/* WJ */ { 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 }, -
444/* H2 */ { 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 }, -
445/* H3 */ { 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 }, -
446/* JL */ { 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 }, -
447/* JV */ { 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 }, -
448/* JT */ { 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 }, -
449/* RI */ { 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 }, -
450/* CB */ { 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 } -
451}; -
452 -
453} // namespace LB -
454 -
455static void getLineBreaks(const ushort *string, quint32 len, QCharAttributes *attributes) -
456{ -
457 quint32 nestart = 0;
executed (the execution status of this line is deduced): quint32 nestart = 0;
-
458 LB::NS::Class nelast = LB::NS::XX;
executed (the execution status of this line is deduced): LB::NS::Class nelast = LB::NS::XX;
-
459 -
460 QUnicodeTables::LineBreakClass lcls = QUnicodeTables::LineBreak_LF; // to meet LB10
executed (the execution status of this line is deduced): QUnicodeTables::LineBreakClass lcls = QUnicodeTables::LineBreak_LF;
-
461 QUnicodeTables::LineBreakClass cls = lcls;
executed (the execution status of this line is deduced): QUnicodeTables::LineBreakClass cls = lcls;
-
462 for (quint32 i = 0; i != len; ++i) {
evaluated: i != len
TRUEFALSE
yes
Evaluation Count:3197072
yes
Evaluation Count:197540
197540-3197072
463 quint32 pos = i;
executed (the execution status of this line is deduced): quint32 pos = i;
-
464 uint ucs4 = string[i];
executed (the execution status of this line is deduced): uint ucs4 = string[i];
-
465 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
466 ushort low = string[i + 1];
never executed (the execution status of this line is deduced): ushort low = string[i + 1];
-
467 if (QChar::isLowSurrogate(low)) {
never evaluated: QChar::isLowSurrogate(low)
0
468 ucs4 = QChar::surrogateToUcs4(ucs4, low);
never executed (the execution status of this line is deduced): ucs4 = QChar::surrogateToUcs4(ucs4, low);
-
469 ++i;
never executed (the execution status of this line is deduced): ++i;
-
470 }
never executed: }
0
471 }
never executed: }
0
472 -
473 const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ucs4);
executed (the execution status of this line is deduced): const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ucs4);
-
474 QUnicodeTables::LineBreakClass ncls = (QUnicodeTables::LineBreakClass) prop->lineBreakClass;
executed (the execution status of this line is deduced): QUnicodeTables::LineBreakClass ncls = (QUnicodeTables::LineBreakClass) prop->lineBreakClass;
-
475 -
476 if (Q_UNLIKELY(ncls == QUnicodeTables::LineBreak_SA)) {
evaluated: __builtin_expect(!!(ncls == QUnicodeTables::LineBreak_SA), false)
TRUEFALSE
yes
Evaluation Count:206868
yes
Evaluation Count:2990204
206868-2990204
477 // LB1: resolve SA to AL, except of those that have Category Mn or Mc be resolved to CM -
478 static const int test = FLAG(QChar::Mark_NonSpacing) | FLAG(QChar::Mark_SpacingCombining); -
479 if (FLAG(prop->category) & test)
evaluated: (1 << (prop->category)) & test
TRUEFALSE
yes
Evaluation Count:204984
yes
Evaluation Count:1884
1884-204984
480 ncls = QUnicodeTables::LineBreak_CM;
executed: ncls = QUnicodeTables::LineBreak_CM;
Execution Count:204984
204984
481 }
executed: }
Execution Count:206868
206868
482 if (Q_UNLIKELY(ncls == QUnicodeTables::LineBreak_CM)) {
evaluated: __builtin_expect(!!(ncls == QUnicodeTables::LineBreak_CM), false)
TRUEFALSE
yes
Evaluation Count:206121
yes
Evaluation Count:2990951
206121-2990951
483 // LB10: treat CM that follows SP, BK, CR, LF, NL, or ZW as AL -
484 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
485 ncls = QUnicodeTables::LineBreak_AL;
executed: ncls = QUnicodeTables::LineBreak_AL;
Execution Count:49
49
486 }
executed: }
Execution Count:206121
206121
487 -
488 if (Q_LIKELY(ncls != QUnicodeTables::LineBreak_CM)) {
evaluated: __builtin_expect(!!(ncls != QUnicodeTables::LineBreak_CM), true)
TRUEFALSE
yes
Evaluation Count:2991000
yes
Evaluation Count:206072
206072-2991000
489 // LB25: do not break lines inside numbers -
490 LB::NS::Class necur = LB::NS::toClass(ncls, (QChar::Category)prop->category);
executed (the execution status of this line is deduced): LB::NS::Class necur = LB::NS::toClass(ncls, (QChar::Category)prop->category);
-
491 switch (LB::NS::actionTable[nelast][necur]) { -
492 case LB::NS::Break: -
493 // do not change breaks before and after the expression -
494 for (quint32 j = nestart + 1; j < pos; ++j)
evaluated: j < pos
TRUEFALSE
yes
Evaluation Count:97498
yes
Evaluation Count:153014
97498-153014
495 attributes[j].lineBreak = false;
executed: attributes[j].lineBreak = false;
Execution Count:97498
97498
496 // fall through -
497 case LB::NS::None:
code before this statement executed: case LB::NS::None:
Execution Count:153014
153014
498 nelast = LB::NS::XX; // reset state
executed (the execution status of this line is deduced): nelast = LB::NS::XX;
-
499 break;
executed: break;
Execution Count:2467096
2467096
500 case LB::NS::Start: -
501 nestart = i;
executed (the execution status of this line is deduced): nestart = i;
-
502 // fall through -
503 default:
code before this statement executed: default:
Execution Count:300113
300113
504 nelast = necur;
executed (the execution status of this line is deduced): nelast = necur;
-
505 break;
executed: break;
Execution Count:523904
523904
506 } -
507 }
executed: }
Execution Count:2991000
2991000
508 -
509 if (Q_UNLIKELY(lcls >= QUnicodeTables::LineBreak_CR)) {
evaluated: __builtin_expect(!!(lcls >= QUnicodeTables::LineBreak_CR), false)
TRUEFALSE
yes
Evaluation Count:207541
yes
Evaluation Count:2989531
207541-2989531
510 // LB4: BK!, LB5: (CRxLF|CR|LF|NL)! -
511 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
512 attributes[pos].lineBreak = attributes[pos].mandatoryBreak = true;
executed: attributes[pos].lineBreak = attributes[pos].mandatoryBreak = true;
Execution Count:207537
207537
513 goto next;
executed: goto next;
Execution Count:207541
207541
514 } -
515 -
516 if (Q_UNLIKELY(ncls >= QUnicodeTables::LineBreak_SP)) {
evaluated: __builtin_expect(!!(ncls >= QUnicodeTables::LineBreak_SP), false)
TRUEFALSE
yes
Evaluation Count:360706
yes
Evaluation Count:2628825
360706-2628825
517 if (ncls > QUnicodeTables::LineBreak_SP)
evaluated: ncls > QUnicodeTables::LineBreak_SP
TRUEFALSE
yes
Evaluation Count:10102
yes
Evaluation Count:350604
10102-350604
518 goto next; // LB6: x(BK|CR|LF|NL)
executed: goto next;
Execution Count:10102
10102
519 goto next_no_cls_update; // LB7: xSP
executed: goto next_no_cls_update;
Execution Count:350604
350604
520 } -
521 -
522 // for South East Asian chars that require a complex analysis, the Unicode -
523 // standard recommends to treat them as AL. tailoring that do dictionary analysis can override -
524 if (Q_UNLIKELY(cls >= QUnicodeTables::LineBreak_SA))
evaluated: __builtin_expect(!!(cls >= QUnicodeTables::LineBreak_SA), false)
TRUEFALSE
yes
Evaluation Count:1941
yes
Evaluation Count:2626884
1941-2626884
525 cls = QUnicodeTables::LineBreak_AL;
executed: cls = QUnicodeTables::LineBreak_AL;
Execution Count:1941
1941
526 -
527 switch (LB::breakTable[cls][ncls < QUnicodeTables::LineBreak_SA ? ncls : QUnicodeTables::LineBreak_AL]) { -
528 case LB::DirectBreak: -
529 attributes[pos].lineBreak = true;
executed (the execution status of this line is deduced): attributes[pos].lineBreak = true;
-
530 break;
executed: break;
Execution Count:35794
35794
531 case LB::IndirectBreak: -
532 if (lcls == QUnicodeTables::LineBreak_SP)
evaluated: lcls == QUnicodeTables::LineBreak_SP
TRUEFALSE
yes
Evaluation Count:345761
yes
Evaluation Count:1951497
345761-1951497
533 attributes[pos].lineBreak = true;
executed: attributes[pos].lineBreak = true;
Execution Count:345761
345761
534 break;
executed: break;
Execution Count:2297258
2297258
535 case LB::CombiningIndirectBreak: -
536 if (lcls != QUnicodeTables::LineBreak_SP)
partially evaluated: lcls != QUnicodeTables::LineBreak_SP
TRUEFALSE
yes
Evaluation Count:206072
no
Evaluation Count:0
0-206072
537 goto next_no_cls_update;
executed: goto next_no_cls_update;
Execution Count:206072
206072
538 attributes[pos].lineBreak = true;
never executed (the execution status of this line is deduced): attributes[pos].lineBreak = true;
-
539 break;
never executed: break;
0
540 case LB::CombiningProhibitedBreak: -
541 if (lcls != QUnicodeTables::LineBreak_SP)
never evaluated: lcls != QUnicodeTables::LineBreak_SP
0
542 goto next_no_cls_update;
never executed: goto next_no_cls_update;
0
543 break;
never executed: break;
0
544 case LB::ProhibitedBreak: -
545 // nothing to do -
546 default: -
547 break;
executed: break;
Execution Count:89701
89701
548 } -
549 -
550 next:
code before this statement executed: next:
Execution Count:2422753
2422753
551 cls = ncls;
executed (the execution status of this line is deduced): cls = ncls;
-
552 next_no_cls_update:
code before this statement executed: next_no_cls_update:
Execution Count:2640396
2640396
553 lcls = ncls;
executed (the execution status of this line is deduced): lcls = ncls;
-
554 }
executed: }
Execution Count:3197072
3197072
555 -
556 if (Q_UNLIKELY(LB::NS::actionTable[nelast][LB::NS::XX] == LB::NS::Break)) {
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
557 // LB25: do not break lines inside numbers -
558 for (quint32 j = nestart + 1; j < len; ++j)
evaluated: j < len
TRUEFALSE
yes
Evaluation Count:126257
yes
Evaluation Count:140428
126257-140428
559 attributes[j].lineBreak = false;
executed: attributes[j].lineBreak = false;
Execution Count:126257
126257
560 }
executed: }
Execution Count:140428
140428
561 -
562 attributes[0].lineBreak = attributes[0].mandatoryBreak = false; // LB2
executed (the execution status of this line is deduced): attributes[0].lineBreak = attributes[0].mandatoryBreak = false;
-
563 attributes[len].lineBreak = attributes[len].mandatoryBreak = true; // LB3
executed (the execution status of this line is deduced): attributes[len].lineBreak = attributes[len].mandatoryBreak = true;
-
564}
executed: }
Execution Count:197540
197540
565 -
566 -
567static void getWhiteSpaces(const ushort *string, quint32 len, QCharAttributes *attributes) -
568{ -
569 for (quint32 i = 0; i != len; ++i) {
evaluated: i != len
TRUEFALSE
yes
Evaluation Count:3196739
yes
Evaluation Count:197513
197513-3196739
570 uint ucs4 = string[i];
executed (the execution status of this line is deduced): uint ucs4 = string[i];
-
571 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
572 ushort low = string[i + 1];
never executed (the execution status of this line is deduced): ushort low = string[i + 1];
-
573 if (QChar::isLowSurrogate(low)) {
never evaluated: QChar::isLowSurrogate(low)
0
574 ucs4 = QChar::surrogateToUcs4(ucs4, low);
never executed (the execution status of this line is deduced): ucs4 = QChar::surrogateToUcs4(ucs4, low);
-
575 ++i;
never executed (the execution status of this line is deduced): ++i;
-
576 }
never executed: }
0
577 }
never executed: }
0
578 -
579 if (Q_UNLIKELY(QChar::isSpace(ucs4)))
evaluated: __builtin_expect(!!(QChar::isSpace(ucs4)), false)
TRUEFALSE
yes
Evaluation Count:360892
yes
Evaluation Count:2835847
360892-2835847
580 attributes[i].whiteSpace = true;
executed: attributes[i].whiteSpace = true;
Execution Count:360892
360892
581 }
executed: }
Execution Count:3196739
3196739
582}
executed: }
Execution Count:197513
197513
583 -
584 -
585Q_CORE_EXPORT void initCharAttributes(const ushort *string, int length, -
586 const ScriptItem *items, int numItems, -
587 QCharAttributes *attributes, CharAttributeOptions options) -
588{ -
589 if (length <= 0)
evaluated: length <= 0
TRUEFALSE
yes
Evaluation Count:59
yes
Evaluation Count:197626
59-197626
590 return;
executed: return;
Execution Count:59
59
591 -
592 if (!(options & DontClearAttributes))
partially evaluated: !(options & DontClearAttributes)
TRUEFALSE
yes
Evaluation Count:197626
no
Evaluation Count:0
0-197626
593 ::memset(attributes, 0, (length + 1) * sizeof(QCharAttributes));
executed: ::memset(attributes, 0, (length + 1) * sizeof(QCharAttributes));
Execution Count:197626
197626
594 -
595 if (options & GraphemeBreaks)
evaluated: options & GraphemeBreaks
TRUEFALSE
yes
Evaluation Count:197519
yes
Evaluation Count:107
107-197519
596 getGraphemeBreaks(string, length, attributes);
executed: getGraphemeBreaks(string, length, attributes);
Execution Count:197519
197519
597 if (options & WordBreaks)
evaluated: options & WordBreaks
TRUEFALSE
yes
Evaluation Count:62
yes
Evaluation Count:197564
62-197564
598 getWordBreaks(string, length, attributes);
executed: getWordBreaks(string, length, attributes);
Execution Count:62
62
599 if (options & SentenceBreaks)
evaluated: options & SentenceBreaks
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:197608
18-197608
600 getSentenceBreaks(string, length, attributes);
executed: getSentenceBreaks(string, length, attributes);
Execution Count:18
18
601 if (options & LineBreaks)
evaluated: options & LineBreaks
TRUEFALSE
yes
Evaluation Count:197540
yes
Evaluation Count:86
86-197540
602 getLineBreaks(string, length, attributes);
executed: getLineBreaks(string, length, attributes);
Execution Count:197540
197540
603 if (options & WhiteSpaces)
evaluated: options & WhiteSpaces
TRUEFALSE
yes
Evaluation Count:197513
yes
Evaluation Count:113
113-197513
604 getWhiteSpaces(string, length, attributes);
executed: getWhiteSpaces(string, length, attributes);
Execution Count:197513
197513
605 -
606 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
607 return;
never executed: return;
0
608 if (!qt_initcharattributes_default_algorithm_only) {
partially evaluated: !qt_initcharattributes_default_algorithm_only
TRUEFALSE
yes
Evaluation Count:197626
no
Evaluation Count:0
0-197626
609 QVarLengthArray<HB_ScriptItem, 64> scriptItems;
executed (the execution status of this line is deduced): QVarLengthArray<HB_ScriptItem, 64> scriptItems;
-
610 scriptItems.reserve(numItems);
executed (the execution status of this line is deduced): scriptItems.reserve(numItems);
-
611 int start = 0;
executed (the execution status of this line is deduced): int start = 0;
-
612 for (int i = start + 1; i < numItems; ++i) {
evaluated: i < numItems
TRUEFALSE
yes
Evaluation Count:21776
yes
Evaluation Count:197626
21776-197626
613 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
614 continue;
executed: continue;
Execution Count:21170
21170
615 HB_ScriptItem item;
executed (the execution status of this line is deduced): HB_ScriptItem item;
-
616 item.pos = items[start].position;
executed (the execution status of this line is deduced): item.pos = items[start].position;
-
617 item.length = items[i].position - items[start].position;
executed (the execution status of this line is deduced): item.length = items[i].position - items[start].position;
-
618 item.script = (HB_Script)items[start].script;
executed (the execution status of this line is deduced): item.script = (HB_Script)items[start].script;
-
619 item.bidiLevel = 0; // unused
executed (the execution status of this line is deduced): item.bidiLevel = 0;
-
620 scriptItems.append(item);
executed (the execution status of this line is deduced): scriptItems.append(item);
-
621 start = i;
executed (the execution status of this line is deduced): start = i;
-
622 }
executed: }
Execution Count:606
606
623 if (items[start].position + 1 < length) {
evaluated: items[start].position + 1 < length
TRUEFALSE
yes
Evaluation Count:176027
yes
Evaluation Count:21599
21599-176027
624 HB_ScriptItem item;
executed (the execution status of this line is deduced): HB_ScriptItem item;
-
625 item.pos = items[start].position;
executed (the execution status of this line is deduced): item.pos = items[start].position;
-
626 item.length = length - items[start].position;
executed (the execution status of this line is deduced): item.length = length - items[start].position;
-
627 item.script = (HB_Script)items[start].script;
executed (the execution status of this line is deduced): item.script = (HB_Script)items[start].script;
-
628 item.bidiLevel = 0; // unused
executed (the execution status of this line is deduced): item.bidiLevel = 0;
-
629 scriptItems.append(item);
executed (the execution status of this line is deduced): scriptItems.append(item);
-
630 }
executed: }
Execution Count:176027
176027
631 Q_STATIC_ASSERT(sizeof(QCharAttributes) == sizeof(HB_CharAttributes));
executed (the execution status of this line is deduced): static_assert(bool(sizeof(QCharAttributes) == sizeof(HB_CharAttributes)), "sizeof(QCharAttributes) == sizeof(HB_CharAttributes)");
-
632 HB_GetTailoredCharAttributes(string, length,
executed (the execution status of this line is deduced): HB_GetTailoredCharAttributes(string, length,
-
633 scriptItems.constData(), scriptItems.size(),
executed (the execution status of this line is deduced): scriptItems.constData(), scriptItems.size(),
-
634 reinterpret_cast<HB_CharAttributes *>(attributes));
executed (the execution status of this line is deduced): reinterpret_cast<HB_CharAttributes *>(attributes));
-
635 }
executed: }
Execution Count:197626
197626
636}
executed: }
Execution Count:197626
197626
637 -
638} // namespace QUnicodeTools -
639 -
640QT_END_NAMESPACE -
641 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial