aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cppcheck.suppress2
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--src/Document.cxx37
-rw-r--r--test/unit/testDocument.cxx2
4 files changed, 22 insertions, 23 deletions
diff --git a/cppcheck.suppress b/cppcheck.suppress
index 5e404b6df..092de64ee 100644
--- a/cppcheck.suppress
+++ b/cppcheck.suppress
@@ -85,8 +85,6 @@ passedByValue
// Checks for moves move to variables that are not read but the moved from is checked
unreadVariable:scintilla/test/unit/*.cxx
accessMoved:scintilla/test/unit/*.cxx
-// Temporary code for test that fails
-redundantAssignment:scintilla/test/unit/testDocument.cxx
// cppcheck fails REQUIRE from Catch
comparisonOfFuncReturningBoolError:scintilla/test/unit/*.cxx
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index dc2a8415e..ca780bc46 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -618,6 +618,10 @@
<a href="https://sourceforge.net/p/scintilla/bugs/2405/">Bug #2405</a>.
</li>
<li>
+ Fix regular expression bug in reverse direction where shortened match returned.
+ <a href="https://sourceforge.net/p/scintilla/bugs/2405/">Bug #2405</a>.
+ </li>
+ <li>
With a document that does not have the SC_DOCUMENTOPTION_TEXT_LARGE option set,
allocating more than 2G (calling SCI_ALLOCATE or similar) will now fail with SC_STATUS_FAILURE.
</li>
diff --git a/src/Document.cxx b/src/Document.cxx
index e6521df45..dcb087930 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -3269,34 +3269,31 @@ Sci::Position BuiltinRegex::FindText(Document *doc, Sci::Position minPos, Sci::P
search.SetLineRange(lineStartPos, lineEndPos);
int success = search.Execute(di, startOfLine, endOfLine);
if (success) {
- pos = search.bopat[0];
// Ensure only whole characters selected
- search.eopat[0] = doc->MovePositionOutsideChar(search.eopat[0], 1, false);
- lenRet = search.eopat[0] - search.bopat[0];
+ Sci::Position endPos = doc->MovePositionOutsideChar(search.eopat[0], 1, false);
// There can be only one start of a line, so no need to look for last match in line
if ((resr.increment == -1) && !searchforLineStart) {
// Check for the last match on this line.
- int repetitions = 1000; // Break out of infinite loop
- RESearch::MatchPositions bopat{};
- RESearch::MatchPositions eopat{};
- while (success && (search.eopat[0] <= endOfLine) && (repetitions--)) {
- bopat = search.bopat;
- eopat = search.eopat;
- success = search.Execute(di, pos+1, endOfLine);
+ while (success && (endPos < endOfLine)) {
+ const RESearch::MatchPositions bopat = search.bopat;
+ const RESearch::MatchPositions eopat = search.eopat;
+ pos = endPos;
+ if (pos == bopat[0]) {
+ // empty match
+ pos = doc->NextPosition(pos, 1);
+ }
+ success = search.Execute(di, pos, endOfLine);
if (success) {
- if (search.eopat[0] <= minPos) {
- pos = search.bopat[0];
- lenRet = search.eopat[0] - search.bopat[0];
- } else {
- success = 0;
- }
+ endPos = doc->MovePositionOutsideChar(search.eopat[0], 1, false);
+ } else {
+ search.bopat = bopat;
+ search.eopat = eopat;
}
}
- if (!success) {
- search.bopat = bopat;
- search.eopat = eopat;
- }
}
+ search.eopat[0] = endPos;
+ pos = search.bopat[0];
+ lenRet = endPos - pos;
break;
}
}
diff --git a/test/unit/testDocument.cxx b/test/unit/testDocument.cxx
index 52af45167..ba7bb8616 100644
--- a/test/unit/testDocument.cxx
+++ b/test/unit/testDocument.cxx
@@ -517,7 +517,7 @@ TEST_CASE("Document") {
REQUIRE(substituted == "\tb\xCE\x93y\n");
match = doc.FindString(docLength, 0, longest, rePosix);
- //REQUIRE(match == Match(16, 5));
+ REQUIRE(match == Match(16, 5));
#ifndef NO_CXX11_REGEX
match = doc.FindString(0, docLength, finding, reCxx11);