Better compare of IP strings.
This commit is contained in:
parent
c926d96e32
commit
82a33fa0f6
|
@ -161,27 +161,22 @@
|
||||||
{
|
{
|
||||||
if ([self isEqualToString: string])
|
if ([self isEqualToString: string])
|
||||||
return NSOrderedSame;
|
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;
|
NSComparisonResult result;
|
||||||
NSString * selfString = [selfSections nextObject], * newString = [newSections nextObject];
|
while ((selfString = [selfSectionsEnum nextObject]) && (newString = [newSectionsEnum nextObject]))
|
||||||
while (selfString && newString)
|
|
||||||
{
|
|
||||||
if ((result = [selfString compare: newString options: NSNumericSearch]) != NSOrderedSame)
|
if ((result = [selfString compare: newString options: NSNumericSearch]) != NSOrderedSame)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
selfString = [selfSections nextObject];
|
|
||||||
newString = [newSections nextObject];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selfString)
|
return NSOrderedSame;
|
||||||
return NSOrderedDescending;
|
|
||||||
else if (newString)
|
|
||||||
return NSOrderedAscending;
|
|
||||||
else
|
|
||||||
return NSOrderedSame;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -106,8 +106,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
if ([barImage size].width < width)
|
if ([barImage size].width < width)
|
||||||
[barImage setSize: NSMakeSize(width * 1.5, BAR_HEIGHT)];
|
[barImage setSize: NSMakeSize(width * 1.5, BAR_HEIGHT)];
|
||||||
|
|
||||||
[barImage compositeToPoint: point fromRect: NSMakeRect(0, 0, width, BAR_HEIGHT)
|
[barImage compositeToPoint: point fromRect: NSMakeRect(0, 0, width, BAR_HEIGHT) operation: NSCompositeSourceOver];
|
||||||
operation: NSCompositeSourceOver];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) buildSimpleBar: (float) width point: (NSPoint) point
|
- (void) buildSimpleBar: (float) width point: (NSPoint) point
|
||||||
|
|
Loading…
Reference in New Issue