NetBSD Problem Report #23177

Received: (qmail 17330 invoked by uid 605); 17 Oct 2003 14:57:42 -0000
Message-Id: <Pine.NEB.4.58.0310171635220.24301@r2d2.rave.org>
Date: Fri, 17 Oct 2003 16:55:44 +0200 (CEST)
From: dieter <dieter.NetBSD@pandora.be>
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: dieter <dieter.NetBSD@pandora.be>
To: gnats-bugs@gnats.NetBSD.org
Subject: devlist2h.awk errors and warnings with GNU Awk 3.1.3
X-Send-Pr-Version: pine 4.58 ;)

>Number:         23177
>Category:       toolchain
>Synopsis:       devlist2h.awk errors and warnings with GNU Awk 3.1.3
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    toolchain-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Oct 17 14:58:00 +0000 2003
>Closed-Date:    Mon Dec 15 07:33:12 +0000 2003
>Last-Modified:  Mon Dec 15 07:34:00 +0000 2003
>Originator:     dieter Roelants
>Release:        NetBSD 1.6ZC
>Organization:

>Environment:
System: NetBSD okuma 1.6ZC NetBSD 1.6ZC (OKUMA) #70: Wed Oct 15 22:32:48 CEST 2003  root@okuma:/usr/src/sys/arch/i386/compile/OKUMA i386
Architecture: i386
Machine: i386
>Description:

	Since the GNU awk update in -current, some of the devlist2h.awk
	scripts (at least pcmcia and isapnp, I don't remember if
	there were others) let awk dump core with an abort signal.
	These and also other devlist2h.awk's produce a lot of
	warnings when run with --lint.


>How-To-Repeat:

	cd src/sys/dev/pcmcia
	awk --lint -f devlist2h.awk pcmciadevs
	(with GNU Awk 3.1.3)


>Fix:

	Attached are patches for:

	src/sys/arch/hp300/dev/devlist2h.awk
	src/sys/arch/hp700/dev/devlist2h.awk
	src/sys/dev/acpi/devlist2h.awk
	src/sys/dev/cardbus/devlist2h.awk
	src/sys/dev/eisa/devlist2h.awk
	src/sys/dev/isapnp/devlist2h.awk
	src/sys/dev/mca/devlist2h.awk
	src/sys/dev/mii/devlist2h.awk
	src/sys/dev/pci/devlist2h.awk
	src/sys/dev/pcmcia/devlist2h.awk
	src/sys/dev/tc/devlist2h.awk
	src/sys/dev/usb/devlist2h.awk

	I have verified that the patched scripts produce the same
	result as the in-tree header files. They do, except for
	src/sys/arch/hp700/dev/devlist2h.awk, which for some reason,
	unknown to me, prints its own ident string in the produced
	headers. (Well, I know why, because the script says so,
	but I don't know why this was done.)


--- src/sys/dev/acpi/devlist2h.awk	2003-02-04 02:42:32.000000000 +0100
+++ devlist2h.awk	2003-10-17 12:25:39.000000000 +0200
@@ -43,7 +43,7 @@
 	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
@@ -76,4 +76,6 @@
 		printf("\t},\n") > dfile
 	}
 	printf("};\n") > dfile
+
+	close(dfile)
 }

--- src/sys/dev/cardbus/devlist2h.awk	2001-02-07 11:05:37.000000000 +0100
+++ devlist2h.awk	2003-10-17 13:51:01.000000000 +0200
@@ -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 @@
 	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 @@
 	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 @@

 	next
 }
-$1 == "vendor" {
+NF > 0 && $1 == "vendor" {
 	nvendors++

 	vendorindex[$2] = nvendors;		# record index for this name, for later.
@@ -103,7 +103,7 @@

 	next
 }
-$1 == "product" {
+NF > 0 && $1 == "product" {
 	nproducts++

 	products[nproducts, 1] = $2;		# vendor name
@@ -183,7 +183,7 @@
 		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 @@
 		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 @@
 		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,7 @@
 	}
 	printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
 	printf("};\n") > dfile
+
+	close(dfile)
+	close(hfile)
 }

--- src/sys/dev/eisa/devlist2h.awk	2001-01-18 21:28:25.000000000 +0100
+++ devlist2h.awk	2003-10-17 12:59:55.000000000 +0200
@@ -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 @@
 	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 @@
 	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 @@

 	next
 }
