diff options
-rw-r--r-- | src/qdoc/config.cpp | 2 | ||||
-rw-r--r-- | src/qdoc/cppcodemarker.cpp | 6 | ||||
-rw-r--r-- | src/qdoc/docbookgenerator.cpp | 42 | ||||
-rw-r--r-- | src/qdoc/htmlgenerator.cpp | 17 | ||||
-rw-r--r-- | src/qdoc/openedlist.cpp | 2 | ||||
-rw-r--r-- | src/qdoc/qdocdatabase.cpp | 2 | ||||
-rw-r--r-- | src/qdoc/qmlcodemarker.cpp | 2 | ||||
-rw-r--r-- | src/qdoc/text.cpp | 3 |
8 files changed, 40 insertions, 36 deletions
diff --git a/src/qdoc/config.cpp b/src/qdoc/config.cpp index 5a54d5edc..5552cfa01 100644 --- a/src/qdoc/config.cpp +++ b/src/qdoc/config.cpp @@ -1086,7 +1086,7 @@ void Config::load(Location location, const QString &fileName) QString path = fileInfo.canonicalPath(); pushWorkingDir(path); QDir::setCurrent(path); - QRegularExpression keySyntax(QRegularExpression::anchoredPattern(QLatin1String("\\w+(?:\\.\\w+)*"))); + static const QRegularExpression keySyntax(QRegularExpression::anchoredPattern(QLatin1String("\\w+(?:\\.\\w+)*"))); #define SKIP_CHAR() \ do { \ diff --git a/src/qdoc/cppcodemarker.cpp b/src/qdoc/cppcodemarker.cpp index 647fb4b8f..7d4e8c4ed 100644 --- a/src/qdoc/cppcodemarker.cpp +++ b/src/qdoc/cppcodemarker.cpp @@ -387,9 +387,9 @@ QString CppCodeMarker::addMarkUp(const QString &in, const Node * /* relative */, int start = 0; int finish = 0; QChar ch; - QRegularExpression classRegExp(QRegularExpression::anchoredPattern("Qt?(?:[A-Z3]+[a-z][A-Za-z]*|t)")); - QRegularExpression functionRegExp(QRegularExpression::anchoredPattern("q([A-Z][a-z]+)+")); - QRegularExpression findFunctionRegExp(QStringLiteral("^\\s*\\(")); + static const QRegularExpression classRegExp(QRegularExpression::anchoredPattern("Qt?(?:[A-Z3]+[a-z][A-Za-z]*|t)")); + static const QRegularExpression functionRegExp(QRegularExpression::anchoredPattern("q([A-Z][a-z]+)+")); + static const QRegularExpression findFunctionRegExp(QStringLiteral("^\\s*\\(")); bool atEOF = false; auto readChar = [&]() { diff --git a/src/qdoc/docbookgenerator.cpp b/src/qdoc/docbookgenerator.cpp index 7f660c6d4..ff497237b 100644 --- a/src/qdoc/docbookgenerator.cpp +++ b/src/qdoc/docbookgenerator.cpp @@ -244,7 +244,7 @@ const Atom *DocBookGenerator::generateAtomList(const Atom *atom, const Node *rel QString removeCodeMarkers(const QString& code) { QString rewritten = code; - QRegularExpression re("(<@[^>&]*>)|(<\\/@[^&>]*>)"); + static const QRegularExpression re("(<@[^>&]*>)|(<\\/@[^&>]*>)"); rewritten.replace(re, ""); return rewritten; } @@ -385,7 +385,7 @@ qsizetype DocBookGenerator::generateAtom(const Atom *atom, const Node *relative) // For parameters, understand subscripts. if (atom->string() == ATOM_FORMATTING_PARAMETER) { if (atom->next() != nullptr && atom->next()->type() == Atom::String) { - QRegularExpression subscriptRegExp("^([a-z]+)_([0-9n])$"); + static const QRegularExpression subscriptRegExp("^([a-z]+)_([0-9n])$"); auto match = subscriptRegExp.match(atom->next()->string()); if (match.hasMatch()) { m_writer->writeCharacters(match.captured(1)); @@ -1395,32 +1395,32 @@ qsizetype DocBookGenerator::generateAtom(const Atom *atom, const Node *relative) table = table.replace("<db:br />", QString()); table = table.replace("<db:br/>", QString()); - table = table.replace( - QRegularExpression(R"regex(<db:h(\d).*)>(.*)</db:h(\d)>)regex"), + static const QRegularExpression re1(R"regex(<db:h(\d).*)>(.*)</db:h(\d)>)regex"); + table.replace(re1, R"xml(<db:bridgehead renderas="sect\1">\2</bridgehead>)xml"); // Expecting \1 == \3. table = table.replace(R"( nowrap="nowrap")", QString()); table = table.replace(R"( align="center")", QString()); - table = table.replace( - QRegularExpression(R"regex((row|col)span="\s+(.*)")regex"), + static const QRegularExpression re2(R"regex((row|col)span="\s+(.*)")regex"); + table.replace(re2, R"(\1span="\2")"); - table = table.replace( - QRegularExpression(R"regex(<db:td (.*)bgcolor="#(.*)"(.*)>(.*)</db:td>)regex"), + static const QRegularExpression re3(R"regex(<db:td (.*)bgcolor="#(.*)"(.*)>(.*)</db:td>)regex"); + table.replace(re3, R"xml(<db:td \1 class="bgcolor-\2" \3><?dbhtml bgcolor="\2" ?><?dbfo bgcolor="\2" ?>\4</db:td>)xml"); - table = table.replace( - QRegularExpression(R"regex(<db:td (.*)bgcolor="(.*)"(.*)>(.*)</db:td>)regex"), + static const QRegularExpression re4(R"regex(<db:td (.*)bgcolor="(.*)"(.*)>(.*)</db:td>)regex"); + table.replace(re4, R"xml(<db:td \1 class="bgcolor-\2" \3><?dbhtml bgcolor="\2" ?><?dbfo bgcolor="\2" ?>\4</db:td>)xml"); - table = table.replace( - QRegularExpression(R"regex(<db:tr (.*)bgcolor="#(.*)"(.*)>)regex"), + static const QRegularExpression re5(R"regex(<db:tr (.*)bgcolor="#(.*)"(.*)>)regex"); + table.replace(re5, R"xml(<db:tr \1 class="bgcolor-\2" \3><?dbhtml bgcolor="\2" ?><?dbfo bgcolor="\2" ?>)xml"); - table = table.replace( - QRegularExpression(R"regex(<db:tr (.*)bgcolor="(.*)"(.*)>³)regex"), + static const QRegularExpression re6(R"regex(<db:tr (.*)bgcolor="(.*)"(.*)>³)regex"); + table.replace(re6, R"xml(<db:tr \1 class="bgcolor-\2" \3><?dbhtml bgcolor="\2" ?><?dbfo bgcolor="\2" ?>)xml"); - table = table.replace( - QRegularExpression(R"regex(<db:img src="(.*)" alt="(.*)"\s*/>)regex"), + static const QRegularExpression re7(R"regex(<db:img src="(.*)" alt="(.*)"\s*/>)regex"); + table.replace(re7, R"xml(<db:figure> <db:title>\2</db:title> <db:mediaobject> @@ -2834,10 +2834,10 @@ void DocBookGenerator::generateRequisites(const Aggregate *aggregate) if (!output.isEmpty()) { // Namespaces are mangled in this output, because QXmlStreamWriter doesn't know about them. (Letting it know // would imply generating the xmlns declaration one more time.) - QRegularExpression xmlTag(R"(<(/?)n\d+:)"); // Only for DocBook tags. - QRegularExpression xmlnsDocBookDefinition(R"( xmlns:n\d+=")" + QString{dbNamespace} + "\""); - QRegularExpression xmlnsXLinkDefinition(R"( xmlns:n\d+=")" + QString{xlinkNamespace} + "\""); - QRegularExpression xmlAttr(R"( n\d+:)"); // Only for XLink attributes. + static const QRegularExpression xmlTag(R"(<(/?)n\d+:)"); // Only for DocBook tags. + static const QRegularExpression xmlnsDocBookDefinition(R"( xmlns:n\d+=")" + QString{dbNamespace} + "\""); + static const QRegularExpression xmlnsXLinkDefinition(R"( xmlns:n\d+=")" + QString{xlinkNamespace} + "\""); + static const QRegularExpression xmlAttr(R"( n\d+:)"); // Only for XLink attributes. // Space at the beginning! const QString cleanOutput = output.replace(xmlTag, R"(<\1db:)") .replace(xmlnsDocBookDefinition, "") @@ -4290,7 +4290,7 @@ void DocBookGenerator::generateParameter(const Parameter ¶meter, const Node if (generateExtra || pname.isEmpty()) { // Look for the _ character in the member name followed by a number (or n): // this is intended to be rendered as a subscript. - QRegularExpression sub("([a-z]+)_([0-9]+|n)"); + static const QRegularExpression sub("([a-z]+)_([0-9]+|n)"); m_writer->writeStartElement(dbNamespace, "emphasis"); auto match = sub.match(paramName); diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp index b95ef2932..f0f9f51cd 100644 --- a/src/qdoc/htmlgenerator.cpp +++ b/src/qdoc/htmlgenerator.cpp @@ -403,7 +403,7 @@ qsizetype HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, Co out() << formattingLeftMap()[atom->string()]; if (atom->string() == ATOM_FORMATTING_PARAMETER) { if (atom->next() != nullptr && atom->next()->type() == Atom::String) { - QRegularExpression subscriptRegExp("^([a-z]+)_([0-9n])$"); + static const QRegularExpression subscriptRegExp("^([a-z]+)_([0-9n])$"); auto match = subscriptRegExp.match(atom->next()->string()); if (match.hasMatch()) { out() << match.captured(1) << "<sub>" << match.captured(2) @@ -1807,7 +1807,7 @@ void HtmlGenerator::generateHeader(const QString &title, const Node *node, CodeM QVersionNumber projectVersion = QVersionNumber::fromString(m_qdb->version()); if (!projectVersion.isNull()) { QVersionNumber titleVersion; - QRegularExpression re(QLatin1String(R"(\d+\.\d+)")); + static const QRegularExpression re(QLatin1String(R"(\d+\.\d+)")); const QString &versionedTitle = titleSuffix.isEmpty() ? title : titleSuffix; auto match = re.match(versionedTitle); if (match.hasMatch()) @@ -2938,7 +2938,7 @@ void HtmlGenerator::generateQmlItem(const Node *node, const Node *relative, Code bool summary) { QString marked = marker->markedUpQmlItem(node, summary); - QRegularExpression templateTag("(<[^@>]*>)"); + static const QRegularExpression templateTag("(<[^@>]*>)"); auto match = templateTag.match(marked); if (match.hasMatch()) { QString contents = protectEnc(match.captured(1)); @@ -2947,7 +2947,8 @@ void HtmlGenerator::generateQmlItem(const Node *node, const Node *relative, Code // Look for the _ character in the member name followed by a number (or n): // this is intended to be rendered as a subscript. - marked.replace(QRegularExpression("<@param>([a-z]+)_([0-9]+|n)</@param>"), "<i>\\1<sub>\\2</sub></i>"); + static const QRegularExpression re("<@param>([a-z]+)_([0-9]+|n)</@param>"); + marked.replace(re, "<i>\\1<sub>\\2</sub></i>"); // Replace some markup by HTML tags. Do both the opening and the closing tag // in one go (instead of <@param> and </@param> separately, for instance). marked.replace("@param>", "i>"); @@ -3174,14 +3175,15 @@ void HtmlGenerator::generateSynopsis(const Node *node, const Node *relative, Cod { QString marked = marker->markedUpSynopsis(node, relative, style); - QRegularExpression templateTag("(<[^@>]*>)"); + static const QRegularExpression templateTag("(<[^@>]*>)"); auto match = templateTag.match(marked); if (match.hasMatch()) { QString contents = protectEnc(match.captured(1)); marked.replace(match.capturedStart(1), match.capturedLength(1), contents); } - marked.replace(QRegularExpression("<@param>([a-z]+)_([1-9n])</@param>"), "<i>\\1<sub>\\2</sub></i>"); + static const QRegularExpression re("<@param>([a-z]+)_([1-9n])</@param>"); + marked.replace(re, "<i>\\1<sub>\\2</sub></i>"); marked.replace("<@param>", "<i>"); marked.replace("</@param>", "</i>"); @@ -3191,7 +3193,8 @@ void HtmlGenerator::generateSynopsis(const Node *node, const Node *relative, Cod } if (style == Section::AllMembers) { - QRegularExpression extraRegExp("<@extra>.*</@extra>", QRegularExpression::InvertedGreedinessOption); + static const QRegularExpression extraRegExp("<@extra>.*</@extra>", + QRegularExpression::InvertedGreedinessOption); marked.remove(extraRegExp); } else { marked.replace("<@extra>", "<code translate=\"no\">"); diff --git a/src/qdoc/openedlist.cpp b/src/qdoc/openedlist.cpp index f2ee45b49..a85e45ec4 100644 --- a/src/qdoc/openedlist.cpp +++ b/src/qdoc/openedlist.cpp @@ -15,7 +15,7 @@ OpenedList::OpenedList(ListStyle style) : sty(style), ini(1), nex(0) {} OpenedList::OpenedList(const Location &location, const QString &hint) : sty(Bullet), ini(1) { - QRegularExpression hintSyntax("^(\\W*)([0-9]+|[A-Z]+|[a-z]+)(\\W*)$"); + static const QRegularExpression hintSyntax("^(\\W*)([0-9]+|[A-Z]+|[a-z]+)(\\W*)$"); auto match = hintSyntax.match(hint); if (match.hasMatch()) { diff --git a/src/qdoc/qdocdatabase.cpp b/src/qdoc/qdocdatabase.cpp index ae7152e9a..49a882f56 100644 --- a/src/qdoc/qdocdatabase.cpp +++ b/src/qdoc/qdocdatabase.cpp @@ -1358,7 +1358,7 @@ void QDocDatabase::mergeCollections(Node::NodeType type, CNMap &cnm, const Node } if (cnmm.isEmpty()) return; - QRegularExpression singleDigit("\\b([0-9])\\b"); + static const QRegularExpression singleDigit("\\b([0-9])\\b"); const QStringList keys = cnmm.uniqueKeys(); for (const auto &key : keys) { const QList<CollectionNode *> values = cnmm.values(key); diff --git a/src/qdoc/qmlcodemarker.cpp b/src/qdoc/qmlcodemarker.cpp index 1475d2083..3ad787c93 100644 --- a/src/qdoc/qmlcodemarker.cpp +++ b/src/qdoc/qmlcodemarker.cpp @@ -27,7 +27,7 @@ bool QmlCodeMarker::recognizeCode(const QString &code) { #ifndef QT_NO_DECLARATIVE // Naive pre-check; starts with an import statement or 'CamelCase {' - QRegularExpression regExp(QStringLiteral("^\\s*(import |([A-Z][a-z0-9]*)+\\s?{)")); + static const QRegularExpression regExp(QStringLiteral("^\\s*(import |([A-Z][a-z0-9]*)+\\s?{)")); if (!regExp.match(code).hasMatch()) return false; diff --git a/src/qdoc/text.cpp b/src/qdoc/text.cpp index 7c526ad1f..387883109 100644 --- a/src/qdoc/text.cpp +++ b/src/qdoc/text.cpp @@ -234,7 +234,8 @@ void Text::dump() const str.replace("\\", "\\\\"); str.replace("\"", "\\\""); str.replace("\n", "\\n"); - str.replace(QRegularExpression(R"([^ -~])"), "?"); + static const QRegularExpression re(R"([^ -~])"); + str.replace(re, "?"); if (!str.isEmpty()) str = " \"" + str + QLatin1Char('"'); |