ovs-vsctl: Score perfect matches higher than ones that differ in case.
authorBen Pfaff <blp@nicira.com>
Wed, 27 Jan 2010 19:21:43 +0000 (11:21 -0800)
committerBen Pfaff <blp@nicira.com>
Wed, 27 Jan 2010 21:51:52 +0000 (13:51 -0800)
Before, both "xY_z" and "xy-z" were considered equally good matches for
"xy-z", but obviously the latter is a much better match.  This commit fixes
the problem (which was found by inspection).

utilities/ovs-vsctl.c

index 0eef55f0935b877a970d4e290055c7410ab4e292..031001b68873a5bf92cccef03ab3461b44bcb938 100644 (file)
@@ -1659,11 +1659,14 @@ score_partial_match(const char *name, const char *s)
 {
     int score;
 
+    if (!strcmp(name, s)) {
+        return UINT_MAX;
+    }
     for (score = 0; ; score++, name++, s++) {
         if (to_lower_and_underscores(*name) != to_lower_and_underscores(*s)) {
             break;
         } else if (*name == '\0') {
-            return UINT_MAX;
+            return UINT_MAX - 1;
         }
     }
     return *s == '\0' ? score : 0;