Bugfix from Isaac Dunham (new pci database has # comments in it) and some minor cleanups I had in my tree already.
diff --git a/toys/pending/lspci.c b/toys/pending/lspci.c
index c61f582..aef40d8 100644
--- a/toys/pending/lspci.c
+++ b/toys/pending/lspci.c
@@ -20,10 +20,11 @@
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 @@
if (id[i] == buf[i]) i++;
else return 0;
}
+
return buf + i + 2;
}
@@ -67,7 +69,8 @@
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 @@
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;