qmimemagicrule.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/mimetypes/qmimemagicrule.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8static const char magicRuleTypes_string[] =-
9 "invalid\0"-
10 "string\0"-
11 "host16\0"-
12 "host32\0"-
13 "big16\0"-
14 "big32\0"-
15 "little16\0"-
16 "little32\0"-
17 "byte\0"-
18 "\0";-
19-
20static const int magicRuleTypes_indices[] = {-
21 0, 8, 15, 22, 29, 35, 41, 50, 59, 65, 0-
22};-
23-
24QMimeMagicRule::Type QMimeMagicRule::type(const QByteArray &theTypeName)-
25{-
26 for (int i = String; i <= Byte; ++i) {-
27 if (theTypeName == magicRuleTypes_string + magicRuleTypes_indices[i])-
28 return Type(i);-
29 }-
30 return Invalid;-
31}-
32-
33QByteArray QMimeMagicRule::typeName(QMimeMagicRule::Type theType)-
34{-
35 return magicRuleTypes_string + magicRuleTypes_indices[theType];-
36}-
37-
class QMimeMagicRulePrivate
{
public:bool operator==(const QMimeMagicRulePrivate &other) const;QMimeMagicRule::Type type;
QByteArray value;
int startPos;
int endPos;
QByteArray mask;
QByteArray pattern;
quint32 number;
quint32 numberMask;
typedef bool (*MatchFunction)(const QMimeMagicRulePrivate *d, const QByteArray &data);
MatchFunction matchFunction;
};
bool QMimeMagicRulePrivate::operator==(const QMimeMagicRulePrivateQMimeMagicRule &other) const
39{-
40 return
never executed: return m_type == other.m_type && m_value == other.m_value && m_startPos == other.m_startPos && m_endPos == other.m_endPos && m_mask == other.m_mask && m_pattern == other.m_pattern && m_number == other.m_number && m_numberMask == other.m_numberMask && m_matchFunction == other.m_matchFunction;
typem_type == other.typem_type &&
never executed: return m_type == other.m_type && m_value == other.m_value && m_startPos == other.m_startPos && m_endPos == other.m_endPos && m_mask == other.m_mask && m_pattern == other.m_pattern && m_number == other.m_number && m_numberMask == other.m_numberMask && m_matchFunction == other.m_matchFunction;
0
41 valuem_value == other.valuem_value &&
never executed: return m_type == other.m_type && m_value == other.m_value && m_startPos == other.m_startPos && m_endPos == other.m_endPos && m_mask == other.m_mask && m_pattern == other.m_pattern && m_number == other.m_number && m_numberMask == other.m_numberMask && m_matchFunction == other.m_matchFunction;
0
42 startPosm_startPos == other.startPosm_startPos &&
never executed: return m_type == other.m_type && m_value == other.m_value && m_startPos == other.m_startPos && m_endPos == other.m_endPos && m_mask == other.m_mask && m_pattern == other.m_pattern && m_number == other.m_number && m_numberMask == other.m_numberMask && m_matchFunction == other.m_matchFunction;
0
43 endPosm_endPos == other.endPosm_endPos &&
never executed: return m_type == other.m_type && m_value == other.m_value && m_startPos == other.m_startPos && m_endPos == other.m_endPos && m_mask == other.m_mask && m_pattern == other.m_pattern && m_number == other.m_number && m_numberMask == other.m_numberMask && m_matchFunction == other.m_matchFunction;
0
44 maskm_mask == other.maskm_mask &&
never executed: return m_type == other.m_type && m_value == other.m_value && m_startPos == other.m_startPos && m_endPos == other.m_endPos && m_mask == other.m_mask && m_pattern == other.m_pattern && m_number == other.m_number && m_numberMask == other.m_numberMask && m_matchFunction == other.m_matchFunction;
0
45 patternm_pattern == other.patternm_pattern &&
never executed: return m_type == other.m_type && m_value == other.m_value && m_startPos == other.m_startPos && m_endPos == other.m_endPos && m_mask == other.m_mask && m_pattern == other.m_pattern && m_number == other.m_number && m_numberMask == other.m_numberMask && m_matchFunction == other.m_matchFunction;
0
46 numberm_number == other.numberm_number &&
never executed: return m_type == other.m_type && m_value == other.m_value && m_startPos == other.m_startPos && m_endPos == other.m_endPos && m_mask == other.m_mask && m_pattern == other.m_pattern && m_number == other.m_number && m_numberMask == other.m_numberMask && m_matchFunction == other.m_matchFunction;
0
47 numberMaskm_numberMask == other.numberMaskm_numberMask &&
never executed: return m_type == other.m_type && m_value == other.m_value && m_startPos == other.m_startPos && m_endPos == other.m_endPos && m_mask == other.m_mask && m_pattern == other.m_pattern && m_number == other.m_number && m_numberMask == other.m_numberMask && m_matchFunction == other.m_matchFunction;
0
48 matchFunctionm_matchFunction == other.matchFunctionm_matchFunction;
never executed: return m_type == other.m_type && m_value == other.m_value && m_startPos == other.m_startPos && m_endPos == other.m_endPos && m_mask == other.m_mask && m_pattern == other.m_pattern && m_number == other.m_number && m_numberMask == other.m_numberMask && m_matchFunction == other.m_matchFunction;
0
49}-
50-
51-
52bool QMimeMagicRule::matchSubstring(const char *dataPtr, int dataSize, int rangeStart, int rangeLength,-
53 int valueLength, const char *valueData, const char *mask)-
54{-
55-
56-
57 const int dataNeeded = qMin(rangeLength + valueLength - 1, dataSize - rangeStart);-
58-
59 if (!mask) {-
60-
61-
62 bool found = false;-
63 for (int i = rangeStart; i < rangeStart + rangeLength; ++i) {-
64 if (i + valueLength > dataSize)-
65 break;-
66-
67 if (memcmp(valueData, dataPtr + i, valueLength) == 0) {-
68 found = true;-
69 break;-
70 }-
71 }-
72 if (!found)-
73 return false;-
74 } else {-
75 bool found = false;-
76 const char *readDataBase = dataPtr + rangeStart;-
77-
78-
79-
80-
81 const int maxStartPos = dataNeeded - valueLength + 1;-
82 for (int i = 0; i < maxStartPos; ++i) {-
83 const char *d = readDataBase + i;-
84 bool valid = true;-
85 for (int idx = 0; idx < valueLength; ++idx) {-
86 if (((*d++) & mask[idx]) != (valueData[idx] & mask[idx])) {-
87 valid = false;-
88 break;-
89 }-
90 }-
91 if (valid)-
92 found = true;-
93 }-
94 if (!found)-
95 return false;-
96 }-
97-
98 return true;-
99}-
100-
staticbool QMimeMagicRule::matchString(const QMimeMagicRulePrivate *d,const QByteArray &data) const
102{-
103 const int rangeLength = d->endPosm_endPos - d->startPosm_startPos + 1;-
104 return
executed 17377 times by 1 test: return QMimeMagicRule::matchSubstring(data.constData(), data.size(), m_startPos, rangeLength, m_pattern.size(), m_pattern.constData(), m_mask.constData());
Executed by:
  • tst_QMimeDatabase
QMimeMagicRule::matchSubstring(data.constData(), data.size(), d->startPosm_startPos, rangeLength, d->patternm_pattern.size(), d->patternm_pattern.constData(), d->maskm_mask.constData());
executed 17377 times by 1 test: return QMimeMagicRule::matchSubstring(data.constData(), data.size(), m_startPos, rangeLength, m_pattern.size(), m_pattern.constData(), m_mask.constData());
Executed by:
  • tst_QMimeDatabase
17377
105}-
106-
107template <typename T>-
staticbool QMimeMagicRule::matchNumber(const QMimeMagicRulePrivate *d,const QByteArray &data) const
109{-
110 const T value(d->numberm_number);-
111 const T mask(d->numberMaskm_numberMask);-
112-
113-
114-
115-
116 const char *p = data.constData() + d->startPosm_startPos;-
117 const char *e = data.constData() + qMin(data.size() - int(sizeof(T)), d->endPosm_endPos + 1);-
118 for ( ; p <= e
p <= eDescription
TRUEevaluated 3457 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 1854 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
; ++p) {
1854-3457
119 if ((
(qFromUnaligne...(value & mask)Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 3444 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
qFromUnaligned<T>(reinterpret_cast<const uchar *>(p))) & mask) == (value & mask)
(qFromUnaligne...(value & mask)Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 3444 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)
13-3444
120 return
executed 13 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
true;
executed 13 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
13
121 }
executed 3444 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
3444
122-
123 return
executed 1854 times by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
false;
executed 1854 times by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
1854
124}-
125-
126static inline QByteArray makePattern(const QByteArray &value)-
127{-
128 QByteArray pattern(value.size(), Qt::Uninitialized);-
129 char *data = pattern.data();-
130-
131 const char *p = value.constData();-
132 const char *e = p + value.size();-
133 for ( ; p < e; ++p) {-
134 if (*p == '\\' && ++p < e) {-
135 if (*p == 'x') {-
136 char c = 0;-
137 for (int i = 0; i < 2 && p + 1 < e; ++i) {-
138 ++p;-
139 if (*p >= '0' && *p <= '9')-
140 c = (c << 4) + *p - '0';-
141 else if (*p >= 'a' && *p <= 'f')-
142 c = (c << 4) + *p - 'a' + 10;-
143 else if (*p >= 'A' && *p <= 'F')-
144 c = (c << 4) + *p - 'A' + 10;-
145 else-
146 continue;-
147 }-
148 *data++ = c;-
149 } else if (*p >= '0' && *p <= '7') {-
150 char c = *p - '0';-
151 if (p + 1 < e && p[1] >= '0' && p[1] <= '7') {-
152 c = (c << 3) + *(++p) - '0';-
153 if (p + 1 < e && p[1] >= '0' && p[1] <= '7' && p[-1] <= '3')-
154 c = (c << 3) + *(++p) - '0';-
155 }-
156 *data++ = c;-
157 } else if (*p == 'n') {-
158 *data++ = '\n';-
159 } else if (*p == 'r') {-
160 *data++ = '\r';-
161 } else if (*p == 't') {-
162 *data++ = '\t';-
163 } else {-
164 *data++ = *p;-
165 }-
166 } else {-
167 *data++ = *p;-
168 }-
169 }-
170 pattern.truncate(data - pattern.data());-
171-
172 return pattern;-
173}-
174-
175-
176-
177-
178-
179QMimeMagicRule::QMimeMagicRule(const QString &typeStr&type,-
180 const QByteArray &theValue&value,-
181 const QString &offsets,-
182 const QByteArray &theMask&mask,-
183 QString *errorString)-
184 : dm_type(new QMimeMagicRulePrivate)-
{
d->value = theValue;
d->mask = theMask;
d->matchFunction = 0;
d->type =QMimeMagicRule::type(typeStrtype.toLatin1());())),
185 m_value(value),-
186 m_mask(mask),-
187 m_matchFunction(nullptr)-
188{-
189 if (d->type__builtin_expect(!!(m_type
__builtin_expe...valid), false)Description
TRUEnever evaluated
FALSEevaluated 4058 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
== Invalid) {), false)
__builtin_expe...valid), false)Description
TRUEnever evaluated
FALSEevaluated 4058 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)
0-4058
190 *
never executed: *errorString = QLatin1String("Type ") + type + QLatin1String(" is not supported");
errorString = ([]() -> QString { enum { Size= sizeofQLatin1String(u"" "Type %s is not supported")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData") }, u"" "Type %s+ type + QLatin1String(" is not supported"}; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()).arg(typeStr);
never executed: *errorString = QLatin1String("Type ") + type + QLatin1String(" is not supported");
0
191-
192-
193 }const int colonIndex = offsets.indexOf(QLatin1Char(':'));-
194 const QStringQStringRef startPosStr = colonIndex == -1 ? offsets :offsets.midmidRef(0, colonIndex);-
195 const QStringQStringRef endPosStr = colonIndex == -1 ? offsets :offsets.midmidRef(colonIndex + 1);-
196 if (!(__builtin_expect(!!(!
__builtin_expe...ring)), false)Description
TRUEnever evaluated
FALSEevaluated 4058 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
QMimeTypeParserBase::parseNumber(startPosStr, &d->startPos&m_startPos, errorString)), false)
__builtin_expe...ring)), false)Description
TRUEnever evaluated
FALSEevaluated 4058 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
||
0-4058
197 !__builtin_expect(!!(!
__builtin_expe...ring)), false)Description
TRUEnever evaluated
FALSEevaluated 4058 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
QMimeTypeParserBase::parseNumber(endPosStr, &d->endPos&m_endPos, errorString)), false)
__builtin_expe...ring)), false)Description
TRUEnever evaluated
FALSEevaluated 4058 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
0-4058
198 d->typem_type = Invalid;-
199 return;
never executed: return;
0
200 }-
201-
202 if (d->value__builtin_expect(!!(m_value
__builtin_expe...pty()), false)Description
TRUEnever evaluated
FALSEevaluated 4058 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
.isEmpty())()), false)
__builtin_expe...pty()), false)Description
TRUEnever evaluated
FALSEevaluated 4058 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
0-4058
203 d->typem_type = Invalid;-
204 if (errorString
errorStringDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
205 *
never executed: *errorString = ([]() -> QString { enum { Size = sizeof(u"" "Invalid empty magic rule value")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Invalid empty magic rule value" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
errorString = QLatin1String([]() -> QString { enum { Size = sizeof(u"" "Invalid empty magic rule value")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Invalid empty magic rule value" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}());
never executed: *errorString = ([]() -> QString { enum { Size = sizeof(u"" "Invalid empty magic rule value")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Invalid empty magic rule value" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
0
206 return;
never executed: return;
0
207 }-
208-
209 if (d->typem_type
m_type >= Host16Description
TRUEevaluated 627 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 3431 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
>= Host16
m_type >= Host16Description
TRUEevaluated 627 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 3431 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
&& d->typem_type
m_type <= ByteDescription
TRUEevaluated 627 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
<= Byte
m_type <= ByteDescription
TRUEevaluated 627 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
) {
0-3431
210 bool ok;-
211 d->numberm_number = d->valuem_value.toUInt(&ok, 0);-
212 if (!(__builtin_expect(!!(!
__builtin_expe...!(!ok), false)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 625 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
ok)), false)
__builtin_expe...!(!ok), false)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 625 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
2-625
213 d->typem_type = Invalid;-
214 if (errorString
errorStringDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
)
0-2
215 *
executed 2 times by 1 test: *errorString = QLatin1String("Invalid magic rule value \"") + QLatin1String(m_value) + QLatin1Char('"');
Executed by:
  • tst_QMimeDatabase
errorString = QString::fromLatin1QLatin1String("Invalid magic rule value \"%1\"").arg\"") + QLatin1String(QString::fromLatin1m_value) + QLatin1Char(d->value));'"');
executed 2 times by 1 test: *errorString = QLatin1String("Invalid magic rule value \"") + QLatin1String(m_value) + QLatin1Char('"');
Executed by:
  • tst_QMimeDatabase
2
216 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_QMimeDatabase
2
217 }d->numberMask-
218 m_numberMask = !d->maskm_mask.isEmpty()
!m_mask.isEmpty()Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 575 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
?d->mask m_mask.toUInt(&ok, 0) : 0;
50-575
219 }
executed 625 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
625
220-
221 switch (d->typem_type) {-
222 case
executed 3431 times by 1 test: case String:
Executed by:
  • tst_QMimeDatabase
String:d->pattern
executed 3431 times by 1 test: case String:
Executed by:
  • tst_QMimeDatabase
3431
223 m_pattern = makePattern(d->valuem_value);d->pattern-
224 m_pattern.squeeze();-
225 if (!d->maskm_mask.isEmpty()
!m_mask.isEmpty()Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 3402 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
29-3402
226 if (d->mask__builtin_expect(!!(m_mask
__builtin_expe..."0x")), false)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 27 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
.size() < 4 || !d->maskm_mask.startsWith("0x")), false)
__builtin_expe..."0x")), false)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 27 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {d->type
2-27
227 m_type = Invalid;-
228 if (errorString
errorStringDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
)
0-2
229 *
executed 2 times by 1 test: *errorString = QLatin1String("Invalid magic rule mask \"") + QLatin1String(m_mask) + QLatin1Char('"');
Executed by:
  • tst_QMimeDatabase
errorString =QString::fromLatin1 QLatin1String("Invalid magic rule mask \"") \"%1\"").arg+ QLatin1String(QString::fromLatin1m_mask) + QLatin1Char(d->mask));'"');
executed 2 times by 1 test: *errorString = QLatin1String("Invalid magic rule mask \"") + QLatin1String(m_mask) + QLatin1Char('"');
Executed by:
  • tst_QMimeDatabase
