From: Ben Pfaff Date: Wed, 27 Jan 2010 19:21:43 +0000 (-0800) Subject: ovs-vsctl: Score perfect matches higher than ones that differ in case. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5128bd9c3c71a0cd4428ec42f04da1156e16e685;p=openvswitch ovs-vsctl: Score perfect matches higher than ones that differ in case. 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). --- diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 0eef55f0..031001b6 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -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;