summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-08-26 20:06:57 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-08-26 20:06:57 +0200
commitafab1546a7665bac2a8d7a6452e6aea46bfd2127 (patch)
treed616a7559c54a40e35a12b464f606774c9b0475b /src/corelib
parent06b457c693f207e392d3021d77a0ab18cd78da92 (diff)
parent53ecaade10319ecc1d8115521ae6d8eba1ee55c1 (diff)
Merge remote-tracking branch 'origin/5.5' into 5.6
Conflicts: qmake/doc/snippets/code/doc_src_qmake-manual.pro qmake/doc/src/qmake-manual.qdoc src/corelib/io/qstorageinfo_unix.cpp src/corelib/tools/qbytearray.cpp src/widgets/kernel/qwidgetwindow.cpp tests/auto/corelib/io/qprocess/tst_qprocess.cpp tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp tests/auto/network/access/qnetworkreply/BLACKLIST Change-Id: I9efcd7e1cce1c394eed425c43aa6fce7d2edf31c
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qnamespace.qdoc1
-rw-r--r--src/corelib/io/qfileinfo.cpp16
-rw-r--r--src/corelib/io/qprocess.cpp23
-rw-r--r--src/corelib/io/qprocess_win.cpp6
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp6
-rw-r--r--src/corelib/io/qwindowspipewriter.cpp2
-rw-r--r--src/corelib/kernel/qobject.cpp2
-rw-r--r--src/corelib/mimetypes/qmimeprovider.cpp16
-rw-r--r--src/corelib/mimetypes/qmimeprovider_p.h3
-rw-r--r--src/corelib/thread/qmutex.cpp23
-rw-r--r--src/corelib/thread/thread.pri24
-rw-r--r--src/corelib/tools/qchar.cpp10
-rw-r--r--src/corelib/tools/qdatetime.cpp1
-rw-r--r--src/corelib/tools/qelapsedtimer_mac.cpp5
-rw-r--r--src/corelib/tools/qregexp.cpp4
-rw-r--r--src/corelib/tools/qregularexpression.cpp45
16 files changed, 124 insertions, 63 deletions
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index a912e65d30..a7da751da4 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -2658,6 +2658,7 @@
\value ItemIsTristate \e{This enum value is deprecated.} Use Qt::ItemIsAutoTristate
instead.
\value ItemNeverHasChildren The item never has child items.
+ This is used for optimization purposes only.
\value ItemIsUserTristate The user can cycle through three separate states.
This value has been added in Qt 5.5.
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index 8a86ec5858..51b39b1114 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -263,6 +263,7 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request)
groupId(). You can examine a file's permissions and ownership in a
single statement using the permission() function.
+ \target NTFS permissions
\note On NTFS file systems, ownership and permissions checking is
disabled by default for performance reasons. To enable it,
include the following line:
@@ -893,6 +894,9 @@ QDir QFileInfo::absoluteDir() const
/*!
Returns \c true if the user can read the file; otherwise returns \c false.
+ \note If the \l{NTFS permissions} check has not been enabled, the result
+ on Windows will merely reflect whether the file exists.
+
\sa isWritable(), isExecutable(), permission()
*/
bool QFileInfo::isReadable() const
@@ -911,6 +915,9 @@ bool QFileInfo::isReadable() const
/*!
Returns \c true if the user can write to the file; otherwise returns \c false.
+ \note If the \l{NTFS permissions} check has not been enabled, the result on
+ Windows will merely reflect whether the file is marked as Read Only.
+
\sa isReadable(), isExecutable(), permission()
*/
bool QFileInfo::isWritable() const
@@ -1137,7 +1144,8 @@ QString QFileInfo::readLink() const
returned.
This function can be time consuming under Unix (in the order of
- milliseconds).
+ milliseconds). On Windows, it will return an empty string unless
+ the \l{NTFS permissions} check has been enabled.
\sa ownerId(), group(), groupId()
*/
@@ -1217,6 +1225,9 @@ uint QFileInfo::groupId() const
On systems where files do not have permissions this function
always returns \c true.
+ \note The result might be inaccurate on Windows if the
+ \l{NTFS permissions} check has not been enabled.
+
Example:
\snippet code/src_corelib_io_qfileinfo.cpp 10
@@ -1240,6 +1251,9 @@ bool QFileInfo::permission(QFile::Permissions permissions) const
/*!
Returns the complete OR-ed together combination of
QFile::Permissions for the file.
+
+ \note The result might be inaccurate on Windows if the
+ \l{NTFS permissions} check has not been enabled.
*/
QFile::Permissions QFileInfo::permissions() const
{
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index cdae149678..8ee8d0b703 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
-** Copyright (C) 2014 Intel Corporation
+** Copyright (C) 2015 Intel Corporation
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -139,7 +139,7 @@ QT_BEGIN_NAMESPACE
Unix environment allows both variable names and contents to contain arbitrary
binary data (except for the NUL character). QProcessEnvironment will preserve
such variables, but does not support manipulating variables whose names or
- values are not encodable by the current locale settings (see
+ values cannot be encoded by the current locale settings (see
QTextCodec::codecForLocale).
On Windows, the variable names are case-insensitive, but case-preserving.
@@ -395,8 +395,8 @@ QString QProcessEnvironment::value(const QString &name, const QString &defaultVa
Use with the QProcess::setEnvironment function is not recommended due to
potential encoding problems under Unix, and worse performance.
- \sa systemEnvironment(), QProcess::systemEnvironment(), QProcess::environment(),
- QProcess::setEnvironment()
+ \sa systemEnvironment(), QProcess::systemEnvironment(),
+ QProcess::setProcessEnvironment()
*/
QStringList QProcessEnvironment::toStringList() const
{
@@ -545,7 +545,7 @@ void QProcessPrivate::Channel::clear()
QProcess can merge the two output channels, so that standard
output and standard error data from the running process both use
the standard output channel. Call setProcessChannelMode() with
- MergedChannels before starting the process to activative
+ MergedChannels before starting the process to activate
this feature. You also have the option of forwarding the output of
the running process to the calling, main process, by passing
ForwardedChannels as the argument. It is also possible to forward
@@ -556,7 +556,7 @@ void QProcessPrivate::Channel::clear()
Certain processes need special environment settings in order to
operate. You can set environment variables for your process by
- calling setEnvironment(). To set a working directory, call
+ calling setProcessEnvironment(). To set a working directory, call
setWorkingDirectory(). By default, processes are run in the
current working directory of the calling process.
@@ -1328,7 +1328,7 @@ QProcess::InputChannelMode QProcess::inputChannelMode() const
/*!
\since 5.2
- Sets the channel mode of the QProcess standard intput
+ Sets the channel mode of the QProcess standard input
channel to the \a mode specified.
This mode will be used the next time start() is called.
@@ -2195,6 +2195,7 @@ void QProcessPrivate::start(QIODevice::OpenMode mode)
qDebug() << "QProcess::start(" << program << ',' << arguments << ',' << mode << ')';
#endif
+ stdinChannel.buffer.clear();
stdoutChannel.buffer.clear();
stderrChannel.buffer.clear();
@@ -2393,7 +2394,7 @@ void QProcess::setArguments(const QStringList &arguments)
The process may not exit as a result of calling this function (it is given
the chance to prompt the user for any unsaved files, etc).
- On Windows, terminate() posts a WM_CLOSE message to all toplevel windows
+ On Windows, terminate() posts a WM_CLOSE message to all top-level windows
of the process and then to the main thread of the process itself. On Unix
and OS X the \c SIGTERM signal is sent.
@@ -2589,14 +2590,14 @@ QT_END_INCLUDE_NAMESPACE
This function does not cache the system environment. Therefore, it's
possible to obtain an updated version of the environment if low-level C
- library functions like \tt setenv ot \tt putenv have been called.
+ library functions like \tt setenv or \tt putenv have been called.
However, note that repeated calls to this function will recreate the
list of environment variables, which is a non-trivial operation.
\note For new code, it is recommended to use QProcessEnvironment::systemEnvironment()
- \sa QProcessEnvironment::systemEnvironment(), environment(), setEnvironment()
+ \sa QProcessEnvironment::systemEnvironment(), setProcessEnvironment()
*/
QStringList QProcess::systemEnvironment()
{
@@ -2619,7 +2620,7 @@ QStringList QProcess::systemEnvironment()
It is returned as a QProcessEnvironment. This function does not
cache the system environment. Therefore, it's possible to obtain
an updated version of the environment if low-level C library
- functions like \tt setenv ot \tt putenv have been called.
+ functions like \tt setenv or \tt putenv have been called.
However, note that repeated calls to this function will recreate the
QProcessEnvironment object, which is a non-trivial operation.
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 5c9db05eff..e77249975c 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -694,13 +694,15 @@ bool QProcessPrivate::waitForBytesWritten(int msecs)
return true;
// If we wouldn't write anything, check if we can read stdout.
- if (bytesAvailableInChannel(&stdoutChannel) != 0) {
+ if (stdoutChannel.pipe[0] != INVALID_Q_PIPE
+ && bytesAvailableInChannel(&stdoutChannel) != 0) {
tryReadFromChannel(&stdoutChannel);
timer.resetIncrements();
}
// Check if we can read stderr.
- if (bytesAvailableInChannel(&stderrChannel) != 0) {
+ if (stderrChannel.pipe[0] != INVALID_Q_PIPE
+ && bytesAvailableInChannel(&stderrChannel) != 0) {
tryReadFromChannel(&stderrChannel);
timer.resetIncrements();
}
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index 83c52dbf2c..54a2855239 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -507,9 +507,9 @@ void QStorageInfoPrivate::retrieveVolumeInfo()
valid = true;
ready = true;
- bytesTotal = statfs_buf.f_blocks * statfs_buf.f_bsize;
- bytesFree = statfs_buf.f_bfree * statfs_buf.f_bsize;
- bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_bsize;
+ bytesTotal = statfs_buf.f_blocks * statfs_buf.f_frsize;
+ bytesFree = statfs_buf.f_bfree * statfs_buf.f_frsize;
+ bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_frsize;
blockSize = statfs_buf.f_bsize;
#if defined(Q_OS_ANDROID) || defined (Q_OS_BSD4)
#if defined(_STATFS_F_FLAGS)
diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp
index add2ac94da..57053f129a 100644
--- a/src/corelib/io/qwindowspipewriter.cpp
+++ b/src/corelib/io/qwindowspipewriter.cpp
@@ -85,7 +85,7 @@ qint64 QWindowsPipeWriter::write(const char *ptr, qint64 maxlen)
return -1;
QMutexLocker locker(&lock);
- data.append(QByteArray(ptr, maxlen));
+ data.append(ptr, maxlen);
waitCondition.wakeOne();
return maxlen;
}
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 4d4cccd7b1..b624c3880e 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -1395,6 +1395,8 @@ bool QObject::eventFilter(QObject * /* watched */, QEvent * /* event */)
Note that the destroyed() signal will be emitted even if the signals
for this object have been blocked.
+ Signals emitted while being blocked are not buffered.
+
\sa signalsBlocked()
*/
diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp
index dd8f385c82..fa40b743d3 100644
--- a/src/corelib/mimetypes/qmimeprovider.cpp
+++ b/src/corelib/mimetypes/qmimeprovider.cpp
@@ -79,10 +79,9 @@ Q_CORE_EXPORT int qmime_secondsBetweenChecks = 5; // exported for the unit test
bool QMimeProviderBase::shouldCheck()
{
- const QDateTime now = QDateTime::currentDateTime();
- if (m_lastCheck.isValid() && m_lastCheck.secsTo(now) < qmime_secondsBetweenChecks)
+ if (m_lastCheck.isValid() && m_lastCheck.elapsed() < qmime_secondsBetweenChecks * 1000)
return false;
- m_lastCheck = now;
+ m_lastCheck.start();
return true;
}
@@ -562,10 +561,13 @@ void QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)
// load comment and globPatterns
const QString file = data.name + QLatin1String(".xml");
- const QStringList mimeFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString::fromLatin1("mime/") + file);
+ // shared-mime-info since 1.3 lowercases the xml files
+ QStringList mimeFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString::fromLatin1("mime/") + file.toLower());
if (mimeFiles.isEmpty()) {
- // TODO: ask Thiago about this
- qWarning() << "No file found for" << file << ", even though the file appeared in a directory listing.";
+ mimeFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString::fromLatin1("mime/") + file); // pre-1.3
+ }
+ if (mimeFiles.isEmpty()) {
+ qWarning() << "No file found for" << file << ", even though update-mime-info said it would exist.";
qWarning() << "Either it was just removed, or the directory doesn't have executable permission...";
qWarning() << QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime"), QStandardPaths::LocateDirectory);
return;
@@ -626,7 +628,7 @@ void QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)
// Let's assume that shared-mime-info is at least version 0.70
// Otherwise we would need 1) a version check, and 2) code for parsing patterns from the globs file.
#if 1
- if (!mainPattern.isEmpty() && data.globPatterns.first() != mainPattern) {
+ if (!mainPattern.isEmpty() && (data.globPatterns.isEmpty() || data.globPatterns.first() != mainPattern)) {
// ensure it's first in the list of patterns
data.globPatterns.removeAll(mainPattern);
data.globPatterns.prepend(mainPattern);
diff --git a/src/corelib/mimetypes/qmimeprovider_p.h b/src/corelib/mimetypes/qmimeprovider_p.h
index 5a89ac23c3..eaf95942f7 100644
--- a/src/corelib/mimetypes/qmimeprovider_p.h
+++ b/src/corelib/mimetypes/qmimeprovider_p.h
@@ -51,6 +51,7 @@
#include <QtCore/qdatetime.h>
#include <QtCore/qset.h>
+#include <QtCore/qelapsedtimer.h>
QT_BEGIN_NAMESPACE
@@ -77,7 +78,7 @@ public:
QMimeDatabasePrivate *m_db;
protected:
bool shouldCheck();
- QDateTime m_lastCheck;
+ QElapsedTimer m_lastCheck;
};
/*
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp
index 002a9cc7bc..3269ee3ae8 100644
--- a/src/corelib/thread/qmutex.cpp
+++ b/src/corelib/thread/qmutex.cpp
@@ -563,7 +563,28 @@ const int FreeListConstants::Sizes[FreeListConstants::BlockCount] = {
};
typedef QFreeList<QMutexPrivate, FreeListConstants> FreeList;
-Q_GLOBAL_STATIC(FreeList, freelist);
+// We cannot use Q_GLOBAL_STATIC because it uses QMutex
+#if defined(Q_COMPILER_THREADSAFE_STATICS)
+FreeList *freelist()
+{
+ static FreeList list;
+ return &list;
+}
+#else
+FreeList *freelist()
+{
+ static QAtomicPointer<FreeList> list;
+ FreeList *local = list.loadAcquire();
+ if (!local) {
+ local = new FreeList;
+ if (!list.testAndSetRelease(0, local)) {
+ delete local;
+ local = list.loadAcquire();
+ }
+ }
+ return local;
+}
+#endif
}
QMutexPrivate *QMutexPrivate::allocate()
diff --git a/src/corelib/thread/thread.pri b/src/corelib/thread/thread.pri
index 3c1ddd984a..2cb00a6cf4 100644
--- a/src/corelib/thread/thread.pri
+++ b/src/corelib/thread/thread.pri
@@ -46,21 +46,21 @@ SOURCES += thread/qatomic.cpp \
unix:SOURCES += thread/qthread_unix.cpp \
thread/qwaitcondition_unix.cpp
-win32:SOURCES += thread/qmutex_win.cpp \
- thread/qthread_win.cpp \
+win32:SOURCES += thread/qthread_win.cpp \
thread/qwaitcondition_win.cpp
-integrity:SOURCES += thread/qmutex_unix.cpp \
- thread/qthread_unix.cpp \
+integrity:SOURCES += thread/qthread_unix.cpp \
thread/qwaitcondition_unix.cpp
-unix: {
- mac {
- SOURCES += thread/qmutex_mac.cpp
- } else:linux-*:!linux-lsb-* {
- SOURCES += thread/qmutex_linux.cpp
- } else {
- SOURCES += thread/qmutex_unix.cpp
- }
+false {
+ # files #included by others, but listed here so IDEs parsing this file know
+ # they are part of QtCore. Usually, qmake can find out that certain files
+ # are #included by others and thus remove from SOURCES, but it gets lost
+ # with qmutex.cpp.
+ SOURCES += \
+ thread/qmutex_linux.cpp \
+ thread/qmutex_mac.cpp \
+ thread/qmutex_unix.cpp \
+ thread/qmutex_win.cpp
}
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp
index e6c246e8e6..5469eee14d 100644
--- a/src/corelib/tools/qchar.cpp
+++ b/src/corelib/tools/qchar.cpp
@@ -598,12 +598,22 @@ QT_BEGIN_NAMESPACE
\fn QChar::QChar(char ch)
Constructs a QChar corresponding to ASCII/Latin-1 character \a ch.
+
+ \note This constructor is not available when \c QT_NO_CAST_FROM_ASCII
+ is defined.
+
+ \sa QT_NO_CAST_FROM_ASCII
*/
/*!
\fn QChar::QChar(uchar ch)
Constructs a QChar corresponding to ASCII/Latin-1 character \a ch.
+
+ \note This constructor is not available when \c QT_NO_CAST_FROM_ASCII
+ is defined.
+
+ \sa QT_NO_CAST_FROM_ASCII
*/
/*!
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index e445055e1d..eb4eff32b4 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -1681,6 +1681,7 @@ bool QTime::setHMS(int h, int m, int s, int ms)
QTime QTime::addSecs(int s) const
{
+ s %= SECS_PER_DAY;
return addMSecs(s * 1000);
}
diff --git a/src/corelib/tools/qelapsedtimer_mac.cpp b/src/corelib/tools/qelapsedtimer_mac.cpp
index a355bf03e8..e946ac096f 100644
--- a/src/corelib/tools/qelapsedtimer_mac.cpp
+++ b/src/corelib/tools/qelapsedtimer_mac.cpp
@@ -59,8 +59,13 @@ static qint64 absoluteToNSecs(qint64 cpuTime)
{
if (info.denom == 0)
mach_timebase_info(&info);
+#ifdef __LP64__
+ __uint128_t nsecs = static_cast<__uint128_t>(cpuTime) * info.numer / info.denom;
+ return static_cast<qint64>(nsecs);
+#else
qint64 nsecs = cpuTime * info.numer / info.denom;
return nsecs;
+#endif
}
static qint64 absoluteToMSecs(qint64 cpuTime)
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index 8000dc8688..c52e4b5a7c 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -116,6 +116,10 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
A good text on regexps is \e {Mastering Regular Expressions}
(Third Edition) by Jeffrey E. F. Friedl, ISBN 0-596-52812-4.
+ \note In Qt 5, the new QRegularExpression class provides a Perl
+ compatible implementation of regular expressions and is recommended
+ in place of QRegExp.
+
\tableofcontents
\section1 Introduction
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index 88a048d826..d8b0bf6e9f 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2012 Giuseppe D'Angelo <dangelog@gmail.com>.
-** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
+** Copyright (C) 2015 Giuseppe D'Angelo <dangelog@gmail.com>.
+** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
@@ -1326,48 +1326,45 @@ QRegularExpressionMatchPrivate *QRegularExpressionPrivate::doMatch(const QString
int * const captureOffsets = priv->capturedOffsets.data();
const int captureOffsetsCount = priv->capturedOffsets.size();
- int realOffset = offset + subjectStart;
- const int realSubjectLength = subjectLength + subjectStart;
-
- const unsigned short * const subjectUtf16 = subject.utf16();
+ const unsigned short * const subjectUtf16 = subject.utf16() + subjectStart;
int result;
if (!previousMatchWasEmpty) {
result = pcre16SafeExec(compiledPattern, currentStudyData,
- subjectUtf16, realSubjectLength,
- realOffset, pcreOptions,
+ subjectUtf16, subjectLength,
+ offset, pcreOptions,
captureOffsets, captureOffsetsCount);
} else {
result = pcre16SafeExec(compiledPattern, currentStudyData,
- subjectUtf16, realSubjectLength,
- realOffset, pcreOptions | PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED,
+ subjectUtf16, subjectLength,
+ offset, pcreOptions | PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED,
captureOffsets, captureOffsetsCount);
if (result == PCRE_ERROR_NOMATCH) {
- ++realOffset;
+ ++offset;
if (usingCrLfNewlines
- && realOffset < realSubjectLength
- && subjectUtf16[realOffset - 1] == QLatin1Char('\r')
- && subjectUtf16[realOffset] == QLatin1Char('\n')) {
- ++realOffset;
- } else if (realOffset < realSubjectLength
- && QChar::isLowSurrogate(subjectUtf16[realOffset])) {
- ++realOffset;
+ && offset < subjectLength
+ && subjectUtf16[offset - 1] == QLatin1Char('\r')
+ && subjectUtf16[offset] == QLatin1Char('\n')) {
+ ++offset;
+ } else if (offset < subjectLength
+ && QChar::isLowSurrogate(subjectUtf16[offset])) {
+ ++offset;
}
result = pcre16SafeExec(compiledPattern, currentStudyData,
- subjectUtf16, realSubjectLength,
- realOffset, pcreOptions,
+ subjectUtf16, subjectLength,
+ offset, pcreOptions,
captureOffsets, captureOffsetsCount);
}
}
#ifdef QREGULAREXPRESSION_DEBUG
qDebug() << "Matching" << pattern << "against" << subject
- << "starting at" << subjectStart << "len" << subjectLength << "real len" << realSubjectLength
- << "offset" << offset << "real offset" << realOffset
+ << "starting at" << subjectStart << "len" << subjectLength
+ << "offset" << offset
<< matchType << matchOptions << previousMatchWasEmpty
<< "result" << result;
#endif
@@ -2057,7 +2054,7 @@ QString QRegularExpressionMatch::captured(int nth) const
if (start == -1) // didn't capture
return QString();
- return d->subject.mid(start, capturedLength(nth));
+ return d->subject.mid(start + d->subjectStart, capturedLength(nth));
}
/*!
@@ -2078,7 +2075,7 @@ QStringRef QRegularExpressionMatch::capturedRef(int nth) const
if (start == -1) // didn't capture
return QStringRef();
- return d->subject.midRef(start, capturedLength(nth));
+ return d->subject.midRef(start + d->subjectStart, capturedLength(nth));
}
/*!