2
230 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_QMimeDatabase
2
231 }-
232 const QByteArray &tempMask = QByteArray::fromHex(QByteArray::fromRawData(-
233 d->maskm_mask.constData() + 2, d->maskm_mask.size() - 2));-
234 if (__builtin_expect(!!(
__builtin_expe...ize()), false)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 25 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
tempMask.size() != d->patternm_pattern.size())()), false)
__builtin_expe...ize()), false)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 25 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
2-25
235 d->typem_type = Invalid;-
236 if (errorString
errorStringDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
)
0-2
237 *
executed 2 times by 1 test: *errorString = QLatin1String("Invalid magic rule mask size \"") + QLatin1String(m_mask) + QLatin1Char('"');
Executed by:
  • tst_QMimeDatabase
errorString = QString::fromLatin1QLatin1String("Invalid magic rule mask size \"%1\"").arg\"") + QLatin1String(QString::fromLatin1m_mask) + QLatin1Char(d->mask));'"');
executed 2 times by 1 test: *errorString = QLatin1String("Invalid magic rule mask size \"") + QLatin1String(m_mask) + QLatin1Char('"');
Executed by:
  • tst_QMimeDatabase
2
238 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_QMimeDatabase
2
239 }d->mask-
240 m_mask = tempMask;-
241 }
executed 25 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
else {d->mask
25
242 m_mask.fill(char(-1),d->pattern m_pattern.size());-
243 }
executed 3402 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
d->mask
executed 3402 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
3402
244 m_mask.squeeze();d->matchFunction-
245 m_matchFunction = &QMimeMagicRule::matchString;-
246 break;
executed 3427 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
3427
247 case
executed 205 times by 1 test: case Byte:
Executed by:
  • tst_QMimeDatabase
