mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 12:28:52 +00:00
Sort IP addresses correctly.
This commit is contained in:
BIN
macosx/English.lproj/InfoWindow.nib/keyedobjects.nib
generated
BIN
macosx/English.lproj/InfoWindow.nib/keyedobjects.nib
generated
Binary file not shown.
@@ -39,4 +39,6 @@
|
||||
- (NSAttributedString *) attributedStringFittingInWidth: (float) width
|
||||
attributes: (NSDictionary *) attributes;
|
||||
|
||||
- (NSComparisonResult) compareIP: (NSString *) string;
|
||||
|
||||
@end
|
||||
|
||||
@@ -157,4 +157,31 @@
|
||||
attributes: attributes] autorelease];
|
||||
}
|
||||
|
||||
- (NSComparisonResult) compareIP: (NSString *) string
|
||||
{
|
||||
if ([self isEqualToString: string])
|
||||
return NSOrderedSame;
|
||||
|
||||
NSEnumerator * selfSections = [[self componentsSeparatedByString: @"."] objectEnumerator],
|
||||
* newSections = [[string componentsSeparatedByString: @"."] objectEnumerator];
|
||||
|
||||
NSComparisonResult result;
|
||||
NSString * selfString = [selfSections nextObject], * newString = [newSections nextObject];
|
||||
while (selfString && newString)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user