lspci: fix output of device info with new pci.ids

With a new pci id database, available at
http://pciids.sourceforge.net/v2.2/pci.ids.bz2
(or also in gzip/uncompressed format),
lspci was frequently ignoring the device.
The fix was to explicitly ignore comments.

--
Reading lspci.c again, memset(toybuf, 0, 4096); is needed because it 
initializes vname/devname to an empty state; removing that line would 
result in garbage text output/repetition of the wrong vendor and device
information.

HTH,
Isaac Dunham

diff --git a/toys/pending/lspci.c b/toys/pending/lspci.c
index c61f582..f07f8d2 100644
--- a/toys/pending/lspci.c
+++ b/toys/pending/lspci.c
@@ -67,7 +67,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);
   }
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to