changeset 1314:bc618abf4fb2 draft

Bugfix from Isaac Dunham (new pci database has # comments in it) and some minor cleanups I had in my tree already.
author Rob Landley <rob@landley.net>
date Sat, 24 May 2014 22:40:41 -0500
parents 5d64dc59e569
children 0f42d83199a9
files toys/pending/lspci.c
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/toys/pending/lspci.c	Sat May 24 14:41:30 2014 -0500
+++ b/toys/pending/lspci.c	Sat May 24 22:40:41 2014 -0500
@@ -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;