commit:     d0008990d9c734c1e5bfbb52a33babf382efc2ab
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 25 12:54:55 2021 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Wed Aug 25 14:35:48 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d0008990

dev-qt/qtcore: Revert "QString::lastIndexOf: fix off-by-one ..."

"... for zero length matches"

See also:
https://bugreports.qt.io/browse/QTBUG-94215
https://invent.kde.org/qt/qt/qtbase/-/merge_requests/46

Package-Manager: Portage-3.0.22, Repoman-3.0.3
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 .../files/qtcore-5.15.2-revert-3a273ac4.patch      | 56 ++++++++++++++++++++++
 dev-qt/qtcore/qtcore-5.15.2-r10.ebuild             |  3 ++
 2 files changed, 59 insertions(+)

diff --git a/dev-qt/qtcore/files/qtcore-5.15.2-revert-3a273ac4.patch 
b/dev-qt/qtcore/files/qtcore-5.15.2-revert-3a273ac4.patch
new file mode 100644
index 00000000000..a29e1b5256d
--- /dev/null
+++ b/dev-qt/qtcore/files/qtcore-5.15.2-revert-3a273ac4.patch
@@ -0,0 +1,56 @@
+From d9a85af5f24d0608c79b2d87b01213833bee01e5 Mon Sep 17 00:00:00 2001
+From: David Faure <[email protected]>
+Date: Thu, 19 Aug 2021 15:07:13 +0200
+Subject: [PATCH] Revert "QString::lastIndexOf: fix off-by-one for zero length
+ matches"
+
+This reverts commit 3a273ac47f20e82a1f2f63411b210025ca0f4495.
+
+See QTBUG-94215
+
+6cee204d56205e250b0675c9c6d4dd8a2367f3c4 for qtbase/dev changes the
+behaviour even further, I'm pretty sure we don't want that in Qt 5.15.x,
+see discussion in https://codereview.qt-project.org/c/qt/qtbase/+/365179.
+
+Change-Id: I663d74e0d44ebf46291fe0e8a7dc609be82eedc6
+---
+ src/corelib/text/qstring.cpp                    | 4 ++--
+ tests/auto/corelib/text/qstring/tst_qstring.cpp | 2 +-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
+index 02a9fe3a30..e6e7cbaad4 100644
+--- a/src/corelib/text/qstring.cpp
++++ b/src/corelib/text/qstring.cpp
+@@ -4558,13 +4558,13 @@ int QString::lastIndexOf(const QRegularExpression &re, 
int from, QRegularExpress
+         return -1;
+     }
+ 
+-    int endpos = (from < 0) ? (size() + from + 1) : (from);
++    int endpos = (from < 0) ? (size() + from + 1) : (from + 1);
+     QRegularExpressionMatchIterator iterator = re.globalMatch(*this);
+     int lastIndex = -1;
+     while (iterator.hasNext()) {
+         QRegularExpressionMatch match = iterator.next();
+         int start = match.capturedStart();
+-        if (start <= endpos) {
++        if (start < endpos) {
+             lastIndex = start;
+             if (rmatch)
+                 *rmatch = std::move(match);
+diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp 
b/tests/auto/corelib/text/qstring/tst_qstring.cpp
+index 8f53824050..4c4a8f0416 100644
+--- a/tests/auto/corelib/text/qstring/tst_qstring.cpp
++++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp
+@@ -1674,7 +1674,7 @@ void tst_QString::lastIndexOf()
+     QCOMPARE(haystack.lastIndexOf(needle.toLatin1(), from, cs), expected);
+     QCOMPARE(haystack.lastIndexOf(needle.toLatin1().data(), from, cs), 
expected);
+ 
+-    if (from >= -1 && from < haystack.size() && needle.size() > 0) {
++    if (from >= -1 && from < haystack.size()) {
+         // unfortunately, QString and QRegExp don't have the same out of 
bound semantics
+         // I think QString is wrong -- See file log for contact information.
+         {
+-- 
+GitLab
+

diff --git a/dev-qt/qtcore/qtcore-5.15.2-r10.ebuild 
b/dev-qt/qtcore/qtcore-5.15.2-r10.ebuild
index 5d5fc72d4cc..d8791013a67 100644
--- a/dev-qt/qtcore/qtcore-5.15.2-r10.ebuild
+++ b/dev-qt/qtcore/qtcore-5.15.2-r10.ebuild
@@ -48,6 +48,9 @@ QT5_GENTOO_PRIVATE_CONFIG=(
 PATCHES=(
        "${FILESDIR}"/${PN}-5.14.1-cmake-macro-backward-compat.patch # bug 
703306
        "${FILESDIR}"/${PN}-5.15.1-timezone-{1,2}.patch # bug 737914
+       # Revert to 5.15.2 (upstream Qt release) behavior, QTBUG-94215
+       # See also: https://invent.kde.org/qt/qt/qtbase/-/merge_requests/46
+       "${FILESDIR}"/${P}-revert-3a273ac4.patch
 )
 
 pkg_pretend() {

Reply via email to