summaryrefslogtreecommitdiff
path: root/sys/dev/devlist2h.awk
diff options
context:
space:
mode:
authorpgoyette <pgoyette@NetBSD.org>2016-10-26 01:03:23 +0000
committerpgoyette <pgoyette@NetBSD.org>2016-10-26 01:03:23 +0000
commita1fb8843f290c60555ca8ac60afcfd51dd012226 (patch)
tree411993aea3e87949854fd094351e73d86a034115 /sys/dev/devlist2h.awk
parent709e7d2a7d1edcbc7badd2df0c0d2c100d036760 (diff)
Update the devlist2h.awk script to track the maximum lengths of vendor
and product strings, and report the max values at end of the run. Update the Makefiles.{pci,usb,hdaudio}devs to point users at the places which might need to be updated if the maximum lengths get larger. Since this commit makes no changes to the generated files, we don't need to regenerate them now.
Diffstat (limited to 'sys/dev/devlist2h.awk')
-rw-r--r--sys/dev/devlist2h.awk19
1 files changed, 17 insertions, 2 deletions
diff --git a/sys/dev/devlist2h.awk b/sys/dev/devlist2h.awk
index 00ada66a033..fd23737a751 100644
--- a/sys/dev/devlist2h.awk
+++ b/sys/dev/devlist2h.awk
@@ -1,5 +1,5 @@
#! /usr/bin/awk -f
-# $NetBSD: devlist2h.awk,v 1.1 2014/09/21 14:30:22 christos Exp $
+# $NetBSD: devlist2h.awk,v 1.2 2016/10/26 01:03:23 pgoyette Exp $
#
# Copyright (c) 1995, 1996 Christopher G. Demetriou
# All rights reserved.
@@ -31,6 +31,7 @@
#
NR == 1 {
nproducts = nvendors = blanklines = 0
+ vendormaxlen = productmaxlen = 0
nchars = 1
dfile= FILENAME "_data.h"
hfile= FILENAME ".h"
@@ -117,6 +118,10 @@ NF > 0 && $1 == "vendor" {
printf(" */") > hfile
printf("\n") > hfile
+ if (length($2) > vendormaxlen) {
+ vendormaxlen = length($2)
+ }
+
next
}
NF > 0 && $1 == "product" {
@@ -131,7 +136,7 @@ NF > 0 && $1 == "product" {
i=4; f = 5;
# comments
- ocomment = oparen = 0
+ productlen = ocomment = oparen = 0
if (f <= NF) {
printf("\t\t/* ") > hfile
ocomment = 1;
@@ -161,6 +166,7 @@ NF > 0 && $1 == "product" {
wordlist[nwords, 3] = nchars;
nchars = nchars + l + 1;
}
+ productlen += words[$f, 2] + 1;
wordlist[words[$f, 1], 2]++;
products[nproducts, i] = words[$f, 1];
printf("%s", $f) > hfile
@@ -174,6 +180,10 @@ NF > 0 && $1 == "product" {
printf(" */") > hfile
printf("\n") > hfile
+ if (productlen > productmaxlen) {
+ productmaxlen = productlen;
+ }
+
next
}
{
@@ -240,6 +250,11 @@ END {
printf("\n") > dfile
+ printf("Maximum vendor string length: %d\n", vendormaxlen + 1)
+ printf("Maximum product string length: %d\n", productmaxlen + 1)
+ printf("\nEnsure that device-specific values are sufficiently large");
+ printf("\ncheck Makefile.%s for details).\n", FILENAME);
+
close(dfile)
close(hfile)
}