-$1 == "vendor" {
+NF > 0 && $1 == "vendor" {
 	nvendors++

 	vendorindex[$2] = nvendors;	# record index for this name, for later.
@@ -86,7 +86,7 @@

 	next
 }
-$1 == "product" {
+NF > 0 && $1 == "product" {
 	nproducts++

 	products[nproducts, 1] = $2;		# vendor name
@@ -96,7 +96,7 @@

 	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 @@
 		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,7 @@
 	}
 	printf("\t{ 0, NULL, NULL, }\n") > dfile
 	printf("};\n") > dfile
+
+	close(dfile)
+	close(hfile)
 }

--- src/sys/arch/hp300/dev/devlist2h.awk	1998-01-09 07:59:10.000000000 +0100
+++ devlist2h.awk	2003-10-17 12:06:51.000000000 +0200
@@ -34,6 +34,7 @@
 BEGIN {
 	ndevices = 0
 	fbid = 0
+	blanklines = 0
 	dfile="diodevs_data.h"
 	hfile="diodevs.h"
 }
@@ -41,7 +42,7 @@
 	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 +51,7 @@
 	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 +62,7 @@

 	next
 }
-$1 == "device" {
+NF > 0 && $1 == "device" {
 	ndevices++

 	devices[ndevices, 1] = $2		# nickname
@@ -95,7 +96,7 @@

 	next
 }
-$1 == "framebuffer" {
+NF > 0 && $1 == "framebuffer" {
 	ndevices++

 	devices[ndevices, 1] = $2		# nickname
@@ -165,4 +166,7 @@
 	printf("};\n") > dfile

 	printf("#endif /* DIOVERBOSE */\n") > dfile
+
+	close(dfile)
+	close(hfile)
 }

--- src/sys/arch/hp700/dev/devlist2h.awk	2002-08-05 22:58:36.000000000 +0200
+++ devlist2h.awk	2003-10-17 12:09:51.000000000 +0200
@@ -36,6 +36,7 @@
 	ncpu = 0;
 	cpuh="cpudevs.h";
 	cpud="cpudevs_data.h";
+	busted = 0;
 	SUBSEP = "_";
 }

@@ -133,5 +134,8 @@
 		exit(1);
 	}
 	printf("{ -1 }\n") > cpud;
+
+	close(cpuh)
+	close(cpud)
 }

--- src/sys/dev/isapnp/devlist2h.awk	2001-11-13 08:52:41.000000000 +0100
+++ devlist2h.awk	2003-10-17 13:07:59.000000000 +0200
@@ -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 @@
 		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 = ncompats = nlogicals = ndriver = blanklines = 0
 	cfile="isapnpdevs.c"
 	hfile="isapnpdevs.h"
 }
@@ -118,7 +118,7 @@
 	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 @@
 	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 @@
 	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,7 @@
 		printf("};\n\n") > cfile;

 	}
+
+	close(cfile)
+	close(hfile)
 }

--- src/sys/dev/mca/devlist2h.awk	2000-05-11 17:42:04.000000000 +0200
+++ devlist2h.awk	2003-10-17 13:11:52.000000000 +0200
@@ -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 @@
 	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 @@
 	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 @@
 	next
 }

-$1 == "product" {
+NF > 0 && $1 == "product" {
 	nproducts++

 	alias = $3
@@ -110,4 +110,7 @@
 	}
 	printf("    { 0, NULL, }\n") > dfile
 	printf("};\n") > dfile
+
+	close(dfile)
+	close(hfile)
 }


--- src/sys/dev/mii/devlist2h.awk	2000-05-08 15:25:35.000000000 +0200
+++ devlist2h.awk	2003-10-17 15:21:42.000000000 +0200
@@ -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 @@
 	return line
 }
 BEGIN {
-	nmodels = nouis = 0
+	nmodels = blanklines = firstdone = 0
 	hfile="miidevs.h"
 	dfile="miidevs_data.h"
 }
@@ -99,7 +99,7 @@
 	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 @@
 	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,20 +119,14 @@

 	next
 }
-$1 == "oui" {
-	nuios++
+NF > 0 && $1 == "oui" {

-	ouiindex[$2] = nouis;		# record index for this name, for later.
-
-	ouis[nouis, 1] = $2;		# name
-	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)
-	printf("/* %s */\n", ouis[nouis, 3]) > hfile
+	# $2 is the name, $3 the id
+	printf("#define\tMII_OUI_%s\t%s\t", $2, $3) > hfile
+	printf("/* %s */\n", collectline(4)) > hfile
 	next
 }
