From 67ba22986d84b8d793d9bb39d6d7545204924124 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 24 May 2014 22:40:41 -0500 Subject: Bugfix from Isaac Dunham (new pci database has # comments in it) and some minor cleanups I had in my tree already. --- toys/pending/lspci.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'toys') diff --git a/toys/pending/lspci.c b/toys/pending/lspci.c index c61f5820..aef40d8b 100644 --- a/toys/pending/lspci.c +++ b/toys/pending/lspci.c @@ -20,10 +20,11 @@ config LSPCI_TEXT depends on LSPCI default n help - usage: lspci [-n] [-i /usr/share/misc/pci.ids ] + usage: lspci [-n] [-i FILE ] -n Numeric output (repeat for readable and numeric) - -i Path to PCI ID database + -i PCI ID database (default /usr/share/misc/pci.ids) + */ #define FOR_lspci @@ -44,6 +45,7 @@ char *id_check_match(char *id, char *buf) if (id[i] == buf[i]) i++; else return 0; } + return buf + i + 2; } @@ -67,7 +69,8 @@ int find_in_db(char *vendid, char *devid, FILE *fil, char *vname, char *devname) strncpy(vname, vtext, strlen(vtext) - 1); } while (!*devname) { - if (!fgets(buf, 255, fil) || *buf != '\t') return 1; + if (!fgets(buf, 255, fil) || (*buf != '\t' && *buf != '#')) return 1; + if (*buf == '#') continue; if ((dtext = id_check_match(devid, buf + 1))) strncpy(devname, dtext, strlen(dtext) - 1); } @@ -139,7 +142,7 @@ int do_lspci(struct dirtree *new) void lspci_main(void) { - if (CFG_LSPCI_TEXT && (TT.numeric != 1)) { + if (CFG_LSPCI_TEXT && TT.numeric != 1) { TT.db = fopen(TT.ids ? TT.ids : "/usr/share/misc/pci.ids", "r"); if (errno) { TT.numeric = 1; -- cgit v1.2.3