2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-29 15:28:56 +00:00

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).
This commit is contained in:
Ben Pfaff
2010-01-27 11:21:43 -08:00
parent 93255bc565
commit 5128bd9c3c

View 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;