-$1 == "model" {
+NF > 0 && $1 == "model" {
 	nmodels++

 	models[nmodels, 1] = $2;		# oui name
@@ -142,7 +136,7 @@
 	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 +162,7 @@
 END {
 	printf(" { 0, 0, NULL }\n") > dfile
 	printf("};\n") > dfile
+
+	close(hfile)
+	close(dfile)
 }

--- src/sys/dev/pci/devlist2h.awk	2001-01-18 14:03:22.000000000 +0100
+++ devlist2h.awk	2003-10-17 13:36:41.000000000 +0200
@@ -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 @@
 	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 @@
 	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 @@

 	next
 }
-$1 == "vendor" {
+NF > 0 && $1 == "vendor" {
 	nvendors++

 	vendorindex[$2] = nvendors;		# record index for this name, for later.
@@ -103,7 +103,7 @@

 	next
 }
-$1 == "product" {
+NF > 0 && $1 == "product" {
 	nproducts++

 	products[nproducts, 1] = $2;		# vendor name
@@ -174,7 +174,7 @@
 		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 @@
 		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 @@
 		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,7 @@
 	}
 	printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
 	printf("};\n") > dfile
+
+	close(dfile)
+	close(hfile)
 }

--- src/sys/dev/pcmcia/devlist2h.awk	2003-10-15 13:37:19.000000000 +0200
+++ devlist2h.awk	2003-10-17 14:00:40.000000000 +0200
@@ -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 @@
 	return line
 }
 BEGIN {
-	nproducts = nvendors = 0
+	nproducts = nvendors = blanklines = 0
 	dfile="pcmciadevs_data.h"
 	hfile="pcmciadevs.h"
 }
@@ -99,7 +99,7 @@
 	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
@@ -108,7 +108,7 @@
 	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
@@ -119,7 +119,7 @@

 	next
 }
