From d545d36c8e11dcd974244a69d2beef726be9ed9d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 12 Dec 2018 15:00:43 +0100 Subject: Remove QRegExp dependency from QtXml Use QRegularExpression instead. Change-Id: I6fc9400064ef6b7e425b140f5ffac0c9248c1ec0 Reviewed-by: Samuel Gaist --- src/xml/dom/qdom.cpp | 14 ++++++++------ src/xml/sax/qxml.cpp | 14 ++++++++++---- 2 files changed, 18 insertions(+), 10 deletions(-) (limited to 'src/xml') diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index 5893d8448e..a1f4d57da6 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -48,7 +48,9 @@ #include #include #include -#include +#if QT_CONFIG(regularexpression) +#include +#endif #if QT_CONFIG(textcodec) #include #endif @@ -6430,7 +6432,7 @@ void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNod const QDomNodePrivate* n = first; if(encUsed == QDomNode::EncodingFromDocument) { -#if QT_CONFIG(textcodec) +#if QT_CONFIG(textcodec) && QT_CONFIG(regularexpression) const QDomNodePrivate* n = first; QTextCodec *codec = 0; @@ -6438,11 +6440,11 @@ void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNod if (n && n->isProcessingInstruction() && n->nodeName() == QLatin1String("xml")) { // we have an XML declaration QString data = n->nodeValue(); - QRegExp encoding(QString::fromLatin1("encoding\\s*=\\s*((\"([^\"]*)\")|('([^']*)'))")); - encoding.indexIn(data); - QString enc = encoding.cap(3); + QRegularExpression encoding(QString::fromLatin1("encoding\\s*=\\s*((\"([^\"]*)\")|('([^']*)'))")); + auto match = encoding.match(data); + QString enc = match.captured(3); if (enc.isEmpty()) - enc = encoding.cap(5); + enc = match.captured(5); if (!enc.isEmpty()) codec = QTextCodec::codecForName(std::move(enc).toLatin1()); } diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index 7b6669b057..fa31e71cc1 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -43,7 +43,9 @@ #include "qtextcodec.h" #endif #include "qbuffer.h" -#include "qregexp.h" +#if QT_CONFIG(regularexpression) +#include "qregularexpression.h" +#endif #include "qmap.h" #include "qhash.h" #include "qstack.h" @@ -193,19 +195,23 @@ static const signed char charLookupTable[256]={ */ static bool stripTextDecl(QString& str) { - QString textDeclStart(QLatin1String("" - )); + )); QString strTmp = str.replace(textDecl, QLatin1String("")); if (strTmp.length() != str.length()) return false; // external entity has wrong TextDecl str = strTmp; +#else + return false; +#endif } return true; } -- cgit v1.2.3