Monotone-Parent: f4a48c355ec45a380e52409f4443bd4198ea038a

Monotone-Revision: 2067a16090e68b1eac6c1e860f41b09c466ff2f5

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2008-08-21T21:40:28
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Francis Lachapelle 2008-08-21 21:40:28 +00:00
parent d9c815dc40
commit be982cdc35
3 changed files with 18 additions and 4 deletions

View File

@ -55,7 +55,7 @@
- (void) addObjectUniquely: (id) object;
- (void) addRange: (NSRange) newRange;
- (BOOL) hasRangeIntersection: (NSRange) testRange;
- (BOOL) hasRangeIntersection: (NSRange) testRange withOffset: (unsigned int) offset;
@end

View File

@ -206,7 +206,7 @@
[self addObject: NSStringFromRange (newRange)];
}
- (BOOL) hasRangeIntersection: (NSRange) testRange
- (BOOL) hasRangeIntersection: (NSRange) testRange withOffset: (unsigned int) offset
{
NSEnumerator *ranges;
NSString *currentRangeString;
@ -217,9 +217,11 @@
ranges = [self objectEnumerator];
currentRangeString = [ranges nextObject];
while (!response && currentRangeString)
{
currentRange = NSRangeFromString (currentRangeString);
currentRange.location = currentRange.location + offset;
if (NSLocationInRange (testRange.location, currentRange)
|| NSLocationInRange (NSMaxRange (testRange), currentRange))
response = YES;

View File

@ -197,7 +197,7 @@ static NSMutableCharacterSet *urlStartChars = nil;
{
NSRange httpRange, currentURL, rest;
NSString *urlText, *newUrlText;
unsigned int length, matchLength;
unsigned int length, matchLength, offset;
int startLocation;
if (!urlStartChars)
@ -211,6 +211,7 @@ static NSMutableCharacterSet *urlStartChars = nil;
httpRange = [selfCopy rangeOfString: match];
if (httpRange.location != NSNotFound)
{
offset = 0;
startLocation = httpRange.location;
while (startLocation > -1
&& [urlStartChars characterIsMember:
@ -220,7 +221,8 @@ static NSMutableCharacterSet *urlStartChars = nil;
}
while (httpRange.location != NSNotFound)
{
if ([ranges hasRangeIntersection: httpRange])
currentURL = [selfCopy _rangeOfURLInRange: httpRange];
if ([ranges hasRangeIntersection: httpRange withOffset: offset])
rest.location = NSMaxRange(httpRange);
else
{
@ -237,6 +239,7 @@ static NSMutableCharacterSet *urlStartChars = nil;
currentURL
= NSMakeRange (currentURL.location, [newUrlText length]);
[ranges addRange: currentURL];
offset = offset + 9 + [prefix length];
}
rest.location = NSMaxRange(currentURL);
}
@ -245,6 +248,15 @@ static NSMutableCharacterSet *urlStartChars = nil;
rest.length = length - rest.location;
httpRange = [selfCopy rangeOfString: match
options: 0 range: rest];
if (httpRange.location != NSNotFound)
{
startLocation = httpRange.location;
while (startLocation > -1
&& [urlStartChars characterIsMember:
[selfCopy characterAtIndex: startLocation]])
startLocation--;
httpRange.location = startLocation + 1;
}
}
}