Skip to content
Snippets Groups Projects
Commit 811f0c5e authored by George Nachman's avatar George Nachman
Browse files

Fix a bug in regex search where a regex like xa* would return multiple search...

Fix a bug in regex search where a regex like xa* would return multiple search results against a document like xaaaa (xa, xaa, etc.). Now that search results are properly sorted, this causes strange behavior. For example, only part of a match might be selected. Now, we ignore results that are a subset of a previous result. This works because the search progressively shortens and re-searches the document (e.g., xaaa, xaa, xa, x). Issue 5937
parent 46fe3ca0
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -1174,6 +1174,7 @@ static int Search(NSString* needle,
&deltas);
int numUnichars = [haystack length];
const unsigned long long kMaxSaneStringLength = 1000000000LL;
NSRange previousRange = NSMakeRange(NSNotFound, 0);
do {
haystack = CharArrayToString(charHaystack, numUnichars);
if ([haystack length] >= kMaxSaneStringLength) {
Loading
Loading
@@ -1190,7 +1191,11 @@ static int Search(NSString* needle,
while (numUnichars >= 0 && numUnichars + deltas[numUnichars] > limit) {
--numUnichars;
}
if (tempPosition != -1 && tempPosition <= skip) {
NSRange range = NSMakeRange(tempPosition, tempResultLength);
if (tempPosition != -1 &&
tempPosition <= skip &&
!NSEqualRanges(NSIntersectionRange(range, previousRange), range)) {
previousRange = range;
ResultRange* r = [[[ResultRange alloc] init] autorelease];
r->position = tempPosition;
r->length = tempResultLength;
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment