diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2005-08-18 11:11:40 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2005-08-18 11:11:40 +0000 |
commit | 7df76a1312abf2cde530f56e174f80474eada996 (patch) | |
tree | d9efeb8fe5806e92404bdd52494116f96de02ae7 /usr.sbin/pciconf/pciconf.c | |
parent | 2af9b91993f14bb15892d9d6cf4b3262c7b76e17 (diff) | |
download | src-7df76a1312abf2cde530f56e174f80474eada996.tar.gz src-7df76a1312abf2cde530f56e174f80474eada996.zip |
Notes
Diffstat (limited to 'usr.sbin/pciconf/pciconf.c')
-rw-r--r-- | usr.sbin/pciconf/pciconf.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/usr.sbin/pciconf/pciconf.c b/usr.sbin/pciconf/pciconf.c index 828eb85595c7..8fc3146d1fd0 100644 --- a/usr.sbin/pciconf/pciconf.c +++ b/usr.sbin/pciconf/pciconf.c @@ -369,7 +369,8 @@ load_vendors(void) FILE *db; struct pci_vendor_info *cv; struct pci_device_info *cd; - char buf[100], str[100]; + char buf[1024], str[1024]; + char *ch; int id, error; /* @@ -391,8 +392,20 @@ load_vendors(void) if (fgets(buf, sizeof(buf), db) == NULL) break; + if ((ch = strchr(buf, '#')) != NULL) + *ch = '\0'; + ch = strchr(buf, '\0') - 1; + while (ch > buf && isspace(*ch)) + *ch-- = '\0'; + if (ch <= buf) + continue; + + /* Can't handle subvendor / subdevice entries yet */ + if (buf[0] == '\t' && buf[1] == '\t') + continue; + /* Check for vendor entry */ - if ((buf[0] != '\t') && (sscanf(buf, "%04x\t%[^\n]", &id, str) == 2)) { + if (buf[0] != '\t' && sscanf(buf, "%04x %[^\n]", &id, str) == 2) { if ((id == 0) || (strlen(str) < 1)) continue; if ((cv = malloc(sizeof(struct pci_vendor_info))) == NULL) { @@ -413,7 +426,7 @@ load_vendors(void) } /* Check for device entry */ - if ((buf[0] == '\t') && (sscanf(buf + 1, "%04x\t%[^\n]", &id, str) == 2)) { + if (buf[0] == '\t' && sscanf(buf + 1, "%04x %[^\n]", &id, str) == 2) { if ((id == 0) || (strlen(str) < 1)) continue; if (cv == NULL) { |