Fixes from PR#23177. Various lint/logic fixes:

Fix some non-initialized variables
close the output files when done
Redo the printing for RCS strings so they don't expand in the awk script too
Do proper tests for variables existance before accessing

Verified output from all scripts is identical to original versions
This commit is contained in:
jmc 2003-12-15 07:32:20 +00:00
parent 9efe6a5366
commit 43bf89bfc6
12 changed files with 138 additions and 117 deletions

View File

@ -1,6 +1,6 @@
#! /usr/bin/awk -f
#
# $NetBSD: devlist2h.awk,v 1.5 1998/01/09 06:59:10 thorpej Exp $
# $NetBSD: devlist2h.awk,v 1.6 2003/12/15 07:32:20 jmc Exp $
#
# Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
# Copyright (c) 1995, 1996 Christopher G. Demetriou
@ -32,7 +32,7 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
BEGIN {
ndevices = 0
ndevices = blanklines = 0
fbid = 0
dfile="diodevs_data.h"
hfile="diodevs.h"
@ -41,7 +41,7 @@ NR == 1 {
VERSION = $0
gsub("\\$", "", VERSION)
printf("/*\t\$NetBSD\$\t*/\n\n") > dfile
printf("/*\t$NetBSD" "$\t*/\n\n") > dfile
printf("/*\n") > dfile
printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> dfile
@ -50,7 +50,7 @@ NR == 1 {
printf(" *\t%s\n", VERSION) > dfile
printf(" */\n") > dfile
printf("/*\t\$NetBSD\$\t*/\n\n") > hfile
printf("/*\t$NetBSD" "$\t*/\n\n") > hfile
printf("/*\n") > hfile
printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> hfile
@ -61,7 +61,7 @@ NR == 1 {
next
}
$1 == "device" {
NF > 0 && $1 == "device" {
ndevices++
devices[ndevices, 1] = $2 # nickname
@ -95,7 +95,7 @@ $1 == "device" {
next
}
$1 == "framebuffer" {
NF > 0 && $1 == "framebuffer" {
ndevices++
devices[ndevices, 1] = $2 # nickname
@ -165,4 +165,6 @@ END {
printf("};\n") > dfile
printf("#endif /* DIOVERBOSE */\n") > dfile
close(dfile)
close(hfile)
}

View File

@ -1,4 +1,4 @@
# $NetBSD: devlist2h.awk,v 1.2 2002/08/05 20:58:36 fredette Exp $
# $NetBSD: devlist2h.awk,v 1.3 2003/12/15 07:32:20 jmc Exp $
# $OpenBSD: devlist2h.awk,v 1.4 2001/03/29 00:43:00 mickey Exp $
@ -33,7 +33,7 @@
#
BEGIN {
ncpu = 0;
ncpu = busted = 0;
cpuh="cpudevs.h";
cpud="cpudevs_data.h";
SUBSEP = "_";
@ -59,24 +59,19 @@ busted {
}
NR == 1 {
printf("/*\t$NetBSD: devlist2h.awk,v 1.2 2002/08/05 20:58:36 fredette Exp $\t*/\n\n") > cpud;
printf("/*\t$NetBSD" "$\t*/\n\n") > cpud;
printf("/* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. */\n\n") \
> cpud;
printf("/*\t$NetBSD: devlist2h.awk,v 1.2 2002/08/05 20:58:36 fredette Exp $\t*/\n\n") > cpuh;
printf("/*\t$NetBSD" "$\t*/\n\n") > cpuh;
printf("/* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. */\n\n") \
> cpuh;
}
/^\$/ {
VERSION = $0;
gsub("\\$", "", VERSION);
printf("/* generated from: %s */\n\n", VERSION) > cpud;
printf("/* generated from: %s */\n\n", VERSION) > cpuh;
next;
}
$1 == "type" {
NF > 0 && $1 == "type" {
printf("#define\tHPPA_TYPE_%s\t%s\n", toupper($2), $3) > cpuh;
types[tolower($2)] = toupper($2);
next;
@ -133,5 +128,6 @@ END {
exit(1);
}
printf("{ -1 }\n") > cpud;
close(cpud)
close(cpuh)
}

View File

@ -1,5 +1,5 @@
#! /usr/bin/awk -f
# $NetBSD: devlist2h.awk,v 1.3 2003/12/12 06:50:54 jmc Exp $
# $NetBSD: devlist2h.awk,v 1.4 2003/12/15 07:32:20 jmc Exp $
#
# Copyright (c) 1998 The NetBSD Foundation, Inc.
# All rights reserved.
@ -43,7 +43,7 @@ NR == 1 {
VERSION = $0
gsub("\\$", "", VERSION)
printf("/*\t\$NetBSD\$\t*/\n\n") > dfile
printf("/*\t$NetBSD" "$\t*/\n\n") > dfile
printf("/*\n") > dfile
printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> dfile

View File

@ -1,5 +1,5 @@
#! /usr/bin/awk -f
# $NetBSD: devlist2h.awk,v 1.3 2003/10/24 17:01:58 mycroft Exp $
# $NetBSD: devlist2h.awk,v 1.4 2003/12/15 07:32:20 jmc Exp $
#
# Copyright (c) 1995, 1996 Christopher G. Demetriou
# All rights reserved.
@ -30,7 +30,7 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
BEGIN {
nproducts = nvendors = 0
nproducts = nvendors = blanklines = 0
dfile="cardbusdevs_data.h"
hfile="cardbusdevs.h"
}
@ -38,7 +38,7 @@ NR == 1 {
VERSION = $0
gsub("\\$", "", VERSION)
printf("/*\t$NetBSD: devlist2h.awk,v 1.3 2003/10/24 17:01:58 mycroft Exp $\t*/\n\n") > dfile
printf("/*\t$NetBSD" "$\t*/\n\n") > dfile
printf("/*\n") > dfile
printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> dfile
@ -47,7 +47,7 @@ NR == 1 {
printf(" *\t%s\n", VERSION) > dfile
printf(" */\n") > dfile
printf("/*\t$NetBSD: devlist2h.awk,v 1.3 2003/10/24 17:01:58 mycroft Exp $\t*/\n\n") > hfile
printf("/*\t$NetBSD" "$\t*/\n\n") > hfile
printf("/*\n") > hfile
printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> hfile
@ -58,7 +58,7 @@ NR == 1 {
next
}
$1 == "vendor" {
NF > 0 && $1 == "vendor" {
nvendors++
vendorindex[$2] = nvendors; # record index for this name, for later.
@ -103,7 +103,7 @@ $1 == "vendor" {
next
}
$1 == "product" {
NF > 0 && $1 == "product" {
nproducts++
products[nproducts, 1] = $2; # vendor name
@ -183,7 +183,7 @@ END {
printf("\t \"") > dfile
j = 3;
needspace = 0;
while (vendors[vendi, j] != "") {
while ((vendi, j) in vendors) {
if (needspace)
printf(" ") > dfile
printf("%s", vendors[vendi, j]) > dfile
@ -195,7 +195,7 @@ END {
printf("\t \"") > dfile
j = 4;
needspace = 0;
while (products[i, j] != "") {
while ((i, j) in products) {
if (needspace)
printf(" ") > dfile
printf("%s", products[i, j]) > dfile
@ -214,7 +214,7 @@ END {
printf("\t \"") > dfile
j = 3;
needspace = 0;
while (vendors[i, j] != "") {
while ((i, j) in vendors) {
if (needspace)
printf(" ") > dfile
printf("%s", vendors[i, j]) > dfile
@ -227,4 +227,6 @@ END {
}
printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
printf("};\n") > dfile
close(dfile)
close(hfile)
}

View File

@ -1,5 +1,5 @@
#! /usr/bin/awk -f
# $NetBSD: devlist2h.awk,v 1.6 2001/01/18 20:28:25 jdolecek Exp $
# $NetBSD: devlist2h.awk,v 1.7 2003/12/15 07:32:20 jmc Exp $
#
# Copyright (c) 1995, 1996 Christopher G. Demetriou
# All rights reserved.
@ -30,7 +30,7 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
BEGIN {
nproducts = nvendors = 0
nproducts = nvendors = blanklines = 0
dfile="eisadevs_data.h"
hfile="eisadevs.h"
}
@ -38,7 +38,7 @@ NR == 1 {
VERSION = $0
gsub("\\$", "", VERSION)
printf("/*\t\$NetBSD\$\t*/\n\n") > dfile
printf("/*\t$NetBSD" "$\t*/\n\n") > dfile
printf("/*\n") > dfile
printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> dfile
@ -47,7 +47,7 @@ NR == 1 {
printf(" *\t%s\n", VERSION) > dfile
printf(" */\n") > dfile
printf("/*\t\$NetBSD\$\t*/\n\n") > hfile
printf("/*\t$NetBSD" "$\t*/\n\n") > hfile
printf("/*\n") > hfile
printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> hfile
@ -58,7 +58,7 @@ NR == 1 {
next
}
$1 == "vendor" {
NF > 0 && $1 == "vendor" {
nvendors++
vendorindex[$2] = nvendors; # record index for this name, for later.
@ -86,7 +86,7 @@ $1 == "vendor" {
next
}
$1 == "product" {
NF > 0 && $1 == "product" {
nproducts++
products[nproducts, 1] = $2; # vendor name
@ -96,7 +96,7 @@ $1 == "product" {
i = vendorindex[products[nproducts, 1]]; j = 2;
needspace = 0;
while (vendors[i, j] != "") {
while ((i,j) in vendors) {
if (needspace)
printf(" ") > hfile
printf("%s", vendors[i, j]) > hfile
@ -176,7 +176,7 @@ END {
printf("\t \"") > dfile
j = 2;
needspace = 0;
while (vendors[i, j] != "") {
while ((i, j) in vendors) {
if (needspace)
printf(" ") > dfile
printf("%s", vendors[i, j]) > dfile
@ -188,4 +188,6 @@ END {
}
printf("\t{ 0, NULL, NULL, }\n") > dfile
printf("};\n") > dfile
close(dfile)
close(hfile)
}

View File

@ -1,5 +1,5 @@
#! /usr/bin/awk -f
# $NetBSD: devlist2h.awk,v 1.5 2001/11/13 07:52:41 lukem Exp $
# $NetBSD: devlist2h.awk,v 1.6 2003/12/15 07:32:20 jmc Exp $
#
# Copyright (c) 1998 The NetBSD Foundation, Inc.
# All rights reserved.
@ -64,7 +64,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
function collectline(f, line) {
function collectline(f) {
oparen = 0
line = ""
while (f <= NF) {
@ -104,13 +104,13 @@ function checkdecl() {
printf("\tconst struct isapnp_matchinfo *devcompat;\n") > hfile
printf("\tint ncompat;\n") > hfile
printf("};\n\n") > hfile
printf("\n#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"\$NetBSD\$\");\n\n") > cfile
printf("\n#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"$NetBSD" "$\");\n\n") > cfile
printf("#include <sys/param.h>\n") > cfile
printf("#include <dev/isapnp/isapnpdevs.h>\n\n") > cfile
}
}
BEGIN {
decl = done = ncompat = nlogicals = ndriver = 0
decl = done = ncompat = nlogicals = ndriver = blanklines = ncompats = 0
cfile="isapnpdevs.c"
hfile="isapnpdevs.h"
}
@ -118,7 +118,7 @@ NR == 1 {
VERSION = $0
gsub("\\$", "", VERSION)
printf("/*\t\$NetBSD\$\t*/\n\n") > cfile
printf("/*\t$NetBSD" "$\t*/\n\n") > cfile
printf("/*\n") > cfile
printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> cfile
@ -127,7 +127,7 @@ NR == 1 {
printf(" *\t%s\n", VERSION) > cfile
printf(" */\n") > cfile
printf("/*\t\$NetBSD\$\t*/\n\n") > hfile
printf("/*\t$NetBSD" "$\t*/\n\n") > hfile
printf("/*\n") > hfile
printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> hfile
@ -138,36 +138,36 @@ NR == 1 {
printf("\n") > hfile
next
}
$1 == "driver" {
NF > 0 && $1 == "driver" {
checkdecl()
ndriver++
driverindex[$2] = ndriver;
driver[ndriver, 1] = $2;
driver[ndriver, 2] = collectline(3, line);
driver[ndriver, 2] = collectline(3);
printf("/* %s */\n", driver[ndriver, 2]) > hfile
printf("extern const struct isapnp_devinfo isapnp_%s_devinfo;\n",
driver[ndriver, 1]) > hfile
next
}
$1 == "devlogic" {
NF > 0 && $1 == "devlogic" {
checkdecl()
nlogicals++
logicals[nlogicals, 1] = $2;
logicals[nlogicals, 2] = $3;
logicals[nlogicals, 3] = $4;
logicals[nlogicals, 4] = collectline(5, line);
logicals[nlogicals, 4] = collectline(5);
next
}
$1 == "devcompat" {
NF > 0 && $1 == "devcompat" {
checkdecl()
ncompats++
compats[ncompats, 1] = $2;
compats[ncompats, 2] = $3;
compats[ncompats, 3] = $4;
compats[ncompats, 4] = collectline(5, line);
compats[ncompats, 4] = collectline(5);
next
}
{
@ -228,4 +228,6 @@ END {
printf("};\n\n") > cfile;
}
close(cfile)
close(hfile)
}

View File

@ -1,5 +1,5 @@
#! /usr/bin/awk -f
# $NetBSD: devlist2h.awk,v 1.1 2000/05/11 15:42:04 jdolecek Exp $
# $NetBSD: devlist2h.awk,v 1.2 2003/12/15 07:32:20 jmc Exp $
#
# Copyright (c) 1995, 1996 Christopher G. Demetriou
# All rights reserved.
@ -33,7 +33,7 @@
# Adapted for MCA needs by Jaromir Dolecek.
BEGIN {
nproducts = nvendors = 0
nproducts = nvendors = blanklines = 0
dfile="mcadevs_data.h"
hfile="mcadevs.h"
FS=" "
@ -44,7 +44,7 @@ NR == 1 {
VERSION = $0
gsub("\\$", "", VERSION)
printf("/*\t\$NetBSD\$\t*/\n\n") > dfile
printf("/*\t$NetBSD" "$\t*/\n\n") > dfile
printf("/*\n") > dfile
printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> dfile
@ -53,7 +53,7 @@ NR == 1 {
printf(" *\t%s\n", VERSION) > dfile
printf(" */\n") > dfile
printf("/*\t\$NetBSD\$\t*/\n\n") > hfile
printf("/*\t$NetBSD" "$\t*/\n\n") > hfile
printf("/*\n") > hfile
printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> hfile
@ -65,7 +65,7 @@ NR == 1 {
next
}
$1 == "product" {
NF > 0 && $1 == "product" {
nproducts++
alias = $3
@ -110,4 +110,6 @@ END {
}
printf(" { 0, NULL, }\n") > dfile
printf("};\n") > dfile
close(dfile)
close(hfile)
}

View File

@ -1,5 +1,5 @@
#! /usr/bin/awk -f
# $NetBSD: devlist2h.awk,v 1.3 2000/05/08 13:25:35 augustss Exp $
# $NetBSD: devlist2h.awk,v 1.4 2003/12/15 07:32:20 jmc Exp $
#
# Copyright (c) 1998 The NetBSD Foundation, Inc.
# All rights reserved.
@ -64,7 +64,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
function collectline(f, line) {
function collectline(f) {
oparen = 0
line = ""
while (f <= NF) {
@ -91,7 +91,7 @@ function collectline(f, line) {
return line
}
BEGIN {
nmodels = nouis = 0
nmodels = nouis = nuios = blanklines = firstdone = 0
hfile="miidevs.h"
dfile="miidevs_data.h"
}
@ -99,7 +99,7 @@ NR == 1 {
VERSION = $0
gsub("\\$", "", VERSION)
printf("/*\t\$NetBSD\$\t*/\n\n") > hfile
printf("/*\t$NetBSD" "$\t*/\n\n") > hfile
printf("/*\n") > hfile
printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> hfile
@ -108,7 +108,7 @@ NR == 1 {
printf(" *\t%s\n", VERSION) > hfile
printf(" */\n") > hfile
printf("/*\t\$NetBSD\$\t*/\n\n") > dfile
printf("/*\t$NetBSD" "$\t*/\n\n") > dfile
printf("/*\n") > dfile
printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> dfile
@ -119,7 +119,7 @@ NR == 1 {
next
}
$1 == "oui" {
NF > 0 && $1 == "oui" {
nuios++
ouiindex[$2] = nouis; # record index for this name, for later.
@ -128,11 +128,11 @@ $1 == "oui" {
ouis[nouis, 2] = $3; # id
printf("#define\tMII_OUI_%s\t%s\t", ouis[nouis, 1],
ouis[nouis, 2]) > hfile
ouis[nouis, 3] = collectline(4, line)
ouis[nouis, 3] = collectline(4)
printf("/* %s */\n", ouis[nouis, 3]) > hfile
next
}
$1 == "model" {
NF > 0 && $1 == "model" {
nmodels++
models[nmodels, 1] = $2; # oui name
@ -142,7 +142,7 @@ $1 == "model" {
printf("#define\tMII_MODEL_%s_%s\t%s\n", models[nmodels, 1],
models[nmodels, 2], models[nmodels, 3]) > hfile
models[nmodels, 4] = collectline(5, line)
models[nmodels, 4] = collectline(5)
printf("#define\tMII_STR_%s_%s\t\"%s\"\n",
models[nmodels, 1], models[nmodels, 2],
@ -168,4 +168,6 @@ $1 == "model" {
END {
printf(" { 0, 0, NULL }\n") > dfile
printf("};\n") > dfile
close(dfile)
close(hfile)
}

View File

@ -1,5 +1,5 @@
#! /usr/bin/awk -f
# $NetBSD: devlist2h.awk,v 1.7 2003/12/05 04:33:27 grant Exp $
# $NetBSD: devlist2h.awk,v 1.8 2003/12/15 07:32:21 jmc Exp $
#
# Copyright (c) 1995, 1996 Christopher G. Demetriou
# All rights reserved.
@ -30,7 +30,7 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
BEGIN {
nproducts = nvendors = 0
nproducts = nvendors = blanklines = 0
dfile="pcidevs_data.h"
hfile="pcidevs.h"
}
@ -38,7 +38,7 @@ NR == 1 {
VERSION = $0
gsub("\\$", "", VERSION)
printf("/*\t$NetBSD: devlist2h.awk,v 1.7 2003/12/05 04:33:27 grant Exp $\t*/\n\n") > dfile
printf("/*\t$NetBSD" "$\t*/\n\n") > dfile
printf("/*\n") > dfile
printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> dfile
@ -47,7 +47,7 @@ NR == 1 {
printf(" *\t%s\n", VERSION) > dfile
printf(" */\n") > dfile
printf("/*\t$NetBSD: devlist2h.awk,v 1.7 2003/12/05 04:33:27 grant Exp $\t*/\n\n") > hfile
printf("/*\t$NetBSD" "$\t*/\n\n") > hfile
printf("/*\n") > hfile
printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> hfile
@ -58,7 +58,7 @@ NR == 1 {
next
}
$1 == "vendor" {
NF > 0 && $1 == "vendor" {
nvendors++
vendorindex[$2] = nvendors; # record index for this name, for later.
@ -103,7 +103,7 @@ $1 == "vendor" {
next
}
$1 == "product" {
NF > 0 && $1 == "product" {
nproducts++
products[nproducts, 1] = $2; # vendor name
@ -174,7 +174,7 @@ END {
printf("\t \"") > dfile
j = 3;
needspace = 0;
while (vendors[vendi, j] != "") {
while ((vendi, j) in vendors) {
if (needspace)
printf(" ") > dfile
printf("%s", vendors[vendi, j]) > dfile
@ -186,7 +186,7 @@ END {
printf("\t \"") > dfile
j = 4;
needspace = 0;
while (products[i, j] != "") {
while ((i, j) in products) {
if (needspace)
printf(" ") > dfile
printf("%s", products[i, j]) > dfile
@ -205,7 +205,7 @@ END {
printf("\t \"") > dfile
j = 3;
needspace = 0;
while (vendors[i, j] != "") {
while ((i, j) in vendors) {
if (needspace)
printf(" ") > dfile
printf("%s", vendors[i, j]) > dfile
@ -218,4 +218,6 @@ END {
}
printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
printf("};\n") > dfile
close(dfile)
close(hfile)
}

View File

@ -1,5 +1,5 @@
#! /usr/bin/awk -f
# $NetBSD: devlist2h.awk,v 1.6 2003/10/22 00:17:39 christos Exp $
# $NetBSD: devlist2h.awk,v 1.7 2003/12/15 07:32:21 jmc Exp $
#
# Copyright (c) 1998 The NetBSD Foundation, Inc.
# All rights reserved.
@ -64,34 +64,34 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
function collectline(f, line) {
oparen = 0
line = ""
while (f <= NF) {
if ($f == "#") {
line = line "("
oparen = 1
f++
function collectline(_f, _line) {
_oparen = 0
_line = ""
while (_f <= NF) {
if ($_f == "#") {
_line = _line "("
_oparen = 1
_f++
continue
}
if (oparen) {
line = line $f
if (f < NF)
line = line " "
f++
if (_oparen) {
_line = _line $_f
if (_f < NF)
_line = _line " "
_f++
continue
}
line = line $f
if (f < NF)
line = line " "
f++
_line = _line $_f
if (_f < NF)
_line = _line " "
_f++
}
if (oparen)
line = line ")"
return line
if (_oparen)
_line = _line ")"
return _line
}
BEGIN {
nproducts = nvendors = 0
nproducts = nvendors = blanklines = 0
dfile="pcmciadevs_data.h"
hfile="pcmciadevs.h"
line=""
@ -100,7 +100,7 @@ NR == 1 {
VERSION = $0
gsub("\\$", "", VERSION)
printf("/*\t$NetBSD: devlist2h.awk,v 1.6 2003/10/22 00:17:39 christos Exp $\t*/\n\n") > dfile
printf("/*\t$NetBSD" "$\t*/\n\n") > dfile
printf("/*\n") > dfile
printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> dfile
@ -109,7 +109,7 @@ NR == 1 {
printf(" *\t%s\n", VERSION) > dfile
printf(" */\n") > dfile
printf("/*\t$NetBSD: devlist2h.awk,v 1.6 2003/10/22 00:17:39 christos Exp $\t*/\n\n") > hfile
printf("/*\t$NetBSD" "$\t*/\n\n") > hfile
printf("/*\n") > hfile
printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> hfile
@ -120,7 +120,7 @@ NR == 1 {
next
}
$1 == "vendor" {
NF > 0 && $1 == "vendor" {
nvendors++
vendorindex[$2] = nvendors; # record index for this name, for later.
@ -132,7 +132,7 @@ $1 == "vendor" {
printf("/* %s */\n", vendors[nvendors, 3]) > hfile
next
}
$1 == "product" {
NF > 0 && $1 == "product" {
nproducts++
products[nproducts, 1] = $2; # vendor name
@ -223,8 +223,13 @@ END {
printf("0") > dfile
printf(",\n") > dfile
vendi = vendorindex[products[i, 1]];
printf("\t \"%s\",\n", vendors[vendi, 3]) > dfile
if (products[i, 1] in vendorindex) {
vendi = vendorindex[products[i, 1]];
vendname = vendors[vendi, 3]
}
else
vendname = ""
printf("\t \"%s\",\n", vendname) > dfile
printf("\t \"%s\",\t}\n", products[i, 5]) > dfile
printf("\t,\n") > dfile
}
@ -240,4 +245,6 @@ END {
}
printf("\t{ 0, 0, { NULL, NULL, NULL, NULL }, 0, NULL, NULL, }\n") > dfile
printf("};\n") > dfile
close(dfile)
close(hfile)
}

View File

@ -1,5 +1,5 @@
#! /usr/bin/awk -f
# $NetBSD: devlist2h.awk,v 1.6 1998/01/09 06:56:23 thorpej Exp $
# $NetBSD: devlist2h.awk,v 1.7 2003/12/15 07:32:21 jmc Exp $
#
# Copyright (c) 1995, 1996 Christopher G. Demetriou
# All rights reserved.
@ -30,7 +30,7 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
BEGIN {
nproducts = 0
nproducts = ndevices = blanklines = 0
dfile="tcdevs_data.h"
hfile="tcdevs.h"
}
@ -38,7 +38,7 @@ NR == 1 {
VERSION = $0
gsub("\\$", "", VERSION)
printf("/*\t\$NetBSD\$\t*/\n\n") > dfile
printf("/*\t$NetBSD" "$\t*/\n\n") > dfile
printf("/*\n") > dfile
printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> dfile
@ -47,7 +47,7 @@ NR == 1 {
printf(" *\t%s\n", VERSION) > dfile
printf(" */\n") > dfile
printf("/*\t\$NetBSD\$\t*/\n\n") > hfile
printf("/*\t$NetBSD" "$\t*/\n\n") > hfile
printf("/*\n") > hfile
printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> hfile
@ -58,7 +58,7 @@ NR == 1 {
next
}
$1 == "device" {
NF > 0 && $1 == "device" {
ndevices++
devices[ndevices, 0] = $2; # devices id
@ -136,4 +136,6 @@ END {
}
printf("\t{ NULL, NULL, NULL, }\n") > dfile
printf("};\n") > dfile
close(dfile)
close(hfile)
}

View File

@ -1,5 +1,5 @@
#! /usr/bin/awk -f
# $NetBSD: devlist2h.awk,v 1.10 2003/10/28 10:35:12 augustss Exp $
# $NetBSD: devlist2h.awk,v 1.11 2003/12/15 07:32:21 jmc Exp $
#
# Copyright (c) 1995, 1996 Christopher G. Demetriou
# All rights reserved.
@ -30,7 +30,7 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
BEGIN {
nproducts = nvendors = 0
nproducts = nvendors = blanklines = 0
dfile="usbdevs_data.h"
hfile="usbdevs.h"
}
@ -39,11 +39,11 @@ NR == 1 {
gsub("\\$", "", VERSION)
if (os == "NetBSD")
printf("/*\t$NetBSD: devlist2h.awk,v 1.10 2003/10/28 10:35:12 augustss Exp $\t*/\n\n") > dfile
printf("/*\t$NetBSD" "$\t*/\n\n") > dfile
else if (os == "FreeBSD")
printf("/*\t$FreeBSD$\t*/\n\n") > dfile
printf("/*\t$FreeBSD" "$\t*/\n\n") > dfile
else if (os == "OpenBSD")
printf("/*\t$OpenBSD$\t*/\n\n") > dfile
printf("/*\t$OpenBSD" "$\t*/\n\n") > dfile
else
printf("/* ??? */\n\n") > dfile
printf("/*\n") > dfile
@ -55,11 +55,11 @@ NR == 1 {
printf(" */\n") > dfile
if (os == "NetBSD")
printf("/*\t$NetBSD: devlist2h.awk,v 1.10 2003/10/28 10:35:12 augustss Exp $\t*/\n\n") > hfile
printf("/*\t$NetBSD" "$\t*/\n\n") > hfile
else if (os == "FreeBSD")
printf("/*\t$FreeBSD$\t*/\n\n") > hfile
printf("/*\t$FreeBSD" "$\t*/\n\n") > hfile
else if (os == "OpenBSD")
printf("/*\t$OpenBSD$\t*/\n\n") > hfile
printf("/*\t$OpenBSD" "$\t*/\n\n") > hfile
else
printf("/* ??? */\n\n") > hfile
printf("/*\n") > hfile
@ -72,7 +72,7 @@ NR == 1 {
next
}
$1 == "vendor" {
NF > 0 && $1 == "vendor" {
nvendors++
vendorindex[$2] = nvendors; # record index for this name, for later.
@ -117,7 +117,7 @@ $1 == "vendor" {
next
}
$1 == "product" {
NF > 0 && $1 == "product" {
nproducts++
products[nproducts, 1] = $2; # vendor name
@ -188,7 +188,7 @@ END {
printf("\t \"") > dfile
j = 3;
needspace = 0;
while (vendors[vendi, j] != "") {
while ((vendi, j) in vendors) {
if (needspace)
printf(" ") > dfile
printf("%s", vendors[vendi, j]) > dfile
@ -200,7 +200,7 @@ END {
printf("\t \"") > dfile
j = 4;
needspace = 0;
while (products[i, j] != "") {
while ((i, j) in products) {
if (needspace)
printf(" ") > dfile
printf("%s", products[i, j]) > dfile
@ -219,7 +219,7 @@ END {
printf("\t \"") > dfile
j = 3;
needspace = 0;
while (vendors[i, j] != "") {
while ((i, j) in vendors) {
if (needspace)
printf(" ") > dfile
printf("%s", vendors[i, j]) > dfile
@ -232,4 +232,6 @@ END {
}
printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
printf("};\n") > dfile
close(dfile)
close(hfile)
}