diff options
| author | Burt P <pburt0@gmail.com> | 2018-10-24 20:35:34 -0500 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2018-11-04 15:02:12 -0800 | 
| commit | 5587f3bf5d620e2f25e81e0587e01c978ca787dc (patch) | |
| tree | 242c268d03cad079bc29c396d4a1e40e985e3c9f | |
| parent | 90e4cedcfc40c17c833d4acce374027044ac7377 (diff) | |
vendor: find shortest name tweaks
If lengths are equal then prefer
name_short > name > id_str.
Signed-off-by: Burt P <pburt0@gmail.com>
| -rw-r--r-- | hardinfo/vendor.c | 11 | 
1 files changed, 7 insertions, 4 deletions
| 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;      } | 
