Skip to content

Commit 710c29e

Browse files
Edwin GroothuisEdwin Groothuis
authored andcommitted
pciconf(8) removes characters after an #, therefor remove them.
Also remove \s used to escape 's.
1 parent 22d82e6 commit 710c29e

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

tools/tools/pciid/mk_pci_vendors.pl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
exit 0;
185185

186186

187-
# Parse a line from the Boemler file and place the vendor id, pciid,
187+
# Parse a line from the Boemler CSV file and place the vendor id, pciid,
188188
# vendor description and description in the scalars.
189189
#
190190
# Returns 0 if there is a problem.
@@ -194,17 +194,19 @@ ($\$\$\$\$)
194194
my ($line, $vendorid_ref, $pciid_ref, $vendor_ref, $descr_ref) = @_;
195195

196196
my @a = split(/","/, $line);
197-
$a[0] =~ s/0x//;
197+
$a[0] =~ s/0x//; # 0x1234 -> 1234
198198
$a[1] =~ s/0x//;
199199

200-
$a[0] =~ s/^"//;
200+
$a[0] =~ s/^"//; # Remove starting or trailing "
201201
$a[4] =~ s/"$//;
202202

203-
$a[0] = uc($a[0]);
203+
$a[0] = uc($a[0]); # Some are lowercase hex-digits
204204
$a[1] = uc($a[1]);
205205

206+
# Length of the Vendor ID or PCI ID is not four hex-digits, ignore it
206207
return 0 if (length($a[0]) != 4 || length($a[1]) != 4);
207208

209+
# If there is no description, see if the chip data exists and use that
208210
if ($a[4] eq "") {
209211
if ($a[3] ne "") {
210212
$a[4] = $a[3];
@@ -218,9 +220,7 @@ ($\$\$\$\$)
218220
$$pciid_ref = $a[1];
219221
$$vendor_ref = $a[2];
220222
$$descr_ref = clean_descr($a[4]);
221-
if ($a[3] =~ /[a-zA-Z0-0]/) {
222-
$$descr_ref .= clean_descr(" ($a[3])");
223-
}
223+
$$descr_ref .= clean_descr(" ($a[3])") if ($a[3] =~ /[a-zA-Z0-0]/);
224224
return 1;
225225
}
226226

@@ -255,7 +255,9 @@ ($)
255255
{
256256
my ($descr) = @_;
257257

258-
$descr =~ s/[^[:print:]]//g;
258+
$descr =~ s/[^[:print:]]//g; # non-printable
259+
$descr =~ s/\\//g; # escape of 's
260+
$descr =~ s/\#/*/g; # pciconf(8) ignores data after this
259261

260262
return $descr;
261263
}

0 commit comments

Comments
 (0)