184184exit 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
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