Byte:
executed 205 times by 1 test: case Byte:
Executed by:
  • tst_QMimeDatabase
205
248 if (d->numberm_number
m_number <= quint8(-1)Description
TRUEevaluated 205 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
<= quint8(-1)
m_number <= quint8(-1)Description
TRUEevaluated 205 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
) {
0-205
249 if (d->numberMaskm_numberMask
m_numberMask == 0Description
TRUEevaluated 205 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
== 0
m_numberMask == 0Description
TRUEevaluated 205 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
)d->numberMask
0-205
250 m_numberMask
executed 205 times by 1 test: m_numberMask = quint8(-1);
Executed by:
  • tst_QMimeDatabase
executed 205 times by 1 test: m_numberMask = quint8(-1);
Executed by:
  • tst_QMimeDatabase
= quint8(-1);d->matchFunction
executed 205 times by 1 test: m_numberMask = quint8(-1);
Executed by:
  • tst_QMimeDatabase
205
251 m_matchFunction = &QMimeMagicRule::matchNumber<quint8>;-
252 }
executed 205 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
205
253 break;
executed 205 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
205
254 case
executed 65 times by 1 test: case Big16:
Executed by:
  • tst_QMimeDatabase
Big16:
executed 65 times by 1 test: case Big16:
Executed by:
  • tst_QMimeDatabase
