summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2018-02-23 14:52:05 +0100
committerLubomir Rintel <lkundrak@v3.sk>2018-02-23 19:47:19 +0100
commit4c963d719c4892e82c997e63bd21ac88f23dcb17 (patch)
treefa5aaa752d4859a3a727157e5ebc03e3d51b3f3d
parent0c151ae39db5dc924e521fdcb40d189b455b2c9e (diff)
downloadNetworkManager-4c963d719c4892e82c997e63bd21ac88f23dcb17.tar.gz
libnm/utils: drop part after a dash in product name
It's always garbage. At this point we seem to reasonably handle all product names that come from hwdb.
-rw-r--r--libnm/nm-libnm-utils.c9
-rw-r--r--libnm/tests/test-general.c8
2 files changed, 17 insertions, 0 deletions
diff --git a/libnm/nm-libnm-utils.c b/libnm/nm-libnm-utils.c
index 4a4922b6ed..3621906597 100644
--- a/libnm/nm-libnm-utils.c
+++ b/libnm/nm-libnm-utils.c
@@ -543,11 +543,20 @@ nm_utils_fixup_product_string (const char *desc)
NULL,
};
char *desc_full;
+ char *p;
desc_full = _fixup_string (desc, IGNORED_PHRASES, IGNORED_WORDS, FALSE);
if (!desc_full)
return NULL;
+ /* Chop off everything after a '-'. */
+ for (p = desc_full; *p; p++) {
+ if (p[0] == ' ' && p[1] == '-' && p[2] == ' ') {
+ p[0] = '\0';
+ break;
+ }
+ }
+
nm_assert (g_utf8_validate (desc_full, -1, NULL));
return desc_full;
diff --git a/libnm/tests/test-general.c b/libnm/tests/test-general.c
index 6ae0e97c93..a6968c17ec 100644
--- a/libnm/tests/test-general.c
+++ b/libnm/tests/test-general.c
@@ -474,9 +474,17 @@ test_fixup_product_string (void)
T (nm_utils_fixup_product_string, "82559 Ethernet Controller", "82559");
T (nm_utils_fixup_product_string, "82559 InBusiness 10/100", "82559 InBusiness");
T (nm_utils_fixup_product_string, "8255xER/82551IT Fast Ethernet Controller", "8255xER/82551IT");
+ T (nm_utils_fixup_product_string, "82562 EM/EX/GX - PRO/100 VM Ethernet Controller", "82562 EM/EX/GX");
+ T (nm_utils_fixup_product_string, "82562 EM/EX/GX - PRO/100 VM (LOM) Ethernet Controller", "82562 EM/EX/GX");
+ T (nm_utils_fixup_product_string, "82562EM/EX/GX - PRO/100 VM (LOM) Ethernet Controller Mobile", "82562EM/EX/GX");
+ T (nm_utils_fixup_product_string, "82562ET/EZ/GT/GZ - PRO/100 VE Ethernet Controller", "82562ET/EZ/GT/GZ");
+ T (nm_utils_fixup_product_string, "82562ET/EZ/GT/GZ - PRO/100 VE (LOM) Ethernet Controller", "82562ET/EZ/GT/GZ");
+ T (nm_utils_fixup_product_string, "82562ET/EZ/GT/GZ - PRO/100 VE (LOM) Ethernet Controller Mobile", "82562ET/EZ/GT/GZ");
T (nm_utils_fixup_product_string, "82562EZ 10/100 Ethernet Controller", "82562EZ");
T (nm_utils_fixup_product_string, "82562G 10/100 Network Connection", "82562G");
T (nm_utils_fixup_product_string, "82562G-2 10/100 Network Connection", "82562G-2");
+ T (nm_utils_fixup_product_string, "82562G - PRO/100 VE Ethernet Controller Mobile", "82562G");
+ T (nm_utils_fixup_product_string, "82562G - PRO/100 VE (LOM) Ethernet Controller", "82562G");
T (nm_utils_fixup_product_string, "82562GT 10/100 Network Connection", "82562GT");
T (nm_utils_fixup_product_string, "82562GT-2 10/100 Network Connection", "82562GT-2");
T (nm_utils_fixup_product_string, "82562V 10/100 Network Connection", "82562V");