From 21a5088ba447f31d0bcbde3106550ea863b801af Mon Sep 17 00:00:00 2001 From: jmg Date: Fri, 20 Jun 2003 23:59:25 +0000 Subject: make pciconf understand it's own output as stated in the manpage. pciconf -r none8@pci1:12:2: 0x0 now works. PR: bin/10312 Submitted by: Castor Fu --- usr.sbin/pciconf/pciconf.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'usr.sbin/pciconf') diff --git a/usr.sbin/pciconf/pciconf.c b/usr.sbin/pciconf/pciconf.c index 764fd3d..0dc9dcc 100644 --- a/usr.sbin/pciconf/pciconf.c +++ b/usr.sbin/pciconf/pciconf.c @@ -425,9 +425,17 @@ load_vendors(void) static struct pcisel getsel(const char *str) { - char *ep = (char*) str; + char *ep = strchr(str, '@'); + char *epbase; struct pcisel sel; - + + if (ep == NULL) + ep = (char *)str; + else + ep++; + + epbase = ep; + if (strncmp(ep, "pci", 3) == 0) { ep += 3; sel.pc_bus = strtoul(ep, &ep, 0); @@ -440,10 +448,10 @@ getsel(const char *str) ep++; sel.pc_func = strtoul(ep, &ep, 0); } + if (*ep == ':') + ep++; } - if (*ep == ':') - ep++; - if (*ep || ep == str) + if (*ep != '\x0' || ep == epbase) errx(1, "cannot parse selector %s", str); return sel; } -- cgit v1.1