65
255 case
executed 20 times by 1 test: case Host16:
Executed by:
  • tst_QMimeDatabase
Host16:
executed 20 times by 1 test: case Host16:
Executed by:
  • tst_QMimeDatabase
20
256 case
executed 85 times by 1 test: case Little16:
Executed by:
  • tst_QMimeDatabase
Little16:
executed 85 times by 1 test: case Little16:
Executed by:
  • tst_QMimeDatabase
85
257 if (d->numberm_number
m_number <= quint16(-1)Description
TRUEevaluated 170 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
<= quint16(-1)
m_number <= quint16(-1)Description
TRUEevaluated 170 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
) {d->number
0-170
258 m_number =d->type m_type
m_type == Little16Description
TRUEevaluated 85 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 85 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
== Little16
m_type == Little16Description
TRUEevaluated 85 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 85 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
? qFromLittleEndian<quint16>(d->numberm_number) : qFromBigEndian<quint16>(d->numberm_number);
85
259 if (d->numberMaskm_numberMask
m_numberMask == 0Description
TRUEevaluated 165 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
== 0
m_numberMask == 0Description
TRUEevaluated 165 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)d->numberMask
5-165
260 m_numberMask
executed 165 times by 1 test: m_numberMask = quint16(-1);
Executed by:
  • tst_QMimeDatabase
executed 165 times by 1 test: m_numberMask = quint16(-1);
Executed by:
  • tst_QMimeDatabase
= quint16(-1);d->matchFunction
executed 165 times by 1 test: m_numberMask = quint16(-1);
Executed by:
  • tst_QMimeDatabase
165
261 m_matchFunction = &QMimeMagicRule::matchNumber<quint16>;-
262 }
executed 170 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
170
263 break;
executed 170 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
170
264 case
executed 95 times by 1 test: case Big32:
Executed by:
  • tst_QMimeDatabase
