summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qregexp.cpp
diff options
context:
space:
mode:
authorJoão Abecasis <joao@trolltech.com>2010-01-25 17:27:47 (GMT)
committerJoão Abecasis <joao@trolltech.com>2010-02-25 12:07:41 (GMT)
commitdadb99ea2c59d7d0f7a83134b7df5aaaaf80a995 (patch)
treeaa5d28af81cf30b9bab31d178f11baf7cee065be /src/corelib/tools/qregexp.cpp
parent977d88856d8bbe199e293a677a7fe3d401aad4b8 (diff)
downloadQt-dadb99ea2c59d7d0f7a83134b7df5aaaaf80a995.zip
Qt-dadb99ea2c59d7d0f7a83134b7df5aaaaf80a995.tar.gz
Qt-dadb99ea2c59d7d0f7a83134b7df5aaaaf80a995.tar.bz2
QRegExp::pos() should return -1 for empty/non-matching captures
Instead, we were returning 0, even if this index did not belong to the match. Task-number: QTBUG-7049 Reviewed-by: Volker Hilsheimer Reviewed-by: Olivier Goffart
Diffstat (limited to 'src/corelib/tools/qregexp.cpp')
-rw-r--r--src/corelib/tools/qregexp.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index 25255f9..20ad444 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -1466,9 +1466,14 @@ void QRegExpMatchState::match(const QChar *str0, int len0, int pos0,
#ifndef QT_NO_REGEXP_CAPTURE
for (int i = 0; i < numCaptures; ++i) {
int j = eng->captureForOfficialCapture.at(i);
- int len = capEnd[j] - capBegin[j];
- *c++ = (len > 0) ? pos + capBegin[j] : 0;
- *c++ = len;
+ if (capBegin[j] != EmptyCapture) {
+ int len = capEnd[j] - capBegin[j];
+ *c++ = (len > 0) ? pos + capBegin[j] : 0;
+ *c++ = len;
+ } else {
+ *c++ = -1;
+ *c++ = -1;
+ }
}
#endif
} else {