From b4ead572501179244aa036e7a590fa7536929f2b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 14 May 2019 15:04:18 +0200 Subject: Move away from using 0 as a pointer constant Cleans up most of corelib to use nullptr or default enums where appropriate. Change-Id: Ifcaac14ecdaaee730f87f10941db3ce407d71ef9 Reviewed-by: Thiago Macieira --- src/corelib/codecs/qlatincodec.cpp | 4 +- src/corelib/codecs/qtextcodec.cpp | 24 +-- src/corelib/global/qglobal.cpp | 2 +- src/corelib/global/qlogging.cpp | 14 +- src/corelib/global/qmalloc.cpp | 8 +- src/corelib/io/qabstractfileengine.cpp | 10 +- src/corelib/io/qbuffer.cpp | 2 +- src/corelib/io/qdir.cpp | 4 +- src/corelib/io/qfile.cpp | 6 +- src/corelib/io/qfiledevice.cpp | 4 +- src/corelib/io/qfileinfo.cpp | 16 +- src/corelib/io/qfilesystemengine.cpp | 4 +- src/corelib/io/qfilesystemengine_unix.cpp | 4 +- src/corelib/io/qfilesystemiterator_unix.cpp | 6 +- src/corelib/io/qfsfileengine.cpp | 16 +- src/corelib/io/qfsfileengine_unix.cpp | 20 +-- src/corelib/io/qiodevice.cpp | 2 +- src/corelib/io/qipaddress.cpp | 8 +- src/corelib/io/qloggingcategory.cpp | 8 +- src/corelib/io/qloggingregistry.cpp | 4 +- src/corelib/io/qresource.cpp | 18 ++- src/corelib/io/qsavefile.cpp | 12 +- src/corelib/io/qtemporaryfile.cpp | 6 +- src/corelib/io/qurl.cpp | 34 ++--- src/corelib/io/qurlidna.cpp | 6 +- src/corelib/io/qurlquery.cpp | 10 +- src/corelib/io/qurlrecode.cpp | 2 +- src/corelib/kernel/qcoreapplication.cpp | 22 +-- src/corelib/kernel/qcoreglobaldata.cpp | 4 +- src/corelib/kernel/qmetatype.cpp | 66 +++++---- src/corelib/kernel/qmetatype_p.h | 16 +- src/corelib/kernel/qmetatypeswitcher_p.h | 2 +- src/corelib/kernel/qsystemerror.cpp | 2 +- src/corelib/kernel/qvariant.cpp | 44 +++--- src/corelib/serialization/qdatastream.cpp | 14 +- src/corelib/serialization/qjsonarray.cpp | 6 +- src/corelib/serialization/qjsondocument.cpp | 10 +- src/corelib/serialization/qjsonobject.cpp | 6 +- src/corelib/serialization/qjsonparser.cpp | 4 +- src/corelib/serialization/qjsonvalue.cpp | 16 +- src/corelib/serialization/qtextstream.cpp | 26 ++-- src/corelib/serialization/qxmlstream.cpp | 26 ++-- src/corelib/serialization/qxmlstream.g | 2 +- src/corelib/time/qdatetime.cpp | 30 ++-- src/corelib/tools/qarraydata.cpp | 2 +- src/corelib/tools/qbytearray.cpp | 6 +- src/corelib/tools/qbytearraymatcher.cpp | 10 +- src/corelib/tools/qchar.cpp | 2 +- src/corelib/tools/qhash.cpp | 6 +- src/corelib/tools/qlist.cpp | 2 +- src/corelib/tools/qlocale.cpp | 8 +- src/corelib/tools/qlocale_p.h | 4 +- src/corelib/tools/qlocale_tools.cpp | 4 +- src/corelib/tools/qmap.cpp | 30 ++-- src/corelib/tools/qregexp.cpp | 20 +-- src/corelib/tools/qringbuffer.cpp | 2 +- src/corelib/tools/qstring.cpp | 10 +- src/corelib/tools/qstringmatcher.cpp | 6 +- src/xml/dom/qdom.cpp | 220 ++++++++++++++-------------- src/xml/sax/qxml.cpp | 110 +++++++------- 60 files changed, 502 insertions(+), 490 deletions(-) diff --git a/src/corelib/codecs/qlatincodec.cpp b/src/corelib/codecs/qlatincodec.cpp index 1b53d26ef4..463c5a56ae 100644 --- a/src/corelib/codecs/qlatincodec.cpp +++ b/src/corelib/codecs/qlatincodec.cpp @@ -48,7 +48,7 @@ QLatin1Codec::~QLatin1Codec() QString QLatin1Codec::convertToUnicode(const char *chars, int len, ConverterState *) const { - if (chars == 0) + if (chars == nullptr) return QString(); return QString::fromLatin1(chars, len); @@ -104,7 +104,7 @@ QLatin15Codec::~QLatin15Codec() QString QLatin15Codec::convertToUnicode(const char* chars, int len, ConverterState *) const { - if (chars == 0) + if (chars == nullptr) return QString(); QString str = QString::fromLatin1(chars, len); diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index a86db142f9..85cfcdbf48 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -159,7 +159,7 @@ static QTextCodec *setupLocaleMapper() { QCoreGlobalData *globalData = QCoreGlobalData::instance(); - QTextCodec *locale = 0; + QTextCodec *locale = nullptr; { QMutexLocker locker(textCodecsMutex()); @@ -208,7 +208,7 @@ static QTextCodec *setupLocaleMapper() // First part is getting that locale name. First try setlocale() which // definitely knows it, but since we cannot fully trust it, get ready // to fall back to environment variables. - const QByteArray ctype = setlocale(LC_CTYPE, 0); + const QByteArray ctype = setlocale(LC_CTYPE, nullptr); // Get the first nonempty value from $LC_ALL, $LC_CTYPE, and $LANG // environment variables. @@ -532,13 +532,13 @@ QTextCodec::~QTextCodec() QTextCodec *QTextCodec::codecForName(const QByteArray &name) { if (name.isEmpty()) - return 0; + return nullptr; QMutexLocker locker(textCodecsMutex()); QCoreGlobalData *globalData = QCoreGlobalData::instance(); if (!globalData) - return 0; + return nullptr; setup(); #if !QT_CONFIG(icu) @@ -567,7 +567,7 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name) } } - return 0; + return nullptr; #else return QIcuCodec::codecForNameUnlocked(name); #endif @@ -585,7 +585,7 @@ QTextCodec* QTextCodec::codecForMib(int mib) QCoreGlobalData *globalData = QCoreGlobalData::instance(); if (!globalData) - return 0; + return nullptr; if (globalData->allCodecs.isEmpty()) setup(); @@ -611,7 +611,7 @@ QTextCodec* QTextCodec::codecForMib(int mib) #if QT_CONFIG(icu) return QIcuCodec::codecForMibUnlocked(mib); #else - return 0; + return nullptr; #endif } @@ -704,7 +704,7 @@ QTextCodec* QTextCodec::codecForLocale() { QCoreGlobalData *globalData = QCoreGlobalData::instance(); if (!globalData) - return 0; + return nullptr; QTextCodec *codec = globalData->codecForLocale.loadAcquire(); if (!codec) { @@ -830,7 +830,7 @@ QTextEncoder* QTextCodec::makeEncoder(QTextCodec::ConversionFlags flags) const */ QByteArray QTextCodec::fromUnicode(const QString& str) const { - return convertFromUnicode(str.constData(), str.length(), 0); + return convertFromUnicode(str.constData(), str.length(), nullptr); } #endif @@ -863,7 +863,7 @@ QByteArray QTextCodec::fromUnicode(QStringView str) const */ QString QTextCodec::toUnicode(const QByteArray& a) const { - return convertToUnicode(a.constData(), a.length(), 0); + return convertToUnicode(a.constData(), a.length(), nullptr); } /*! @@ -915,7 +915,7 @@ bool QTextCodec::canEncode(QStringView s) const QString QTextCodec::toUnicode(const char *chars) const { int len = qstrlen(chars); - return convertToUnicode(chars, len, 0); + return convertToUnicode(chars, len, nullptr); } @@ -1110,7 +1110,7 @@ QString QTextDecoder::toUnicode(const QByteArray &ba) QTextCodec *QTextCodec::codecForHtml(const QByteArray &ba, QTextCodec *defaultCodec) { // determine charset - QTextCodec *c = QTextCodec::codecForUtfText(ba, 0); + QTextCodec *c = QTextCodec::codecForUtfText(ba, nullptr); if (!c) { static Q_RELAXED_CONSTEXPR auto matcher = qMakeStaticByteArrayMatcher("meta "); QByteArray header = ba.left(1024).toLower(); diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index be01e5a605..897f92a4ea 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -3612,7 +3612,7 @@ bool qEnvironmentVariableIsSet(const char *varName) noexcept (void)getenv_s(&requiredSize, 0, 0, varName); return requiredSize != 0; #else - return ::getenv(varName) != 0; + return ::getenv(varName) != nullptr; #endif } diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 292a459e5d..49411306c2 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1100,8 +1100,8 @@ Q_DECLARE_TYPEINFO(QMessagePattern::BacktraceParams, Q_MOVABLE_TYPE); QBasicMutex QMessagePattern::mutex; QMessagePattern::QMessagePattern() - : literals(0) - , tokens(0) + : literals(nullptr) + , tokens(nullptr) , fromEnvironment(false) { #ifndef QT_BOOTSTRAPPED @@ -1121,9 +1121,9 @@ QMessagePattern::~QMessagePattern() for (int i = 0; literals[i]; ++i) delete [] literals[i]; delete [] literals; - literals = 0; + literals = nullptr; delete [] tokens; - tokens = 0; + tokens = nullptr; } void QMessagePattern::setPattern(const QString &pattern) @@ -1173,7 +1173,7 @@ void QMessagePattern::setPattern(const QString &pattern) // tokenizer QVarLengthArray literalsVar; tokens = new const char*[lexemes.size() + 1]; - tokens[lexemes.size()] = 0; + tokens[lexemes.size()] = nullptr; bool nestedIfError = false; bool inIf = false; @@ -1280,7 +1280,7 @@ void QMessagePattern::setPattern(const QString &pattern) qt_message_print(error); literals = new const char*[literalsVar.size() + 1]; - literals[literalsVar.size()] = 0; + literals[literalsVar.size()] = nullptr; memcpy(literals, literalsVar.constData(), literalsVar.size() * sizeof(const char*)); } @@ -1406,7 +1406,7 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con #endif // we do not convert file, function, line literals to local encoding due to overhead - for (int i = 0; pattern->tokens[i] != 0; ++i) { + for (int i = 0; pattern->tokens[i]; ++i) { const char *token = pattern->tokens[i]; if (token == endifTokenC) { skip = false; diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp index 05676a0da2..b071c1df62 100644 --- a/src/corelib/global/qmalloc.cpp +++ b/src/corelib/global/qmalloc.cpp @@ -74,18 +74,18 @@ void *qRealloc(void *ptr, size_t size) void *qMallocAligned(size_t size, size_t alignment) { - return qReallocAligned(0, size, 0, alignment); + return qReallocAligned(nullptr, size, 0, alignment); } void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t alignment) { // fake an aligned allocation - void *actualptr = oldptr ? static_cast(oldptr)[-1] : 0; + void *actualptr = oldptr ? static_cast(oldptr)[-1] : nullptr; if (alignment <= sizeof(void*)) { // special, fast case void **newptr = static_cast(realloc(actualptr, newsize + sizeof(void*))); if (!newptr) - return 0; + return nullptr; if (newptr == actualptr) { // realloc succeeded without reallocating return oldptr; @@ -105,7 +105,7 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align void *real = realloc(actualptr, newsize + alignment); if (!real) - return 0; + return nullptr; quintptr faked = reinterpret_cast(real) + alignment; faked &= ~(alignment - 1); diff --git a/src/corelib/io/qabstractfileengine.cpp b/src/corelib/io/qabstractfileengine.cpp index f2a895bbb8..8a1679c5af 100644 --- a/src/corelib/io/qabstractfileengine.cpp +++ b/src/corelib/io/qabstractfileengine.cpp @@ -159,7 +159,7 @@ QAbstractFileEngineHandler::~QAbstractFileEngineHandler() */ QAbstractFileEngine *qt_custom_file_engine_handler_create(const QString &path) { - QAbstractFileEngine *engine = 0; + QAbstractFileEngine *engine = nullptr; if (qt_file_engine_handlers_in_use) { QReadLocker locker(fileEngineHandlerMutex()); @@ -658,7 +658,7 @@ QStringList QAbstractFileEngine::entryList(QDir::Filters filters, const QStringL QAbstractFileEngine::FileFlags QAbstractFileEngine::fileFlags(FileFlags type) const { Q_UNUSED(type); - return 0; + return nullptr; } /*! @@ -838,7 +838,7 @@ uchar *QAbstractFileEngine::map(qint64 offset, qint64 size, QFile::MemoryMapFlag option.flags = flags; MapExtensionReturn r; if (!extension(MapExtension, &option, &r)) - return 0; + return nullptr; return r.address; } @@ -1118,7 +1118,7 @@ QAbstractFileEngine::Iterator *QAbstractFileEngine::beginEntryList(QDir::Filters { Q_UNUSED(filters); Q_UNUSED(filterNames); - return 0; + return nullptr; } /*! @@ -1126,7 +1126,7 @@ QAbstractFileEngine::Iterator *QAbstractFileEngine::beginEntryList(QDir::Filters */ QAbstractFileEngine::Iterator *QAbstractFileEngine::endEntryList() { - return 0; + return nullptr; } /*! diff --git a/src/corelib/io/qbuffer.cpp b/src/corelib/io/qbuffer.cpp index 7b3fa2ccad..8e980733de 100644 --- a/src/corelib/io/qbuffer.cpp +++ b/src/corelib/io/qbuffer.cpp @@ -50,7 +50,7 @@ class QBufferPrivate : public QIODevicePrivate public: QBufferPrivate() - : buf(0) + : buf(nullptr) #ifndef QT_NO_QOBJECT , writtenSinceLastEmit(0), signalConnectionCount(0), signalsEmitted(false) #endif diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 671913e92f..62dae3577c 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -1431,7 +1431,7 @@ QStringList QDir::entryList(const QStringList &nameFilters, Filters filters, l.append(it.fileInfo()); } QStringList ret; - d->sortFileList(sort, l, &ret, 0); + d->sortFileList(sort, l, &ret, nullptr); return ret; } @@ -1473,7 +1473,7 @@ QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filter l.append(it.fileInfo()); } QFileInfoList ret; - d->sortFileList(sort, l, 0, &ret); + d->sortFileList(sort, l, nullptr, &ret); return ret; } diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 8d871904bc..6959c7a40b 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -86,7 +86,7 @@ QFilePrivate::openExternalFile(int flags, int fd, QFile::FileHandleFlags handleF return false; #else delete fileEngine; - fileEngine = 0; + fileEngine = nullptr; QFSFileEngine *fe = new QFSFileEngine; fileEngine = fe; return fe->open(QIODevice::OpenMode(flags), fd, handleFlags); @@ -102,7 +102,7 @@ QFilePrivate::openExternalFile(int flags, FILE *fh, QFile::FileHandleFlags handl return false; #else delete fileEngine; - fileEngine = 0; + fileEngine = nullptr; QFSFileEngine *fe = new QFSFileEngine; fileEngine = fe; return fe->open(QIODevice::OpenMode(flags), fh, handleFlags); @@ -336,7 +336,7 @@ QFile::setFileName(const QString &name) } if(d->fileEngine) { //get a new file engine later delete d->fileEngine; - d->fileEngine = 0; + d->fileEngine = nullptr; } d->fileName = name; } diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp index 0689118f3e..2f74547054 100644 --- a/src/corelib/io/qfiledevice.cpp +++ b/src/corelib/io/qfiledevice.cpp @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE #endif QFileDevicePrivate::QFileDevicePrivate() - : fileEngine(0), + : fileEngine(nullptr), cachedSize(0), error(QFile::NoError), lastWasWrite(false) { @@ -63,7 +63,7 @@ QFileDevicePrivate::QFileDevicePrivate() QFileDevicePrivate::~QFileDevicePrivate() { delete fileEngine; - fileEngine = 0; + fileEngine = nullptr; } QAbstractFileEngine * QFileDevicePrivate::engine() const diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 998382021d..f5b398feae 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -52,7 +52,7 @@ QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const return fileNames[(int)name]; QString ret; - if (fileEngine == 0) { // local file; use the QFileSystemEngine directly + if (fileEngine == nullptr) { // local file; use the QFileSystemEngine directly switch (name) { case QAbstractFileEngine::CanonicalName: case QAbstractFileEngine::CanonicalPathName: { @@ -103,7 +103,7 @@ QString QFileInfoPrivate::getFileOwner(QAbstractFileEngine::FileOwner own) const if (cache_enabled && !fileOwners[(int)own].isNull()) return fileOwners[(int)own]; QString ret; - if (fileEngine == 0) { + if (fileEngine == nullptr) { switch (own) { case QAbstractFileEngine::OwnerUser: ret = QFileSystemEngine::resolveUserName(fileEntry, metaData); @@ -134,7 +134,7 @@ uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) cons // extra syscall. Bundle detecton on Mac can be slow, expecially on network // paths, so we separate out that as well. - QAbstractFileEngine::FileFlags req = 0; + QAbstractFileEngine::FileFlags req = nullptr; uint cachedFlags = 0; if (request & (QAbstractFileEngine::FlagsMask | QAbstractFileEngine::TypesMask)) { @@ -434,7 +434,7 @@ bool QFileInfo::operator==(const QFileInfo &fileinfo) const return true; Qt::CaseSensitivity sensitive; - if (d->fileEngine == 0 || fileinfo.d_ptr->fileEngine == 0) { + if (d->fileEngine == nullptr || fileinfo.d_ptr->fileEngine == nullptr) { if (d->fileEngine != fileinfo.d_ptr->fileEngine) // one is native, the other is a custom file-engine return false; @@ -649,7 +649,7 @@ bool QFileInfo::isRelative() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return true; - if (d->fileEngine == 0) + if (d->fileEngine == nullptr) return d->fileEntry.isRelative(); return d->fileEngine->isRelativePath(); } @@ -682,7 +682,7 @@ bool QFileInfo::exists() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return false; - if (d->fileEngine == 0) { + if (d->fileEngine == nullptr) { if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ExistsAttribute)) QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::ExistsAttribute); return d->metaData.exists(); @@ -982,7 +982,7 @@ bool QFileInfo::isNativePath() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return false; - if (d->fileEngine == 0) + if (d->fileEngine == nullptr) return true; return d->getFileFlags(QAbstractFileEngine::LocalDiskFlag); } @@ -1075,7 +1075,7 @@ bool QFileInfo::isRoot() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return false; - if (d->fileEngine == 0) { + if (d->fileEngine == nullptr) { if (d->fileEntry.isRoot()) { #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) //the path is a drive root, but the drive may not exist diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index 7abdf90bf5..21847c2a7c 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -124,7 +124,7 @@ static inline bool _q_checkEntry(QAbstractFileEngine *&engine, bool resolvingEnt if (resolvingEntry) { if (!(engine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::ExistsFlag)) { delete engine; - engine = 0; + engine = nullptr; return false; } } @@ -191,7 +191,7 @@ static bool _q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry &ent QAbstractFileEngine *QFileSystemEngine::resolveEntryAndCreateLegacyEngine( QFileSystemEntry &entry, QFileSystemMetaData &data) { QFileSystemEntry copy = entry; - QAbstractFileEngine *engine = 0; + QAbstractFileEngine *engine = nullptr; if (_q_resolveEntryAndCreateLegacyEngine_recursive(copy, data, engine)) // Reset entry to resolved copy. diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index b78e037865..066a7c3f01 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -813,7 +813,7 @@ QString QFileSystemEngine::resolveUserName(uint userId) #endif #if !defined(Q_OS_INTEGRITY) && !defined(Q_OS_WASM) - struct passwd *pw = 0; + struct passwd *pw = nullptr; #if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS) struct passwd entry; getpwuid_r(userId, &entry, buf.data(), buf.size(), &pw); @@ -837,7 +837,7 @@ QString QFileSystemEngine::resolveGroupName(uint groupId) #endif #if !defined(Q_OS_INTEGRITY) && !defined(Q_OS_WASM) - struct group *gr = 0; + struct group *gr = nullptr; #if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID) && (__ANDROID_API__ >= 24)) size_max = sysconf(_SC_GETGR_R_SIZE_MAX); if (size_max == -1) diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp index a9acf542d4..5ac7e13a2e 100644 --- a/src/corelib/io/qfilesystemiterator_unix.cpp +++ b/src/corelib/io/qfilesystemiterator_unix.cpp @@ -50,15 +50,15 @@ QT_BEGIN_NAMESPACE QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters, const QStringList &nameFilters, QDirIterator::IteratorFlags flags) : nativePath(entry.nativeFilePath()) - , dir(0) - , dirEntry(0) + , dir(nullptr) + , dirEntry(nullptr) , lastError(0) { Q_UNUSED(filters) Q_UNUSED(nameFilters) Q_UNUSED(flags) - if ((dir = QT_OPENDIR(nativePath.constData())) == 0) { + if ((dir = QT_OPENDIR(nativePath.constData())) == nullptr) { lastError = errno; } else { if (!nativePath.endsWith('/')) diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 387990ed79..0db27f3e25 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -127,7 +127,7 @@ void QFSFileEnginePrivate::init() is_link = 0; openMode = QIODevice::NotOpen; fd = -1; - fh = 0; + fh = nullptr; lastIOCommand = IOFlushCommand; lastFlushFailed = false; closeFileHandle = false; @@ -240,7 +240,7 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode) d->openMode = openMode; d->lastFlushFailed = false; d->tried_stat = 0; - d->fh = 0; + d->fh = nullptr; d->fd = -1; return d->nativeOpen(openMode); @@ -299,7 +299,7 @@ bool QFSFileEnginePrivate::openFh(QIODevice::OpenMode openMode, FILE *fh) QSystemError::stdString()); this->openMode = QIODevice::NotOpen; - this->fh = 0; + this->fh = nullptr; return false; } @@ -328,7 +328,7 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode, int fd, QFile::FileHandle d->lastFlushFailed = false; d->closeFileHandle = (handleFlags & QFile::AutoCloseHandle); d->fileEntry.clear(); - d->fh = 0; + d->fh = nullptr; d->fd = -1; d->tried_stat = 0; @@ -344,7 +344,7 @@ bool QFSFileEnginePrivate::openFd(QIODevice::OpenMode openMode, int fd) { Q_Q(QFSFileEngine); this->fd = fd; - fh = 0; + fh = nullptr; // Seek to the end when in Append mode. if (openMode & QFile::Append) { @@ -405,7 +405,7 @@ bool QFSFileEnginePrivate::closeFdFh() // We must reset these guys regardless; calling close again after a // failed close causes crashes on some systems. - fh = 0; + fh = nullptr; fd = -1; closed = (ret == 0); } @@ -822,7 +822,7 @@ QAbstractFileEngine::Iterator *QFSFileEngine::beginEntryList(QDir::Filters filte */ QAbstractFileEngine::Iterator *QFSFileEngine::endEntryList() { - return 0; + return nullptr; } #endif // QT_NO_FILESYSTEMITERATOR @@ -870,7 +870,7 @@ bool QFSFileEngine::extension(Extension extension, const ExtensionOption *option const MapExtensionOption *options = (const MapExtensionOption*)(option); MapExtensionReturn *returnValue = static_cast(output); returnValue->address = d->map(options->offset, options->size, options->flags); - return (returnValue->address != 0); + return (returnValue->address != nullptr); } if (extension == UnMapExtension) { const UnMapExtensionOption *options = (const UnMapExtensionOption*)option; diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 90ad0126d6..d4983c72af 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -153,7 +153,7 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) } } - fh = 0; + fh = nullptr; } closeFileHandle = true; @@ -451,14 +451,14 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const if (type & Refresh) d->metaData.clear(); - QAbstractFileEngine::FileFlags ret = 0; + QAbstractFileEngine::FileFlags ret = { }; if (type & FlagsMask) ret |= LocalDiskFlag; bool exists; { - QFileSystemMetaData::MetaDataFlags queryFlags = 0; + QFileSystemMetaData::MetaDataFlags queryFlags = { }; queryFlags |= QFileSystemMetaData::MetaDataFlags(uint(type)) & QFileSystemMetaData::Permissions; @@ -590,9 +590,9 @@ bool QFSFileEngine::setPermissions(uint perms) QSystemError error; bool ok; if (d->fd != -1) - ok = QFileSystemEngine::setPermissions(d->fd, QFile::Permissions(perms), error, 0); + ok = QFileSystemEngine::setPermissions(d->fd, QFile::Permissions(perms), error); else - ok = QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error, 0); + ok = QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error); if (!ok) { setError(QFile::PermissionsError, error.toString()); return false; @@ -651,13 +651,13 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla Q_Q(QFSFileEngine); if (openMode == QIODevice::NotOpen) { q->setError(QFile::PermissionsError, qt_error_string(int(EACCES))); - return 0; + return nullptr; } if (offset < 0 || offset > maxFileOffset || size < 0 || quint64(size) > quint64(size_t(-1))) { q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL))); - return 0; + return nullptr; } // If we know the mapping will extend beyond EOF, fail early to avoid @@ -685,14 +685,14 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla if (quint64(size + extra) > quint64((size_t)-1)) { q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL))); - return 0; + return nullptr; } size_t realSize = (size_t)size + extra; QT_OFF_T realOffset = QT_OFF_T(offset); realOffset &= ~(QT_OFF_T(pageSize - 1)); - void *mapAddress = QT_MMAP((void*)0, realSize, + void *mapAddress = QT_MMAP((void*)nullptr, realSize, access, sharemode, nativeHandle(), realOffset); if (MAP_FAILED != mapAddress) { uchar *address = extra + static_cast(mapAddress); @@ -714,7 +714,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla q->setError(QFile::UnspecifiedError, qt_error_string(int(errno))); break; } - return 0; + return nullptr; } bool QFSFileEnginePrivate::unmap(uchar *ptr) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 74df0f71ef..e26508e631 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -169,7 +169,7 @@ QIODevicePrivate::QIODevicePrivate() , baseReadLineDataCalled(false) , accessMode(Unset) #ifdef QT_NO_QOBJECT - , q_ptr(0) + , q_ptr(nullptr) #endif { } diff --git a/src/corelib/io/qipaddress.cpp b/src/corelib/io/qipaddress.cpp index d9f7916dd4..131795330b 100644 --- a/src/corelib/io/qipaddress.cpp +++ b/src/corelib/io/qipaddress.cpp @@ -67,7 +67,7 @@ static const QChar *checkedToAscii(Buffer &buffer, const QChar *begin, const QCh *dst++ = *src++; } *dst = '\0'; - return 0; + return nullptr; } static bool parseIp4Internal(IPv4Address &address, const char *ptr, bool acceptLeadingZero); @@ -175,7 +175,7 @@ const QChar *parseIp6(IPv6Address &address, const QChar *begin, const QChar *end memset(address, 0, sizeof address); if (colonCount == 2 && end - begin == 2) // "::" - return 0; + return nullptr; // if there's a double colon ("::"), this is how many zeroes it means int zeroWordsToFill; @@ -236,7 +236,7 @@ const QChar *parseIp6(IPv6Address &address, const QChar *begin, const QChar *end address[13] = ip4 >> 16; address[14] = ip4 >> 8; address[15] = ip4; - return 0; + return nullptr; } address[pos++] = x >> 8; @@ -248,7 +248,7 @@ const QChar *parseIp6(IPv6Address &address, const QChar *begin, const QChar *end return begin + (endptr - buffer.data()); ptr = endptr + 1; } - return pos == 16 ? 0 : end; + return pos == 16 ? nullptr : end; } static inline QChar toHex(uchar c) diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp index 33253429a2..91b3396217 100644 --- a/src/corelib/io/qloggingcategory.cpp +++ b/src/corelib/io/qloggingcategory.cpp @@ -214,8 +214,8 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift) Note that \a category must be kept valid during the lifetime of this object. */ QLoggingCategory::QLoggingCategory(const char *category) - : d(0), - name(0) + : d(nullptr), + name(nullptr) { init(category, QtDebugMsg); } @@ -231,8 +231,8 @@ QLoggingCategory::QLoggingCategory(const char *category) \since 5.4 */ QLoggingCategory::QLoggingCategory(const char *category, QtMsgType enableForLevel) - : d(0), - name(0) + : d(nullptr), + name(nullptr) { init(category, enableForLevel); } diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 9792d956cc..7849dfd14c 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -165,7 +165,7 @@ void QLoggingRule::parse(const QStringRef &pattern) p = QStringRef(p.string(), p.position() + 1, p.length() - 1); } if (p.contains(QLatin1Char('*'))) // '*' only supported at start/end - flags = 0; + flags = PatternFlags(); } category = p.toString(); @@ -415,7 +415,7 @@ QLoggingRegistry::installFilter(QLoggingCategory::CategoryFilter filter) { QMutexLocker locker(®istryMutex); - if (filter == 0) + if (!filter) filter = defaultCategoryFilter; QLoggingCategory::CategoryFilter old = categoryFilter; diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index e7d739b4dc..d143f7fda3 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -147,7 +147,7 @@ private: public: mutable QAtomicInt ref; - inline QResourceRoot(): tree(0), names(0), payloads(0), version(0) {} + inline QResourceRoot(): tree(nullptr), names(nullptr), payloads(nullptr), version(0) {} inline QResourceRoot(int version, const uchar *t, const uchar *n, const uchar *d) { setSource(version, t, n, d); } virtual ~QResourceRoot() { } int findNode(const QString &path, const QLocale &locale=QLocale()) const; @@ -165,7 +165,7 @@ public: quint64 lastModified(int node) const; QStringList children(int node) const; virtual QString mappingRoot() const { return QString(); } - bool mappingRootSubdir(const QString &path, QString *match=0) const; + bool mappingRootSubdir(const QString &path, QString *match = nullptr) const; inline bool operator==(const QResourceRoot &other) const { return tree == other.tree && names == other.names && payloads == other.payloads && version == other.version; } inline bool operator!=(const QResourceRoot &other) const @@ -320,7 +320,7 @@ QResourcePrivate::clear() { absoluteFilePath.clear(); compressionAlgo = QResource::NoCompression; - data = 0; + data = nullptr; size = 0; children.clear(); lastModified = 0; @@ -864,7 +864,7 @@ const uchar *QResourceRoot::data(int node, qint64 *size) const { if(node == -1) { *size = 0; - return 0; + return nullptr; } int offset = findOffset(node) + 4; //jump past name @@ -881,7 +881,7 @@ const uchar *QResourceRoot::data(int node, qint64 *size) const return ret; } *size = 0; - return 0; + return nullptr; } quint64 QResourceRoot::lastModified(int node) const @@ -991,7 +991,7 @@ class QDynamicBufferResourceRoot: public QResourceRoot const uchar *buffer; public: - inline QDynamicBufferResourceRoot(const QString &_root) : root(_root), buffer(0) { } + inline QDynamicBufferResourceRoot(const QString &_root) : root(_root), buffer(nullptr) { } inline ~QDynamicBufferResourceRoot() { } inline const uchar *mappingBuffer() const { return buffer; } QString mappingRoot() const override { return root; } @@ -1063,12 +1063,14 @@ class QDynamicFileResourceRoot: public QDynamicBufferResourceRoot qsizetype unmapLength; public: - inline QDynamicFileResourceRoot(const QString &_root) : QDynamicBufferResourceRoot(_root), unmapPointer(0), unmapLength(0) { } + QDynamicFileResourceRoot(const QString &_root) + : QDynamicBufferResourceRoot(_root), unmapPointer(nullptr), unmapLength(0) + { } ~QDynamicFileResourceRoot() { #if defined(QT_USE_MMAP) if (unmapPointer) { munmap((char*)unmapPointer, unmapLength); - unmapPointer = 0; + unmapPointer = nullptr; unmapLength = 0; } else #endif diff --git a/src/corelib/io/qsavefile.cpp b/src/corelib/io/qsavefile.cpp index bde5133cb3..915d0a0a00 100644 --- a/src/corelib/io/qsavefile.cpp +++ b/src/corelib/io/qsavefile.cpp @@ -151,7 +151,7 @@ QSaveFile::~QSaveFile() if (d->fileEngine) { d->fileEngine->remove(); delete d->fileEngine; - d->fileEngine = 0; + d->fileEngine = nullptr; } } @@ -252,7 +252,7 @@ bool QSaveFile::open(OpenMode mode) return true; d->setError(d->fileEngine->error(), d->fileEngine->errorString()); delete d->fileEngine; - d->fileEngine = 0; + d->fileEngine = nullptr; } else { QString msg = QSaveFile::tr("QSaveFile cannot open '%1' without direct write fallback " @@ -285,7 +285,7 @@ bool QSaveFile::open(OpenMode mode) err = QFileDevice::OpenError; d->setError(err, d->fileEngine->errorString()); delete d->fileEngine; - d->fileEngine = 0; + d->fileEngine = nullptr; return false; } @@ -339,7 +339,7 @@ bool QSaveFile::commit() d->fileEngine->remove(); d->writeError = QFileDevice::NoError; delete d->fileEngine; - d->fileEngine = 0; + d->fileEngine = nullptr; return false; } // atomically replace old file with new file @@ -349,12 +349,12 @@ bool QSaveFile::commit() d->setError(d->fileEngine->error(), d->fileEngine->errorString()); d->fileEngine->remove(); delete d->fileEngine; - d->fileEngine = 0; + d->fileEngine = nullptr; return false; } } delete d->fileEngine; - d->fileEngine = 0; + d->fileEngine = nullptr; return true; } diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index ced08a9a87..c89ad06a1f 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -327,7 +327,7 @@ bool QTemporaryFileEngine::isReallyOpen() const { Q_D(const QFSFileEngine); - if (!((0 == d->fh) && (-1 == d->fd) + if (!((nullptr == d->fh) && (-1 == d->fd) #if defined Q_OS_WIN && (INVALID_HANDLE_VALUE == d->fileHandle) #endif @@ -902,7 +902,7 @@ QTemporaryFile *QTemporaryFile::createNativeFile(QFile &file) { if (QAbstractFileEngine *engine = file.d_func()->engine()) { if(engine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::LocalDiskFlag) - return 0; //native already + return nullptr; // native already //cache bool wasOpen = file.isOpen(); qint64 old_off = 0; @@ -934,7 +934,7 @@ QTemporaryFile *QTemporaryFile::createNativeFile(QFile &file) //done return ret; } - return 0; + return nullptr; } /*! diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 681a0c7ef2..4d0306abde 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -523,7 +523,7 @@ public: Error *cloneError() const; void clearError(); void setError(ErrorCode errorCode, const QString &source, int supplement = -1); - ErrorCode validityError(QString *source = 0, int *position = 0) const; + ErrorCode validityError(QString *source = nullptr, int *position = nullptr) const; bool validateComponent(Section section, const QString &input, int begin, int end); bool validateComponent(Section section, const QString &input) { return validateComponent(section, input, 0, uint(input.length())); } @@ -591,7 +591,7 @@ public: inline QUrlPrivate::QUrlPrivate() : ref(1), port(-1), - error(0), + error(nullptr), sectionIsPresent(0), flags(0) { @@ -619,13 +619,13 @@ inline QUrlPrivate::~QUrlPrivate() inline QUrlPrivate::Error *QUrlPrivate::cloneError() const { - return error ? new Error(*error) : 0; + return error ? new Error(*error) : nullptr; } inline void QUrlPrivate::clearError() { delete error; - error = 0; + error = nullptr; } inline void QUrlPrivate::setError(ErrorCode errorCode, const QString &source, int supplement) @@ -826,7 +826,7 @@ recodeFromUser(const QString &input, const ushort *actions, int from, int to) QString output; const QChar *begin = input.constData() + from; const QChar *end = input.constData() + to; - if (qt_urlRecode(output, begin, end, 0, actions)) + if (qt_urlRecode(output, begin, end, nullptr, actions)) return output; return input.mid(from, to - from); @@ -954,7 +954,7 @@ inline void QUrlPrivate::appendFragment(QString &appendTo, QUrl::FormattingOptio { appendToUser(appendTo, fragment, options, options & QUrl::EncodeDelimiters ? fragmentInUrl : - appendingTo == FullUrl ? 0 : fragmentInIsolation); + appendingTo == FullUrl ? nullptr : fragmentInIsolation); } inline void QUrlPrivate::appendQuery(QString &appendTo, QUrl::FormattingOptions options, Section appendingTo) const @@ -1179,7 +1179,7 @@ inline void QUrlPrivate::appendHost(QString &appendTo, QUrl::FormattingOptions o if (host.at(0).unicode() == '[') { // IPv6 addresses might contain a zone-id which needs to be recoded if (options != 0) - if (qt_urlRecode(appendTo, host.constBegin(), host.constEnd(), options, 0)) + if (qt_urlRecode(appendTo, host.constBegin(), host.constEnd(), options, nullptr)) return; appendTo += host; } else { @@ -1221,7 +1221,7 @@ static const QChar *parseIpFuture(QString &host, const QChar *begin, const QChar --end; QString decoded; - if (mode == QUrl::TolerantMode && qt_urlRecode(decoded, begin, end, QUrl::FullyDecoded, 0)) { + if (mode == QUrl::TolerantMode && qt_urlRecode(decoded, begin, end, QUrl::FullyDecoded, nullptr)) { begin = decoded.constBegin(); end = decoded.constEnd(); } @@ -1233,13 +1233,13 @@ static const QChar *parseIpFuture(QString &host, const QChar *begin, const QChar host += *begin; else if (begin->unicode() >= '0' && begin->unicode() <= '9') host += *begin; - else if (begin->unicode() < 0x80 && strchr(acceptable, begin->unicode()) != 0) + else if (begin->unicode() < 0x80 && strchr(acceptable, begin->unicode()) != nullptr) host += *begin; else return decoded.isEmpty() ? begin : &origBegin[2]; } host += QLatin1Char(']'); - return 0; + return nullptr; } return &origBegin[2]; } @@ -1286,7 +1286,7 @@ static const QChar *parseIp6(QString &host, const QChar *begin, const QChar *end host += zoneId; } host += QLatin1Char(']'); - return 0; + return nullptr; } inline bool QUrlPrivate::setHost(const QString &value, int from, int iend, QUrl::ParsingMode mode) @@ -1352,7 +1352,7 @@ inline bool QUrlPrivate::setHost(const QString &value, int from, int iend, QUrl: // check for percent-encoding first QString s; - if (mode == QUrl::TolerantMode && qt_urlRecode(s, begin, end, 0, 0)) { + if (mode == QUrl::TolerantMode && qt_urlRecode(s, begin, end, { }, nullptr)) { // something was decoded // anything encoded left? int pos = s.indexOf(QChar(0x25)); // '%' @@ -1837,7 +1837,7 @@ inline void QUrlPrivate::validate() const \sa setUrl(), fromEncoded(), TolerantMode */ -QUrl::QUrl(const QString &url, ParsingMode parsingMode) : d(0) +QUrl::QUrl(const QString &url, ParsingMode parsingMode) : d(nullptr) { setUrl(url, parsingMode); } @@ -1845,7 +1845,7 @@ QUrl::QUrl(const QString &url, ParsingMode parsingMode) : d(0) /*! Constructs an empty QUrl object. */ -QUrl::QUrl() : d(0) +QUrl::QUrl() : d(nullptr) { } @@ -1879,7 +1879,7 @@ QUrl::~QUrl() bool QUrl::isValid() const { if (isEmpty()) { - // also catches d == 0 + // also catches d == nullptr return false; } return d->validityError() == QUrlPrivate::NoError; @@ -1907,7 +1907,7 @@ void QUrl::clear() { if (d && !d->ref.deref()) delete d; - d = 0; + d = nullptr; } /*! @@ -4187,7 +4187,7 @@ static QUrl adjustFtpPath(QUrl url) static bool isIp6(const QString &text) { QIPAddressUtils::IPv6Address address; - return !text.isEmpty() && QIPAddressUtils::parseIp6(address, text.begin(), text.end()) == 0; + return !text.isEmpty() && QIPAddressUtils::parseIp6(address, text.begin(), text.end()) == nullptr; } /*! diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp index 2305e66407..2f89d22660 100644 --- a/src/corelib/io/qurlidna.cpp +++ b/src/corelib/io/qurlidna.cpp @@ -1444,7 +1444,7 @@ static void mapToLowerCase(QString *str, int from) { int N = sizeof(NameprepCaseFolding) / sizeof(NameprepCaseFolding[0]); - ushort *d = 0; + ushort *d = nullptr; for (int i = from; i < str->size(); ++i) { uint uc = str->at(i).unicode(); if (uc < 0x80) { @@ -1474,7 +1474,7 @@ static void mapToLowerCase(QString *str, int from) else str->replace(--i, 2, reinterpret_cast(&entry->mapping[0]), l); i += l - 1; - d = 0; + d = nullptr; } else { if (!d) d = reinterpret_cast(str->data()); @@ -2404,7 +2404,7 @@ static const char * const idn_whitelist[] = { }; static const size_t idn_whitelist_size = sizeof idn_whitelist / sizeof *idn_whitelist; -static QStringList *user_idn_whitelist = 0; +static QStringList *user_idn_whitelist = nullptr; static bool lessThan(const QChar *a, int l, const char *c) { diff --git a/src/corelib/io/qurlquery.cpp b/src/corelib/io/qurlquery.cpp index d76107abfd..a8f40a3a12 100644 --- a/src/corelib/io/qurlquery.cpp +++ b/src/corelib/io/qurlquery.cpp @@ -262,7 +262,7 @@ inline QString QUrlQueryPrivate::recodeToUser(const QString &input, QUrl::Compon if (!(encoding & QUrl::EncodeDelimiters)) { QString output; if (qt_urlRecode(output, input.constData(), input.constData() + input.length(), - encoding, 0)) + encoding, nullptr)) return output; return input; } @@ -290,7 +290,7 @@ void QUrlQueryPrivate::setQuery(const QString &query) const QChar *const end = pos + query.size(); while (pos != end) { const QChar *begin = pos; - const QChar *delimiter = 0; + const QChar *delimiter = nullptr; while (pos != end) { // scan for the component parts of this pair if (!delimiter && pos->unicode() == valueDelimiter) @@ -345,7 +345,7 @@ QSharedDataPointer::clone() \sa setQuery(), addQueryItem() */ QUrlQuery::QUrlQuery() - : d(0) + : d(nullptr) { } @@ -356,7 +356,7 @@ QUrlQuery::QUrlQuery() set the query with setQuery(). */ QUrlQuery::QUrlQuery(const QString &queryString) - : d(queryString.isEmpty() ? 0 : new QUrlQueryPrivate(queryString)) + : d(queryString.isEmpty() ? nullptr : new QUrlQueryPrivate(queryString)) { } @@ -369,7 +369,7 @@ QUrlQuery::QUrlQuery(const QString &queryString) \sa QUrl::query() */ QUrlQuery::QUrlQuery(const QUrl &url) - : d(0) + : d(nullptr) { // use internals to avoid unnecessary recoding // ### FIXME: actually do it diff --git a/src/corelib/io/qurlrecode.cpp b/src/corelib/io/qurlrecode.cpp index f23480c755..35ede8d078 100644 --- a/src/corelib/io/qurlrecode.cpp +++ b/src/corelib/io/qurlrecode.cpp @@ -377,7 +377,7 @@ static int recode(QString &result, const ushort *begin, const ushort *end, QUrl: { const int origSize = result.size(); const ushort *input = begin; - ushort *output = 0; + ushort *output = nullptr; EncodingAction action = EncodeCharacter; for ( ; input != end; ++input) { diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 72aaac44a6..a48a7c80f2 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -216,11 +216,11 @@ QString QCoreApplicationPrivate::appVersion() const } #endif -QString *QCoreApplicationPrivate::cachedApplicationFilePath = 0; +QString *QCoreApplicationPrivate::cachedApplicationFilePath = nullptr; bool QCoreApplicationPrivate::checkInstance(const char *function) { - bool b = (QCoreApplication::self != 0); + bool b = (QCoreApplication::self != nullptr); if (!b) qWarning("QApplication::%s: Please instantiate the QApplication object first", function); return b; @@ -257,7 +257,7 @@ void QCoreApplicationPrivate::processCommandLineArguments() } if (j < argc) { - argv[j] = 0; + argv[j] = nullptr; argc = j; } } @@ -367,11 +367,11 @@ Q_CORE_EXPORT uint qGlobalPostedEventsCount() return currentThreadData->postEventList.size() - currentThreadData->postEventList.startOffset; } -QAbstractEventDispatcher *QCoreApplicationPrivate::eventDispatcher = 0; +QAbstractEventDispatcher *QCoreApplicationPrivate::eventDispatcher = nullptr; #endif // QT_NO_QOBJECT -QCoreApplication *QCoreApplication::self = 0; +QCoreApplication *QCoreApplication::self = nullptr; uint QCoreApplicationPrivate::attribs = (1 << Qt::AA_SynthesizeMouseForUnhandledTouchEvents) | (1 << Qt::AA_SynthesizeMouseForUnhandledTabletEvents); @@ -455,12 +455,12 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint , aboutToQuitEmitted(false) , threadData_clean(false) #else - , q_ptr(0) + , q_ptr(nullptr) #endif { app_compile_version = flags & 0xffffff; static const char *const empty = ""; - if (argc == 0 || argv == 0) { + if (argc == 0 || argv == nullptr) { argc = 0; argv = const_cast(&empty); } @@ -886,7 +886,7 @@ QCoreApplication::~QCoreApplication() { qt_call_post_routines(); - self = 0; + self = nullptr; #ifndef QT_NO_QOBJECT QCoreApplicationPrivate::is_app_closing = true; QCoreApplicationPrivate::is_app_running = false; @@ -894,7 +894,7 @@ QCoreApplication::~QCoreApplication() #if QT_CONFIG(thread) // Synchronize and stop the global thread pool threads. - QThreadPool *globalThreadPool = 0; + QThreadPool *globalThreadPool = nullptr; QT_TRY { globalThreadPool = QThreadPool::globalInstance(); } QT_CATCH (...) { @@ -905,10 +905,10 @@ QCoreApplication::~QCoreApplication() #endif #ifndef QT_NO_QOBJECT - d_func()->threadData->eventDispatcher = 0; + d_func()->threadData->eventDispatcher = nullptr; if (QCoreApplicationPrivate::eventDispatcher) QCoreApplicationPrivate::eventDispatcher->closingDown(); - QCoreApplicationPrivate::eventDispatcher = 0; + QCoreApplicationPrivate::eventDispatcher = nullptr; #endif #if QT_CONFIG(library) diff --git a/src/corelib/kernel/qcoreglobaldata.cpp b/src/corelib/kernel/qcoreglobaldata.cpp index 104be1b87b..7ff222f170 100644 --- a/src/corelib/kernel/qcoreglobaldata.cpp +++ b/src/corelib/kernel/qcoreglobaldata.cpp @@ -48,7 +48,7 @@ Q_GLOBAL_STATIC(QCoreGlobalData, globalInstance) QCoreGlobalData::QCoreGlobalData() #if QT_CONFIG(textcodec) - : codecForLocale(0) + : codecForLocale(nullptr) #endif { } @@ -56,7 +56,7 @@ QCoreGlobalData::QCoreGlobalData() QCoreGlobalData::~QCoreGlobalData() { #if QT_CONFIG(textcodec) - codecForLocale = 0; + codecForLocale = nullptr; QList tmp = allCodecs; allCodecs.clear(); codecCache.clear(); diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 855d36794d..311fb01fd0 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -517,12 +517,12 @@ static const struct { const char * typeName; int typeNameLength; int type; } typ QT_FOR_EACH_STATIC_TYPE(QT_ADD_STATIC_METATYPE) QT_FOR_EACH_STATIC_ALIAS_TYPE(QT_ADD_STATIC_METATYPE_ALIASES_ITER) QT_FOR_EACH_STATIC_HACKS_TYPE(QT_ADD_STATIC_METATYPE_HACKS_ITER) - {0, 0, QMetaType::UnknownType} + {nullptr, 0, QMetaType::UnknownType} }; -Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeGuiHelper = 0; -Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeWidgetsHelper = 0; -Q_CORE_EXPORT const QMetaObject *qMetaObjectWidgetsHelper = 0; +Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeGuiHelper = nullptr; +Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeWidgetsHelper = nullptr; +Q_CORE_EXPORT const QMetaObject *qMetaObjectWidgetsHelper = nullptr; class QCustomTypeInfo : public QMetaTypeInterface { @@ -557,7 +557,7 @@ public: { const QWriteLocker locker(&lock); const T* &fun = map[k]; - if (fun != 0) + if (fun) return false; fun = f; return true; @@ -566,7 +566,7 @@ public: const T *function(Key k) const { const QReadLocker locker(&lock); - return map.value(k, 0); + return map.value(k, nullptr); } void remove(int from, int to) @@ -973,7 +973,7 @@ static inline int qMetaTypeStaticType(const char *typeName, int length) The extra \a firstInvalidIndex parameter is an easy way to avoid iterating over customTypes() a second time in registerNormalizedType(). */ -static int qMetaTypeCustomType_unlocked(const char *typeName, int length, int *firstInvalidIndex = 0) +static int qMetaTypeCustomType_unlocked(const char *typeName, int length, int *firstInvalidIndex = nullptr) { const QVector * const ct = customTypes(); if (!ct) @@ -1006,7 +1006,7 @@ int QMetaType::registerType(const char *typeName, Deleter deleter, { return registerType(typeName, deleter, creator, QtMetaTypePrivate::QMetaTypeFunctionHelper::Destruct, - QtMetaTypePrivate::QMetaTypeFunctionHelper::Construct, 0, TypeFlags(), 0); + QtMetaTypePrivate::QMetaTypeFunctionHelper::Construct, 0, TypeFlags(), nullptr); } /*! @@ -1613,7 +1613,7 @@ void *QMetaType::create(int type, const void *copy) QMetaType info(type); if (int size = info.sizeOf()) return info.construct(operator new(size), copy); - return 0; + return nullptr; } /*! @@ -1639,14 +1639,18 @@ class TypeConstructor { static void *Construct(const int type, void *where, const void *copy) { if (QModulesPrivate::QTypeModuleInfo::IsGui) - return Q_LIKELY(qMetaTypeGuiHelper) ? qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].constructor(where, copy) : 0; + return Q_LIKELY(qMetaTypeGuiHelper) + ? qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].constructor(where, copy) + : nullptr; if (QModulesPrivate::QTypeModuleInfo::IsWidget) - return Q_LIKELY(qMetaTypeWidgetsHelper) ? qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].constructor(where, copy) : 0; + return Q_LIKELY(qMetaTypeWidgetsHelper) + ? qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].constructor(where, copy) + : nullptr; // This point can be reached only for known types that definition is not available, for example // in bootstrap mode. We have no other choice then ignore it. - return 0; + return nullptr; } }; public: @@ -1670,7 +1674,7 @@ private: { QReadLocker locker(customTypesLock()); if (Q_UNLIKELY(type < QMetaType::User || !ct || ct->count() <= type - QMetaType::User)) - return 0; + return nullptr; const auto &typeInfo = ct->at(type - QMetaType::User); ctor = typeInfo.constructor; tctor = typeInfo.typedConstructor; @@ -1715,7 +1719,7 @@ private: void *QMetaType::construct(int type, void *where, const void *copy) { if (!where) - return 0; + return nullptr; TypeConstructor constructor(type, where); return QMetaTypeSwitcher::switcher(constructor, type, copy); } @@ -1861,7 +1865,7 @@ private: int QMetaType::sizeOf(int type) { SizeOf sizeOf(type); - return QMetaTypeSwitcher::switcher(sizeOf, type, 0); + return QMetaTypeSwitcher::switcher(sizeOf, type); } namespace { @@ -1925,7 +1929,7 @@ private: QMetaType::TypeFlags QMetaType::typeFlags(int type) { Flags flags(type); - return static_cast(QMetaTypeSwitcher::switcher(flags, type, 0)); + return static_cast(QMetaTypeSwitcher::switcher(flags, type)); } #ifndef QT_BOOTSTRAPPED @@ -1948,17 +1952,21 @@ public: { static const QMetaObject *MetaObject(int type) { if (QModulesPrivate::QTypeModuleInfo::IsGui) - return Q_LIKELY(qMetaTypeGuiHelper) ? qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].metaObject : 0; + return Q_LIKELY(qMetaTypeGuiHelper) + ? qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].metaObject + : nullptr; if (QModulesPrivate::QTypeModuleInfo::IsWidget) - return Q_LIKELY(qMetaTypeWidgetsHelper) ? qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].metaObject : 0; + return Q_LIKELY(qMetaTypeWidgetsHelper) + ? qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].metaObject + : nullptr; return 0; } }; template const QMetaObject *delegate(const T *) { return MetaObjectImpl::MetaObject(m_type); } - const QMetaObject *delegate(const void*) { return 0; } - const QMetaObject *delegate(const QMetaTypeSwitcher::UnknownType*) { return 0; } + const QMetaObject *delegate(const void*) { return nullptr; } + const QMetaObject *delegate(const QMetaTypeSwitcher::UnknownType*) { return nullptr; } const QMetaObject *delegate(const QMetaTypeSwitcher::NotBuiltinType*) { return customMetaObject(m_type); } private: const int m_type; @@ -1966,10 +1974,10 @@ private: { const QVector * const ct = customTypes(); if (Q_UNLIKELY(!ct || type < QMetaType::User)) - return 0; + return nullptr; QReadLocker locker(customTypesLock()); if (Q_UNLIKELY(ct->count() <= type - QMetaType::User)) - return 0; + return nullptr; return ct->at(type - QMetaType::User).metaObject; } }; @@ -1987,10 +1995,10 @@ const QMetaObject *QMetaType::metaObjectForType(int type) { #ifndef QT_BOOTSTRAPPED MetaObject mo(type); - return QMetaTypeSwitcher::switcher(mo, type, 0); + return QMetaTypeSwitcher::switcher(mo, type); #else Q_UNUSED(type); - return 0; + return nullptr; #endif } @@ -2187,7 +2195,7 @@ private: QMetaType QMetaType::typeInfo(const int type) { TypeInfo typeInfo(type); - QMetaTypeSwitcher::switcher(typeInfo, type, 0); + QMetaTypeSwitcher::switcher(typeInfo, type); return (typeInfo.info.constructor || typeInfo.info.typedConstructor) ? QMetaType(static_cast(QMetaType::CreateEx | QMetaType::DestroyEx | (typeInfo.info.typedConstructor ? QMetaType::ConstructEx | QMetaType::DestructEx : 0)) @@ -2307,7 +2315,7 @@ void QMetaType::dtor() void *QMetaType::createExtended(const void *copy) const { if (m_typeId == QMetaType::UnknownType) - return 0; + return nullptr; if (Q_UNLIKELY(m_typedConstructor && !m_constructor)) return m_typedConstructor(m_typeId, operator new(m_size), copy); return m_constructor(operator new(m_size), copy); @@ -2387,7 +2395,7 @@ uint QMetaType::sizeExtended() const */ QMetaType::TypeFlags QMetaType::flagsExtended() const { - return 0; + return { }; } /*! @@ -2400,7 +2408,7 @@ QMetaType::TypeFlags QMetaType::flagsExtended() const */ const QMetaObject *QMetaType::metaObjectExtended() const { - return 0; + return nullptr; } @@ -2409,7 +2417,7 @@ namespace QtPrivate const QMetaObject *metaObjectForQWidget() { if (!qMetaTypeWidgetsHelper) - return 0; + return nullptr; return qMetaObjectWidgetsHelper; } } diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h index 0846193e66..97d6001937 100644 --- a/src/corelib/kernel/qmetatype_p.h +++ b/src/corelib/kernel/qmetatype_p.h @@ -140,12 +140,12 @@ public: /*saveOp*/(QtMetaTypePrivate::QMetaTypeFunctionHelper::IsAvailable>::Save), \ /*loadOp*/(QtMetaTypePrivate::QMetaTypeFunctionHelper::IsAvailable>::Load), # define QT_METATYPE_INTERFACE_INIT_EMPTY_DATASTREAM_IMPL(Type) \ - /*saveOp*/ 0, \ - /*loadOp*/ 0, + /*saveOp*/ nullptr, \ + /*loadOp*/ nullptr, #else # define QT_METATYPE_INTERFACE_INIT_EMPTY_DATASTREAM_IMPL(Type) \ - /*saveOp*/ 0, \ - /*loadOp*/ 0, + /*saveOp*/ nullptr, \ + /*loadOp*/ nullptr, # define QT_METATYPE_INTERFACE_INIT_DATASTREAM_IMPL(Type) \ QT_METATYPE_INTERFACE_INIT_EMPTY_DATASTREAM_IMPL(Type) #endif @@ -153,7 +153,7 @@ public: #ifndef QT_BOOTSTRAPPED #define METAOBJECT_DELEGATE(Type) (QtPrivate::MetaObjectForType::value()) #else -#define METAOBJECT_DELEGATE(Type) 0 +#define METAOBJECT_DELEGATE(Type) nullptr #endif #define QT_METATYPE_INTERFACE_INIT_IMPL(Type, DATASTREAM_DELEGATE) \ @@ -184,11 +184,11 @@ public: #define QT_METATYPE_INTERFACE_INIT_EMPTY() \ { \ QT_METATYPE_INTERFACE_INIT_EMPTY_DATASTREAM_IMPL(void) \ - /*constructor*/ 0, \ - /*destructor*/ 0, \ + /*constructor*/ nullptr, \ + /*destructor*/ nullptr, \ /*size*/ 0, \ /*flags*/ 0, \ - /*metaObject*/ 0 , \ + /*metaObject*/ nullptr , \ /*typedConstructor*/ nullptr, \ /*typedDestructor*/ nullptr \ } diff --git a/src/corelib/kernel/qmetatypeswitcher_p.h b/src/corelib/kernel/qmetatypeswitcher_p.h index 154fb8ab7f..dabc70f4b0 100644 --- a/src/corelib/kernel/qmetatypeswitcher_p.h +++ b/src/corelib/kernel/qmetatypeswitcher_p.h @@ -60,7 +60,7 @@ public: class NotBuiltinType; // type is not a built-in type, but it may be a custom type or an unknown type class UnknownType; // type not known to QMetaType system template - static ReturnType switcher(DelegateObject &logic, int type, const void *data); + static ReturnType switcher(DelegateObject &logic, int type, const void *data = nullptr); }; diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp index 9d0394e4a5..a735e12925 100644 --- a/src/corelib/kernel/qsystemerror.cpp +++ b/src/corelib/kernel/qsystemerror.cpp @@ -112,7 +112,7 @@ static QString windowsErrorString(int errorCode) static QString standardLibraryErrorString(int errorCode) { - const char *s = 0; + const char *s = nullptr; QString ret; switch (errorCode) { case 0: diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 1ac47f3972..b9563b8395 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -119,19 +119,19 @@ namespace { // annonymous used to hide QVariant handlers static void construct(QVariant::Private *x, const void *copy) { QVariantConstructor constructor(x, copy); - QMetaTypeSwitcher::switcher(constructor, x->type, 0); + QMetaTypeSwitcher::switcher(constructor, x->type); } static void clear(QVariant::Private *d) { QVariantDestructor cleaner(d); - QMetaTypeSwitcher::switcher(cleaner, d->type, 0); + QMetaTypeSwitcher::switcher(cleaner, d->type); } static bool isNull(const QVariant::Private *d) { QVariantIsNull isNull(d); - return QMetaTypeSwitcher::switcher(isNull, d->type, 0); + return QMetaTypeSwitcher::switcher(isNull, d->type); } /*! @@ -143,7 +143,7 @@ static bool isNull(const QVariant::Private *d) static bool compare(const QVariant::Private *a, const QVariant::Private *b) { QVariantComparator comparator(a, b); - return QMetaTypeSwitcher::switcher(comparator, a->type, 0); + return QMetaTypeSwitcher::switcher(comparator, a->type); } /*! @@ -1401,7 +1401,7 @@ static void streamDebug(QDebug dbg, const QVariant &v) { QVariant::Private *d = const_cast(&v.data_ptr()); QVariantDebugStream stream(dbg, d); - QMetaTypeSwitcher::switcher(stream, d->type, 0); + QMetaTypeSwitcher::switcher(stream, d->type); } #endif @@ -1410,16 +1410,16 @@ const QVariant::Handler qt_kernel_variant_handler = { clear, isNull, #ifndef QT_NO_DATASTREAM - 0, - 0, + nullptr, + nullptr, #endif compare, convert, - 0, + nullptr, #if !defined(QT_NO_DEBUG_STREAM) streamDebug #else - 0 + nullptr #endif }; @@ -1436,16 +1436,16 @@ const QVariant::Handler qt_dummy_variant_handler = { dummyClear, dummyIsNull, #ifndef QT_NO_DATASTREAM - 0, - 0, + nullptr, + nullptr, #endif dummyCompare, dummyConvert, - 0, + nullptr, #if !defined(QT_NO_DEBUG_STREAM) dummyStreamDebug #else - 0 + nullptr #endif }; @@ -1555,16 +1555,16 @@ const QVariant::Handler qt_custom_variant_handler = { customClear, customIsNull, #ifndef QT_NO_DATASTREAM - 0, - 0, + nullptr, + nullptr, #endif customCompare, customConvert, - 0, + nullptr, #if !defined(QT_NO_DEBUG_STREAM) customStreamDebug #else - 0 + nullptr #endif }; @@ -2125,7 +2125,7 @@ QVariant::QVariant(const char *val) */ QVariant::QVariant(Type type) -{ create(type, 0); } +{ create(type, nullptr); } QVariant::QVariant(int typeId, const void *copy) { create(typeId, copy); d.is_null = false; } @@ -2667,7 +2667,7 @@ inline T qVariantToHelper(const QVariant::Private &d, const HandlersManager &han return ret; } - handlerManager[d.type]->convert(&d, targetType, &ret, 0); + handlerManager[d.type]->convert(&d, targetType, &ret, nullptr); return ret; } @@ -3217,7 +3217,7 @@ bool QVariant::toBool() const return d.data.b; bool res = false; - handlerManager[d.type]->convert(&d, Bool, &res, 0); + handlerManager[d.type]->convert(&d, Bool, &res, nullptr); return res; } @@ -3735,7 +3735,7 @@ bool QVariant::convert(int targetTypeId) if (!oldValue.canConvert(targetTypeId)) return false; - create(targetTypeId, 0); + create(targetTypeId, nullptr); // Fail if the value is not initialized or was forced null by a previous failed convert. if (oldValue.d.is_null && oldValue.d.type != QMetaType::Nullptr) return false; @@ -3760,7 +3760,7 @@ bool QVariant::convert(int targetTypeId) */ bool QVariant::convert(const int type, void *ptr) const { - return handlerManager[type]->convert(&d, type, ptr, 0); + return handlerManager[type]->convert(&d, type, ptr, nullptr); } diff --git a/src/corelib/serialization/qdatastream.cpp b/src/corelib/serialization/qdatastream.cpp index 2c29b81f7c..b3330d6cea 100644 --- a/src/corelib/serialization/qdatastream.cpp +++ b/src/corelib/serialization/qdatastream.cpp @@ -277,7 +277,7 @@ QT_BEGIN_NAMESPACE QDataStream::QDataStream() { - dev = 0; + dev = nullptr; owndev = false; byteorder = BigEndian; ver = Qt_DefaultCompiledVersion; @@ -433,7 +433,7 @@ bool QDataStream::atEnd() const */ QDataStream::FloatingPointPrecision QDataStream::floatingPointPrecision() const { - return d == 0 ? QDataStream::DoublePrecision : d->floatingPointPrecision; + return d ? d->floatingPointPrecision : QDataStream::DoublePrecision; } /*! @@ -458,7 +458,7 @@ QDataStream::FloatingPointPrecision QDataStream::floatingPointPrecision() const */ void QDataStream::setFloatingPointPrecision(QDataStream::FloatingPointPrecision precision) { - if (d == 0) + if (!d) d.reset(new QDataStreamPrivate()); d->floatingPointPrecision = precision; } @@ -639,7 +639,7 @@ void QDataStream::startTransaction() { CHECK_STREAM_PRECOND(Q_VOID) - if (d == 0) + if (!d) d.reset(new QDataStreamPrivate()); if (++d->transactionDepth == 1) { @@ -1043,7 +1043,7 @@ QDataStream &QDataStream::operator>>(char *&s) QDataStream &QDataStream::readBytes(char *&s, uint &l) { - s = 0; + s = nullptr; l = 0; CHECK_STREAM_PRECOND(*this) @@ -1054,8 +1054,8 @@ QDataStream &QDataStream::readBytes(char *&s, uint &l) const quint32 Step = 1024 * 1024; quint32 allocated = 0; - char *prevBuf = 0; - char *curBuf = 0; + char *prevBuf = nullptr; + char *curBuf = nullptr; do { int blockSize = qMin(Step, len - allocated); diff --git a/src/corelib/serialization/qjsonarray.cpp b/src/corelib/serialization/qjsonarray.cpp index 7dfa9b43f0..3a6244f5ac 100644 --- a/src/corelib/serialization/qjsonarray.cpp +++ b/src/corelib/serialization/qjsonarray.cpp @@ -132,7 +132,7 @@ QT_BEGIN_NAMESPACE Creates an empty array. */ QJsonArray::QJsonArray() - : d(0), a(0) + : d(nullptr), a(nullptr) { } @@ -168,8 +168,8 @@ QJsonArray::QJsonArray(QJsonPrivate::Data *data, QJsonPrivate::Array *array) */ void QJsonArray::initialize() { - d = 0; - a = 0; + d = nullptr; + a = nullptr; } /*! diff --git a/src/corelib/serialization/qjsondocument.cpp b/src/corelib/serialization/qjsondocument.cpp index 179a87c699..f8027efb58 100644 --- a/src/corelib/serialization/qjsondocument.cpp +++ b/src/corelib/serialization/qjsondocument.cpp @@ -84,7 +84,7 @@ QT_BEGIN_NAMESPACE * Constructs an empty and invalid document. */ QJsonDocument::QJsonDocument() - : d(0) + : d(nullptr) { } @@ -92,7 +92,7 @@ QJsonDocument::QJsonDocument() * Creates a QJsonDocument from \a object. */ QJsonDocument::QJsonDocument(const QJsonObject &object) - : d(0) + : d(nullptr) { setObject(object); } @@ -101,7 +101,7 @@ QJsonDocument::QJsonDocument(const QJsonObject &object) * Constructs a QJsonDocument from \a array. */ QJsonDocument::QJsonDocument(const QJsonArray &array) - : d(0) + : d(nullptr) { setArray(array); } @@ -236,7 +236,7 @@ const char *QJsonDocument::rawData(int *size) const { if (!d) { *size = 0; - return 0; + return nullptr; } *size = d->alloc; return d->rawData; @@ -635,7 +635,7 @@ bool QJsonDocument::operator==(const QJsonDocument &other) const */ bool QJsonDocument::isNull() const { - return (d == 0); + return (d == nullptr); } #if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY) diff --git a/src/corelib/serialization/qjsonobject.cpp b/src/corelib/serialization/qjsonobject.cpp index a9f25a119c..f92bdd0e80 100644 --- a/src/corelib/serialization/qjsonobject.cpp +++ b/src/corelib/serialization/qjsonobject.cpp @@ -110,7 +110,7 @@ QT_BEGIN_NAMESPACE \sa isEmpty() */ QJsonObject::QJsonObject() - : d(0), o(0) + : d(nullptr), o(nullptr) { } @@ -149,8 +149,8 @@ QJsonObject::QJsonObject(QJsonPrivate::Data *data, QJsonPrivate::Object *object) void QJsonObject::initialize() { - d = 0; - o = 0; + d = nullptr; + o = nullptr; } /*! diff --git a/src/corelib/serialization/qjsonparser.cpp b/src/corelib/serialization/qjsonparser.cpp index f29348d593..cd36bd5a5b 100644 --- a/src/corelib/serialization/qjsonparser.cpp +++ b/src/corelib/serialization/qjsonparser.cpp @@ -198,7 +198,9 @@ QString QJsonParseError::errorString() const using namespace QJsonPrivate; Parser::Parser(const char *json, int length) - : head(json), json(json), data(0), dataLength(0), current(0), nestingLevel(0), lastError(QJsonParseError::NoError) + : head(json), json(json), data(nullptr) + , dataLength(0), current(0), nestingLevel(0) + , lastError(QJsonParseError::NoError) { end = json + length; } diff --git a/src/corelib/serialization/qjsonvalue.cpp b/src/corelib/serialization/qjsonvalue.cpp index 1fc610d7c7..0bd28581f3 100644 --- a/src/corelib/serialization/qjsonvalue.cpp +++ b/src/corelib/serialization/qjsonvalue.cpp @@ -112,7 +112,7 @@ QT_BEGIN_NAMESPACE The default is to create a Null value. */ QJsonValue::QJsonValue(Type type) - : ui(0), d(0), t(type) + : ui(0), d(nullptr), t(type) { } @@ -120,7 +120,7 @@ QJsonValue::QJsonValue(Type type) \internal */ QJsonValue::QJsonValue(QJsonPrivate::Data *data, QJsonPrivate::Base *base, const QJsonPrivate::Value &v) - : d(0) + : d(nullptr) { t = (Type)(uint)v.type; switch (t) { @@ -154,7 +154,7 @@ QJsonValue::QJsonValue(QJsonPrivate::Data *data, QJsonPrivate::Base *base, const Creates a value of type Bool, with value \a b. */ QJsonValue::QJsonValue(bool b) - : d(0), t(Bool) + : d(nullptr), t(Bool) { this->b = b; } @@ -163,7 +163,7 @@ QJsonValue::QJsonValue(bool b) Creates a value of type Double, with value \a n. */ QJsonValue::QJsonValue(double n) - : d(0), t(Double) + : d(nullptr), t(Double) { this->dbl = n; } @@ -173,7 +173,7 @@ QJsonValue::QJsonValue(double n) Creates a value of type Double, with value \a n. */ QJsonValue::QJsonValue(int n) - : d(0), t(Double) + : d(nullptr), t(Double) { this->dbl = n; } @@ -185,7 +185,7 @@ QJsonValue::QJsonValue(int n) If you pass in values outside this range expect a loss of precision to occur. */ QJsonValue::QJsonValue(qint64 n) - : d(0), t(Double) + : d(nullptr), t(Double) { this->dbl = double(n); } @@ -194,7 +194,7 @@ QJsonValue::QJsonValue(qint64 n) Creates a value of type String, with value \a s. */ QJsonValue::QJsonValue(const QString &s) - : d(0), t(String) + : d(nullptr), t(String) { stringDataFromQStringHelper(s); } @@ -221,7 +221,7 @@ void QJsonValue::stringDataFromQStringHelper(const QString &string) Creates a value of type String, with value \a s. */ QJsonValue::QJsonValue(QLatin1String s) - : d(0), t(String) + : d(nullptr), t(String) { // ### FIXME: Avoid creating the temp QString below QString str(s); diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp index ef2a9c97ee..9d4bc223ab 100644 --- a/src/corelib/serialization/qtextstream.cpp +++ b/src/corelib/serialization/qtextstream.cpp @@ -327,7 +327,7 @@ QT_BEGIN_NAMESPACE QTextStreamPrivate::QTextStreamPrivate(QTextStream *q_ptr) : #if QT_CONFIG(textcodec) - readConverterSavedState(0), + readConverterSavedState(nullptr), #endif readConverterSavedStateOffset(0), locale(QLocale::c()) @@ -381,7 +381,7 @@ void QTextStreamPrivate::Params::reset() padChar = QLatin1Char(' '); fieldAlignment = QTextStream::AlignRight; realNumberNotation = QTextStream::SmartNotation; - numberFlags = 0; + numberFlags = { }; } /*! @@ -391,9 +391,9 @@ void QTextStreamPrivate::reset() { params.reset(); - device = 0; + device = nullptr; deleteDevice = false; - string = 0; + string = nullptr; stringOffset = 0; stringOpenMode = QIODevice::NotOpen; @@ -406,7 +406,7 @@ void QTextStreamPrivate::reset() resetCodecConverterStateHelper(&readConverterState); resetCodecConverterStateHelper(&writeConverterState); delete readConverterSavedState; - readConverterSavedState = 0; + readConverterSavedState = nullptr; writeConverterState.flags |= QTextCodec::IgnoreHeader; autoDetectUnicode = true; #endif @@ -1207,7 +1207,7 @@ bool QTextStream::seek(qint64 pos) resetCodecConverterStateHelper(&d->readConverterState); resetCodecConverterStateHelper(&d->writeConverterState); delete d->readConverterSavedState; - d->readConverterSavedState = 0; + d->readConverterSavedState = nullptr; d->writeConverterState.flags |= QTextCodec::IgnoreHeader; #endif return true; @@ -1295,7 +1295,7 @@ void QTextStream::skipWhiteSpace() { Q_D(QTextStream); CHECK_VALID_STREAM(Q_VOID); - d->scan(0, 0, 0, QTextStreamPrivate::NotSpace); + d->scan(nullptr, nullptr, 0, QTextStreamPrivate::NotSpace); d->consumeLastToken(); } @@ -1751,7 +1751,7 @@ QString QTextStream::read(qint64 maxlen) */ QTextStreamPrivate::NumberParsingStatus QTextStreamPrivate::getNumber(qulonglong *ret) { - scan(0, 0, 0, NotSpace); + scan(nullptr, nullptr, 0, NotSpace); consumeLastToken(); // detect int encoding @@ -1980,7 +1980,7 @@ bool QTextStreamPrivate::getReal(double *f) ParserState state = Init; InputToken input = None; - scan(0, 0, 0, NotSpace); + scan(nullptr, nullptr, 0, NotSpace); consumeLastToken(); const int BufferSize = 128; @@ -2084,7 +2084,7 @@ QTextStream &QTextStream::operator>>(QChar &c) { Q_D(QTextStream); CHECK_VALID_STREAM(*this); - d->scan(0, 0, 0, QTextStreamPrivate::NotSpace); + d->scan(nullptr, nullptr, 0, QTextStreamPrivate::NotSpace); if (!d->getChar(&c)) setStatus(ReadPastEnd); return *this; @@ -2245,7 +2245,7 @@ QTextStream &QTextStream::operator>>(QString &str) CHECK_VALID_STREAM(*this); str.clear(); - d->scan(0, 0, 0, QTextStreamPrivate::NotSpace); + d->scan(nullptr, nullptr, 0, QTextStreamPrivate::NotSpace); d->consumeLastToken(); const QChar *ptr; @@ -2273,7 +2273,7 @@ QTextStream &QTextStream::operator>>(QByteArray &array) CHECK_VALID_STREAM(*this); array.clear(); - d->scan(0, 0, 0, QTextStreamPrivate::NotSpace); + d->scan(nullptr, nullptr, 0, QTextStreamPrivate::NotSpace); d->consumeLastToken(); const QChar *ptr; @@ -2308,7 +2308,7 @@ QTextStream &QTextStream::operator>>(char *c) Q_D(QTextStream); *c = 0; CHECK_VALID_STREAM(*this); - d->scan(0, 0, 0, QTextStreamPrivate::NotSpace); + d->scan(nullptr, nullptr, 0, QTextStreamPrivate::NotSpace); d->consumeLastToken(); const QChar *ptr; diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index d43d9c4e14..be3a476cb2 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -58,9 +58,9 @@ // case for most bootstrapped applications. #define Q_DECLARE_TR_FUNCTIONS(context) \ public: \ - static inline QString tr(const char *sourceText, const char *comment = 0) \ + static inline QString tr(const char *sourceText, const char *comment = nullptr) \ { Q_UNUSED(comment); return QString::fromLatin1(sourceText); } \ - static inline QString trUtf8(const char *sourceText, const char *comment = 0) \ + static inline QString trUtf8(const char *sourceText, const char *comment = nullptr) \ { Q_UNUSED(comment); return QString::fromLatin1(sourceText); } \ static inline QString tr(const char *sourceText, const char*, int) \ { return QString::fromLatin1(sourceText); } \ @@ -548,7 +548,7 @@ void QXmlStreamReader::clear() if (d->device) { if (d->deleteDevice) delete d->device; - d->device = 0; + d->device = nullptr; } } @@ -792,16 +792,16 @@ QXmlStreamPrivateTagStack::QXmlStreamPrivateTagStack() QXmlStreamReaderPrivate::QXmlStreamReaderPrivate(QXmlStreamReader *q) :q_ptr(q) { - device = 0; + device = nullptr; deleteDevice = false; #if QT_CONFIG(textcodec) - decoder = 0; + decoder = nullptr; #endif stack_size = 64; - sym_stack = 0; - state_stack = 0; + sym_stack = nullptr; + state_stack = nullptr; reallocateStack(); - entityResolver = 0; + entityResolver = nullptr; init(); #define ADD_PREDEFINED(n, v) \ do { \ @@ -843,11 +843,11 @@ void QXmlStreamReaderPrivate::init() #if QT_CONFIG(textcodec) codec = QTextCodec::codecForMib(106); // utf8 delete decoder; - decoder = 0; + decoder = nullptr; #endif attributeStack.clear(); attributeStack.reserve(16); - entityParser = 0; + entityParser = nullptr; hasCheckedStartDocument = false; normalizeLiterals = false; hasSeenTag = false; @@ -3024,8 +3024,8 @@ QXmlStreamWriterPrivate::QXmlStreamWriterPrivate(QXmlStreamWriter *q) :autoFormattingIndent(4, ' ') { q_ptr = q; - device = 0; - stringDevice = 0; + device = nullptr; + stringDevice = nullptr; deleteDevice = false; #if QT_CONFIG(textcodec) codec = QTextCodec::codecForMib(106); // utf8 @@ -3315,7 +3315,7 @@ void QXmlStreamWriter::setDevice(QIODevice *device) Q_D(QXmlStreamWriter); if (device == d->device) return; - d->stringDevice = 0; + d->stringDevice = nullptr; if (d->deleteDevice) { delete d->device; d->deleteDevice = false; diff --git a/src/corelib/serialization/qxmlstream.g b/src/corelib/serialization/qxmlstream.g index e6328a11ac..12ecc9bdb2 100644 --- a/src/corelib/serialization/qxmlstream.g +++ b/src/corelib/serialization/qxmlstream.g @@ -506,7 +506,7 @@ public: int fastScanLiteralContent(); int fastScanSpace(); int fastScanContentCharList(); - int fastScanName(int *prefix = 0); + int fastScanName(int *prefix = nullptr); inline int fastScanNMTOKEN(); diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 9220d210f1..92b243f60e 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -615,7 +615,7 @@ int QDate::weekNumber(int *yearNumber) const Q_ASSERT(week == 53 || week == 1); } - if (yearNumber != 0) + if (yearNumber) *yearNumber = year; return week; } @@ -2265,7 +2265,7 @@ QTime QTime::fromString(const QString &string, Qt::DateFormat format) case Qt::ISODateWithMs: case Qt::TextDate: default: - return fromIsoTimeString(QStringRef(&string), format, 0); + return fromIsoTimeString(QStringRef(&string), format, nullptr); } } @@ -2512,7 +2512,7 @@ int QDateTimeParser::startsWithLocalTimeZone(const QStringRef name) // then null date/time will be returned, you should adjust the date first if // you need a guaranteed result. static qint64 qt_mktime(QDate *date, QTime *time, QDateTimePrivate::DaylightStatus *daylightStatus, - QString *abbreviation, bool *ok = 0) + QString *abbreviation, bool *ok = nullptr) { const qint64 msec = time->msec(); int yy, mm, dd; @@ -2601,7 +2601,7 @@ static bool qt_localtime(qint64 msecsSinceEpoch, QDate *localDate, QTime *localT #if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) // Use the reentrant version of localtime() where available // as is thread-safe and doesn't use a shared static data area - tm *res = 0; + tm *res = nullptr; res = localtime_r(&secsSinceEpoch, &local); if (res) valid = true; @@ -2611,7 +2611,7 @@ static bool qt_localtime(qint64 msecsSinceEpoch, QDate *localDate, QTime *localT #else // Returns shared static data which may be overwritten at any time // So copy the result asap - tm *res = 0; + tm *res = nullptr; res = localtime(&secsSinceEpoch); if (res) { local = *res; @@ -2674,7 +2674,7 @@ static qint64 timeToMSecs(const QDate &date, const QTime &time) // Convert an MSecs Since Epoch into Local Time static bool epochMSecsToLocalTime(qint64 msecs, QDate *localDate, QTime *localTime, - QDateTimePrivate::DaylightStatus *daylightStatus = 0) + QDateTimePrivate::DaylightStatus *daylightStatus = nullptr) { if (msecs < 0) { // Docs state any LocalTime before 1970-01-01 will *not* have any Daylight Time applied @@ -2714,8 +2714,8 @@ static bool epochMSecsToLocalTime(qint64 msecs, QDate *localDate, QTime *localTi // values from mktime for the adjusted local date and time. static qint64 localMSecsToEpochMSecs(qint64 localMsecs, QDateTimePrivate::DaylightStatus *daylightStatus, - QDate *localDate = 0, QTime *localTime = 0, - QString *abbreviation = 0) + QDate *localDate = nullptr, QTime *localTime = nullptr, + QString *abbreviation = nullptr) { QDate dt; QTime tm; @@ -3018,7 +3018,7 @@ static void setDateTime(QDateTimeData &d, const QDate &date, const QTime &time) if (!useTime.isValid() && date.isValid()) useTime = QTime::fromMSecsSinceStartOfDay(0); - QDateTimePrivate::StatusFlags newStatus = 0; + QDateTimePrivate::StatusFlags newStatus = { }; // Set date value and status qint64 days = 0; @@ -3096,7 +3096,7 @@ inline QDateTime::Data::Data(Qt::TimeSpec spec) // the structure is too small, we need to detach d = new QDateTimePrivate; d->ref.ref(); - d->m_status = mergeSpec(0, spec); + d->m_status = mergeSpec(nullptr, spec); } } @@ -3550,7 +3550,7 @@ QDate QDateTime::date() const if (!status.testFlag(QDateTimePrivate::ValidDate)) return QDate(); QDate dt; - msecsToTime(getMSecs(d), &dt, 0); + msecsToTime(getMSecs(d), &dt, nullptr); return dt; } @@ -3566,7 +3566,7 @@ QTime QDateTime::time() const if (!status.testFlag(QDateTimePrivate::ValidTime)) return QTime(); QTime tm; - msecsToTime(getMSecs(d), 0, &tm); + msecsToTime(getMSecs(d), nullptr, &tm); return tm; } @@ -3684,7 +3684,7 @@ QString QDateTime::timeZoneAbbreviation() const case Qt::LocalTime: { QString abbrev; auto status = extractDaylightStatus(getStatus(d)); - localMSecsToEpochMSecs(getMSecs(d), &status, 0, 0, &abbrev); + localMSecsToEpochMSecs(getMSecs(d), &status, nullptr, nullptr, &abbrev); return abbrev; } } @@ -4769,14 +4769,14 @@ qint64 QDateTime::currentMSecsSinceEpoch() noexcept // posix compliant system // we have milliseconds struct timeval tv; - gettimeofday(&tv, 0); + gettimeofday(&tv, nullptr); return qint64(tv.tv_sec) * Q_INT64_C(1000) + tv.tv_usec / 1000; } qint64 QDateTime::currentSecsSinceEpoch() noexcept { struct timeval tv; - gettimeofday(&tv, 0); + gettimeofday(&tv, nullptr); return qint64(tv.tv_sec); } #else diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index 88d8b8244d..844cde5563 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -215,7 +215,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, headerSize += (alignment - Q_ALIGNOF(QArrayData)); if (headerSize > size_t(MaxAllocSize)) - return 0; + return nullptr; size_t allocSize = calculateBlockSize(capacity, objectSize, headerSize, options); QArrayData *header = static_cast(::malloc(allocSize)); diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 9526350126..c25d39461f 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -2072,7 +2072,7 @@ static inline QByteArray &qbytearray_insert(QByteArray *ba, { Q_ASSERT(pos >= 0); - if (pos < 0 || len <= 0 || arr == 0) + if (pos < 0 || len <= 0 || arr == nullptr) return *ba; int oldsize = ba->size(); @@ -4775,7 +4775,7 @@ static void q_toPercentEncoding(QByteArray *ba, const char *dontEncode, const ch QByteArray input = *ba; int len = input.count(); const char *inputData = input.constData(); - char *output = 0; + char *output = nullptr; int length = 0; for (int i = 0; i < len; ++i) { @@ -4815,7 +4815,7 @@ void q_toPercentEncoding(QByteArray *ba, const char *exclude, const char *includ void q_normalizePercentEncoding(QByteArray *ba, const char *exclude) { q_fromPercentEncoding(ba, '%'); - q_toPercentEncoding(ba, exclude, 0, '%'); + q_toPercentEncoding(ba, exclude, nullptr, '%'); } /*! diff --git a/src/corelib/tools/qbytearraymatcher.cpp b/src/corelib/tools/qbytearraymatcher.cpp index d2eb4e0e3c..72e09226af 100644 --- a/src/corelib/tools/qbytearraymatcher.cpp +++ b/src/corelib/tools/qbytearraymatcher.cpp @@ -116,9 +116,9 @@ static inline int bm_find(const uchar *cc, int l, int index, const uchar *puc, u Call setPattern() to give it a pattern to match. */ QByteArrayMatcher::QByteArrayMatcher() - : d(0) + : d(nullptr) { - p.p = 0; + p.p = nullptr; p.l = 0; memset(p.q_skiptable, 0, sizeof(p.q_skiptable)); } @@ -129,7 +129,7 @@ QByteArrayMatcher::QByteArrayMatcher() the destructor does not delete \a pattern. */ QByteArrayMatcher::QByteArrayMatcher(const char *pattern, int length) - : d(0) + : d(nullptr) { p.p = reinterpret_cast(pattern); p.l = length; @@ -141,7 +141,7 @@ QByteArrayMatcher::QByteArrayMatcher(const char *pattern, int length) Call indexIn() to perform a search. */ QByteArrayMatcher::QByteArrayMatcher(const QByteArray &pattern) - : d(0), q_pattern(pattern) + : d(nullptr), q_pattern(pattern) { p.p = reinterpret_cast(pattern.constData()); p.l = pattern.size(); @@ -152,7 +152,7 @@ QByteArrayMatcher::QByteArrayMatcher(const QByteArray &pattern) Copies the \a other byte array matcher to this byte array matcher. */ QByteArrayMatcher::QByteArrayMatcher(const QByteArrayMatcher &other) - : d(0) + : d(nullptr) { operator=(other); } diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index d6061defc3..e097e4a5fe 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -1339,7 +1339,7 @@ static const unsigned short * QT_FASTCALL decompositionHelper if (index == 0xffff) { *length = 0; *tag = QChar::NoDecomposition; - return 0; + return nullptr; } const unsigned short *decomposition = uc_decomposition_map+index; diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 85a3456d71..6b003fe739 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -471,7 +471,7 @@ static int countBits(int hint) const int MinNumBits = 4; const QHashData QHashData::shared_null = { - 0, 0, Q_REFCOUNT_INITIALIZE_STATIC, 0, 0, MinNumBits, 0, 0, 0, true, false, 0 + nullptr, nullptr, Q_REFCOUNT_INITIALIZE_STATIC, 0, 0, MinNumBits, 0, 0, 0, true, false, 0 }; void *QHashData::allocateNode(int nodeAlign) @@ -501,8 +501,8 @@ QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *), if (this == &shared_null) qt_initialize_qhash_seed(); // may throw d = new QHashData; - d->fakeNext = 0; - d->buckets = 0; + d->fakeNext = nullptr; + d->buckets = nullptr; d->ref.initializeOwned(); d->size = size; d->nodeSize = nodeSize; diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp index 48617f0539..dfebd57e34 100644 --- a/src/corelib/tools/qlist.cpp +++ b/src/corelib/tools/qlist.cpp @@ -75,7 +75,7 @@ template class Q_CORE_EXPORT QVector; the number of elements in the list. */ -const QListData::Data QListData::shared_null = { Q_REFCOUNT_INITIALIZE_STATIC, 0, 0, 0, { 0 } }; +const QListData::Data QListData::shared_null = { Q_REFCOUNT_INITIALIZE_STATIC, 0, 0, 0, { nullptr } }; /*! * Detaches the QListData by allocating new memory for a list which will be bigger diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index c8740e55f3..939f8eb34d 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -301,9 +301,9 @@ QByteArray QLocaleId::name(char separator) const const unsigned char *lang = language_code_list + 3 * language_id; const unsigned char *script = - (script_id != QLocale::AnyScript ? script_code_list + 4 * script_id : 0); + (script_id != QLocale::AnyScript ? script_code_list + 4 * script_id : nullptr); const unsigned char *country = - (country_id != QLocale::AnyCountry ? country_code_list + 3 * country_id : 0); + (country_id != QLocale::AnyCountry ? country_code_list + 3 * country_id : nullptr); char len = (lang[2] != 0 ? 3 : 2) + (script ? 4+1 : 0) + (country ? (country[2] != 0 ? 3 : 2)+1 : 0); QByteArray name(len, Qt::Uninitialized); char *uc = name.data(); @@ -373,7 +373,7 @@ static const QLocaleData *findLocaleDataById(const QLocaleId &localeId) } while (data->m_language_id && data->m_language_id == localeId.language_id); } - return 0; + return nullptr; } const QLocaleData *QLocaleData::findLocaleData(QLocale::Language language, QLocale::Script script, QLocale::Country country) @@ -604,7 +604,7 @@ int qt_repeatCount(QStringView s) return int(j); } -static const QLocaleData *default_data = 0; +static const QLocaleData *default_data = nullptr; static QLocale::NumberOptions default_number_options = QLocale::DefaultNumberOptions; static const QLocaleData *const c_data = locale_data; diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 15398ded32..59cc33700d 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -250,14 +250,14 @@ public: if (qIsInf(d)) return float(d); if (std::fabs(d) > std::numeric_limits::max()) { - if (ok != nullptr) + if (ok) *ok = false; const float huge = std::numeric_limits::infinity(); return d < 0 ? -huge : huge; } if (d != 0 && float(d) == 0) { // Values that underflow double already failed. Match them: - if (ok != 0) + if (ok) *ok = false; return 0; } diff --git a/src/corelib/tools/qlocale_tools.cpp b/src/corelib/tools/qlocale_tools.cpp index 53258bec3e..db8c8cd12f 100644 --- a/src/corelib/tools/qlocale_tools.cpp +++ b/src/corelib/tools/qlocale_tools.cpp @@ -398,7 +398,7 @@ qstrtoull(const char * nptr, const char **endptr, int base, bool *ok) *ok = true; errno = 0; - char *endptr2 = 0; + char *endptr2 = nullptr; unsigned long long result = qt_strtoull(nptr, &endptr2, base); if (endptr) *endptr = endptr2; @@ -415,7 +415,7 @@ qstrtoll(const char * nptr, const char **endptr, int base, bool *ok) { *ok = true; errno = 0; - char *endptr2 = 0; + char *endptr2 = nullptr; long long result = qt_strtoll(nptr, &endptr2, base); if (endptr) *endptr = endptr2; diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp index 5f7275c5f8..a0ec372f9a 100644 --- a/src/corelib/tools/qmap.cpp +++ b/src/corelib/tools/qmap.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE -const QMapDataBase QMapDataBase::shared_null = { Q_REFCOUNT_INITIALIZE_STATIC, 0, { 0, 0, 0 }, 0 }; +const QMapDataBase QMapDataBase::shared_null = { Q_REFCOUNT_INITIALIZE_STATIC, 0, { 0, nullptr, nullptr }, nullptr }; const QMapNodeBase *QMapNodeBase::nextNode() const { @@ -92,7 +92,7 @@ void QMapDataBase::rotateLeft(QMapNodeBase *x) QMapNodeBase *&root = header.left; QMapNodeBase *y = x->right; x->right = y->left; - if (y->left != 0) + if (y->left != nullptr) y->left->setParent(x); y->setParent(x->parent()); if (x == root) @@ -111,7 +111,7 @@ void QMapDataBase::rotateRight(QMapNodeBase *x) QMapNodeBase *&root = header.left; QMapNodeBase *y = x->left; x->left = y->right; - if (y->right != 0) + if (y->right != nullptr) y->right->setParent(x); y->setParent(x->parent()); if (x == root) @@ -173,7 +173,7 @@ void QMapDataBase::freeNodeAndRebalance(QMapNodeBase *z) QMapNodeBase *y = z; QMapNodeBase *x; QMapNodeBase *x_parent; - if (y->left == 0) { + if (y->left == nullptr) { x = y->right; if (y == mostLeftNode) { if (x) @@ -182,11 +182,11 @@ void QMapDataBase::freeNodeAndRebalance(QMapNodeBase *z) mostLeftNode = y->parent(); } } else { - if (y->right == 0) { + if (y->right == nullptr) { x = y->left; } else { y = y->right; - while (y->left != 0) + while (y->left != nullptr) y = y->left; x = y->right; } @@ -228,7 +228,7 @@ void QMapDataBase::freeNodeAndRebalance(QMapNodeBase *z) z->parent()->right = x; } if (y->color() != QMapNodeBase::Red) { - while (x != root && (x == 0 || x->color() == QMapNodeBase::Black)) { + while (x != root && (x == nullptr || x->color() == QMapNodeBase::Black)) { if (x == x_parent->left) { QMapNodeBase *w = x_parent->right; if (w->color() == QMapNodeBase::Red) { @@ -237,13 +237,13 @@ void QMapDataBase::freeNodeAndRebalance(QMapNodeBase *z) rotateLeft(x_parent); w = x_parent->right; } - if ((w->left == 0 || w->left->color() == QMapNodeBase::Black) && - (w->right == 0 || w->right->color() == QMapNodeBase::Black)) { + if ((w->left == nullptr || w->left->color() == QMapNodeBase::Black) && + (w->right == nullptr || w->right->color() == QMapNodeBase::Black)) { w->setColor(QMapNodeBase::Red); x = x_parent; x_parent = x_parent->parent(); } else { - if (w->right == 0 || w->right->color() == QMapNodeBase::Black) { + if (w->right == nullptr || w->right->color() == QMapNodeBase::Black) { if (w->left) w->left->setColor(QMapNodeBase::Black); w->setColor(QMapNodeBase::Red); @@ -265,13 +265,13 @@ void QMapDataBase::freeNodeAndRebalance(QMapNodeBase *z) rotateRight(x_parent); w = x_parent->left; } - if ((w->right == 0 || w->right->color() == QMapNodeBase::Black) && - (w->left == 0 || w->left->color() == QMapNodeBase::Black)) { + if ((w->right == nullptr || w->right->color() == QMapNodeBase::Black) && + (w->left == nullptr|| w->left->color() == QMapNodeBase::Black)) { w->setColor(QMapNodeBase::Red); x = x_parent; x_parent = x_parent->parent(); } else { - if (w->left == 0 || w->left->color() == QMapNodeBase::Black) { + if (w->left == nullptr || w->left->color() == QMapNodeBase::Black) { if (w->right) w->right->setColor(QMapNodeBase::Black); w->setColor(QMapNodeBase::Red); @@ -363,8 +363,8 @@ QMapDataBase *QMapDataBase::createData() d->size = 0; d->header.p = 0; - d->header.left = 0; - d->header.right = 0; + d->header.left = nullptr; + d->header.right = nullptr; d->mostLeftNode = &(d->header); return d; diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index d970843dea..132ff48846 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -937,10 +937,10 @@ struct QRegExpMatchState const QRegExpEngine *eng; - inline QRegExpMatchState() : bigArray(0), captured(0) {} + inline QRegExpMatchState() : bigArray(nullptr), captured(nullptr) {} inline ~QRegExpMatchState() { free(bigArray); } - void drain() { free(bigArray); bigArray = 0; captured = 0; } // to save memory + void drain() { free(bigArray); bigArray = nullptr; captured = nullptr; } // to save memory void prepareForMatch(QRegExpEngine *eng); void match(const QChar *str, int len, int pos, bool minimal, bool oneTest, int caretIndex); @@ -1428,7 +1428,7 @@ void QRegExpMatchState::match(const QChar *str0, int len0, int pos0, #endif { in = str0; - if (in == 0) + if (in == nullptr) in = &char_null; pos = pos0; caretPos = caretIndex; @@ -2910,7 +2910,7 @@ int QRegExpEngine::getEscape() #ifndef QT_NO_REGEXP_ESCAPE if ((prevCh & ~0xff) == 0) { const char *p = strchr(tab, prevCh); - if (p != 0) + if (p != nullptr) return Tok_Char | backTab[p - tab]; } #endif @@ -3530,7 +3530,7 @@ int QRegExpEngine::parse(const QChar *pattern, int len) #endif box.cat(middleBox); box.cat(rightBox); - yyCharClass.reset(0); + yyCharClass.reset(); #ifndef QT_NO_REGEXP_CAPTURE for (int i = 0; i < nf; ++i) { @@ -3608,7 +3608,7 @@ int QRegExpEngine::parse(const QChar *pattern, int len) void QRegExpEngine::parseAtom(Box *box) { #ifndef QT_NO_REGEXP_LOOKAHEAD - QRegExpEngine *eng = 0; + QRegExpEngine *eng = nullptr; bool neg; int len; #endif @@ -3805,9 +3805,9 @@ struct QRegExpPrivate QRegExpMatchState matchState; inline QRegExpPrivate() - : eng(0), engineKey(QString(), QRegExp::RegExp, Qt::CaseSensitive), minimal(false) { } + : eng(nullptr), engineKey(QString(), QRegExp::RegExp, Qt::CaseSensitive), minimal(false) { } inline QRegExpPrivate(const QRegExpEngineKey &key) - : eng(0), engineKey(key), minimal(false) {} + : eng(nullptr), engineKey(key), minimal(false) {} }; #if !defined(QT_NO_REGEXP_OPTIM) @@ -3886,9 +3886,9 @@ static void prepareEngineForMatch(QRegExpPrivate *priv, const QString &str) static void invalidateEngine(QRegExpPrivate *priv) { - if (priv->eng != 0) { + if (priv->eng) { derefEngine(priv->eng, priv->engineKey); - priv->eng = 0; + priv->eng = nullptr; priv->matchState.drain(); } } diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp index 67cce57d01..311058a776 100644 --- a/src/corelib/tools/qringbuffer.cpp +++ b/src/corelib/tools/qringbuffer.cpp @@ -105,7 +105,7 @@ const char *QRingBuffer::readPointerAtPosition(qint64 pos, qint64 &length) const } length = 0; - return 0; + return nullptr; } void QRingBuffer::free(qint64 bytes) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 963c2a4d34..345a786df4 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -3044,7 +3044,7 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar { // Copy after if it lies inside our own d->data() area (which we could // possibly invalidate via a realloc or modify by replacement). - QChar *afterBuffer = 0; + QChar *afterBuffer = nullptr; if (pointsIntoRange(after, d->data(), d->size)) // Use copy in place of vulnerable original: after = afterBuffer = textCopy(after, alen); @@ -3129,7 +3129,7 @@ QString &QString::replace(const QChar *before, int blen, return *this; QStringMatcher matcher(before, blen, cs); - QChar *beforeBuffer = 0, *afterBuffer = 0; + QChar *beforeBuffer = nullptr, *afterBuffer = nullptr; int index = 0; while (1) { @@ -5591,7 +5591,7 @@ QString QString::fromUtf16(const ushort *unicode, int size) while (unicode[size] != 0) ++size; } - return QUtf16::convertToUnicode((const char *)unicode, size*2, 0); + return QUtf16::convertToUnicode((const char *)unicode, size*2, nullptr); } /*! @@ -5645,7 +5645,7 @@ QString QString::fromUcs4(const uint *unicode, int size) while (unicode[size] != 0) ++size; } - return QUtf32::convertToUnicode((const char *)unicode, size*4, 0); + return QUtf32::convertToUnicode((const char *)unicode, size*4, nullptr); } @@ -8060,7 +8060,7 @@ void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar:: version = QChar::currentUnicodeVersion(); } else if (int(version) <= NormalizationCorrectionsVersionMax) { const QString &s = *data; - QChar *d = 0; + QChar *d = nullptr; for (int i = 0; i < NumNormalizationCorrections; ++i) { const NormalizationCorrection &n = uc_normalization_corrections[i]; if (n.version > version) { diff --git a/src/corelib/tools/qstringmatcher.cpp b/src/corelib/tools/qstringmatcher.cpp index 2e2ae18b9a..167a467480 100644 --- a/src/corelib/tools/qstringmatcher.cpp +++ b/src/corelib/tools/qstringmatcher.cpp @@ -149,7 +149,7 @@ static inline qsizetype bm_find(const ushort *uc, qsizetype l, qsizetype index, Call setPattern() to give it a pattern to match. */ QStringMatcher::QStringMatcher() - : d_ptr(0), q_cs(Qt::CaseSensitive) + : d_ptr(nullptr), q_cs(Qt::CaseSensitive) { memset(q_data, 0, sizeof(q_data)); } @@ -161,7 +161,7 @@ QStringMatcher::QStringMatcher() Call indexIn() to perform a search. */ QStringMatcher::QStringMatcher(const QString &pattern, Qt::CaseSensitivity cs) - : d_ptr(0), q_pattern(pattern), q_cs(cs) + : d_ptr(nullptr), q_pattern(pattern), q_cs(cs) { p.uc = pattern.unicode(); p.len = pattern.size(); @@ -200,7 +200,7 @@ QStringMatcher::QStringMatcher(QStringView str, Qt::CaseSensitivity cs) Copies the \a other string matcher to this string matcher. */ QStringMatcher::QStringMatcher(const QStringMatcher &other) - : d_ptr(0) + : d_ptr(nullptr) { operator=(other); } diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index 6498d53b96..25655c09b2 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -136,7 +136,7 @@ public: class QDomNodePrivate { public: - QDomNodePrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = 0); + QDomNodePrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = nullptr); QDomNodePrivate(QDomNodePrivate* n, bool deep); virtual ~QDomNodePrivate(); @@ -159,11 +159,11 @@ public: virtual void normalize(); virtual void clear(); - inline QDomNodePrivate* parent() const { return hasParent ? ownerNode : 0; } + inline QDomNodePrivate* parent() const { return hasParent ? ownerNode : nullptr; } inline void setParent(QDomNodePrivate *p) { ownerNode = p; hasParent = true; } void setNoParent() { - ownerNode = hasParent ? (QDomNodePrivate*)ownerDocument() : 0; + ownerNode = hasParent ? (QDomNodePrivate*)ownerDocument() : nullptr; hasParent = false; } @@ -289,7 +289,7 @@ public: class QDomDocumentTypePrivate : public QDomNodePrivate { public: - QDomDocumentTypePrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = 0); + QDomDocumentTypePrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = nullptr); QDomDocumentTypePrivate(QDomDocumentTypePrivate* n, bool deep); ~QDomDocumentTypePrivate(); void init(); @@ -317,7 +317,7 @@ public: class QDomDocumentFragmentPrivate : public QDomNodePrivate { public: - QDomDocumentFragmentPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = 0); + QDomDocumentFragmentPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = nullptr); QDomDocumentFragmentPrivate(QDomNodePrivate* n, bool deep); // Reimplemented from QDomNodePrivate @@ -907,7 +907,7 @@ QDomImplementationPrivate* QDomImplementationPrivate::clone() */ QDomImplementation::QDomImplementation() { - impl = 0; + impl = nullptr; } /*! @@ -1036,7 +1036,7 @@ QDomDocumentType QDomImplementation::createDocumentType(const QString& qName, co if (!ok) return QDomDocumentType(); - QDomDocumentTypePrivate *dt = new QDomDocumentTypePrivate(0); + QDomDocumentTypePrivate *dt = new QDomDocumentTypePrivate(nullptr); dt->name = fixedName; if (systemId.isNull()) { dt->publicId.clear(); @@ -1070,7 +1070,7 @@ QDomDocument QDomImplementation::createDocument(const QString& nsURI, const QStr */ bool QDomImplementation::isNull() { - return (impl == 0); + return (impl == nullptr); } /*! @@ -1244,14 +1244,14 @@ void QDomNodeListPrivate::createList() QDomNodePrivate* QDomNodeListPrivate::item(int index) { if (!node_impl) - return 0; + return nullptr; const QDomDocumentPrivate *const doc = node_impl->ownerDocument(); if (!doc || timestamp != doc->nodeListTime) createList(); if (index >= list.size()) - return 0; + return nullptr; return list.at(index); } @@ -1305,13 +1305,13 @@ int QDomNodeListPrivate::length() const Creates an empty node list. */ QDomNodeList::QDomNodeList() + : impl(nullptr) { - impl = 0; } QDomNodeList::QDomNodeList(QDomNodeListPrivate* p) + : impl(p) { - impl = p; } /*! @@ -1443,10 +1443,10 @@ QDomNodePrivate::QDomNodePrivate(QDomDocumentPrivate *doc, QDomNodePrivate *par) setParent(par); else setOwnerDocument(doc); - prev = 0; - next = 0; - first = 0; - last = 0; + prev = nullptr; + next = nullptr; + first = nullptr; + last = nullptr; createdWithDom1Interface = true; lineNumber = -1; columnNumber = -1; @@ -1455,10 +1455,10 @@ QDomNodePrivate::QDomNodePrivate(QDomDocumentPrivate *doc, QDomNodePrivate *par) QDomNodePrivate::QDomNodePrivate(QDomNodePrivate *n, bool deep) : ref(1) { setOwnerDocument(n->ownerDocument()); - prev = 0; - next = 0; - first = 0; - last = 0; + prev = nullptr; + next = nullptr; + first = nullptr; + last = nullptr; name = n->name; value = n->value; @@ -1488,8 +1488,8 @@ QDomNodePrivate::~QDomNodePrivate() p->setNoParent(); p = n; } - first = 0; - last = 0; + first = nullptr; + last = nullptr; } void QDomNodePrivate::clear() @@ -1503,8 +1503,8 @@ void QDomNodePrivate::clear() delete p; p = n; } - first = 0; - last = 0; + first = nullptr; + last = nullptr; } QDomNodePrivate* QDomNodePrivate::namedItem(const QString &n) @@ -1515,7 +1515,7 @@ QDomNodePrivate* QDomNodePrivate::namedItem(const QString &n) return p; p = p->next; } - return 0; + return nullptr; } @@ -1523,15 +1523,15 @@ QDomNodePrivate* QDomNodePrivate::insertBefore(QDomNodePrivate* newChild, QDomNo { // Error check if (!newChild) - return 0; + return nullptr; // Error check if (newChild == refChild) - return 0; + return nullptr; // Error check if (refChild && refChild->parent() != this) - return 0; + return nullptr; // "mark lists as dirty" QDomDocumentPrivate *const doc = ownerDocument(); @@ -1542,7 +1542,7 @@ QDomNodePrivate* QDomNodePrivate::insertBefore(QDomNodePrivate* newChild, QDomNo // all elements of the fragment instead of the fragment itself. if (newChild->isDocumentFragment()) { // Fragment is empty ? - if (newChild->first == 0) + if (newChild->first == nullptr) return newChild; // New parent @@ -1553,7 +1553,7 @@ QDomNodePrivate* QDomNodePrivate::insertBefore(QDomNodePrivate* newChild, QDomNo } // Insert at the beginning ? - if (!refChild || refChild->prev == 0) { + if (!refChild || refChild->prev == nullptr) { if (first) first->prev = newChild->last; newChild->last->next = first; @@ -1572,8 +1572,8 @@ QDomNodePrivate* QDomNodePrivate::insertBefore(QDomNodePrivate* newChild, QDomNo // does not decrease the reference. // Remove the nodes from the fragment - newChild->first = 0; - newChild->last = 0; + newChild->first = nullptr; + newChild->last = nullptr; return newChild; } @@ -1596,7 +1596,7 @@ QDomNodePrivate* QDomNodePrivate::insertBefore(QDomNodePrivate* newChild, QDomNo return newChild; } - if (refChild->prev == 0) { + if (refChild->prev == nullptr) { if (first) first->prev = newChild; newChild->next = first; @@ -1618,15 +1618,15 @@ QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNod { // Error check if (!newChild) - return 0; + return nullptr; // Error check if (newChild == refChild) - return 0; + return nullptr; // Error check if (refChild && refChild->parent() != this) - return 0; + return nullptr; // "mark lists as dirty" QDomDocumentPrivate *const doc = ownerDocument(); @@ -1637,7 +1637,7 @@ QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNod // all elements of the fragment instead of the fragment itself. if (newChild->isDocumentFragment()) { // Fragment is empty ? - if (newChild->first == 0) + if (newChild->first == nullptr) return newChild; // New parent @@ -1648,7 +1648,7 @@ QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNod } // Insert at the end - if (!refChild || refChild->next == 0) { + if (!refChild || refChild->next == nullptr) { if (last) last->next = newChild->first; newChild->first->prev = last; @@ -1666,8 +1666,8 @@ QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNod // does not decrease the reference. // Remove the nodes from the fragment - newChild->first = 0; - newChild->last = 0; + newChild->first = nullptr; + newChild->last = nullptr; return newChild; } @@ -1692,7 +1692,7 @@ QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNod return newChild; } - if (refChild->next == 0) { + if (refChild->next == nullptr) { if (last) last->next = newChild; newChild->prev = last; @@ -1713,11 +1713,11 @@ QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNod QDomNodePrivate* QDomNodePrivate::replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild) { if (!newChild || !oldChild) - return 0; + return nullptr; if (oldChild->parent() != this) - return 0; + return nullptr; if (newChild == oldChild) - return 0; + return nullptr; // mark lists as dirty QDomDocumentPrivate *const doc = ownerDocument(); @@ -1728,7 +1728,7 @@ QDomNodePrivate* QDomNodePrivate::replaceChild(QDomNodePrivate* newChild, QDomNo // all elements of the fragment instead of the fragment itself. if (newChild->isDocumentFragment()) { // Fragment is empty ? - if (newChild->first == 0) + if (newChild->first == nullptr) return newChild; // New parent @@ -1753,15 +1753,15 @@ QDomNodePrivate* QDomNodePrivate::replaceChild(QDomNodePrivate* newChild, QDomNo last = newChild->last; oldChild->setNoParent(); - oldChild->next = 0; - oldChild->prev = 0; + oldChild->next = nullptr; + oldChild->prev = nullptr; // No need to increase the reference since QDomDocumentFragment // does not decrease the reference. // Remove the nodes from the fragment - newChild->first = 0; - newChild->last = 0; + newChild->first = nullptr; + newChild->last = nullptr; // We are no longer interested in the old node if (oldChild) @@ -1794,8 +1794,8 @@ QDomNodePrivate* QDomNodePrivate::replaceChild(QDomNodePrivate* newChild, QDomNo last = newChild; oldChild->setNoParent(); - oldChild->next = 0; - oldChild->prev = 0; + oldChild->next = nullptr; + oldChild->prev = nullptr; // We are no longer interested in the old node if (oldChild) @@ -1808,7 +1808,7 @@ QDomNodePrivate* QDomNodePrivate::removeChild(QDomNodePrivate* oldChild) { // Error check if (oldChild->parent() != this) - return 0; + return nullptr; // "mark lists as dirty" QDomDocumentPrivate *const doc = ownerDocument(); @@ -1817,8 +1817,8 @@ QDomNodePrivate* QDomNodePrivate::removeChild(QDomNodePrivate* oldChild) // Perhaps oldChild was just created with "createElement" or that. In this case // its parent is QDomDocument but it is not part of the documents child list. - if (oldChild->next == 0 && oldChild->prev == 0 && first != oldChild) - return 0; + if (oldChild->next == nullptr && oldChild->prev == nullptr && first != oldChild) + return nullptr; if (oldChild->next) oldChild->next->prev = oldChild->prev; @@ -1831,8 +1831,8 @@ QDomNodePrivate* QDomNodePrivate::removeChild(QDomNodePrivate* oldChild) first = oldChild->next; oldChild->setNoParent(); - oldChild->next = 0; - oldChild->prev = 0; + oldChild->next = nullptr; + oldChild->prev = nullptr; // We are no longer interested in the old node oldChild->ref.deref(); @@ -1843,7 +1843,7 @@ QDomNodePrivate* QDomNodePrivate::removeChild(QDomNodePrivate* oldChild) QDomNodePrivate* QDomNodePrivate::appendChild(QDomNodePrivate* newChild) { // No reference manipulation needed. Done in insertAfter. - return insertAfter(newChild, 0); + return insertAfter(newChild, nullptr); } QDomDocumentPrivate* QDomNodePrivate::ownerDocument() @@ -1869,7 +1869,7 @@ QDomNodePrivate* QDomNodePrivate::cloneNode(bool deep) static void qNormalizeNode(QDomNodePrivate* n) { QDomNodePrivate* p = n->first; - QDomTextPrivate* t = 0; + QDomTextPrivate* t = nullptr; while (p) { if (p->isText()) { @@ -1884,7 +1884,7 @@ static void qNormalizeNode(QDomNodePrivate* n) } } else { p = p->next; - t = 0; + t = nullptr; } } } @@ -2009,8 +2009,8 @@ void QDomNodePrivate::setLocation(int lineNumber, int columnNumber) Constructs a \l{isNull()}{null} node. */ QDomNode::QDomNode() + : impl(nullptr) { - impl = 0; } /*! @@ -2619,7 +2619,7 @@ bool QDomNode::hasChildNodes() const { if (!impl) return false; - return IMPL->first != 0; + return IMPL->first != nullptr; } /*! @@ -2628,7 +2628,7 @@ bool QDomNode::hasChildNodes() const */ bool QDomNode::isNull() const { - return (impl == 0); + return (impl == nullptr); } /*! @@ -2641,7 +2641,7 @@ void QDomNode::clear() { if (impl && !impl->ref.deref()) delete impl; - impl = 0; + impl = nullptr; } /*! @@ -3094,13 +3094,13 @@ QDomNodePrivate* QDomNamedNodeMapPrivate::namedItemNS(const QString& nsURI, cons return n; } } - return 0; + return nullptr; } QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItem(QDomNodePrivate* arg) { if (readonly || !arg) - return 0; + return nullptr; if (appendToParent) return parent->appendChild(arg); @@ -3115,7 +3115,7 @@ QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItem(QDomNodePrivate* arg) QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItemNS(QDomNodePrivate* arg) { if (readonly || !arg) - return 0; + return nullptr; if (appendToParent) return parent->appendChild(arg); @@ -3136,11 +3136,11 @@ QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItemNS(QDomNodePrivate* arg) QDomNodePrivate* QDomNamedNodeMapPrivate::removeNamedItem(const QString& name) { if (readonly) - return 0; + return nullptr; QDomNodePrivate* p = namedItem(name); - if (p == 0) - return 0; + if (p == nullptr) + return nullptr; if (appendToParent) return parent->removeChild(p); @@ -3153,7 +3153,7 @@ QDomNodePrivate* QDomNamedNodeMapPrivate::removeNamedItem(const QString& name) QDomNodePrivate* QDomNamedNodeMapPrivate::item(int index) const { if (index >= length() || index < 0) - return 0; + return nullptr; return *(map.constBegin() + index); } @@ -3164,12 +3164,12 @@ int QDomNamedNodeMapPrivate::length() const bool QDomNamedNodeMapPrivate::contains(const QString& name) const { - return map.value(name) != 0; + return map.contains(name); } bool QDomNamedNodeMapPrivate::containsNS(const QString& nsURI, const QString & localName) const { - return namedItemNS(nsURI, localName) != 0; + return namedItemNS(nsURI, localName) != nullptr; } /************************************************************** @@ -3222,8 +3222,8 @@ bool QDomNamedNodeMapPrivate::containsNS(const QString& nsURI, const QString & l Constructs an empty named node map. */ QDomNamedNodeMap::QDomNamedNodeMap() + : impl(nullptr) { - impl = 0; } /*! @@ -3570,7 +3570,7 @@ QDomNodePrivate* QDomDocumentTypePrivate::removeChild(QDomNodePrivate* oldChild) QDomNodePrivate* QDomDocumentTypePrivate::appendChild(QDomNodePrivate* newChild) { - return insertAfter(newChild, 0); + return insertAfter(newChild, nullptr); } static QString quotedValue(const QString &data) @@ -4115,7 +4115,7 @@ QDomAttrPrivate::QDomAttrPrivate(QDomAttrPrivate* n, bool deep) void QDomAttrPrivate::setNodeValue(const QString& v) { value = v; - QDomTextPrivate *t = new QDomTextPrivate(0, this, v); + QDomTextPrivate *t = new QDomTextPrivate(nullptr, this, v); // keep the refcount balanced: appendChild() does a ref anyway. t->ref.deref(); if (first) { @@ -4517,7 +4517,7 @@ QDomAttrPrivate* QDomElementPrivate::setAttributeNode(QDomAttrPrivate* newAttr) QDomAttrPrivate* QDomElementPrivate::setAttributeNodeNS(QDomAttrPrivate* newAttr) { - QDomNodePrivate* n = 0; + QDomNodePrivate* n = nullptr; if (!newAttr->prefix.isNull()) n = m_attr->namedItemNS(newAttr->namespaceURI, newAttr->name); @@ -5184,10 +5184,10 @@ QDomTextPrivate* QDomTextPrivate::splitText(int offset) { if (!parent()) { qWarning("QDomText::splitText The node has no parent. So I cannot split"); - return 0; + return nullptr; } - QDomTextPrivate* t = new QDomTextPrivate(ownerDocument(), 0, value.mid(offset)); + QDomTextPrivate* t = new QDomTextPrivate(ownerDocument(), nullptr, value.mid(offset)); value.truncate(offset); parent()->insertAfter(t, this); @@ -6144,7 +6144,7 @@ void QDomProcessingInstruction::setData(const QString& d) **************************************************************/ QDomDocumentPrivate::QDomDocumentPrivate() - : QDomNodePrivate(0), + : QDomNodePrivate(nullptr), impl(new QDomImplementationPrivate), nodeListTime(1) { @@ -6155,7 +6155,7 @@ QDomDocumentPrivate::QDomDocumentPrivate() } QDomDocumentPrivate::QDomDocumentPrivate(const QString& aname) - : QDomNodePrivate(0), + : QDomNodePrivate(nullptr), impl(new QDomImplementationPrivate), nodeListTime(1) { @@ -6167,11 +6167,11 @@ QDomDocumentPrivate::QDomDocumentPrivate(const QString& aname) } QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentTypePrivate* dt) - : QDomNodePrivate(0), + : QDomNodePrivate(nullptr), impl(new QDomImplementationPrivate), nodeListTime(1) { - if (dt != 0) { + if (dt != nullptr) { type = dt; } else { type = new QDomDocumentTypePrivate(this, this); @@ -6267,9 +6267,9 @@ QDomElementPrivate* QDomDocumentPrivate::createElement(const QString &tagName) bool ok; QString fixedName = fixedXmlName(tagName, &ok); if (!ok) - return 0; + return nullptr; - QDomElementPrivate *e = new QDomElementPrivate(this, 0, fixedName); + QDomElementPrivate *e = new QDomElementPrivate(this, nullptr, fixedName); e->ref.deref(); return e; } @@ -6279,16 +6279,16 @@ QDomElementPrivate* QDomDocumentPrivate::createElementNS(const QString &nsURI, c bool ok; QString fixedName = fixedXmlName(qName, &ok, true); if (!ok) - return 0; + return nullptr; - QDomElementPrivate *e = new QDomElementPrivate(this, 0, nsURI, fixedName); + QDomElementPrivate *e = new QDomElementPrivate(this, nullptr, nsURI, fixedName); e->ref.deref(); return e; } QDomDocumentFragmentPrivate* QDomDocumentPrivate::createDocumentFragment() { - QDomDocumentFragmentPrivate *f = new QDomDocumentFragmentPrivate(this, (QDomNodePrivate*)0); + QDomDocumentFragmentPrivate *f = new QDomDocumentFragmentPrivate(this, (QDomNodePrivate*)nullptr); f->ref.deref(); return f; } @@ -6298,9 +6298,9 @@ QDomTextPrivate* QDomDocumentPrivate::createTextNode(const QString &data) bool ok; QString fixedData = fixedCharData(data, &ok); if (!ok) - return 0; + return nullptr; - QDomTextPrivate *t = new QDomTextPrivate(this, 0, fixedData); + QDomTextPrivate *t = new QDomTextPrivate(this, nullptr, fixedData); t->ref.deref(); return t; } @@ -6310,9 +6310,9 @@ QDomCommentPrivate* QDomDocumentPrivate::createComment(const QString &data) bool ok; QString fixedData = fixedComment(data, &ok); if (!ok) - return 0; + return nullptr; - QDomCommentPrivate *c = new QDomCommentPrivate(this, 0, fixedData); + QDomCommentPrivate *c = new QDomCommentPrivate(this, nullptr, fixedData); c->ref.deref(); return c; } @@ -6322,9 +6322,9 @@ QDomCDATASectionPrivate* QDomDocumentPrivate::createCDATASection(const QString & bool ok; QString fixedData = fixedCDataSection(data, &ok); if (!ok) - return 0; + return nullptr; - QDomCDATASectionPrivate *c = new QDomCDATASectionPrivate(this, 0, fixedData); + QDomCDATASectionPrivate *c = new QDomCDATASectionPrivate(this, nullptr, fixedData); c->ref.deref(); return c; } @@ -6335,13 +6335,13 @@ QDomProcessingInstructionPrivate* QDomDocumentPrivate::createProcessingInstructi bool ok; QString fixedData = fixedPIData(data, &ok); if (!ok) - return 0; + return nullptr; // [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l')) QString fixedTarget = fixedXmlName(target, &ok); if (!ok) - return 0; + return nullptr; - QDomProcessingInstructionPrivate *p = new QDomProcessingInstructionPrivate(this, 0, fixedTarget, fixedData); + QDomProcessingInstructionPrivate *p = new QDomProcessingInstructionPrivate(this, nullptr, fixedTarget, fixedData); p->ref.deref(); return p; } @@ -6350,9 +6350,9 @@ QDomAttrPrivate* QDomDocumentPrivate::createAttribute(const QString &aname) bool ok; QString fixedName = fixedXmlName(aname, &ok); if (!ok) - return 0; + return nullptr; - QDomAttrPrivate *a = new QDomAttrPrivate(this, 0, fixedName); + QDomAttrPrivate *a = new QDomAttrPrivate(this, nullptr, fixedName); a->ref.deref(); return a; } @@ -6362,9 +6362,9 @@ QDomAttrPrivate* QDomDocumentPrivate::createAttributeNS(const QString &nsURI, co bool ok; QString fixedName = fixedXmlName(qName, &ok, true); if (!ok) - return 0; + return nullptr; - QDomAttrPrivate *a = new QDomAttrPrivate(this, 0, nsURI, fixedName); + QDomAttrPrivate *a = new QDomAttrPrivate(this, nullptr, nsURI, fixedName); a->ref.deref(); return a; } @@ -6374,16 +6374,16 @@ QDomEntityReferencePrivate* QDomDocumentPrivate::createEntityReference(const QSt bool ok; QString fixedName = fixedXmlName(aname, &ok); if (!ok) - return 0; + return nullptr; - QDomEntityReferencePrivate *e = new QDomEntityReferencePrivate(this, 0, fixedName); + QDomEntityReferencePrivate *e = new QDomEntityReferencePrivate(this, nullptr, fixedName); e->ref.deref(); return e; } QDomNodePrivate* QDomDocumentPrivate::importNode(QDomNodePrivate *importedNode, bool deep) { - QDomNodePrivate *node = 0; + QDomNodePrivate *node = nullptr; switch (importedNode->nodeType()) { case QDomNode::AttributeNode: node = new QDomAttrPrivate((QDomAttrPrivate*)importedNode, true); @@ -6435,7 +6435,7 @@ void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNod #if QT_CONFIG(textcodec) && QT_CONFIG(regularexpression) const QDomNodePrivate* n = first; - QTextCodec *codec = 0; + QTextCodec *codec = nullptr; if (n && n->isProcessingInstruction() && n->nodeName() == QLatin1String("xml")) { // we have an XML declaration @@ -6593,7 +6593,7 @@ void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNod */ QDomDocument::QDomDocument() { - impl = 0; + impl = nullptr; } /*! @@ -6822,7 +6822,7 @@ bool QDomDocument::setContent(QXmlInputSource *source, QXmlReader *reader, QStri { if (!impl) impl = new QDomDocumentPrivate(); - return IMPL->setContent(source, reader, 0, errorMsg, errorLine, errorColumn); + return IMPL->setContent(source, reader, nullptr, errorMsg, errorLine, errorColumn); } /*! @@ -7369,7 +7369,7 @@ QDomComment QDomNode::toComment() const QDomHandler::QDomHandler(QDomDocumentPrivate* adoc, QXmlSimpleReader* areader, bool namespaceProcessing) : errorLine(0), errorColumn(0), doc(adoc), node(adoc), cdata(false), - nsProcessing(namespaceProcessing), locator(0), reader(areader) + nsProcessing(namespaceProcessing), locator(nullptr), reader(areader) { } @@ -7443,7 +7443,7 @@ bool QDomHandler::characters(const QString& ch) if (cdata) { n.reset(doc->createCDATASection(ch)); } else if (!entityName.isEmpty()) { - QScopedPointer e(new QDomEntityPrivate(doc, 0, entityName, + QScopedPointer e(new QDomEntityPrivate(doc, nullptr, entityName, QString(), QString(), QString())); e->value = ch; e->ref.deref(); @@ -7528,7 +7528,7 @@ bool QDomHandler::comment(const QString& ch) bool QDomHandler::unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId, const QString ¬ationName) { - QDomEntityPrivate* e = new QDomEntityPrivate(doc, 0, name, + QDomEntityPrivate* e = new QDomEntityPrivate(doc, nullptr, name, publicId, systemId, notationName); // keep the refcount balanced: appendChild() does a ref anyway. e->ref.deref(); @@ -7543,7 +7543,7 @@ bool QDomHandler::externalEntityDecl(const QString &name, const QString &publicI bool QDomHandler::notationDecl(const QString & name, const QString & publicId, const QString & systemId) { - QDomNotationPrivate* n = new QDomNotationPrivate(doc, 0, name, publicId, systemId); + QDomNotationPrivate* n = new QDomNotationPrivate(doc, nullptr, name, publicId, systemId); // keep the refcount balanced: appendChild() does a ref anyway. n->ref.deref(); doc->doctype()->appendChild(n); diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index b2fff5b61f..1c45118fb1 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -1079,12 +1079,12 @@ void QXmlInputSource::init() d = new QXmlInputSourcePrivate; QT_TRY { - d->inputDevice = 0; - d->inputStream = 0; + d->inputDevice = nullptr; + d->inputStream = nullptr; setData(QString()); #if QT_CONFIG(textcodec) - d->encMapper = 0; + d->encMapper = nullptr; #endif d->nextReturnedEndOfData = true; // first call to next() will call fetchData() @@ -1357,13 +1357,13 @@ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning) return QString(); if (beginning) { delete d->encMapper; - d->encMapper = 0; + d->encMapper = nullptr; } int mib = 106; // UTF-8 // This is the initial UTF codec we will read the encoding declaration with - if (d->encMapper == 0) { + if (d->encMapper == nullptr) { d->encodingDeclBytes.clear(); d->encodingDeclChars.clear(); d->lookingForEncodingDecl = true; @@ -2377,7 +2377,7 @@ bool QXmlDefaultHandler::unparsedEntityDecl(const QString&, const QString&, bool QXmlDefaultHandler::resolveEntity(const QString&, const QString&, QXmlInputSource*& ret) { - ret = 0; + ret = nullptr; return true; } @@ -2520,15 +2520,15 @@ inline void QXmlSimpleReaderPrivate::refClear() QXmlSimpleReaderPrivate::QXmlSimpleReaderPrivate(QXmlSimpleReader *reader) { q_ptr = reader; - parseStack = 0; + parseStack = nullptr; locator.reset(new QXmlSimpleReaderLocator(reader)); - entityRes = 0; - dtdHnd = 0; - contentHnd = 0; - errorHnd = 0; - lexicalHnd = 0; - declHnd = 0; + entityRes = nullptr; + dtdHnd = nullptr; + contentHnd = nullptr; + errorHnd = nullptr; + lexicalHnd = nullptr; + declHnd = nullptr; // default feature settings useNamespaces = true; @@ -2932,7 +2932,7 @@ bool QXmlSimpleReader::feature(const QString& name, bool *ok) const { const QXmlSimpleReaderPrivate *d = d_func(); - if (ok != 0) + if (ok) *ok = true; if (name == QLatin1String("http://xml.org/sax/features/namespaces")) { return d->useNamespaces; @@ -2946,7 +2946,7 @@ bool QXmlSimpleReader::feature(const QString& name, bool *ok) const return d->reportEntities; } else { qWarning("Unknown feature %s", name.toLatin1().data()); - if (ok != 0) + if (ok) *ok = false; } return false; @@ -3023,9 +3023,9 @@ bool QXmlSimpleReader::hasFeature(const QString& name) const */ void* QXmlSimpleReader::property(const QString&, bool *ok) const { - if (ok != 0) + if (ok) *ok = false; - return 0; + return nullptr; } /*! \reimp @@ -3206,7 +3206,7 @@ bool QXmlSimpleReader::parse(const QXmlInputSource *input, bool incremental) d->initIncrementalParsing(); } else { delete d->parseStack; - d->parseStack = 0; + d->parseStack = nullptr; } d->init(input); @@ -3251,7 +3251,7 @@ bool QXmlSimpleReader::parse(const QXmlInputSource *input, bool incremental) bool QXmlSimpleReader::parseContinue() { Q_D(QXmlSimpleReader); - if (d->parseStack == 0 || d->parseStack->isEmpty()) + if (d->parseStack == nullptr || d->parseStack->isEmpty()) return false; d->initData(); int state = d->parseStack->pop().state; @@ -3268,7 +3268,7 @@ bool QXmlSimpleReaderPrivate::parseBeginOrContinue(int state, bool incremental) if (state==0) { if (!parseProlog()) { if (incremental && error.isNull()) { - pushParseState(0, 0); + pushParseState(nullptr, 0); return true; } else { clear(tags); @@ -3280,7 +3280,7 @@ bool QXmlSimpleReaderPrivate::parseBeginOrContinue(int state, bool incremental) if (state==1) { if (!parseElement()) { if (incremental && error.isNull()) { - pushParseState(0, 1); + pushParseState(nullptr, 1); return true; } else { clear(tags); @@ -3293,7 +3293,7 @@ bool QXmlSimpleReaderPrivate::parseBeginOrContinue(int state, bool incremental) while (!atEnd()) { if (!parseMisc()) { if (incremental && error.isNull()) { - pushParseState(0, 2); + pushParseState(nullptr, 2); return true; } else { clear(tags); @@ -3303,7 +3303,7 @@ bool QXmlSimpleReaderPrivate::parseBeginOrContinue(int state, bool incremental) } if (!atEndOrig && incremental) { // we parsed something at all, so be prepared to come back later - pushParseState(0, 2); + pushParseState(nullptr, 2); return true; } // is stack empty? @@ -3315,7 +3315,7 @@ bool QXmlSimpleReaderPrivate::parseBeginOrContinue(int state, bool incremental) // call the handler if (contentHnd) { delete parseStack; - parseStack = 0; + parseStack = nullptr; if (!contentHnd->endDocument()) { reportParseError(contentHnd->errorString()); return false; @@ -3350,7 +3350,7 @@ bool QXmlSimpleReaderPrivate::parseBeginOrContinue(int state, bool incremental) signed char state; signed char input; -(4) if (d->parseStack == 0 || d->parseStack->isEmpty()) { +(4) if (d->parseStack == nullptr || d->parseStack->isEmpty()) { (4a) ... } else { (4b) ... @@ -3440,7 +3440,7 @@ bool QXmlSimpleReaderPrivate::parseProlog() signed char state; signed char input; - if (parseStack == 0 || parseStack->isEmpty()) { + if (parseStack == nullptr|| parseStack->isEmpty()) { xmldecl_possible = true; doctype_read = false; state = Init; @@ -3631,7 +3631,7 @@ bool QXmlSimpleReaderPrivate::parseElement() int state; int input; - if (parseStack == 0 || parseStack->isEmpty()) { + if (parseStack == nullptr|| parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -4000,7 +4000,7 @@ bool QXmlSimpleReaderPrivate::parseContent() signed char state; signed char input; - if (parseStack == 0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { contentCharDataRead = false; state = Init; } else { @@ -4303,7 +4303,7 @@ bool QXmlSimpleReaderPrivate::parseMisc() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -4458,7 +4458,7 @@ bool QXmlSimpleReaderPrivate::parsePI() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -4685,7 +4685,7 @@ bool QXmlSimpleReaderPrivate::parseDoctype() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { startDTDwasReported = false; systemId.clear(); publicId.clear(); @@ -4896,7 +4896,7 @@ bool QXmlSimpleReaderPrivate::parseExternalID() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { systemId.clear(); publicId.clear(); state = Init; @@ -5060,7 +5060,7 @@ bool QXmlSimpleReaderPrivate::parseMarkupdecl() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -5218,7 +5218,7 @@ bool QXmlSimpleReaderPrivate::parsePEReference() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -5255,7 +5255,7 @@ bool QXmlSimpleReaderPrivate::parsePEReference() } else if (entityRes) { QMap::Iterator it2; it2 = externParameterEntities.find(ref()); - QXmlInputSource *ret = 0; + QXmlInputSource *ret = nullptr; if (it2 != externParameterEntities.end()) { if (!entityRes->resolveEntity((*it2).publicId, (*it2).systemId, ret)) { delete ret; @@ -5396,7 +5396,7 @@ bool QXmlSimpleReaderPrivate::parseAttlistDecl() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -5612,7 +5612,7 @@ bool QXmlSimpleReaderPrivate::parseAttType() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -5833,7 +5833,7 @@ bool QXmlSimpleReaderPrivate::parseAttValue() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -5975,7 +5975,7 @@ bool QXmlSimpleReaderPrivate::parseElementDecl() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -6184,7 +6184,7 @@ bool QXmlSimpleReaderPrivate::parseNotationDecl() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -6328,7 +6328,7 @@ bool QXmlSimpleReaderPrivate::parseChoiceSeq() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -6557,7 +6557,7 @@ bool QXmlSimpleReaderPrivate::parseEntityDecl() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -6832,7 +6832,7 @@ bool QXmlSimpleReaderPrivate::parseEntityValue() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -6951,7 +6951,7 @@ bool QXmlSimpleReaderPrivate::parseComment() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -7063,7 +7063,7 @@ bool QXmlSimpleReaderPrivate::parseAttribute() int state; int input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -7162,7 +7162,7 @@ bool QXmlSimpleReaderPrivate::parseName() }; int state; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -7248,7 +7248,7 @@ bool QXmlSimpleReaderPrivate::parseNmtoken() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { state = Init; } else { state = parseStack->pop().state; @@ -7356,7 +7356,7 @@ bool QXmlSimpleReaderPrivate::parseReference() signed char state; signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { parseReference_charDataRead = false; state = Init; } else { @@ -7582,7 +7582,7 @@ bool QXmlSimpleReaderPrivate::processReference() if (parseReference_context == InContent) { if (contentCharDataRead) { if (reportWhitespaceCharData || !string().simplified().isEmpty()) { - if (contentHnd != 0 && !contentHnd->characters(string())) { + if (contentHnd != nullptr && !contentHnd->characters(string())) { reportParseError(contentHnd->errorString()); return false; } @@ -7610,7 +7610,7 @@ bool QXmlSimpleReaderPrivate::processReference() // Included if validating bool skipIt = true; if (entityRes) { - QXmlInputSource *ret = 0; + QXmlInputSource *ret = nullptr; if (!entityRes->resolveEntity((*itExtern).publicId, (*itExtern).systemId, ret)) { delete ret; reportParseError(entityRes->errorString()); @@ -7696,7 +7696,7 @@ bool QXmlSimpleReaderPrivate::parseString() signed char state; // state in this function is the position in the string s signed char input; - if (parseStack==0 || parseStack->isEmpty()) { + if (parseStack == nullptr || parseStack->isEmpty()) { Done = parseString_s.length(); state = 0; } else { @@ -7800,7 +7800,7 @@ void QXmlSimpleReaderPrivate::next() c = inputSource->next(); // If we are not incremental parsing, we just skip over EndOfData chars to give the // parser an uninterrupted stream of document chars. - if (c == QXmlInputSource::EndOfData && parseStack == 0) + if (c == QXmlInputSource::EndOfData && parseStack == nullptr) c = inputSource->next(); if (uc == '\n') { lineNr++; @@ -7832,7 +7832,7 @@ bool QXmlSimpleReaderPrivate::eat_ws() } next(); } - if (parseStack != 0) { + if (parseStack != nullptr) { unexpectedEof(&QXmlSimpleReaderPrivate::eat_ws, 0); return false; } @@ -7922,7 +7922,7 @@ void QXmlSimpleReaderPrivate::reportParseError(const QString& error) */ void QXmlSimpleReaderPrivate::unexpectedEof(ParseFunction where, int state) { - if (parseStack == 0) { + if (parseStack == nullptr) { reportParseError(QLatin1String(XMLERR_UNEXPECTEDEOF)); } else { if (c == QXmlInputSource::EndOfDocument) { @@ -7942,7 +7942,7 @@ void QXmlSimpleReaderPrivate::unexpectedEof(ParseFunction where, int state) */ void QXmlSimpleReaderPrivate::parseFailed(ParseFunction where, int state) { - if (parseStack!=0 && error.isNull()) { + if (parseStack != nullptr && error.isNull()) { pushParseState(where, state); } } -- cgit v1.2.3