From 5587f3bf5d620e2f25e81e0587e01c978ca787dc Mon Sep 17 00:00:00 2001 From: Burt P Date: Wed, 24 Oct 2018 20:35:34 -0500 Subject: vendor: find shortest name tweaks If lengths are equal then prefer name_short > name > id_str. Signed-off-by: Burt P --- hardinfo/vendor.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'hardinfo/vendor.c') diff --git a/hardinfo/vendor.c b/hardinfo/vendor.c index e5ab6951..0e661bb9 100644 --- a/hardinfo/vendor.c +++ b/hardinfo/vendor.c @@ -340,11 +340,14 @@ static const gchar *vendor_get_name_ex(const gchar * id_str, short shortest) { int snl = (v->name_short) ? strlen(v->name_short) : 0; if (!nl) nl = 9999; if (!snl) snl = 9999; - /* if id_str is shortest, then return as if not found (see below) */ - if (nl <= snl) - return (sl <= nl) ? id_str : v->name; + /* if id_str is shortest, then return as if + * not found (see below). + * if all equal then prefer + * name_short > name > id_str. */ + if (nl < snl) + return (sl < nl) ? id_str : v->name; else - return (sl <= snl) ? id_str : v->name_short; + return (sl < snl) ? id_str : v->name_short; } else return v->name; } -- cgit v1.2.3