]> granicus.if.org Git - transmission/commitdiff
comparing with the numeric option works for sorting IP address properly, so let it...
authorMitchell Livingston <livings124@transmissionbt.com>
Fri, 27 Jun 2008 05:40:22 +0000 (05:40 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Fri, 27 Jun 2008 05:40:22 +0000 (05:40 +0000)
macosx/English.lproj/InfoWindow.xib
macosx/InfoWindowController.m
macosx/NSStringAdditions.h
macosx/NSStringAdditions.m

index a475babc6c25e3fe603aa68f6cbb92283008d0c2..2af130d34226640a4bd8836129f5b5b109e1c835 100644 (file)
@@ -8,7 +8,7 @@
                <string key="IBDocument.HIToolboxVersion">352.00</string>
                <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
                        <bool key="EncodedWithXMLCoder">YES</bool>
-                       <integer value="1039"/>
+                       <integer value="1042"/>
                </object>
                <object class="NSArray" key="IBDocument.PluginDependencies">
                        <bool key="EncodedWithXMLCoder">YES</bool>
@@ -2287,10 +2287,10 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                                                                                <int key="NSResizingMask">2</int>
                                                                                                <bool key="NSIsResizeable">YES</bool>
                                                                                                <reference key="NSTableView" ref="221969066"/>
-                                                                                               <object class="NSSortDescriptor" key="NSSortDescriptorPrototype" id="631031026">
+                                                                                               <object class="NSSortDescriptor" key="NSSortDescriptorPrototype">
                                                                                                        <string key="NSKey">IP</string>
                                                                                                        <bool key="NSAscending">YES</bool>
-                                                                                                       <string key="NSSelector">compareIP:</string>
+                                                                                                       <string key="NSSelector">compareNumeric:</string>
                                                                                                </object>
                                                                                        </object>
                                                                                        <object class="NSTableColumn" id="510868589">
@@ -3851,7 +3851,6 @@ zijOSc5pzorOqs66ztvO+88czzzPXc99z57Pvs/fz+/QANAg0EHQYdCC0KLQw9Dj0PPRFNE00VXRddGW
                                                                                <string key="NSAutosaveName">InspectorTable</string>
                                                                                <object class="NSArray" key="NSSortDescriptors">
                                                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                                                       <reference ref="631031026"/>
                                                                                        <reference ref="116573225"/>
                                                                                </object>
                                                                                <int key="NSColumnAutoresizingStyle">1</int>
index e96ecb7350e070e6ad907c4c4f3c8d8f4c9378bd..46df46c76279a35fcd4347a13b2a6fdf6a0ec0be 100644 (file)
@@ -1592,7 +1592,7 @@ typedef enum
     if (useSecond)
     {
         NSSortDescriptor * secondDescriptor = [[NSSortDescriptor alloc] initWithKey: @"IP" ascending: asc
-                                                                        selector: @selector(compareIP:)];
+                                                                        selector: @selector(compareFinder:)];
         [descriptors addObject: secondDescriptor];
         [secondDescriptor release];
     }
index 8e38c424079add296843cd20d6578c976ba44311..11130cb11aea2d5258c2b4aeb840885c97de050f 100644 (file)
@@ -39,6 +39,6 @@
 + (NSString *) timeString: (NSUInteger) seconds showSeconds: (BOOL) showSeconds maxFields: (NSUInteger) max;
 
 - (NSComparisonResult) compareFinder: (NSString *) string; //how the Finder compares strings
-- (NSComparisonResult) compareIP: (NSString *) string;
+- (NSComparisonResult) compareNumeric: (NSString *) string; //simple compare method for strings with numbers (works for IP addresses)
 
 @end
index e03a10bdccdab61119ff0c6d111517f78b63aa26..6f0c625a01feb9e2ae019f7010db5acb8b79781d 100644 (file)
 
 - (NSComparisonResult) compareFinder: (NSString *) string
 {
-    int comparisonOptions = ![NSApp isOnLeopardOrBetter] ? (NSCaseInsensitiveSearch | NSNumericSearch)
-        : (NSCaseInsensitiveSearch | NSNumericSearch| NSWidthInsensitiveSearch | NSForcedOrderingSearch);
+    int comparisonOptions = [NSApp isOnLeopardOrBetter] ? (NSCaseInsensitiveSearch | NSNumericSearch
+                                                            | NSWidthInsensitiveSearch | NSForcedOrderingSearch)
+                                                        : (NSCaseInsensitiveSearch | NSNumericSearch);
     
     return [self compare: string options: comparisonOptions range: NSMakeRange(0, [self length]) locale: [NSLocale currentLocale]];
 }
 
-- (NSComparisonResult) compareIP: (NSString *) string
-{    
-    NSArray * selfSections = [self componentsSeparatedByString: @"."],
-            * newSections = [string componentsSeparatedByString: @"."];
-    
-    if ([selfSections count] != [newSections count])
-        return [selfSections count] > [newSections count] ? NSOrderedDescending : NSOrderedAscending;
-
-    NSEnumerator * selfSectionsEnum = [selfSections objectEnumerator], * newSectionsEnum = [newSections objectEnumerator];
-    NSString * selfString, * newString;
+- (NSComparisonResult) compareNumeric: (NSString *) string
+{
     int comparisonOptions = [NSApp isOnLeopardOrBetter] ? (NSNumericSearch | NSForcedOrderingSearch) : NSNumericSearch;
-    NSComparisonResult result;
-    while ((selfString = [selfSectionsEnum nextObject]) && (newString = [newSectionsEnum nextObject]))
-        if ((result = [selfString compare: newString options: comparisonOptions
-                        range: NSMakeRange(0, [selfString length]) locale: [NSLocale currentLocale]]) != NSOrderedSame)
-            return result;
     
-    return NSOrderedSame;
+    return [self compare: string options: comparisonOptions range: NSMakeRange(0, [self length]) locale: [NSLocale currentLocale]];
 }
 
 @end