1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 09:13:06 +00:00

Better compare of IP strings.

This commit is contained in:
Mitchell Livingston 2006-08-30 21:40:36 +00:00
parent c926d96e32
commit 82a33fa0f6
2 changed files with 12 additions and 18 deletions

View file

@ -161,27 +161,22 @@
{
if ([self isEqualToString: string])
return NSOrderedSame;
NSEnumerator * selfSections = [[self componentsSeparatedByString: @"."] objectEnumerator],
* newSections = [[string componentsSeparatedByString: @"."] objectEnumerator];
NSArray * selfSections = [self componentsSeparatedByString: @"."],
* newSections = [string componentsSeparatedByString: @"."];
if ([selfSections count] != [newSections count])
return [[NSNumber numberWithUnsignedInt: [selfSections count]] compare:
[NSNumber numberWithUnsignedInt: [newSections count]]];
NSEnumerator * selfSectionsEnum = [selfSections objectEnumerator], * newSectionsEnum = [newSections objectEnumerator];
NSString * selfString, * newString;
NSComparisonResult result;
NSString * selfString = [selfSections nextObject], * newString = [newSections nextObject];
while (selfString && newString)
{
while ((selfString = [selfSectionsEnum nextObject]) && (newString = [newSectionsEnum nextObject]))
if ((result = [selfString compare: newString options: NSNumericSearch]) != NSOrderedSame)
return result;
selfString = [selfSections nextObject];
newString = [newSections nextObject];
}
if (selfString)
return NSOrderedDescending;
else if (newString)
return NSOrderedAscending;
else
return NSOrderedSame;
return NSOrderedSame;
}
@end

View file

@ -106,8 +106,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
if ([barImage size].width < width)
[barImage setSize: NSMakeSize(width * 1.5, BAR_HEIGHT)];
[barImage compositeToPoint: point fromRect: NSMakeRect(0, 0, width, BAR_HEIGHT)
operation: NSCompositeSourceOver];
[barImage compositeToPoint: point fromRect: NSMakeRect(0, 0, width, BAR_HEIGHT) operation: NSCompositeSourceOver];
}
- (void) buildSimpleBar: (float) width point: (NSPoint) point