From 06dfc1baefdee4d541036ed71c26853998d1b796 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dariusz=20Knoci=C5=84ski?= <dknoto@gmail.com>
Date: Fri, 18 Dec 2015 16:12:37 +0100
Subject: [PATCH] pci-header.awk: added workaround due to an error in the
operation of the logical operators '||' and '&&' in awk-4.1.3.
---
src/apps/devices/pci-header.awk | 52 +++++++++++++++++++++++++----------------
1 file changed, 32 insertions(+), 20 deletions(-)
diff --git a/src/apps/devices/pci-header.awk b/src/apps/devices/pci-header.awk
index f046ef1..7412ca9 100644
a
|
b
|
BEGIN {
|
36 | 36 | |
37 | 37 | # matches vendor - starts with an id as first thing on the line |
38 | 38 | # because this occurs first in the header file, we output it without worry |
39 | | /^[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] / { |
| 39 | /^[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] / { |
40 | 40 | |
41 | | if ( vendorcount++ > 0 ) { |
| 41 | if ( vendorcount++ > 0 ) { |
42 | 42 | formatting = ",\n" |
43 | 43 | } else { |
44 | 44 | formatting = "" |
… |
… |
BEGIN {
|
52 | 52 | printf formatting "\t{ 0x" vendorid ", \"" vendor "\", \"\" }" > ofile |
53 | 53 | } |
54 | 54 | |
55 | | # matches device |
56 | | /^\t[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] / { |
| 55 | # matches device |
| 56 | /^\t[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] / { |
57 | 57 | |
58 | 58 | device = substr($0, 8) |
59 | 59 | gsub( /\\/, "&&", device ) |
… |
… |
BEGIN {
|
66 | 66 | devices[devicecount, 2] = $1 |
67 | 67 | devices[devicecount, 3] = 0 |
68 | 68 | devices[devicecount, 4] = 0 |
69 | | devices[devicecount, 5] = device |
| 69 | devices[devicecount, 5] = device |
70 | 70 | } |
71 | 71 | |
72 | 72 | # matches subvendor device |
73 | | /^\t\t[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] / { |
| 73 | /^\t\t[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] / { |
74 | 74 | |
75 | 75 | device = substr($0, 14) |
76 | 76 | gsub( /\"/, "\\\"", device ) |
… |
… |
BEGIN {
|
78 | 78 | devicecount++ |
79 | 79 | devices[devicecount, 1] = vendorid |
80 | 80 | devices[devicecount, 2] = deviceid |
81 | | devices[devicecount, 3] = $1 |
| 81 | devices[devicecount, 3] = $1 |
82 | 82 | devices[devicecount, 4] = $2 |
83 | | devices[devicecount, 5] = device |
| 83 | devices[devicecount, 5] = device |
84 | 84 | } |
85 | 85 | |
86 | 86 | # match device class - store data for later |
87 | | /^C [[:xdigit:]][[:xdigit:]] / { |
| 87 | /^C [[:xdigit:]][[:xdigit:]] / { |
88 | 88 | |
89 | 89 | class = $2 |
90 | 90 | classname = substr($0, 7) |
… |
… |
BEGIN {
|
105 | 105 | classes[classcount, 4] = classname |
106 | 106 | classes[classcount, 5] = subclassname |
107 | 107 | classes[classcount, 6] = "" |
108 | | } |
| 108 | } |
109 | 109 | |
110 | 110 | # match programming interface |
111 | 111 | /^\t\t[[:xdigit:]][[:xdigit:]] / { |
… |
… |
BEGIN {
|
121 | 121 | classes[classcount, 4] = classname |
122 | 122 | classes[classcount, 5] = subclassname |
123 | 123 | classes[classcount, 6] = proginterfacename |
124 | | } |
| 124 | } |
125 | 125 | |
126 | 126 | # We've processed the file, now output. |
127 | 127 | END { |
… |
… |
END {
|
144 | 144 | print "\n} ;\n\n// Use this value for loop control during searching:\n#define PCI_DEVTABLE_LEN (sizeof(PciDevTable)/sizeof(PCI_DEVTABLE))\n" > ofile |
145 | 145 | |
146 | 146 | } |
147 | | |
| 147 | |
148 | 148 | if ( classcount > 0 ) { |
149 | 149 | print "typedef struct _PCI_CLASSCODETABLE\n{\n\tunsigned char BaseClass ;\n\tunsigned char SubClass ;\n\tunsigned char ProgIf ;" > ofile |
150 | 150 | print "\tconst char *\t\tBaseDesc ;\n\tconst char *\t\tSubDesc ;\n\tconst char *\t\tProgDesc ;\n} PCI_CLASSCODETABLE, *PPCI_CLASSCODETABLE ;\n" > ofile |
151 | 151 | print "PCI_CLASSCODETABLE PciClassCodeTable [] =\n{" > ofile |
152 | 152 | currentclass = classes[1, 1] |
153 | 153 | for (i = 1; i <= classcount; i++) { |
154 | | |
155 | | if (i != 1) { |
| 154 | |
| 155 | if (i != 1) { |
156 | 156 | formatting = ",\n" |
157 | | } else { |
| 157 | } else { |
158 | 158 | formatting = "" |
159 | 159 | } |
160 | 160 | |
161 | 161 | # pretty print separate classes |
162 | | if ( currentclass != classes[i, 1] ) { |
| 162 | if ( currentclass != classes[i, 1] ) { |
163 | 163 | formatting = formatting "\n" |
164 | 164 | currentclass = classes[i, 1] |
165 | 165 | } |
166 | | |
167 | | # if the next item has the same details, we know we're to skip ourselves |
| 166 | |
| 167 | # if the next item has the same details, we know we're to skip ourselves |
168 | 168 | # this is because the programming interface name needs to be used, and we dont have it ourselves |
169 | | if ( ( classes[i, 1] != classes[i+1, 1] ) || ( classes[i, 2] != classes[i+1, 2] ) || ( classes[i, 3] != classes[i+1, 3] ) ) { |
| 169 | |
| 170 | if (classes[i, 1] != classes[i+1, 1]) |
| 171 | { |
| 172 | printf formatting "\t{ 0x" classes[i, 1] ", 0x" classes[i, 2] ", 0x" classes[i, 3] ", \"" classes[i, 4] "\", \"" classes[i, 5] "\", \"" classes[i, 6] "\" }" > ofile |
| 173 | continue; |
| 174 | } |
| 175 | if (classes[i, 2] != classes[i+1, 2]) |
| 176 | { |
170 | 177 | printf formatting "\t{ 0x" classes[i, 1] ", 0x" classes[i, 2] ", 0x" classes[i, 3] ", \"" classes[i, 4] "\", \"" classes[i, 5] "\", \"" classes[i, 6] "\" }" > ofile |
| 178 | continue; |
| 179 | } |
| 180 | if (classes[i, 3] != classes[i+1, 3]) |
| 181 | { |
| 182 | printf formatting "\t{ 0x" classes[i, 1] ", 0x" classes[i, 2] ", 0x" classes[i, 3] ", \"" classes[i, 4] "\", \"" classes[i, 5] "\", \"" classes[i, 6] "\" }" > ofile |
| 183 | continue; |
171 | 184 | } |
172 | 185 | } |
173 | 186 | print "\n} ;\n\n// Use this value for loop control during searching:\n#define PCI_CLASSCODETABLE_LEN (sizeof(PciClassCodeTable)/sizeof(PCI_CLASSCODETABLE))\n" > ofile |
174 | | |
175 | 187 | } |
176 | 188 | |
177 | 189 | # this is rather ugly, maybe we should include this in a seperate file, and pull it in ? |