diff options
| -rw-r--r-- | hardinfo/vendor.c | 34 | ||||
| -rw-r--r-- | includes/vendor.h | 1 | ||||
| -rw-r--r-- | modules/devices.c | 21 | 
3 files changed, 50 insertions, 6 deletions
| diff --git a/hardinfo/vendor.c b/hardinfo/vendor.c index 7646001c..b52943ec 100644 --- a/hardinfo/vendor.c +++ b/hardinfo/vendor.c @@ -330,9 +330,10 @@ const Vendor *vendor_match(const gchar *id_str, ...) {      return ret;  } -const gchar *vendor_get_name(const gchar * id_str) +static const gchar *vendor_get_name_ex(const gchar * id_str, short shortest)  {      GSList *vendor; +    int found = 0;      if (!id_str)          return NULL; @@ -340,20 +341,45 @@ const gchar *vendor_get_name(const gchar * id_str)      for (vendor = vendor_list; vendor; vendor = vendor->next) {          Vendor *v = (Vendor *)vendor->data; -        if (v) +        if (v) {              if (v->match_case) {                  if (v->match_string && strstr(id_str, v->match_string)) -                    return v->name; +                    found = 1;              } else {                  if (v->match_string && strcasestr(id_str, v->match_string)) -                    return v->name; +                    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; +            } +        }      }      return id_str; /* What about const? */  } +const gchar *vendor_get_name(const gchar * id_str) { +    return vendor_get_name_ex(id_str, 0); +} + +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; diff --git a/includes/vendor.h b/includes/vendor.h index 9fe1f995..1688010d 100644 --- a/includes/vendor.h +++ b/includes/vendor.h @@ -33,6 +33,7 @@ void vendor_init(void);  void vendor_cleanup(void);  const Vendor *vendor_match(const gchar *id_str, ...); /* end list of strings with NULL */  const gchar *vendor_get_name(const gchar *id_str); +const gchar *vendor_get_shortest_name(const gchar *id_str);  const gchar *vendor_get_url(const gchar *id_str);  void vendor_free(Vendor *v); diff --git a/modules/devices.c b/modules/devices.c index 35ded54c..90a7b89b 100644 --- a/modules/devices.c +++ b/modules/devices.c @@ -358,6 +358,7 @@ gchar *get_motherboard(void)      gchar *board_name, *board_vendor, *board_version;      gchar *product_name, *product_vendor, *product_version;      gchar *board_part = NULL, *product_part = NULL; +    const gchar *tmp;      int b = 0, p = 0;      gchar *ret; @@ -366,12 +367,28 @@ gchar *get_motherboard(void)      scan_dmi(FALSE);      board_name = dmi_get_str("baseboard-product-name"); -    board_vendor = dmi_get_str("baseboard-manufacturer");      board_version = dmi_get_str("baseboard-version"); +    board_vendor = dmi_get_str("baseboard-manufacturer"); +    if (board_vendor) { +        /* attempt to shorten */ +        tmp = vendor_get_shortest_name(board_vendor); +        if (tmp) { +            g_free(board_vendor); +            board_vendor = g_strdup(tmp); +        } +    }      product_name = dmi_get_str("system-product-name"); -    product_vendor = dmi_get_str("system-manufacturer");      product_version = dmi_get_str("system-version"); +    product_vendor = dmi_get_str("system-manufacturer"); +    if (product_vendor) { +        /* attempt to shorten */ +        tmp = vendor_get_shortest_name(product_vendor); +        if (tmp) { +            g_free(product_vendor); +            product_vendor = g_strdup(tmp); +        } +    }      if (board_vendor && product_vendor &&          strcmp(board_vendor, product_vendor) == 0) { | 