Big32:
executed 95 times by 1 test: case Big32:
Executed by:
  • tst_QMimeDatabase
95
265 case
executed 20 times by 1 test: case Host32:
Executed by:
  • tst_QMimeDatabase
Host32:
executed 20 times by 1 test: case Host32:
Executed by:
  • tst_QMimeDatabase
20
266 case
executed 135 times by 1 test: case Little32:
Executed by:
  • tst_QMimeDatabase
Little32:
executed 135 times by 1 test: case Little32:
Executed by:
  • tst_QMimeDatabase
135
267 if (d->numberm_number
m_number <= quint32(-1)Description
TRUEevaluated 250 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
<= quint32(-1)
m_number <= quint32(-1)Description
TRUEevaluated 250 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
) {d->number
0-250
268 m_number =d->type m_type
m_type == Little32Description
TRUEevaluated 135 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 115 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
== Little32
m_type == Little32Description
TRUEevaluated 135 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 115 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
? qFromLittleEndian<quint32>(d->numberm_number) : qFromBigEndian<quint32>(d->numberm_number);
115-135
269 if (d->numberMaskm_numberMask
m_numberMask == 0Description
TRUEevaluated 205 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 45 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
== 0
m_numberMask == 0Description
TRUEevaluated 205 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 45 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)d->numberMask
45-205
270 m_numberMask
executed 205 times by 1 test: m_numberMask = quint32(-1);
Executed by:
  • tst_QMimeDatabase
executed 205 times by 1 test: m_numberMask = quint32(-1);
Executed by:
  • tst_QMimeDatabase
= quint32(-1);d->matchFunction
executed 205 times by 1 test: m_numberMask = quint32(-1);
Executed by:
  • tst_QMimeDatabase
205
271 m_matchFunction = &QMimeMagicRule::matchNumber<quint32>;-
272 }
executed 250 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
250
273 break;
executed 250 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
250
274 default
never executed: default:
:
never executed: default:
0
275 break
never executed: break;
;
never executed: break;
0
}
never executed: break;
}
never executed: break;
QMimeMagicRule::QMimeMagicRule(const QMimeMagicRule &other) :
never executed: break;
d(new QMimeMagicRulePrivate(*other.d))
never executed: break;
{
never executed: break;
}
never executed: break;
QMimeMagicRule::~QMimeMagicRule()
never executed: break;
{
never executed: break;
}
never executed: break;
QMimeMagicRule &QMimeMagicRule::operator=(const QMimeMagicRule &other)
never executed: break;
{
never executed: break;
*d = *other.d;
never executed: break;
return *this;
never executed: break;
}
never executed: break;
bool QMimeMagicRule::operator==(const QMimeMagicRule &other) const
never executed: break;
{
never executed: break;
return d == other.d ||
never executed: break;
*d == *other.d;
never executed: break;
}
never executed: break;
QMimeMagicRule::Type QMimeMagicRule::type() const
never executed: break;
{
never executed: break;
return d->type;
never executed: break;
}
never executed: break;
QByteArray QMimeMagicRule::value() const
never executed: break;
{
never executed: break;
return d->value;
never executed: break;
}
never executed: break;
int QMimeMagicRule::startPos() const
never executed: break;
{
never executed: break;
return d->startPos
never executed: break;
never executed: break;
;
never executed: break;
276 }int QMimeMagicRule::endPos() const-
{
return d->endPos;
277}-
278-
279QByteArray QMimeMagicRule::mask() const-
280{-
281 QByteArray result =d->mask m_mask;-
282 if (d->typem_type
m_type == StringDescription
TRUEnever evaluated
FALSEnever evaluated
== String
m_type == StringDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
283-
284 result= = "0x" + result.toHex();-
285 }
never executed: end of block
0
286 return
never executed: return result;
result;
never executed: return result;
0
}
never executed: return result;
bool QMimeMagicRule::isValid() const
never executed: return result;
{
never executed: return result;
return d->matchFunction
never executed: return result;
never executed: return result;
;
never executed: return result;
287}-
288-
289bool QMimeMagicRule::matches(const QByteArray &data) const-
290{-
291 const bool ok =d->matchFunction m_matchFunction &&d->matchFunction (
(this->*m_matchFunction)(data)Description
TRUEevaluated 59 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 19185 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
d.data(),this->*m_matchFunction)(data)
(this->*m_matchFunction)(data)Description
TRUEevaluated 59 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 19185 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
;
59-19185
292 if (!ok
!okDescription
TRUEevaluated 19185 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 59 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)
59-19185
293 return
executed 19185 times by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
false;
executed 19185 times by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
19185
294-
295-
296 if (m_subMatches.isEmpty()
m_subMatches.isEmpty()Description
TRUEevaluated 37 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)
22-37
297 return
executed 37 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
true;
executed 37 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
37
298-
299-
300-
301 for ( QList<QMimeMagicRule>::const_iterator it = m_subMatches.begin(), end = m_subMatches.end() ;-
302 it != end
it != endDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
; ++it ) {
18-22
303 if ((*
(*it).matches(data)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
it).matches(data)
(*it).matches(data)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
4-18
304-
305 return
executed 4 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
true;
executed 4 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
4
306 }-
307 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
18
308 return
executed 18 times by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
false;
executed 18 times by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
18
309-
310-
311}-
312-
313-
Switch to Source codePreprocessed file

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