| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/mimetypes/qmimetypeparser.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||
| 2 | ** | - | ||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||
| 5 | ** | - | ||||||
| 6 | ** This file is part of the QtCore module of the Qt Toolkit. | - | ||||||
| 7 | ** | - | ||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||
| 9 | ** Commercial License Usage | - | ||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||
| 16 | ** | - | ||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||
| 25 | ** | - | ||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||
| 29 | ** | - | ||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||
| 31 | ** | - | ||||||
| 32 | ****************************************************************************/ | - | ||||||
| 33 | - | |||||||
| 34 | #define QT_NO_CAST_FROM_ASCII | - | ||||||
| 35 | - | |||||||
| 36 | #include "qmimetypeparser_p.h" | - | ||||||
| 37 | - | |||||||
| 38 | #ifndef QT_NO_MIMETYPE | - | ||||||
| 39 | - | |||||||
| 40 | #include "qmimetype_p.h" | - | ||||||
| 41 | #include "qmimemagicrulematcher_p.h" | - | ||||||
| 42 | - | |||||||
| 43 | #include <QtCore/QCoreApplication> | - | ||||||
| 44 | #include <QtCore/QDebug> | - | ||||||
| 45 | #include <QtCore/QDir> | - | ||||||
| 46 | #include <QtCore/QPair> | - | ||||||
| 47 | #include <QtCore/QXmlStreamReader> | - | ||||||
| 48 | #include <QtCore/QXmlStreamWriter> | - | ||||||
| 49 | #include <QtCore/QStack> | - | ||||||
| 50 | - | |||||||
| 51 | QT_BEGIN_NAMESPACE | - | ||||||
| 52 | - | |||||||
| 53 | // XML tags in MIME files | - | ||||||
| 54 | static const char mimeInfoTagC[] = "mime-info"; | - | ||||||
| 55 | static const char mimeTypeTagC[] = "mime-type"; | - | ||||||
| 56 | static const char mimeTypeAttributeC[] = "type"; | - | ||||||
| 57 | static const char subClassTagC[] = "sub-class-of"; | - | ||||||
| 58 | static const char commentTagC[] = "comment"; | - | ||||||
| 59 | static const char genericIconTagC[] = "generic-icon"; | - | ||||||
| 60 | static const char iconTagC[] = "icon"; | - | ||||||
| 61 | static const char nameAttributeC[] = "name"; | - | ||||||
| 62 | static const char globTagC[] = "glob"; | - | ||||||
| 63 | static const char aliasTagC[] = "alias"; | - | ||||||
| 64 | static const char patternAttributeC[] = "pattern"; | - | ||||||
| 65 | static const char weightAttributeC[] = "weight"; | - | ||||||
| 66 | static const char caseSensitiveAttributeC[] = "case-sensitive"; | - | ||||||
| 67 | static const char localeAttributeC[] = "xml:lang"; | - | ||||||
| 68 | - | |||||||
| 69 | static const char magicTagC[] = "magic"; | - | ||||||
| 70 | static const char priorityAttributeC[] = "priority"; | - | ||||||
| 71 | - | |||||||
| 72 | static const char matchTagC[] = "match"; | - | ||||||
| 73 | static const char matchValueAttributeC[] = "value"; | - | ||||||
| 74 | static const char matchTypeAttributeC[] = "type"; | - | ||||||
| 75 | static const char matchOffsetAttributeC[] = "offset"; | - | ||||||
| 76 | static const char matchMaskAttributeC[] = "mask"; | - | ||||||
| 77 | - | |||||||
| 78 | /*! | - | ||||||
| 79 | \class QMimeTypeParser | - | ||||||
| 80 | \inmodule QtCore | - | ||||||
| 81 | \internal | - | ||||||
| 82 | \brief The QMimeTypeParser class parses MIME types, and builds a MIME database hierarchy by adding to QMimeDatabasePrivate. | - | ||||||
| 83 | - | |||||||
| 84 | Populates QMimeDataBase | - | ||||||
| 85 | - | |||||||
| 86 | \sa QMimeDatabase, QMimeMagicRuleMatcher, MagicRule, MagicStringRule, MagicByteRule, GlobPattern | - | ||||||
| 87 | \sa QMimeTypeParser | - | ||||||
| 88 | */ | - | ||||||
| 89 | - | |||||||
| 90 | /*! | - | ||||||
| 91 | \class QMimeTypeParserBase | - | ||||||
| 92 | \inmodule QtCore | - | ||||||
| 93 | \internal | - | ||||||
| 94 | \brief The QMimeTypeParserBase class parses for a sequence of <mime-type> in a generic way. | - | ||||||
| 95 | - | |||||||
| 96 | Calls abstract handler function process for QMimeType it finds. | - | ||||||
| 97 | - | |||||||
| 98 | \sa QMimeDatabase, QMimeMagicRuleMatcher, MagicRule, MagicStringRule, MagicByteRule, GlobPattern | - | ||||||
| 99 | \sa QMimeTypeParser | - | ||||||
| 100 | */ | - | ||||||
| 101 | - | |||||||
| 102 | /*! | - | ||||||
| 103 | \fn virtual bool QMimeTypeParserBase::process(const QMimeType &t, QString *errorMessage) = 0; | - | ||||||
| 104 | Overwrite to process the sequence of parsed data | - | ||||||
| 105 | */ | - | ||||||
| 106 | - | |||||||
| 107 | QMimeTypeParserBase::ParseState QMimeTypeParserBase::nextState(ParseState currentState, const QStringRef &startElement) | - | ||||||
| 108 | { | - | ||||||
| 109 | switch (currentState) { | - | ||||||
| 110 | case ParseBeginning: executed 17 times by 1 test: case ParseBeginning:Executed by:
| 17 | ||||||
| 111 | if (startElement == QLatin1String(mimeInfoTagC))
| 0-17 | ||||||
| 112 | return ParseMimeInfo; executed 17 times by 1 test: return ParseMimeInfo;Executed by:
| 17 | ||||||
| 113 | if (startElement == QLatin1String(mimeTypeTagC))
| 0 | ||||||
| 114 | return ParseMimeType; never executed: return ParseMimeType; | 0 | ||||||
| 115 | return ParseError; never executed: return ParseError; | 0 | ||||||
| 116 | case ParseMimeInfo: executed 17 times by 1 test: case ParseMimeInfo:Executed by:
| 17 | ||||||
| 117 | return startElement == QLatin1String(mimeTypeTagC) ? ParseMimeType : ParseError; executed 17 times by 1 test: return startElement == QLatin1String(mimeTypeTagC) ? ParseMimeType : ParseError;Executed by:
| 0-17 | ||||||
| 118 | case ParseMimeType: executed 3319 times by 1 test: case ParseMimeType:Executed by:
| 3319 | ||||||
| 119 | case ParseComment: executed 134104 times by 1 test: case ParseComment:Executed by:
| 134104 | ||||||
| 120 | case ParseGenericIcon: executed 1575 times by 1 test: case ParseGenericIcon:Executed by:
| 1575 | ||||||
| 121 | case ParseIcon: never executed: case ParseIcon: | 0 | ||||||
| 122 | case ParseGlobPattern: executed 4132 times by 1 test: case ParseGlobPattern:Executed by:
| 4132 | ||||||
| 123 | case ParseSubClass: executed 1560 times by 1 test: case ParseSubClass:Executed by:
| 1560 | ||||||
| 124 | case ParseAlias: executed 975 times by 1 test: case ParseAlias:Executed by:
| 975 | ||||||
| 125 | case ParseOtherMimeTypeSubTag: executed 1825 times by 1 test: case ParseOtherMimeTypeSubTag:Executed by:
| 1825 | ||||||
| 126 | case ParseMagicMatchRule: executed 4052 times by 1 test: case ParseMagicMatchRule:Executed by:
| 4052 | ||||||
| 127 | if (startElement == QLatin1String(mimeTypeTagC)) // Sequence of <mime-type>
| 3302-148240 | ||||||
| 128 | return ParseMimeType; executed 3302 times by 1 test: return ParseMimeType;Executed by:
| 3302 | ||||||
| 129 | if (startElement == QLatin1String(commentTagC ))
| 14136-134104 | ||||||
| 130 | return ParseComment; executed 134104 times by 1 test: return ParseComment;Executed by:
| 134104 | ||||||
| 131 | if (startElement == QLatin1String(genericIconTagC))
| 1575-12561 | ||||||
| 132 | return ParseGenericIcon; executed 1575 times by 1 test: return ParseGenericIcon;Executed by:
| 1575 | ||||||
| 133 | if (startElement == QLatin1String(iconTagC))
| 0-12561 | ||||||
| 134 | return ParseIcon; never executed: return ParseIcon; | 0 | ||||||
| 135 | if (startElement == QLatin1String(globTagC))
| 4136-8425 | ||||||
| 136 | return ParseGlobPattern; executed 4136 times by 1 test: return ParseGlobPattern;Executed by:
| 4136 | ||||||
| 137 | if (startElement == QLatin1String(subClassTagC))
| 1560-6865 | ||||||
| 138 | return ParseSubClass; executed 1560 times by 1 test: return ParseSubClass;Executed by:
| 1560 | ||||||
| 139 | if (startElement == QLatin1String(aliasTagC))
| 975-5890 | ||||||
| 140 | return ParseAlias; executed 975 times by 1 test: return ParseAlias;Executed by:
| 975 | ||||||
| 141 | if (startElement == QLatin1String(magicTagC))
| 1733-4157 | ||||||
| 142 | return ParseMagic; executed 1733 times by 1 test: return ParseMagic;Executed by:
| 1733 | ||||||
| 143 | if (startElement == QLatin1String(matchTagC))
| 1832-2325 | ||||||
| 144 | return ParseMagicMatchRule; executed 2325 times by 1 test: return ParseMagicMatchRule;Executed by:
| 2325 | ||||||
| 145 | return ParseOtherMimeTypeSubTag; executed 1832 times by 1 test: return ParseOtherMimeTypeSubTag;Executed by:
| 1832 | ||||||
| 146 | case ParseMagic: executed 1733 times by 1 test: case ParseMagic:Executed by:
| 1733 | ||||||
| 147 | if (startElement == QLatin1String(matchTagC))
| 0-1733 | ||||||
| 148 | return ParseMagicMatchRule; executed 1733 times by 1 test: return ParseMagicMatchRule;Executed by:
| 1733 | ||||||
| 149 | break; never executed: break; | 0 | ||||||
| 150 | case ParseError: never executed: case ParseError: | 0 | ||||||
| 151 | break; never executed: break; | 0 | ||||||
| 152 | } | - | ||||||
| 153 | return ParseError; never executed: return ParseError; | 0 | ||||||
| 154 | } | - | ||||||
| 155 | - | |||||||
| 156 | // Parse int number from an (attribute) string | - | ||||||
| 157 | bool QMimeTypeParserBase::parseNumber(const QString &n, int *target, QString *errorMessage) | - | ||||||
| 158 | { | - | ||||||
| 159 | bool ok; | - | ||||||
| 160 | *target = n.toInt(&ok); | - | ||||||
| 161 | if (!ok) {
| 0-9733 | ||||||
| 162 | *errorMessage = QString::fromLatin1("Not a number '%1'.").arg(n); | - | ||||||
| 163 | return false; never executed: return false; | 0 | ||||||
| 164 | } | - | ||||||
| 165 | return true; executed 9733 times by 1 test: return true;Executed by:
| 9733 | ||||||
| 166 | } | - | ||||||
| 167 | - | |||||||
| 168 | #ifndef QT_NO_XMLSTREAMREADER | - | ||||||
| 169 | static QMimeMagicRule *createMagicMatchRule(const QXmlStreamAttributes &atts, QString *errorMessage) | - | ||||||
| 170 | { | - | ||||||
| 171 | const QString type = atts.value(QLatin1String(matchTypeAttributeC)).toString(); | - | ||||||
| 172 | const QString value = atts.value(QLatin1String(matchValueAttributeC)).toString(); | - | ||||||
| 173 | const QString offsets = atts.value(QLatin1String(matchOffsetAttributeC)).toString(); | - | ||||||
| 174 | const QString mask = atts.value(QLatin1String(matchMaskAttributeC)).toString(); | - | ||||||
| 175 | return new QMimeMagicRule(type, value.toUtf8(), offsets, mask.toLatin1(), errorMessage); executed 4058 times by 1 test: return new QMimeMagicRule(type, value.toUtf8(), offsets, mask.toLatin1(), errorMessage);Executed by:
| 4058 | ||||||
| 176 | } | - | ||||||
| 177 | #endif | - | ||||||
| 178 | - | |||||||
| 179 | bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString *errorMessage) | - | ||||||
| 180 | { | - | ||||||
| 181 | #ifdef QT_NO_XMLSTREAMREADER | - | ||||||
| 182 | if (errorMessage) | - | ||||||
| 183 | *errorMessage = QString::fromLatin1("QXmlStreamReader is not available, cannot parse."); | - | ||||||
| 184 | return false; | - | ||||||
| 185 | #else | - | ||||||
| 186 | QMimeTypePrivate data; | - | ||||||
| 187 | int priority = 50; | - | ||||||
| 188 | QStack<QMimeMagicRule *> currentRules; // stack for the nesting of rules | - | ||||||
| 189 | QList<QMimeMagicRule> rules; // toplevel rules | - | ||||||
| 190 | QXmlStreamReader reader(dev); | - | ||||||
| 191 | ParseState ps = ParseBeginning; | - | ||||||
| 192 | QXmlStreamAttributes atts; | - | ||||||
| 193 | while (!reader.atEnd()) {
| 17-333413 | ||||||
| 194 | switch (reader.readNext()) { | - | ||||||
| 195 | case QXmlStreamReader::StartElement: executed 153309 times by 1 test: case QXmlStreamReader::StartElement:Executed by:
| 153309 | ||||||
| 196 | ps = nextState(ps, reader.name()); | - | ||||||
| 197 | atts = reader.attributes(); | - | ||||||
| 198 | switch (ps) { | - | ||||||
| 199 | case ParseMimeType: { // start parsing a MIME type name executed 3319 times by 1 test: case ParseMimeType:Executed by:
| 3319 | ||||||
| 200 | const QString name = atts.value(QLatin1String(mimeTypeAttributeC)).toString(); | - | ||||||
| 201 | if (name.isEmpty()) {
| 0-3319 | ||||||
| 202 | reader.raiseError(QString::fromLatin1("Missing '%1'-attribute").arg(QString::fromLatin1(mimeTypeAttributeC))); | - | ||||||
| 203 | } else { never executed: end of block | 0 | ||||||
| 204 | data.name = name; | - | ||||||
| 205 | } executed 3319 times by 1 test: end of blockExecuted by:
| 3319 | ||||||
| 206 | } | - | ||||||
| 207 | break; executed 3319 times by 1 test: break;Executed by:
| 3319 | ||||||
| 208 | case ParseGenericIcon: executed 1575 times by 1 test: case ParseGenericIcon:Executed by:
| 1575 | ||||||
| 209 | data.genericIconName = atts.value(QLatin1String(nameAttributeC)).toString(); | - | ||||||
| 210 | break; executed 1575 times by 1 test: break;Executed by:
| 1575 | ||||||
| 211 | case ParseIcon: never executed: case ParseIcon: | 0 | ||||||
| 212 | data.iconName = atts.value(QLatin1String(nameAttributeC)).toString(); | - | ||||||
| 213 | break; never executed: break; | 0 | ||||||
| 214 | case ParseGlobPattern: { executed 4136 times by 1 test: case ParseGlobPattern:Executed by:
| 4136 | ||||||
| 215 | const QString pattern = atts.value(QLatin1String(patternAttributeC)).toString(); | - | ||||||
| 216 | unsigned weight = atts.value(QLatin1String(weightAttributeC)).toString().toInt(); | - | ||||||
| 217 | const bool caseSensitive = atts.value(QLatin1String(caseSensitiveAttributeC)).toString() == QLatin1String("true"); | - | ||||||
| 218 | - | |||||||
| 219 | if (weight == 0)
| 10-4126 | ||||||
| 220 | weight = QMimeGlobPattern::DefaultWeight; executed 4126 times by 1 test: weight = QMimeGlobPattern::DefaultWeight;Executed by:
| 4126 | ||||||
| 221 | - | |||||||
| 222 | Q_ASSERT(!data.name.isEmpty()); | - | ||||||
| 223 | const QMimeGlobPattern glob(pattern, data.name, weight, caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive); | - | ||||||
| 224 | if (!process(glob, errorMessage)) // for actual glob matching
| 0-4136 | ||||||
| 225 | return false; never executed: return false; | 0 | ||||||
| 226 | data.addGlobPattern(pattern); // just for QMimeType::globPatterns() | - | ||||||
| 227 | } | - | ||||||
| 228 | break; executed 4136 times by 1 test: break;Executed by:
| 4136 | ||||||
| 229 | case ParseSubClass: { executed 1560 times by 1 test: case ParseSubClass:Executed by:
| 1560 | ||||||
| 230 | const QString inheritsFrom = atts.value(QLatin1String(mimeTypeAttributeC)).toString(); | - | ||||||
| 231 | if (!inheritsFrom.isEmpty())
| 0-1560 | ||||||
| 232 | processParent(data.name, inheritsFrom); executed 1560 times by 1 test: processParent(data.name, inheritsFrom);Executed by:
| 1560 | ||||||
| 233 | } | - | ||||||
| 234 | break; executed 1560 times by 1 test: break;Executed by:
| 1560 | ||||||
| 235 | case ParseComment: { executed 134104 times by 1 test: case ParseComment:Executed by:
| 134104 | ||||||
| 236 | // comments have locale attributes. We want the default, English one | - | ||||||
| 237 | QString locale = atts.value(QLatin1String(localeAttributeC)).toString(); | - | ||||||
| 238 | const QString comment = reader.readElementText(); | - | ||||||
| 239 | if (locale.isEmpty())
| 3319-130785 | ||||||
| 240 | locale = QString::fromLatin1("en_US"); executed 3319 times by 1 test: locale = QString::fromLatin1("en_US");Executed by:
| 3319 | ||||||
| 241 | data.localeComments.insert(locale, comment); | - | ||||||
| 242 | } | - | ||||||
| 243 | break; executed 134104 times by 1 test: break;Executed by:
| 134104 | ||||||
| 244 | case ParseAlias: { executed 975 times by 1 test: case ParseAlias:Executed by:
| 975 | ||||||
| 245 | const QString alias = atts.value(QLatin1String(mimeTypeAttributeC)).toString(); | - | ||||||
| 246 | if (!alias.isEmpty())
| 0-975 | ||||||
| 247 | processAlias(alias, data.name); executed 975 times by 1 test: processAlias(alias, data.name);Executed by:
| 975 | ||||||
| 248 | } | - | ||||||
| 249 | break; executed 975 times by 1 test: break;Executed by:
| 975 | ||||||
| 250 | case ParseMagic: { executed 1733 times by 1 test: case ParseMagic:Executed by:
| 1733 | ||||||
| 251 | priority = 50; | - | ||||||
| 252 | const QString priorityS = atts.value(QLatin1String(priorityAttributeC)).toString(); | - | ||||||
| 253 | if (!priorityS.isEmpty()) {
| 116-1617 | ||||||
| 254 | if (!parseNumber(priorityS, &priority, errorMessage))
| 0-1617 | ||||||
| 255 | return false; never executed: return false; | 0 | ||||||
| 256 | - | |||||||
| 257 | } executed 1617 times by 1 test: end of blockExecuted by:
| 1617 | ||||||
| 258 | currentRules.clear(); | - | ||||||
| 259 | //qDebug() << "MAGIC start for mimetype" << data.name; | - | ||||||
| 260 | } | - | ||||||
| 261 | break; executed 1733 times by 1 test: break;Executed by:
| 1733 | ||||||
| 262 | case ParseMagicMatchRule: { executed 4058 times by 1 test: case ParseMagicMatchRule:Executed by:
| 4058 | ||||||
| 263 | QString magicErrorMessage; | - | ||||||
| 264 | QMimeMagicRule *rule = createMagicMatchRule(atts, &magicErrorMessage); | - | ||||||
| 265 | if (!rule->isValid())
| 6-4052 | ||||||
| 266 | qWarning("QMimeDatabase: Error parsing %s\n%s", qPrintable(fileName), qPrintable(magicErrorMessage)); executed 6 times by 1 test: QMessageLogger(__FILE__, 266, __PRETTY_FUNCTION__).warning("QMimeDatabase: Error parsing %s\n%s", QString(fileName).toLocal8Bit().constData(), QString(magicErrorMessage).toLocal8Bit().constData());Executed by:
| 6 | ||||||
| 267 | QList<QMimeMagicRule> *ruleList; | - | ||||||
| 268 | if (currentRules.isEmpty())
| 1040-3018 | ||||||
| 269 | ruleList = &rules; executed 3018 times by 1 test: ruleList = &rules;Executed by:
| 3018 | ||||||
| 270 | else // nest this rule into the proper parent | - | ||||||
| 271 | ruleList = ¤tRules.top()->m_subMatches; executed 1040 times by 1 test: ruleList = ¤tRules.top()->m_subMatches;Executed by:
| 1040 | ||||||
| 272 | ruleList->append(*rule); | - | ||||||
| 273 | //qDebug() << " MATCH added. Stack size was" << currentRules.size(); | - | ||||||
| 274 | currentRules.push(&ruleList->last()); | - | ||||||
| 275 | delete rule; | - | ||||||
| 276 | break; executed 4058 times by 1 test: break;Executed by:
| 4058 | ||||||
| 277 | } | - | ||||||
| 278 | case ParseError: never executed: case ParseError: | 0 | ||||||
| 279 | reader.raiseError(QString::fromLatin1("Unexpected element <%1>"). | - | ||||||
| 280 | arg(reader.name().toString())); | - | ||||||
| 281 | break; never executed: break; | 0 | ||||||
| 282 | default: executed 1849 times by 1 test: default:Executed by:
| 1849 | ||||||
| 283 | break; executed 1849 times by 1 test: break;Executed by:
| 1849 | ||||||
| 284 | } | - | ||||||
| 285 | break; executed 153309 times by 1 test: break;Executed by:
| 153309 | ||||||
| 286 | // continue switch QXmlStreamReader::Token... | - | ||||||
| 287 | case QXmlStreamReader::EndElement: // Finished element executed 19205 times by 1 test: case QXmlStreamReader::EndElement:Executed by:
| 19205 | ||||||
| 288 | { | - | ||||||
| 289 | const QStringRef elementName = reader.name(); | - | ||||||
| 290 | if (elementName == QLatin1String(mimeTypeTagC)) {
| 3319-15886 | ||||||
| 291 | if (!process(QMimeType(data), errorMessage))
| 0-3319 | ||||||
| 292 | return false; never executed: return false; | 0 | ||||||
| 293 | data.clear(); | - | ||||||
| 294 | } else if (elementName == QLatin1String(matchTagC)) { executed 3319 times by 1 test: end of blockExecuted by:
| 3319-11828 | ||||||
| 295 | // Closing a <match> tag, pop stack | - | ||||||
| 296 | currentRules.pop(); | - | ||||||
| 297 | //qDebug() << " MATCH closed. Stack size is now" << currentRules.size(); | - | ||||||
| 298 | } else if (elementName == QLatin1String(magicTagC)) { executed 4058 times by 1 test: end of blockExecuted by:
| 1733-10095 | ||||||
| 299 | //qDebug() << "MAGIC ended, we got" << rules.count() << "rules, with prio" << priority; | - | ||||||
| 300 | // Finished a <magic> sequence | - | ||||||
| 301 | QMimeMagicRuleMatcher ruleMatcher(data.name, priority); | - | ||||||
| 302 | ruleMatcher.addRules(rules); | - | ||||||
| 303 | processMagicMatcher(ruleMatcher); | - | ||||||
| 304 | rules.clear(); | - | ||||||
| 305 | } executed 1733 times by 1 test: end of blockExecuted by:
| 1733 | ||||||
| 306 | break; executed 19205 times by 1 test: break;Executed by:
| 19205 | ||||||
| 307 | } | - | ||||||
| 308 | default: executed 160899 times by 1 test: default:Executed by:
| 160899 | ||||||
| 309 | break; executed 160899 times by 1 test: break;Executed by:
| 160899 | ||||||
| 310 | } | - | ||||||
| 311 | } | - | ||||||
| 312 | - | |||||||
| 313 | if (reader.hasError()) {
| 0-17 | ||||||
| 314 | if (errorMessage)
| 0 | ||||||
| 315 | *errorMessage = QString::fromLatin1("An error has been encountered at line %1 of %2: %3:").arg(reader.lineNumber()).arg(fileName, reader.errorString()); never executed: *errorMessage = QString::fromLatin1("An error has been encountered at line %1 of %2: %3:").arg(reader.lineNumber()).arg(fileName, reader.errorString()); | 0 | ||||||
| 316 | return false; never executed: return false; | 0 | ||||||
| 317 | } | - | ||||||
| 318 | - | |||||||
| 319 | return true; executed 17 times by 1 test: return true;Executed by:
| 17 | ||||||
| 320 | #endif //QT_NO_XMLSTREAMREADER | - | ||||||
| 321 | } | - | ||||||
| 322 | - | |||||||
| 323 | QT_END_NAMESPACE | - | ||||||
| 324 | - | |||||||
| 325 | #endif // QT_NO_MIMETYPE | - | ||||||
| Source code | Switch to Preprocessed file |