libnm/utils: ignore parts of vendor name after a slash

At this point the test suite also contains all network vendor names
known to hwdb.
This commit is contained in:
Lubomir Rintel 2018-02-23 14:52:05 +01:00
parent f7805ab602
commit e22b1c1d94
2 changed files with 17 additions and 2 deletions

View file

@ -233,10 +233,21 @@ nm_utils_fixup_vendor_string (const char *desc)
NULL,
};
char *desc_full;
char *p;
desc_full = _fixup_string (desc, IGNORED_PHRASES, IGNORED_WORDS, TRUE);
if (desc_full)
nm_assert (g_utf8_validate (desc_full, -1, NULL));
if (!desc_full)
return NULL;
/* Chop off everything after a slash. */
for (p = desc_full; *p; p++) {
if ((p[0] == ' ' && p[1] == '/') || p[0] == '/') {
p[0] = '\0';
break;
}
}
nm_assert (g_utf8_validate (desc_full, -1, NULL));
return desc_full;
}

View file

@ -199,6 +199,7 @@ test_fixup_vendor_string (void)
T (nm_utils_fixup_vendor_string, "Logitec Corp.", "Logitec");
T (nm_utils_fixup_vendor_string, "Logitech, Inc.", "Logitech");
T (nm_utils_fixup_vendor_string, "LSI Corporation", "LSI");
T (nm_utils_fixup_vendor_string, "LSI Logic / Symbios Logic", "LSI Logic");
T (nm_utils_fixup_vendor_string, "Macronix, Inc. [MXIC]", "MXIC");
T (nm_utils_fixup_vendor_string, "Marvell Semiconductor, Inc.", "Marvell");
T (nm_utils_fixup_vendor_string, "Marvell Technology Group Ltd.", "Marvell");
@ -242,6 +243,7 @@ test_fixup_vendor_string (void)
T (nm_utils_fixup_vendor_string, "OpenMoko, Inc.", "OpenMoko");
T (nm_utils_fixup_vendor_string, "Option", "Option");
T (nm_utils_fixup_vendor_string, "OQO", "OQO");
T (nm_utils_fixup_vendor_string, "Oracle/SUN", "Oracle");
T (nm_utils_fixup_vendor_string, "Ovislink Corp.", "Ovislink");
T (nm_utils_fixup_vendor_string, "Packet Engines Inc.", "Packet Engines");
T (nm_utils_fixup_vendor_string, "Panasonic (Matsushita)", "Panasonic");
@ -264,6 +266,7 @@ test_fixup_vendor_string (void)
T (nm_utils_fixup_vendor_string, "Qualcomm Atheros Communications", "Qualcomm Atheros");
T (nm_utils_fixup_vendor_string, "Qualcomm Atheros", "Qualcomm Atheros");
T (nm_utils_fixup_vendor_string, "Qualcomm, Inc.", "Qualcomm");
T (nm_utils_fixup_vendor_string, "Qualcomm / Option", "Qualcomm");
T (nm_utils_fixup_vendor_string, "Quanta Computer, Inc.", "Quanta Computer");
T (nm_utils_fixup_vendor_string, "Quanta Microsystems, Inc.", "Quanta");
T (nm_utils_fixup_vendor_string, "Quantenna Communications, Inc.", "Quantenna");
@ -297,6 +300,7 @@ test_fixup_vendor_string (void)
T (nm_utils_fixup_vendor_string, "Standard Microsystems Corp [SMC]", "SMC");
T (nm_utils_fixup_vendor_string, "Standard Microsystems Corp.", "Standard");
T (nm_utils_fixup_vendor_string, "STMicroelectronics", "STMicroelectronics");
T (nm_utils_fixup_vendor_string, "Sundance Technology Inc / IC Plus Corp", "Sundance");
T (nm_utils_fixup_vendor_string, "Surecom Technology Corp.", "Surecom");
T (nm_utils_fixup_vendor_string, "Surecom Technology", "Surecom");
T (nm_utils_fixup_vendor_string, "Sweex", "Sweex");