Implement 'T' field matching.

Implement 'T' field matching. This is needed to prevent false
positives. However, it's not general enough. It only handles one field
and there's a ton of edge cases even with that it likely wouldn't
handle. To do it more generally and also eliminate a lot of the
hackiness that's in this program now, we'd need to creating
directories for lookups ala awk, pearl, python, etc. It appears to be
sufficient, though, to get my keyboard loaded on boot.

Sponsored by: Netflix
This commit is contained in:
Warner Losh 2018-02-17 06:57:25 +00:00
parent 7e1637e491
commit b9c40202d8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329442

View file

@ -265,6 +265,7 @@ search_hints(const char *bus, const char *dev, const char *pnpinfo)
bit = -1;
do {
switch (*cp) {
/* All integer fields */
case 'I':
case 'J':
case 'G':
@ -300,6 +301,7 @@ search_hints(const char *bus, const char *dev, const char *pnpinfo)
break;
}
break;
/* String fields */
case 'D':
case 'Z':
getstr(&ptr, val1);
@ -313,6 +315,22 @@ search_hints(const char *bus, const char *dev, const char *pnpinfo)
if (strcmp(s, val1) != 0)
notme++;
break;
/* Key override fields, required to be last in the string */
case 'T':
/*
* This is imperfect and only does one key and will be redone
* to be more general for multiple keys. Currently, nothing
* does that.
*/
if (dump_flag) /* No per-row data stored */
break;
if (cp[strlen(cp) - 1] == ';') /* Skip required ; at end */
cp[strlen(cp) - 1] = '\0'; /* in case it's not there */
if ((s = strstr(pnpinfo, cp + 2)) == NULL)
notme++;
else if (s > pnpinfo && s[-1] != ' ')
notme++;
break;
default:
fprintf(stderr, "Unknown field type %c\n:", *cp);
break;