merge of 'd5bcd77c68cb679b5a1b9a23a4cc86038b0e615e'
and 'ed0cae805a538abfe1c738e426b04f59baa43949' Monotone-Parent: d5bcd77c68cb679b5a1b9a23a4cc86038b0e615e Monotone-Parent: ed0cae805a538abfe1c738e426b04f59baa43949 Monotone-Revision: b1d9b0e8b48341b65d5f440bceeee81fb590bb3e Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-08-22T18:44:10 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
commit
7f03974b4f
|
@ -161,12 +161,12 @@ static NSMutableCharacterSet *urlStartChars = nil;
|
||||||
if (!urlNonEndingChars)
|
if (!urlNonEndingChars)
|
||||||
{
|
{
|
||||||
urlNonEndingChars = [NSMutableCharacterSet new];
|
urlNonEndingChars = [NSMutableCharacterSet new];
|
||||||
[urlNonEndingChars addCharactersInString: @"=,.:;\t \r\n"];
|
[urlNonEndingChars addCharactersInString: @"=,.:;&\t \r\n"];
|
||||||
}
|
}
|
||||||
if (!urlAfterEndingChars)
|
if (!urlAfterEndingChars)
|
||||||
{
|
{
|
||||||
urlAfterEndingChars = [NSMutableCharacterSet new];
|
urlAfterEndingChars = [NSMutableCharacterSet new];
|
||||||
[urlAfterEndingChars addCharactersInString: @"&[]\t \r\n"];
|
[urlAfterEndingChars addCharactersInString: @"[]\t \r\n"];
|
||||||
}
|
}
|
||||||
|
|
||||||
start = refRange.location;
|
start = refRange.location;
|
||||||
|
@ -199,7 +199,7 @@ static NSMutableCharacterSet *urlStartChars = nil;
|
||||||
NSMutableArray *newRanges;
|
NSMutableArray *newRanges;
|
||||||
NSRange matchRange, currentUrlRange, rest;
|
NSRange matchRange, currentUrlRange, rest;
|
||||||
NSString *urlText, *newUrlText, *range;
|
NSString *urlText, *newUrlText, *range;
|
||||||
unsigned int length, matchLength;
|
unsigned int length, matchLength, offset;
|
||||||
int startLocation;
|
int startLocation;
|
||||||
|
|
||||||
if (!urlStartChars)
|
if (!urlStartChars)
|
||||||
|
@ -224,7 +224,6 @@ static NSMutableCharacterSet *urlStartChars = nil;
|
||||||
matchRange.location = startLocation + 1;
|
matchRange.location = startLocation + 1;
|
||||||
|
|
||||||
currentUrlRange = [selfCopy _rangeOfURLInRange: matchRange];
|
currentUrlRange = [selfCopy _rangeOfURLInRange: matchRange];
|
||||||
|
|
||||||
if ([ranges hasRangeIntersection: currentUrlRange])
|
if ([ranges hasRangeIntersection: currentUrlRange])
|
||||||
rest.location = NSMaxRange(currentUrlRange);
|
rest.location = NSMaxRange(currentUrlRange);
|
||||||
else
|
else
|
||||||
|
@ -240,18 +239,21 @@ static NSMutableCharacterSet *urlStartChars = nil;
|
||||||
options: 0 range: rest];
|
options: 0 range: rest];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the substitutions, in reverse order
|
// Make the substitutions, keep track of the new offset
|
||||||
enumRanges = [newRanges reverseObjectEnumerator];
|
offset = 0;
|
||||||
|
enumRanges = [newRanges objectEnumerator];
|
||||||
range = [enumRanges nextObject];
|
range = [enumRanges nextObject];
|
||||||
while (range)
|
while (range)
|
||||||
{
|
{
|
||||||
currentUrlRange = NSRangeFromString(range);
|
currentUrlRange = NSRangeFromString(range);
|
||||||
|
currentUrlRange.location += offset;
|
||||||
urlText = [selfCopy substringFromRange: currentUrlRange];
|
urlText = [selfCopy substringFromRange: currentUrlRange];
|
||||||
if ([urlText hasPrefix: prefix]) prefix = @"";
|
if ([urlText hasPrefix: prefix]) prefix = @"";
|
||||||
newUrlText = [NSString stringWithFormat: @"<a href=\"%@%@\">%@</a>",
|
newUrlText = [NSString stringWithFormat: @"<a href=\"%@%@\">%@</a>",
|
||||||
prefix, urlText, urlText];
|
prefix, urlText, urlText];
|
||||||
[selfCopy replaceCharactersInRange: currentUrlRange
|
[selfCopy replaceCharactersInRange: currentUrlRange
|
||||||
withString: newUrlText];
|
withString: newUrlText];
|
||||||
|
offset += ([newUrlText length] - [urlText length]);
|
||||||
|
|
||||||
// Add range for further substitutions
|
// Add range for further substitutions
|
||||||
currentUrlRange = NSMakeRange (currentUrlRange.location, [newUrlText length]);
|
currentUrlRange = NSMakeRange (currentUrlRange.location, [newUrlText length]);
|
||||||
|
|
Loading…
Reference in a new issue