diff options
| -rw-r--r-- | hardinfo/vendor.c | 78 | ||||
| -rw-r--r-- | modules/devices.c | 4 | 
2 files changed, 23 insertions, 59 deletions
| diff --git a/hardinfo/vendor.c b/hardinfo/vendor.c index b52943ec..e5ab6951 100644 --- a/hardinfo/vendor.c +++ b/hardinfo/vendor.c @@ -330,46 +330,26 @@ const Vendor *vendor_match(const gchar *id_str, ...) {      return ret;  } -static const gchar *vendor_get_name_ex(const gchar * id_str, short shortest) -{ -    GSList *vendor; -    int found = 0; - -    if (!id_str) -        return NULL; +static const gchar *vendor_get_name_ex(const gchar * id_str, short shortest) { +    const Vendor *v = vendor_match(id_str, NULL); -    for (vendor = vendor_list; vendor; vendor = vendor->next) { -        Vendor *v = (Vendor *)vendor->data; - -        if (v) { -            if (v->match_case) { -                if (v->match_string && strstr(id_str, v->match_string)) -                    found = 1; -            } else { -                if (v->match_string && strcasestr(id_str, v->match_string)) -                    found = 1; -            } - -            if (found) { -                if (shortest) { -                    int sl = strlen(id_str); -                    int nl = (v->name) ? strlen(v->name) : 0; -                    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 null as if nothing -                     * was found */ -                    if (nl <= snl) -                        return (sl <= nl) ? NULL : v->name; -                    else -                        return (sl <= snl) ? NULL : v->name_short; -                } else -                    return v->name; -            } -        } +    if (v) { +        if (shortest) { +            int sl = strlen(id_str); +            int nl = (v->name) ? strlen(v->name) : 0; +            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; +            else +                return (sl <= snl) ? id_str : v->name_short; +        } else +            return v->name;      } -    return id_str; /* What about const? */ +    return id_str; /* Preserve an old behavior, but what about const? */  }  const gchar *vendor_get_name(const gchar * id_str) { @@ -380,27 +360,11 @@ const gchar *vendor_get_shortest_name(const gchar * id_str) {      return vendor_get_name_ex(id_str, 1);  } -const gchar *vendor_get_url(const gchar * id_str) -{ -    GSList *vendor; - -    if (!id_str) { -      return NULL; -    } - -    for (vendor = vendor_list; vendor; vendor = vendor->next) { -        Vendor *v = (Vendor *)vendor->data; - -        if (v) -            if (v->match_case) { -                if (v->match_string && strstr(id_str, v->match_string)) -                    return v->url; -            } else { -                if (v->match_string && strcasestr(id_str, v->match_string)) -                    return v->url; -            } +const gchar *vendor_get_url(const gchar * id_str) { +    const Vendor *v = vendor_match(id_str, NULL); -    } +    if (v) +        return v->url;      return NULL;  } diff --git a/modules/devices.c b/modules/devices.c index 90a7b89b..85e5c932 100644 --- a/modules/devices.c +++ b/modules/devices.c @@ -372,7 +372,7 @@ gchar *get_motherboard(void)      if (board_vendor) {          /* attempt to shorten */          tmp = vendor_get_shortest_name(board_vendor); -        if (tmp) { +        if (tmp && tmp != board_vendor) {              g_free(board_vendor);              board_vendor = g_strdup(tmp);          } @@ -384,7 +384,7 @@ gchar *get_motherboard(void)      if (product_vendor) {          /* attempt to shorten */          tmp = vendor_get_shortest_name(product_vendor); -        if (tmp) { +        if (tmp && tmp != product_vendor) {              g_free(product_vendor);              product_vendor = g_strdup(tmp);          } | 
