From 6cf2870bd22d51ee62cd11357977da55ed86d4b0 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Thu, 3 Feb 2005 07:36:57 +0000 Subject: Patch from Josiah Reynolds to prevent backwards searches from matching when the search string extended beyond the end of the search range. --- src/Document.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') 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(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])) -- cgit v1.2.3