From 5128bd9c3c71a0cd4428ec42f04da1156e16e685 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 27 Jan 2010 11:21:43 -0800 Subject: [PATCH] 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). --- utilities/ovs-vsctl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; -- 2.30.2