Ticket #94: pci-clean.2

File pci-clean.2, 1.9 KB (added by johndrinkwater, 19 years ago)

incorporates Korli's suggestion

Line 
1# Clean PCI header script
2#
3# Copyright 2006, Haiku.
4# Distributed under the terms of the MIT License.
5#
6# Authors:
7# John Drinkwater, john@nextraweb.com
8#
9# Use with http://pcidatabase.com/pci_c_header.php
10# run as: sed -f pci-clean pci-input > pci-output
11
12#s/[^:]\/\/.*$// # strip comments
13s/[^][A-Za-z0-9 "{}_,;=#!*()'.:+@/\t&\-]//g # strip unknown characters
14#s/[^[:alnum:][:punct:][:space:]]//g # ^^ is this cleaner ?
15s/&#[[:xdigit:]]*;//g # remove HTML escaped unicode..
16s/[é]//g # remove UTF prefixes, and other junk
17s/???//g # replace filler with something cleaner
18s/(?)//g # remove “Whats this” uncertanty
19/, ,/d # missing IDs
20/"", ""/d # entries with no information
21s/\\n//g # cheeky newlines
22#/PCI\\VEN/d # ugly PCI strings. Todo: delete lines?
23s/\\/\\\\/g # make PCI\VEN strings tidy. Todo: remove anyway?
24s/0X\([[:xdigit:]]\)/0x\1/g # some lines dont have clean xs
25s/0\*\([[:xdigit:]]\)/0x\1/g # some lines dont have clean xs
26s/0x /0x/g # clean redunant space
27#/x[A-Fa-f0-9]*O[A-Fa-f0-9]*/y/O/0/ # Greedy. Todo: find a better replacement ?
28/x[[:xdigit:]]*O[[:xdigit:]]*/ { # cull stupid people, hexes with O
29 s/O/0/ # Only does the first..
30}
31/0x[[:xdigit:]]\{5,8\}/d # weird IDs, remove. Todo: improve
32s/0xIBM\([[:xdigit:]]\{4\}\)/0x\1/g # stupid ID. Todo: delete { wait for pcidatabase }
33 # clean ##(#(#)) IDs into 0x((0)0)##
34s/^\([^"]*\)[^x"[:xdigit:]]\([[:xdigit:]]\{4\}\),/\1 0x\2,/g
35s/^\([^"]*\)[^x"[:xdigit:]]\([[:xdigit:]]\{3\}\),/\1 0x0\2,/g
36s/^\([^"]*\)[^x"[:xdigit:]]\([[:xdigit:]]\{2\}\),/\1 0x00\2,/g
37 # clean 0x### IDs into 0x0###
38s/0x\([[:xdigit:]]\{3\}\),/0x0\1,/g
39
40# now weʼll just strip the lines that dont obey!
41 # look at device table..
42/\t{ 0x[[:xdigit:]]\{4\}, [^"]/ {
43 # because devices classes shouldn't be looked at
44
45 s/0x\([[:xdigit:]]\{2\}\),/0x00\1,/g # make them all 4 wide
46 /, 0x[A-Fa-f0-9]\{4\},/!d # check device IDs are OK
47}
48