diff options
Diffstat (limited to 'src/xml')
-rw-r--r-- | src/xml/dom/qdom.cpp | 16 | ||||
-rw-r--r-- | src/xml/sax/qxml.cpp | 45 |
2 files changed, 35 insertions, 26 deletions
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index 5893d8448e..cffc1974af 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -48,7 +48,9 @@ #include <qhash.h> #include <qiodevice.h> #include <qlist.h> -#include <qregexp.h> +#if QT_CONFIG(regularexpression) +#include <qregularexpression.h> +#endif #if QT_CONFIG(textcodec) #include <qtextcodec.h> #endif @@ -5181,7 +5183,7 @@ QDomNodePrivate* QDomTextPrivate::cloneNode(bool deep) QDomTextPrivate* QDomTextPrivate::splitText(int offset) { if (!parent()) { - qWarning("QDomText::splitText The node has no parent. So I can not split"); + qWarning("QDomText::splitText The node has no parent. So I cannot split"); return 0; } @@ -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..0e3a87e883 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("<?xml")); + QLatin1String textDeclStart("<?xml"); if (str.startsWith(textDeclStart)) { - QRegExp textDecl(QString::fromLatin1( +#if QT_CONFIG(regularexpression) + QRegularExpression textDecl(QString::fromLatin1( "^<\\?xml\\s+" "(version\\s*=\\s*((['\"])[-a-zA-Z0-9_.:]+\\3))?" "\\s*" "(encoding\\s*=\\s*((['\"])[A-Za-z][-a-zA-Z0-9_.]*\\6))?" "\\s*\\?>" - )); + )); 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; } @@ -2607,8 +2613,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() is returned. If no such feature exists the return value is undefined. - If \a ok is not 0: \c{*}\a{ok} is set to true if the reader has the - feature called \a name; otherwise \c{*}\a{ok} is set to false. + If \a ok is not \nullptr: \c{*}\a{ok} is set to true if the + reader has the feature called \a name; otherwise \c{*}\a{ok} is + set to false. \sa setFeature(), hasFeature() */ @@ -2637,7 +2644,7 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() If the reader has the property \a name, this function returns the value of the property; otherwise the return value is undefined. - If \a ok is not 0: if the reader has the \a name property + If \a ok is not \nullptr: if the reader has the \a name property \c{*}\a{ok} is set to true; otherwise \c{*}\a{ok} is set to false. \sa setProperty(), hasProperty() @@ -2670,9 +2677,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() */ /*! - \fn QXmlEntityResolver* QXmlReader::entityResolver() const + \fn QXmlEntityResolver *QXmlReader::entityResolver() const - Returns the entity resolver or 0 if none was set. + Returns the entity resolver or \nullptr if none was set. \sa setEntityResolver() */ @@ -2686,9 +2693,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() */ /*! - \fn QXmlDTDHandler* QXmlReader::DTDHandler() const + \fn QXmlDTDHandler *QXmlReader::DTDHandler() const - Returns the DTD handler or 0 if none was set. + Returns the DTD handler or \nullptr if none was set. \sa setDTDHandler() */ @@ -2702,9 +2709,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() */ /*! - \fn QXmlContentHandler* QXmlReader::contentHandler() const + \fn QXmlContentHandler *QXmlReader::contentHandler() const - Returns the content handler or 0 if none was set. + Returns the content handler or \nullptr if none was set. \sa setContentHandler() */ @@ -2719,9 +2726,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() */ /*! - \fn QXmlErrorHandler* QXmlReader::errorHandler() const + \fn QXmlErrorHandler *QXmlReader::errorHandler() const - Returns the error handler or 0 if none is set. + Returns the error handler or \nullptr if none is set. \sa setErrorHandler() */ @@ -2735,9 +2742,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() */ /*! - \fn QXmlLexicalHandler* QXmlReader::lexicalHandler() const + \fn QXmlLexicalHandler *QXmlReader::lexicalHandler() const - Returns the lexical handler or 0 if none was set. + Returns the lexical handler or \nullptr if none was set. \sa setLexicalHandler() */ @@ -2751,9 +2758,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() */ /*! - \fn QXmlDeclHandler* QXmlReader::declHandler() const + \fn QXmlDeclHandler *QXmlReader::declHandler() const - Returns the declaration handler or 0 if none was set. + Returns the declaration handler or \nullptr if none was set. \sa setDeclHandler() */ |