Do a case insenstive compare then case sensitive compare and finally
authorRoy Marples <roy@marples.name>
Tue, 11 Nov 2014 21:41:25 +0000 (21:41 +0000)
committerRoy Marples <roy@marples.name>
Tue, 11 Nov 2014 21:41:25 +0000 (21:41 +0000)
sort for strength.

src/libdhcpcd/wpa.c

index 200e9ecf515026d07a5d088edb3908271339ca45..8a274405961993b3fc54bcd0332111a8d1c97543 100644 (file)
@@ -359,10 +359,15 @@ dhcpcd_wi_scan_compare(DHCPCD_WI_SCAN *a, DHCPCD_WI_SCAN *b)
 {
        int cmp;
 
 {
        int cmp;
 
+       /* Fist sort non case sensitive, then case sensitive */
        cmp = strcasecmp(a->ssid, b->ssid);
        if (cmp == 0)
        cmp = strcasecmp(a->ssid, b->ssid);
        if (cmp == 0)
-               /* Return strongest first */
+               cmp = strcmp(a->ssid, b->ssid);
+
+       /* If still the same, return strongest first */
+       if (cmp == 0)
                cmp = b->strength.value - a->strength.value;
                cmp = b->strength.value - a->strength.value;
+
        return cmp;
 }
 
        return cmp;
 }