-$1 == "vendor" {
+NF > 0 && $1 == "vendor" {
 	nvendors++

 	vendorindex[$2] = nvendors;		# record index for this name, for later.
@@ -127,29 +127,29 @@
 	vendors[nvendors, 2] = $3;		# id
 	printf("#define\tPCMCIA_VENDOR_%s\t%s\t", vendors[nvendors, 1],
 	    vendors[nvendors, 2]) > hfile
-	vendors[nvendors, 3] = collectline(4, line)
+	vendors[nvendors, 3] = collectline(4)
 	printf("/* %s */\n", vendors[nvendors, 3]) > hfile
 	next
 }
-$1 == "product" {
+NF > 0 && $1 == "product" {
 	nproducts++

 	products[nproducts, 1] = $2;		# vendor name
 	products[nproducts, 2] = $3;		# product id
 	products[nproducts, 3] = $4;		# id

-	f = 5;
+	field = 5;

 	if ($4 == "{") {
 		products[nproducts, 3] = -1
 		z = "{ "
 		for (i = 0; i < 4; i++) {
-			if (f <= NF) {
-				gsub("&sp", " ", $f)
-				gsub("&tab", "\t", $f)
-				gsub("&nl", "\n", $f)
-				z = z $f " "
-				f++
+			if (field <= NF) {
+				gsub("&sp", " ", $field)
+				gsub("&tab", "\t", $field)
+				gsub("&nl", "\n", $field)
+				z = z $field " "
+				field++
 			}
 			else {
 				if (i == 3)
@@ -158,8 +158,8 @@
 					z = z "NULL, "
 			}
 		}
-		products[nproducts, 4] = z $f
-		f++
+		products[nproducts, 4] = z $field
+		field++
 	}
 	else {
 		products[nproducts, 4] = "{ NULL, NULL, NULL, NULL }"
@@ -170,7 +170,7 @@
 	printf("#define\tPCMCIA_PRODUCT_%s_%s\t%s\n", products[nproducts, 1],
 	    products[nproducts, 2], products[nproducts, 3]) > hfile

-	products[nproducts, 5] = collectline(f, line)
+	products[nproducts, 5] = collectline(field)

 	printf("#define\tPCMCIA_STR_%s_%s\t\"%s\"\n",
 	    products[nproducts, 1], products[nproducts, 2],
@@ -222,8 +222,13 @@
 		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
 	}
@@ -239,4 +244,6 @@
 	}
 	printf("\t{ 0, 0, { NULL, NULL, NULL, NULL }, 0, NULL, NULL, }\n") > dfile
 	printf("};\n") > dfile
+	close(dfile)
+	close(hfile)
 }

--- src/sys/dev/tc/devlist2h.awk	1998-01-09 07:56:23.000000000 +0100
+++ devlist2h.awk	2003-10-17 13:42:08.000000000 +0200
@@ -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 @@
 	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 @@
 	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 @@

 	next
 }
-$1 == "device" {
+NF > 0 && $1 == "device" {
 	ndevices++

 	devices[ndevices, 0] = $2;		# devices id
@@ -136,4 +136,7 @@
 	}
 	printf("\t{ NULL, NULL, NULL, }\n") > dfile
 	printf("};\n") > dfile
+
+	close(dfile)
+	close(hfile)
 }

--- src/sys/dev/usb/devlist2h.awk	2001-01-18 21:28:22.000000000 +0100
+++ devlist2h.awk	2003-10-17 13:47:30.000000000 +0200
@@ -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 @@
 	gsub("\\$", "", VERSION)

 	if (os == "NetBSD")
-		printf("/*\t\$NetBSD\$\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 @@
 	printf(" */\n") > dfile

 	if (os == "NetBSD")
-		printf("/*\t\$NetBSD\$\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 @@

 	next
 }
-$1 == "vendor" {
+NF > 0 && $1 == "vendor" {
 	nvendors++

 	vendorindex[$2] = nvendors;		# record index for this name, for later.
@@ -117,7 +117,7 @@

 	next
 }
-$1 == "product" {
+NF > 0 && $1 == "product" {
 	nproducts++

 	products[nproducts, 1] = $2;		# vendor name
@@ -188,7 +188,7 @@
 		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 @@
 		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 @@
 		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,7 @@
 	}
 	printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
 	printf("};\n") > dfile
+
+	close(dfile)
+	close(hfile)
 }
>Release-Note:
>Audit-Trail:

From: James Chacon <jmc@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/23177 CVS commit: src/sys/dev/acpi
Date: Fri, 12 Dec 2003 06:50:54 +0000 (UTC)

 Module Name:	src
 Committed By:	jmc
 Date:		Fri Dec 12 06:50:54 UTC 2003

 Modified Files:
 	src/sys/dev/acpi: devlist2h.awk

 Log Message:
 Fix from PR#23177. Pass lint and while here use a regular field separator
 and shift off the first entry to get the description. This fixes one that
 was getting missed and prevents future errors


 To generate a diff of this commit:
 cvs rdiff -r1.2 -r1.3 src/sys/dev/acpi/devlist2h.awk

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed 
State-Changed-By: jmc 
State-Changed-When: Mon Dec 15 07:32:55 UTC 2003 
State-Changed-Why:  
Patches applied. 

From: James Chacon <jmc@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/23177 CVS commit: src/sys
Date: Mon, 15 Dec 2003 07:32:21 +0000 (UTC)

 Module Name:	src
 Committed By:	jmc
 Date:		Mon Dec 15 07:32:21 UTC 2003

 Modified Files:
 	src/sys/arch/hp300/dev: devlist2h.awk
 	src/sys/arch/hp700/dev: devlist2h.awk
 	src/sys/dev/acpi: devlist2h.awk
 	src/sys/dev/cardbus: devlist2h.awk
 	src/sys/dev/eisa: devlist2h.awk
 	src/sys/dev/isapnp: devlist2h.awk
 	src/sys/dev/mca: devlist2h.awk
 	src/sys/dev/mii: devlist2h.awk
 	src/sys/dev/pci: devlist2h.awk
 	src/sys/dev/pcmcia: devlist2h.awk
 	src/sys/dev/tc: devlist2h.awk
 	src/sys/dev/usb: devlist2h.awk

 Log Message:
 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


 To generate a diff of this commit:
 cvs rdiff -r1.5 -r1.6 src/sys/arch/hp300/dev/devlist2h.awk
 cvs rdiff -r1.2 -r1.3 src/sys/arch/hp700/dev/devlist2h.awk
 cvs rdiff -r1.3 -r1.4 src/sys/dev/acpi/devlist2h.awk
 cvs rdiff -r1.3 -r1.4 src/sys/dev/cardbus/devlist2h.awk
 cvs rdiff -r1.6 -r1.7 src/sys/dev/eisa/devlist2h.awk
 cvs rdiff -r1.5 -r1.6 src/sys/dev/isapnp/devlist2h.awk
 cvs rdiff -r1.1 -r1.2 src/sys/dev/mca/devlist2h.awk
 cvs rdiff -r1.3 -r1.4 src/sys/dev/mii/devlist2h.awk
 cvs rdiff -r1.7 -r1.8 src/sys/dev/pci/devlist2h.awk
 cvs rdiff -r1.6 -r1.7 src/sys/dev/pcmcia/devlist2h.awk
 cvs rdiff -r1.6 -r1.7 src/sys/dev/tc/devlist2h.awk
 cvs rdiff -r1.10 -r1.11 src/sys/dev/usb/devlist2h.awk

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.