aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2005-02-03 07:36:57 +0000
committernyamatongwe <unknown>2005-02-03 07:36:57 +0000
commit6cf2870bd22d51ee62cd11357977da55ed86d4b0 (patch)
tree1f9679e6d2b6b5c654c0682c71125f63870a50c3
parentdc5e390f75ead05ddff1e917e4aa4a133fc51529 (diff)
downloadscintilla-mirror-6cf2870bd22d51ee62cd11357977da55ed86d4b0.tar.gz
Patch from Josiah Reynolds to prevent backwards searches from
matching when the search string extended beyond the end of the search range.
-rw-r--r--src/Document.cxx4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index 82f4c59bc..27363d6e9 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -1052,12 +1052,13 @@ long Document::FindText(int minPos, int maxPos, const char *s,
char firstChar = s[0];
if (!caseSensitive)
firstChar = static_cast<char>(MakeUpperCase(firstChar));
- int pos = startPos;
+ int pos = forward ? startPos : (startPos - 1);
while (forward ? (pos < endSearch) : (pos >= endSearch)) {
char ch = CharAt(pos);
if (caseSensitive) {
if (ch == firstChar) {
bool found = true;
+ if (pos + lengthFind > Platform::Maximum(startPos, endPos)) found = false;
for (int posMatch = 1; posMatch < lengthFind && found; posMatch++) {
ch = CharAt(pos + posMatch);
if (ch != s[posMatch])
@@ -1073,6 +1074,7 @@ long Document::FindText(int minPos, int maxPos, const char *s,
} else {
if (MakeUpperCase(ch) == firstChar) {
bool found = true;
+ if (pos + lengthFind > Platform::Maximum(startPos, endPos)) found = false;
for (int posMatch = 1; posMatch < lengthFind && found; posMatch++) {
ch = CharAt(pos + posMatch);
if (MakeUpperCase(ch) != MakeUpperCase(s[posMatch]))