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

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