qtranslator.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qtranslator.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15-
16-
17-
18-
19-
20-
21enum Tag { Tag_End = 1, Tag_SourceText16, Tag_Translation, Tag_Context16, Tag_Obsolete1,-
22 Tag_SourceText, Tag_Context, Tag_Comment, Tag_Obsolete2 };-
23-
24-
25-
26-
27-
28-
29-
30static const int MagicLength = 16;-
31static const uchar magic[MagicLength] = {-
32 0x3c, 0xb8, 0x64, 0x18, 0xca, 0xef, 0x9c, 0x95,-
33 0xcd, 0x21, 0x1c, 0xbf, 0x60, 0xa1, 0xbd, 0xdd-
34};-
35-
36static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)-
37{-
38-
39-
40 if (foundLen > 0
foundLen > 0Description
TRUEevaluated 346 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 167 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
&& found[foundLen-1] == '\0'
found[foundLen-1] == '\0'Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 334 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
12-346
41 --
executed 12 times by 1 test: --foundLen;
Executed by:
  • tst_QTranslator
foundLen;
executed 12 times by 1 test: --foundLen;
Executed by:
  • tst_QTranslator
12
42 return
executed 513 times by 2 tests: return ((targetLen == foundLen) && memcmp(found, target, foundLen) == 0);
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
((
(targetLen == foundLen)Description
TRUEevaluated 484 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 29 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
targetLen == foundLen)
(targetLen == foundLen)Description
TRUEevaluated 484 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 29 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
&& memcmp(found, target, foundLen) == 0
memcmp(found, ...foundLen) == 0Description
TRUEevaluated 484 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEnever evaluated
);
executed 513 times by 2 tests: return ((targetLen == foundLen) && memcmp(found, target, foundLen) == 0);
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
0-513
43}-
44-
45static void elfHash_continue(const char *name, uint &h)-
46{-
47 const uchar *k;-
48 uint g;-
49-
50 k = (const uchar *) name;-
51 while (*
*kDescription
TRUEevaluated 11634 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 624 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
k
*kDescription
TRUEevaluated 11634 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 624 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
) {
624-11634
52 h = (h << 4) + *k++;-
53 if ((
(g = (h & 0xf0000000)) != 0Description
TRUEevaluated 9554 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 2080 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
g = (h & 0xf0000000)) != 0
(g = (h & 0xf0000000)) != 0Description
TRUEevaluated 9554 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 2080 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
2080-9554
54 h ^= g >> 24;
executed 9554 times by 2 tests: h ^= g >> 24;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
9554
55 h &= ~g;-
56 }
executed 11634 times by 2 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
11634
57}
executed 624 times by 2 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
624
58-
59static void elfHash_finish(uint &h)-
60{-
61 if (!h
!hDescription
TRUEnever evaluated
FALSEevaluated 312 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
0-312
62 h = 1;
never executed: h = 1;
0
63}
executed 312 times by 2 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
312
64-
65static uint elfHash(const char *name)-
66{-
67 uint hash = 0;-
68 elfHash_continue(name, hash);-
69 elfHash_finish(hash);-
70 return
never executed: return hash;
hash;
never executed: return hash;
0
71}-
72-
73-
74-
75-
76-
77-
78-
79static bool isValidNumerusRules(const uchar *rules, uint rulesSize)-
80{-
81-
82-
83-
84 if (rulesSize == 0
rulesSize == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
1-15
85 return
executed 1 time by 1 test: return true;
Executed by:
  • tst_QTranslator
true;
executed 1 time by 1 test: return true;
Executed by:
  • tst_QTranslator
1
86-
87 quint32 offset = 0;-
88 do {-
89 uchar opcode = rules[offset];-
90 uchar op = opcode & Q_OP_MASK;-
91-
92 if (opcode & 0x80
opcode & 0x80Description
TRUEnever evaluated
FALSEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
0-15
93 return
never executed: return false;
false;
never executed: return false;
0
94-
95 if (++
++offset == rulesSizeDescription
TRUEnever evaluated
FALSEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
offset == rulesSize
++offset == rulesSizeDescription
TRUEnever evaluated
FALSEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
0-15
96 return
never executed: return false;
false;
never executed: return false;
0
97-
98-
99 ++offset;-
100-
101 switch (op)-
102 {-
103 case
executed 15 times by 2 tests: case Q_EQ:
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
Q_EQ:
executed 15 times by 2 tests: case Q_EQ:
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
15
104 case
never executed: case Q_LT:
Q_LT:
never executed: case Q_LT:
0
105 case
never executed: case Q_LEQ:
Q_LEQ:
never executed: case Q_LEQ:
0
106 break;
executed 15 times by 2 tests: break;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
15
107-
108 case
never executed: case Q_BETWEEN:
Q_BETWEEN:
never executed: case Q_BETWEEN:
0
109 if (offset != rulesSize
offset != rulesSizeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
110-
111 ++offset;-
112 break;
never executed: break;
0
113 }-
114 return
never executed: return false;
false;
never executed: return false;
0
115-
116 default
never executed: default:
:
never executed: default:
0
117 return
never executed: return false;
false;
never executed: return false;
0
118 }-
119-
120-
121 if (offset == rulesSize
offset == rulesSizeDescription
TRUEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEnever evaluated
)
0-15
122 return
executed 15 times by 2 tests: return true;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
true;
executed 15 times by 2 tests: return true;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
15
123-
124 }
never executed: end of block
while (((
(rules[offset] == Q_AND)Description
TRUEnever evaluated
FALSEnever evaluated
rules[offset] == Q_AND)
(rules[offset] == Q_AND)Description
TRUEnever evaluated
FALSEnever evaluated
0
125 || (
(rules[offset] == Q_OR)Description
TRUEnever evaluated
FALSEnever evaluated
rules[offset] == Q_OR)
(rules[offset] == Q_OR)Description
TRUEnever evaluated
FALSEnever evaluated
0
126 || (
(rules[offset] == Q_NEWRULE)Description
TRUEnever evaluated
FALSEnever evaluated
rules[offset] == Q_NEWRULE)
(rules[offset] == Q_NEWRULE)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
127 && ++
++offset != rulesSizeDescription
TRUEnever evaluated
FALSEnever evaluated
offset != rulesSize
++offset != rulesSizeDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
128-
129-
130 return
never executed: return false;
false;
never executed: return false;
0
131}-
132static uint numerusHelper(int n, const uchar *rules, uint rulesSize)-
133{-
134 uint result = 0;-
135 uint i = 0;-
136-
137 if (rulesSize == 0
rulesSize == 0Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QTranslator
)
0-9
138 return
never executed: return 0;
0;
never executed: return 0;
0
139-
140 for (;;) {-
141 bool orExprTruthValue = false;-
142-
143 for (;;) {-
144 bool andExprTruthValue = true;-
145-
146 for (;;) {-
147 bool truthValue = true;-
148 int opcode = rules[i++];-
149-
150 int leftOperand = n;-
151 if (opcode & Q_MOD_10
opcode & Q_MOD_10Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QTranslator
) {
0-9
152 leftOperand %= 10;-
153 }
never executed: end of block
else if (opcode & Q_MOD_100
opcode & Q_MOD_100Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QTranslator
) {
0-9
154 leftOperand %= 100;-
155 }
never executed: end of block
else if (opcode & Q_LEAD_1000
opcode & Q_LEAD_1000Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QTranslator
) {
0-9
156 while (leftOperand >= 1000
leftOperand >= 1000Description
TRUEnever evaluated
FALSEnever evaluated
)
0
157 leftOperand /= 1000;
never executed: leftOperand /= 1000;
0
158 }
never executed: end of block
0
159-
160 int op = opcode & Q_OP_MASK;-
161 int rightOperand = rules[i++];-
162-
163 switch (op) {-
164 case
executed 9 times by 1 test: case Q_EQ:
Executed by:
  • tst_QTranslator
Q_EQ:
executed 9 times by 1 test: case Q_EQ:
Executed by:
  • tst_QTranslator
9
165 truthValue = (leftOperand == rightOperand);-
166 break;
executed 9 times by 1 test: break;
Executed by:
  • tst_QTranslator
9
167 case
never executed: case Q_LT:
Q_LT:
never executed: case Q_LT:
0
168 truthValue = (leftOperand < rightOperand);-
169 break;
never executed: break;
0
170 case
never executed: case Q_LEQ:
Q_LEQ:
never executed: case Q_LEQ:
0
171 truthValue = (leftOperand <= rightOperand);-
172 break;
never executed: break;
0
173 case
never executed: case Q_BETWEEN:
Q_BETWEEN:
never executed: case Q_BETWEEN:
0
174 int bottom = rightOperand;-
175 int top = rules[i++];-
176 truthValue = (leftOperand >= bottom
leftOperand >= bottomDescription
TRUEnever evaluated
FALSEnever evaluated
&& leftOperand <= top
leftOperand <= topDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
177 }
never executed: end of block
0
178-
179 if (opcode & Q_NOT
opcode & Q_NOTDescription
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QTranslator
)
0-9
180 truthValue = !truthValue;
never executed: truthValue = !truthValue;
0
181-
182 andExprTruthValue = andExprTruthValue
andExprTruthValueDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEnever evaluated
&& truthValue
truthValueDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QTranslator
;
0-9
183-
184 if (i == rulesSize
i == rulesSizeDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEnever evaluated
|| rules[i] != Q_AND
rules[i] != Q_ANDDescription
TRUEnever evaluated
FALSEnever evaluated
)
0-9
185 break;
executed 9 times by 1 test: break;
Executed by:
  • tst_QTranslator
9
186 ++i;-
187 }
never executed: end of block
0
188-
189 orExprTruthValue = orExprTruthValue
orExprTruthValueDescription
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QTranslator
|| andExprTruthValue
andExprTruthValueDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QTranslator
;
0-9
190-
191 if (i == rulesSize
i == rulesSizeDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEnever evaluated
|| rules[i] != Q_OR
rules[i] != Q_ORDescription
TRUEnever evaluated
FALSEnever evaluated
)
0-9
192 break;
executed 9 times by 1 test: break;
Executed by:
  • tst_QTranslator
9
193 ++i;-
194 }
never executed: end of block
0
195-
196 if (orExprTruthValue
orExprTruthValueDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QTranslator
)
3-6
197 return
executed 3 times by 1 test: return result;
Executed by:
  • tst_QTranslator
result;
executed 3 times by 1 test: return result;
Executed by:
  • tst_QTranslator
3
198-
199 ++result;-
200-
201 if (i == rulesSize
i == rulesSizeDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEnever evaluated
)
0-6
202 return
executed 6 times by 1 test: return result;
Executed by:
  • tst_QTranslator
result;
executed 6 times by 1 test: return result;
Executed by:
  • tst_QTranslator
6
203-
204 i++;-
205 }
never executed: end of block
0
206-
207 ((!(false)) ? qt_assert("false",__FILE__,274) : qt_noop());-
208 return
never executed: return 0;
0;
never executed: return 0;
0
209}-
210-
211class QTranslatorPrivate : public QObjectPrivate-
212{-
213 inline QTranslator* q_func() { return static_cast<QTranslator *>(q_ptr); } inline const QTranslator* q_func() const { return static_cast<const QTranslator *>(q_ptr); } friend class QTranslator;-
214public:-
215 enum { Contexts = 0x2f, Hashes = 0x42, Messages = 0x69, NumerusRules = 0x88, Dependencies = 0x96 };-
216-
217 QTranslatorPrivate() :-
218-
219 used_mmap(0),-
220-
221 unmapPointer(0), unmapLength(0), resource(0),-
222 messageArray(0), offsetArray(0), contextArray(0), numerusRulesArray(0),-
223 messageLength(0), offsetLength(0), contextLength(0), numerusRulesLength(0) {}
executed 18 times by 4 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QProgressDialog
  • tst_QTranslator
  • tst_languageChange
18
224-
225-
226 bool used_mmap : 1;-
227-
228 char *unmapPointer;-
229 quint32 unmapLength;-
230-
231-
232 QResource *resource;-
233-
234-
235 QList<QTranslator*> subTranslators;-
236-
237-
238-
239 const uchar *messageArray;-
240 const uchar *offsetArray;-
241 const uchar *contextArray;-
242 const uchar *numerusRulesArray;-
243 uint messageLength;-
244 uint offsetLength;-
245 uint contextLength;-
246 uint numerusRulesLength;-
247-
248 bool do_load(const QString &filename, const QString &directory);-
249 bool do_load(const uchar *data, int len, const QString &directory);-
250 QString do_translate(const char *context, const char *sourceText, const char *comment,-
251 int n) const;-
252 void clear();-
253};-
254QTranslator::QTranslator(QObject * parent)-
255 : QObject(*new QTranslatorPrivate, parent)-
256{-
257}
executed 18 times by 4 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QProgressDialog
  • tst_QTranslator
  • tst_languageChange
18
258-
259-
260-
261-
262-
263QTranslator::~QTranslator()-
264{-
265 if (QCoreApplication::instance()
QCoreApplication::instance()Description
TRUEevaluated 18 times by 4 tests
Evaluated by:
  • tst_QProgressDialog
  • tst_QTranslator
  • tst_languageChange
  • tst_qkeysequence - unknown status
FALSEnever evaluated
)
0-18
266 QCoreApplication::removeTranslator(this);
executed 18 times by 4 tests: QCoreApplication::removeTranslator(this);
Executed by:
  • tst_QProgressDialog
  • tst_QTranslator
  • tst_languageChange
  • tst_qkeysequence - unknown status
18
267 QTranslatorPrivate * const d = d_func();-
268 d->clear();-
269}
executed 18 times by 4 tests: end of block
Executed by:
  • tst_QProgressDialog
  • tst_QTranslator
  • tst_languageChange
  • tst_qkeysequence - unknown status
18
270bool QTranslator::load(const QString & filename, const QString & directory,-
271 const QString & search_delimiters,-
272 const QString & suffix)-
273{-
274 QTranslatorPrivate * const d = d_func();-
275 d->clear();-
276-
277 QString prefix;-
278 if (QFileInfo(filename).isRelative()
QFileInfo(file...).isRelative()Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
) {
3-15
279 prefix = directory;-
280 if (prefix.length()
prefix.length()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_QTranslator
&& !prefix.endsWith(QLatin1Char('/'))
!prefix.endsWi...tin1Char('/'))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTranslator
FALSEnever evaluated
)
0-14
281 prefix += QLatin1Char('/');
executed 1 time by 1 test: prefix += QLatin1Char('/');
Executed by:
  • tst_QTranslator
1
282 }
executed 15 times by 1 test: end of block
Executed by:
  • tst_QTranslator
15
283-
284 QString fname = filename;-
285 QString realname;-
286 QString delims;-
287 delims = search_delimiters.isNull()
search_delimiters.isNull()Description
TRUEevaluated 18 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEnever evaluated
? QString::fromLatin1("_.") : search_delimiters;
0-18
288-
289 for (;;) {-
290 QFileInfo fi;-
291-
292 realname = prefix + fname + (suffix.isNull()
suffix.isNull()Description
TRUEevaluated 18 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEnever evaluated
? QString::fromLatin1(".qm") : suffix);
0-18
293 fi.setFile(realname);-
294 if (fi.isReadable()
fi.isReadable()Description
TRUEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QTranslator
&& fi.isFile()
fi.isFile()Description
TRUEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEnever evaluated
)
0-9
295 break;
executed 9 times by 2 tests: break;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
9
296-
297 realname = prefix + fname;-
298 fi.setFile(realname);-
299 if (fi.isReadable()
fi.isReadable()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QTranslator
&& fi.isFile()
fi.isFile()Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTranslator
)
1-6
300 break;
executed 5 times by 1 test: break;
Executed by:
  • tst_QTranslator
5
301-
302 int rightmost = 0;-
303 for (int i = 0; i < (int)delims.length()
i < (int)delims.length()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QTranslator
; i++) {
4-8
304 int k = fname.lastIndexOf(delims[i]);-
305 if (k > rightmost
k > rightmostDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QTranslator
)
0-8
306 rightmost = k;
never executed: rightmost = k;
0
307 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_QTranslator
8
308-
309-
310 if (rightmost == 0
rightmost == 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEnever evaluated
)
0-4
311 return
executed 4 times by 1 test: return false;
Executed by:
  • tst_QTranslator
false;
executed 4 times by 1 test: return false;
Executed by:
  • tst_QTranslator
4
312-
313 fname.truncate(rightmost);-
314 }
never executed: end of block
0
315-
316-
317 return
executed 14 times by 2 tests: return d->do_load(realname, directory);
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
d->do_load(realname, directory);
executed 14 times by 2 tests: return d->do_load(realname, directory);
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
14
318}-
319-
320bool QTranslatorPrivate::do_load(const QString &realname, const QString &directory)-
321{-
322 QTranslatorPrivate *d = this;-
323 bool ok = false;-
324-
325 if (realname.startsWith(':')
realname.startsWith(':')Description
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tst_QTranslator
) {
3-11
326-
327-
328 ((!(!d->resource)) ? qt_assert("!d->resource",__FILE__,525) : qt_noop());-
329 d->resource = new QResource(realname);-
330 if (resource->isValid()
resource->isValid()Description
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEnever evaluated
&& !resource->isCompressed()
!resource->isCompressed()Description
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QKeySequence
&& resource->size() > MagicLength
resource->size() > MagicLengthDescription
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEnever evaluated
0-3
331 && !memcmp(resource->data(), magic, MagicLength)
!memcmp(resour..., MagicLength)Description
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEnever evaluated
) {
0-2
332 d->unmapLength = resource->size();-
333 d->unmapPointer = reinterpret_cast<char *>(const_cast<uchar *>(resource->data()));-
334-
335 d->used_mmap = false;-
336-
337 ok = true;-
338 }
executed 2 times by 2 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
else {
2
339 delete resource;-
340 resource = 0;-
341 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QKeySequence
1
342 }-
343-
344 if (!ok
!okDescription
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
) {
2-12
345 QFile file(realname);-
346 if (!file.open(QIODevice::ReadOnly | QIODevice::Unbuffered)
!file.open(QIO...e::Unbuffered)Description
TRUEnever evaluated
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
0-12
347 return
never executed: return false;
false;
never executed: return false;
0
348-
349 qint64 fileSize = file.size();-
350 if (fileSize <= MagicLength
fileSize <= MagicLengthDescription
TRUEnever evaluated
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
|| quint32(-1) <= fileSize
quint32(-1) <= fileSizeDescription
TRUEnever evaluated
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
0-12
351 return
never executed: return false;
false;
never executed: return false;
0
352-
353 {-
354 char magicBuffer[MagicLength];-
355 if (MagicLength != file.read(magicBuffer, MagicLength)
MagicLength !=..., MagicLength)Description
TRUEnever evaluated
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
0-12
356 || memcmp(magicBuffer, magic, MagicLength)
memcmp(magicBu..., MagicLength)Description
TRUEnever evaluated
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
0-12
357 return
never executed: return false;
false;
never executed: return false;
0
358 }-
359-
360 d->unmapLength = quint32(fileSize);-
361 int fd = file.handle();-
362 if (fd >= 0
fd >= 0Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QKeySequence
) {
1-11
363 char *ptr;-
364 ptr = reinterpret_cast<char *>(-
365 mmap(0, d->unmapLength,-
366 0x1,-
367 0 | 0x02,-
368 fd, 0));-
369 if (ptr
ptrDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEnever evaluated
&& ptr != reinterpret_cast<char *>(((void *) -1))
ptr != reinter...((void *) -1))Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEnever evaluated
) {
0-11
370 file.close();-
371 d->used_mmap = true;-
372 d->unmapPointer = ptr;-
373 ok = true;-
374 }
executed 11 times by 1 test: end of block
Executed by:
  • tst_QTranslator
11
375 }
executed 11 times by 1 test: end of block
Executed by:
  • tst_QTranslator
11
376-
377-
378 if (!ok
!okDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QKeySequence
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tst_QTranslator
) {
1-11
379 d->unmapPointer = new char[d->unmapLength];-
380 if (d->unmapPointer
d->unmapPointerDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QKeySequence
FALSEnever evaluated
) {
0-1
381 file.seek(0);-
382 qint64 readResult = file.read(d->unmapPointer, d->unmapLength);-
383 if (readResult == qint64(unmapLength)
readResult == ...4(unmapLength)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QKeySequence
FALSEnever evaluated
)
0-1
384 ok = true;
executed 1 time by 1 test: ok = true;
Executed by:
  • tst_QKeySequence
1
385 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QKeySequence
1
386 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QKeySequence
1
387 }
executed 12 times by 2 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
12
388-
389 if (ok
okDescription
TRUEevaluated 14 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEnever evaluated
&& d->do_load(reinterpret_cast<const uchar *>(d->unmapPointer), d->unmapLength, directory)
d->do_load(rei...th, directory)Description
TRUEevaluated 14 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEnever evaluated
)
0-14
390 return
executed 14 times by 2 tests: return true;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
true;
executed 14 times by 2 tests: return true;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
14
391-
392-
393 if (used_mmap
used_mmapDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
394 used_mmap = false;-
395 munmap(unmapPointer, unmapLength);-
396 }
never executed: end of block
else
0
397-
398 if (!d->resource
!d->resourceDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
399 delete [] unmapPointer;
never executed: delete [] unmapPointer;
0
400-
401 delete d->resource;-
402 d->resource = 0;-
403 d->unmapPointer = 0;-
404 d->unmapLength = 0;-
405-
406 return
never executed: return false;
false;
never executed: return false;
0
407}-
408-
409static QString find_translation(const QLocale & locale,-
410 const QString & filename,-
411 const QString & prefix,-
412 const QString & directory,-
413 const QString & suffix)-
414{-
415 QString path;-
416 if (QFileInfo(filename).isRelative()
QFileInfo(file...).isRelative()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
417 path = directory;-
418 if (!path.isEmpty()
!path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& !path.endsWith(QLatin1Char('/'))
!path.endsWith...tin1Char('/'))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
419 path += QLatin1Char('/');
never executed: path += QLatin1Char('/');
0
420 }
never executed: end of block
0
421-
422 QFileInfo fi;-
423 QString realname;-
424 QStringList fuzzyLocales;-
425-
426-
427-
428 QStringList languages = locale.uiLanguages();-
429-
430 for (int i = languages.size()-1; i >= 0
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
; --i) {
0
431 QString lang = languages.at(i);-
432 QString lowerLang = lang.toLower();-
433 if (lang != lowerLang
lang != lowerLangDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
434 languages.insert(i+1, lowerLang);
never executed: languages.insert(i+1, lowerLang);
0
435 }
never executed: end of block
0
436-
437-
438-
439 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(languages)>::type> _container_((languages)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QString localeName = *_container_.i; _container_.control; _container_.control = 0) {-
440 localeName.replace(QLatin1Char('-'), QLatin1Char('_'));-
441-
442 realname = path + filename + prefix + localeName + (suffix.isNull()
suffix.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
? QLatin1String(".qm") : suffix);
0
443 fi.setFile(realname);-
444 if (fi.isReadable()
fi.isReadable()Description
TRUEnever evaluated
FALSEnever evaluated
&& fi.isFile()
fi.isFile()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
445 return
never executed: return realname;
realname;
never executed: return realname;
0
446-
447 realname = path + filename + prefix + localeName;-
448 fi.setFile(realname);-
449 if (fi.isReadable()
fi.isReadable()Description
TRUEnever evaluated
FALSEnever evaluated
&& fi.isFile()
fi.isFile()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
450 return
never executed: return realname;
realname;
never executed: return realname;
0
451-
452 fuzzyLocales.append(localeName);-
453 }
never executed: end of block
0
454-
455-
456 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(fuzzyLocales)>::type> _container_((fuzzyLocales)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QString localeName = *_container_.i; _container_.control; _container_.control = 0) {-
457 for (;;) {-
458 int rightmost = localeName.lastIndexOf(QLatin1Char('_'));-
459-
460 if (rightmost <= 0
rightmost <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
461 break;
never executed: break;
0
462 localeName.truncate(rightmost);-
463-
464 realname = path + filename + prefix + localeName + (suffix.isNull()
suffix.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
? QLatin1String(".qm") : suffix);
0
465 fi.setFile(realname);-
466 if (fi.isReadable()
fi.isReadable()Description
TRUEnever evaluated
FALSEnever evaluated
&& fi.isFile()
fi.isFile()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
467 return
never executed: return realname;
realname;
never executed: return realname;
0
468-
469 realname = path + filename + prefix + localeName;-
470 fi.setFile(realname);-
471 if (fi.isReadable()
fi.isReadable()Description
TRUEnever evaluated
FALSEnever evaluated
&& fi.isFile()
fi.isFile()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
472 return
never executed: return realname;
realname;
never executed: return realname;
0
473 }
never executed: end of block
0
474 }
never executed: end of block
0
475-
476 if (!suffix.isNull()
!suffix.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
477 realname = path + filename + suffix;-
478 fi.setFile(realname);-
479 if (fi.isReadable()
fi.isReadable()Description
TRUEnever evaluated
FALSEnever evaluated
&& fi.isFile()
fi.isFile()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
480 return
never executed: return realname;
realname;
never executed: return realname;
0
481 }
never executed: end of block
0
482-
483 realname = path + filename + prefix;-
484 fi.setFile(realname);-
485 if (fi.isReadable()
fi.isReadable()Description
TRUEnever evaluated
FALSEnever evaluated
&& fi.isFile()
fi.isFile()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
486 return
never executed: return realname;
realname;
never executed: return realname;
0
487-
488 realname = path + filename;-
489 fi.setFile(realname);-
490 if (fi.isReadable()
fi.isReadable()Description
TRUEnever evaluated
FALSEnever evaluated
&& fi.isFile()
fi.isFile()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
491 return
never executed: return realname;
realname;
never executed: return realname;
0
492-
493 return
never executed: return QString();
QString();
never executed: return QString();
0
494}-
495bool QTranslator::load(const QLocale & locale,-
496 const QString & filename,-
497 const QString & prefix,-
498 const QString & directory,-
499 const QString & suffix)-
500{-
501 QTranslatorPrivate * const d = d_func();-
502 d->clear();-
503 QString fname = find_translation(locale, filename, prefix, directory, suffix);-
504 return
never executed: return !fname.isEmpty() && d->do_load(fname, directory);
!fname.isEmpty()
!fname.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& d->do_load(fname, directory)
d->do_load(fname, directory)Description
TRUEnever evaluated
FALSEnever evaluated
;
never executed: return !fname.isEmpty() && d->do_load(fname, directory);
0
505}-
506bool QTranslator::load(const uchar *data, int len, const QString &directory)-
507{-
508 QTranslatorPrivate * const d = d_func();-
509 d->clear();-
510-
511 if (!data
!dataDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTranslator
|| len < MagicLength
len < MagicLengthDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTranslator
|| memcmp(data, magic, MagicLength)
memcmp(data, m..., MagicLength)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTranslator
)
0-2
512 return
never executed: return false;
false;
never executed: return false;
0
513-
514 return
executed 2 times by 1 test: return d->do_load(data, len, directory);
Executed by:
  • tst_QTranslator
d->do_load(data, len, directory);
executed 2 times by 1 test: return d->do_load(data, len, directory);
Executed by:
  • tst_QTranslator
2
515}-
516-
517static quint8 read8(const uchar *data)-
518{-
519 return
executed 902 times by 2 tests: return qFromBigEndian<quint8>(data);
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
qFromBigEndian<quint8>(data);
executed 902 times by 2 tests: return qFromBigEndian<quint8>(data);
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
902
520}-
521-
522static quint16 read16(const uchar *data)-
523{-
524 return
never executed: return qFromBigEndian<quint16>(data);
qFromBigEndian<quint16>(data);
never executed: return qFromBigEndian<quint16>(data);
0
525}-
526-
527static quint32 read32(const uchar *data)-
528{-
529 return
executed 3591 times by 2 tests: return qFromBigEndian<quint32>(data);
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
qFromBigEndian<quint32>(data);
executed 3591 times by 2 tests: return qFromBigEndian<quint32>(data);
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
3591
530}-
531-
532bool QTranslatorPrivate::do_load(const uchar *data, int len, const QString &directory)-
533{-
534 bool ok = true;-
535 const uchar *end = data + len;-
536-
537 data += MagicLength;-
538-
539 QStringList dependencies;-
540 while (data < end - 4
data < end - 4Description
TRUEevaluated 49 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 16 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
) {
16-49
541 quint8 tag = read8(data++);-
542 quint32 blockLen = read32(data);-
543 data += 4;-
544 if (!tag
!tagDescription
TRUEnever evaluated
FALSEevaluated 49 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
|| !blockLen
!blockLenDescription
TRUEnever evaluated
FALSEevaluated 49 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
0-49
545 break;
never executed: break;
0
546 if (quint32(end - data) < blockLen
quint32(end - data) < blockLenDescription
TRUEnever evaluated
FALSEevaluated 49 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
) {
0-49
547 ok = false;-
548 break;
never executed: break;
0
549 }-
550-
551 if (tag == QTranslatorPrivate::Contexts
tag == QTransl...vate::ContextsDescription
TRUEnever evaluated
FALSEevaluated 49 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
) {
0-49
552 contextArray = data;-
553 contextLength = blockLen;-
554 }
never executed: end of block
else if (tag == QTranslatorPrivate::Hashes
tag == QTransl...rivate::HashesDescription
TRUEevaluated 16 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 33 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
) {
0-33
555 offsetArray = data;-
556 offsetLength = blockLen;-
557 }
executed 16 times by 2 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
else if (tag == QTranslatorPrivate::Messages
tag == QTransl...vate::MessagesDescription
TRUEevaluated 16 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 17 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
) {
16-17
558 messageArray = data;-
559 messageLength = blockLen;-
560 }
executed 16 times by 2 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
else if (tag == QTranslatorPrivate::NumerusRules
tag == QTransl...::NumerusRulesDescription
TRUEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTranslator
) {
2-16
561 numerusRulesArray = data;-
562 numerusRulesLength = blockLen;-
563 }
executed 15 times by 2 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
else if (tag == QTranslatorPrivate::Dependencies
tag == QTransl...::DependenciesDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEnever evaluated
) {
0-15
564 QDataStream stream(QByteArray::fromRawData((const char*)data, blockLen));-
565 QString dep;-
566 while (!stream.atEnd()
!stream.atEnd()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTranslator
) {
2
567 stream >> dep;-
568 dependencies.append(dep);-
569 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QTranslator
2
570 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QTranslator
2
571-
572 data += blockLen;-
573 }
executed 49 times by 2 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
49
574-
575 if (dependencies.isEmpty()
dependencies.isEmpty()Description
TRUEevaluated 14 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTranslator
&& (!offsetArray
!offsetArrayDescription
TRUEnever evaluated
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
|| !messageArray
!messageArrayDescription
TRUEnever evaluated
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
))
0-14
576 ok = false;
never executed: ok = false;
0
577 if (ok
okDescription
TRUEevaluated 16 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEnever evaluated
&& !isValidNumerusRules(numerusRulesArray, numerusRulesLength)
!isValidNumeru...usRulesLength)Description
TRUEnever evaluated
FALSEevaluated 16 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
0-16
578 ok = false;
never executed: ok = false;
0
579 if (ok
okDescription
TRUEevaluated 16 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEnever evaluated
) {
0-16
580 const int dependenciesCount = dependencies.count();-
581 subTranslators.reserve(dependenciesCount);-
582 for (int i = 0 ; i < dependenciesCount
i < dependenciesCountDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 16 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
; ++i) {
2-16
583 QTranslator *translator = new QTranslator;-
584 subTranslators.append(translator);-
585 ok = translator->load(dependencies.at(i), directory);-
586 if (!ok
!okDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTranslator
)
0-2
587 break;
never executed: break;
0
588 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QTranslator
2
589-
590-
591 if (!ok
!okDescription
TRUEnever evaluated
FALSEevaluated 16 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
) {
0-16
592 qDeleteAll(subTranslators);-
593 subTranslators.clear();-
594 }
never executed: end of block
0
595 }
executed 16 times by 2 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
16
596-
597 if (!ok
!okDescription
TRUEnever evaluated
FALSEevaluated 16 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
) {
0-16
598 messageArray = 0;-
599 contextArray = 0;-
600 offsetArray = 0;-
601 numerusRulesArray = 0;-
602 messageLength = 0;-
603 contextLength = 0;-
604 offsetLength = 0;-
605 numerusRulesLength = 0;-
606 }
never executed: end of block
0
607-
608 return
executed 16 times by 2 tests: return ok;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
ok;
executed 16 times by 2 tests: return ok;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
16
609}-
610-
611static QString getMessage(const uchar *m, const uchar *end, const char *context,-
612 const char *sourceText, const char *comment, uint numerus)-
613{-
614 const uchar *tn = 0;-
615 uint tn_length = 0;-
616 const uint sourceTextLen = uint(strlen(sourceText));-
617 const uint contextLen = uint(strlen(context));-
618 const uint commentLen = uint(strlen(comment));-
619-
620 for (;;) {-
621 uchar tag = 0;-
622 if (m < end
m < endDescription
TRUEevaluated 853 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEnever evaluated
)
0-853
623 tag = read8(m++);
executed 853 times by 2 tests: tag = read8(m++);
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
853
624 switch((Tag)tag) {-
625 case
executed 144 times by 2 tests: case Tag_End:
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
Tag_End:
executed 144 times by 2 tests: case Tag_End:
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
144
626 goto
executed 144 times by 2 tests: goto end;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
end;
executed 144 times by 2 tests: goto end;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
144
627 case
executed 187 times by 2 tests: case Tag_Translation:
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
Tag_Translation:
executed 187 times by 2 tests: case Tag_Translation:
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
{
187
628 int len = read32(m);-
629 if (len % 1
len % 1Description
TRUEnever evaluated
FALSEevaluated 187 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
0-187
630 return
never executed: return QString();
QString();
never executed: return QString();
0
631 m += 4;-
632 if (!numerus--
!numerus--Description
TRUEevaluated 173 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
) {
14-173
633 tn_length = len;-
634 tn = m;-
635 }
executed 173 times by 2 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
173
636 m += len;-
637 break;
executed 187 times by 2 tests: break;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
187
638 }-
639 case
executed 3 times by 1 test: case Tag_Obsolete1:
Executed by:
  • tst_QTranslator
Tag_Obsolete1:
executed 3 times by 1 test: case Tag_Obsolete1:
Executed by:
  • tst_QTranslator
3
640 m += 4;-
641 break;
executed 3 times by 1 test: break;
Executed by:
  • tst_QTranslator
3
642 case
executed 173 times by 2 tests: case Tag_SourceText:
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
Tag_SourceText:
executed 173 times by 2 tests: case Tag_SourceText:
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
{
173
643 quint32 len = read32(m);-
644 m += 4;-
645 if (!match(m, len, sourceText, sourceTextLen)
!match(m, len,...sourceTextLen)Description
TRUEnever evaluated
FALSEevaluated 173 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
0-173
646 return
never executed: return QString();
QString();
never executed: return QString();
0
647 m += len;-
648 }-
649 break;
executed 173 times by 2 tests: break;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
173
650 case
executed 173 times by 2 tests: case Tag_Context:
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
Tag_Context:
executed 173 times by 2 tests: case Tag_Context:
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
{
173
651 quint32 len = read32(m);-
652 m += 4;-
653 if (!match(m, len, context, contextLen)
!match(m, len,...t, contextLen)Description
TRUEevaluated 29 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 144 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
29-144
654 return
executed 29 times by 2 tests: return QString();
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
QString();
executed 29 times by 2 tests: return QString();
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
29
655 m += len;-
656 }-
657 break;
executed 144 times by 2 tests: break;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
144
658 case
executed 173 times by 2 tests: case Tag_Comment:
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
Tag_Comment:
executed 173 times by 2 tests: case Tag_Comment:
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
{
173
659 quint32 len = read32(m);-
660 m += 4;-
661 if (*
*mDescription
TRUEevaluated 167 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QTranslator
m
*mDescription
TRUEevaluated 167 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QTranslator
&& !match(m, len, comment, commentLen)
!match(m, len,...t, commentLen)Description
TRUEnever evaluated
FALSEevaluated 167 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
0-167
662 return
never executed: return QString();
QString();
never executed: return QString();
0
663 m += len;-
664 }-
665 break;
executed 173 times by 2 tests: break;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
173
666 default
never executed: default:
:
never executed: default:
0
667 return
never executed: return QString();
QString();
never executed: return QString();
0
668 }-
669 }-
670end:
code before this statement never executed: end:
0
671 if (!tn
!tnDescription
TRUEnever evaluated
FALSEevaluated 144 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
0-144
672 return
never executed: return QString();
QString();
never executed: return QString();
0
673 QString str = QString((const QChar *)tn, tn_length/2);-
674 if (QSysInfo::ByteOrder == QSysInfo::LittleEndian
QSysInfo::Byte...::LittleEndianDescription
TRUEevaluated 144 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEnever evaluated
) {
0-144
675 for (int i = 0; i < str.length()
i < str.length()Description
TRUEevaluated 818 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 144 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
; ++i)
144-818
676 str[i] = QChar((str.at(i).unicode() >> 8) + ((str.at(i).unicode() << 8) & 0xff00));
executed 818 times by 2 tests: str[i] = QChar((str.at(i).unicode() >> 8) + ((str.at(i).unicode() << 8) & 0xff00));
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
818
677 }
executed 144 times by 2 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
144
678 return
executed 144 times by 2 tests: return str;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
str;
executed 144 times by 2 tests: return str;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
144
679}-
680-
681QString QTranslatorPrivate::do_translate(const char *context, const char *sourceText,-
682 const char *comment, int n) const-
683{-
684 if (context == 0
context == 0Description
TRUEnever evaluated
FALSEevaluated 260 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
0-260
685 context = "";
never executed: context = "";
0
686 if (sourceText == 0
sourceText == 0Description
TRUEnever evaluated
FALSEevaluated 260 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
0-260
687 sourceText = "";
never executed: sourceText = "";
0
688 if (comment == 0
comment == 0Description
TRUEevaluated 203 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 57 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
57-203
689 comment = "";
executed 203 times by 2 tests: comment = "";
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
203
690-
691 uint numerus = 0;-
692 size_t numItems = 0;-
693-
694 if (!offsetLength
!offsetLengthDescription
TRUEnever evaluated
FALSEevaluated 260 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
0-260
695 goto
never executed: goto searchDependencies;
searchDependencies;
never executed: goto searchDependencies;
0
696-
697-
698-
699-
700-
701 if (contextLength
contextLengthDescription
TRUEnever evaluated
FALSEevaluated 260 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
) {
0-260
702 quint16 hTableSize = read16(contextArray);-
703 uint g = elfHash(context) % hTableSize;-
704 const uchar *c = contextArray + 2 + (g << 1);-
705 quint16 off = read16(c);-
706 c += 2;-
707 if (off == 0
off == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
708 return
never executed: return QString();
QString();
never executed: return QString();
0
709 c = contextArray + (2 + (hTableSize << 1) + (off << 1));-
710-
711 const uint contextLen = uint(strlen(context));-
712 for (;;) {-
713 quint8 len = read8(c++);-
714 if (len == 0
len == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
715 return
never executed: return QString();
QString();
never executed: return QString();
0
716 if (match(c, len, context, contextLen)
match(c, len, ...t, contextLen)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
717 break;
never executed: break;
0
718 c += len;-
719 }
never executed: end of block
0
720 }
never executed: end of block
0
721-
722 numItems = offsetLength / (2 * sizeof(quint32));-
723 if (!numItems
!numItemsDescription
TRUEnever evaluated
FALSEevaluated 260 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
0-260
724 goto
never executed: goto searchDependencies;
searchDependencies;
never executed: goto searchDependencies;
0
725-
726 if (n >= 0
n >= 0Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 251 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
9-251
727 numerus = numerusHelper(n, numerusRulesArray, numerusRulesLength);
executed 9 times by 1 test: numerus = numerusHelper(n, numerusRulesArray, numerusRulesLength);
Executed by:
  • tst_QTranslator
9
728-
729 for (;;) {-
730 quint32 h = 0;-
731 elfHash_continue(sourceText, h);-
732 elfHash_continue(comment, h);-
733 elfHash_finish(h);-
734-
735 const uchar *start = offsetArray;-
736 const uchar *end = start + ((numItems-1) << 3);-
737 while (start <= end
start <= endDescription
TRUEevaluated 2131 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 139 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
) {
139-2131
738 const uchar *middle = start + (((end - start) >> 4) << 3);-
739 uint hash = read32(middle);-
740 if (h == hash
h == hashDescription
TRUEevaluated 173 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 1958 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
) {
173-1958
741 start = middle;-
742 break;
executed 173 times by 2 tests: break;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
173
743 } else if (hash < h
hash < hDescription
TRUEevaluated 745 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 1213 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
) {
745-1213
744 start = middle + 8;-
745 }
executed 745 times by 2 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
else {
745
746 end = middle - 8;-
747 }
executed 1213 times by 2 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
1213
748 }-
749-
750 if (start <= end
start <= endDescription
TRUEevaluated 173 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 139 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
) {
139-173
751-
752 while (start != offsetArray
start != offsetArrayDescription
TRUEevaluated 165 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 8 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
&& read32(start) == read32(start-8)
read32(start) ...ead32(start-8)Description
TRUEnever evaluated
FALSEevaluated 165 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
0-165
753 start -= 8;
never executed: start -= 8;
0
754-
755 while (start < offsetArray + offsetLength
start < offset...+ offsetLengthDescription
TRUEevaluated 202 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEnever evaluated
) {
0-202
756 quint32 rh = read32(start);-
757 start += 4;-
758 if (rh != h
rh != hDescription
TRUEevaluated 29 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 173 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
29-173
759 break;
executed 29 times by 2 tests: break;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
29
760 quint32 ro = read32(start);-
761 start += 4;-
762 QString tn = getMessage(messageArray + ro, messageArray + messageLength, context,-
763 sourceText, comment, numerus);-
764 if (!tn.isNull()
!tn.isNull()Description
TRUEevaluated 144 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 29 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
)
29-144
765 return
executed 144 times by 2 tests: return tn;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
tn;
executed 144 times by 2 tests: return tn;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
144
766 }
executed 29 times by 2 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
29
767 }
executed 29 times by 2 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
29
768 if (!comment[0]
!comment[0]Description
TRUEevaluated 116 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
FALSEevaluated 52 times by 1 test
Evaluated by:
  • tst_QKeySequence
)
52-116
769 break;
executed 116 times by 2 tests: break;
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
116
770 comment = "";-
771 }
executed 52 times by 1 test: end of block
Executed by:
  • tst_QKeySequence
52
772-
773searchDependencies:
code before this statement executed 116 times by 2 tests: searchDependencies:
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
116
774 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(subTranslators)>::type> _container_((subTranslators)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QTranslator *translator = *_container_.i; _container_.control; _container_.control = 0) {-
775 QString tn = translator->translate(context, sourceText, comment, n);-
776 if (!tn.isNull()
!tn.isNull()Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEnever evaluated
)
0-5
777 return
executed 5 times by 1 test: return tn;
Executed by:
  • tst_QTranslator
tn;
executed 5 times by 1 test: return tn;
Executed by:
  • tst_QTranslator
5
778 }
never executed: end of block
0
779 return
executed 111 times by 2 tests: return QString();
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
QString();
executed 111 times by 2 tests: return QString();
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
111
780}-
781-
782-
783-
784-
785-
786-
787-
788void QTranslatorPrivate::clear()-
789{-
790 QTranslator * const q = q_func();-
791 if (unmapPointer
unmapPointerDescription
TRUEevaluated 14 times by 2 tests
Evaluated by:
  • tst_QTranslator
  • tst_qkeysequence - unknown status
FALSEevaluated 24 times by 4 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QProgressDialog
  • tst_QTranslator
  • tst_languageChange
&& unmapLength
unmapLengthDescription
TRUEevaluated 14 times by 2 tests
Evaluated by:
  • tst_QTranslator
  • tst_qkeysequence - unknown status
FALSEnever evaluated
) {
0-24
792-
793 if (used_mmap
used_mmapDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QTranslator
  • tst_qkeysequence - unknown status
) {
3-11
794 used_mmap = false;-
795 munmap(unmapPointer, unmapLength);-
796 }
executed 11 times by 1 test: end of block
Executed by:
  • tst_QTranslator
else
11
797-
798 if (!resource
!resourceDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qkeysequence - unknown status
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QTranslator
  • tst_qkeysequence - unknown status
)
1-2
799 delete [] unmapPointer;
executed 1 time by 1 test: delete [] unmapPointer;
Executed by:
  • tst_qkeysequence - unknown status
1
800 }
executed 14 times by 2 tests: end of block
Executed by:
  • tst_QTranslator
  • tst_qkeysequence - unknown status
14
801-
802 delete resource;-
803 resource = 0;-
804 unmapPointer = 0;-
805 unmapLength = 0;-
806 messageArray = 0;-
807 contextArray = 0;-
808 offsetArray = 0;-
809 numerusRulesArray = 0;-
810 messageLength = 0;-
811 contextLength = 0;-
812 offsetLength = 0;-
813 numerusRulesLength = 0;-
814-
815 qDeleteAll(subTranslators);-
816 subTranslators.clear();-
817-
818 if (QCoreApplicationPrivate::isTranslatorInstalled(q)
QCoreApplicati...orInstalled(q)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 35 times by 5 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QProgressDialog
  • tst_QTranslator
  • tst_languageChange
  • tst_qkeysequence - unknown status
)
3-35
819 QCoreApplication::postEvent(QCoreApplication::instance(),
executed 3 times by 1 test: QCoreApplication::postEvent(QCoreApplication::instance(), new QEvent(QEvent::LanguageChange));
Executed by:
  • tst_QTranslator
3
820 new QEvent(QEvent::LanguageChange));
executed 3 times by 1 test: QCoreApplication::postEvent(QCoreApplication::instance(), new QEvent(QEvent::LanguageChange));
Executed by:
  • tst_QTranslator
3
821}
executed 38 times by 5 tests: end of block
Executed by:
  • tst_QKeySequence
  • tst_QProgressDialog
  • tst_QTranslator
  • tst_languageChange
  • tst_qkeysequence - unknown status
38
822QString QTranslator::translate(const char *context, const char *sourceText, const char *disambiguation,-
823 int n) const-
824{-
825 const QTranslatorPrivate * const d = d_func();-
826 return
executed 260 times by 2 tests: return d->do_translate(context, sourceText, disambiguation, n);
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
d->do_translate(context, sourceText, disambiguation, n);
executed 260 times by 2 tests: return d->do_translate(context, sourceText, disambiguation, n);
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
260
827}-
828-
829-
830-
831-
832-
833bool QTranslator::isEmpty() const-
834{-
835 const QTranslatorPrivate * const d = d_func();-
836 return
executed 39 times by 2 tests: return !d->unmapPointer && !d->unmapLength && !d->messageArray && !d->offsetArray && !d->contextArray && d->subTranslators.isEmpty();
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
!d->unmapPointer
!d->unmapPointerDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 35 times by 2 tests
Evaluated by:
  • tst_QKeySequence
  • tst_QTranslator
&& !d->unmapLength
!d->unmapLengthDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEnever evaluated
&& !d->messageArray
!d->messageArrayDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTranslator
&&
executed 39 times by 2 tests: return !d->unmapPointer && !d->unmapLength && !d->messageArray && !d->offsetArray && !d->contextArray && d->subTranslators.isEmpty();
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
0-39
837 !d->offsetArray
!d->offsetArrayDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEnever evaluated
&& !d->contextArray
!d->contextArrayDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEnever evaluated
&& d->subTranslators.isEmpty()
d->subTranslators.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QTranslator
FALSEnever evaluated
;
executed 39 times by 2 tests: return !d->unmapPointer && !d->unmapLength && !d->messageArray && !d->offsetArray && !d->contextArray && d->subTranslators.isEmpty();
Executed by:
  • tst_QKeySequence
  • tst_QTranslator
0-39
838}-
839-
840-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9