123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- 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++
- continue
- }
- line = line $f
- if (f < NF)
- line = line " "
- f++
- }
- if (oparen)
- line = line ")"
- return line
- }
- BEGIN {
- nproducts = nvendors = 0
- hfile="sdmmcdevs.h"
- }
- NR == 1 {
- VERSION = $0
- gsub("\\$", "", VERSION)
- printf("/*\t\$OpenBSD\$\t*/\n\n") > hfile
- printf("/*\n") > hfile
- printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
- > hfile
- printf(" *\n") > hfile
- printf(" * generated from:\n") > hfile
- printf(" *\t%s\n", VERSION) > hfile
- printf(" */\n") > hfile
- next
- }
- $1 == "vendor" {
- nvendors++
- vendorindex[$2] = nvendors;
- vendors[nvendors, 1] = $2;
- vendors[nvendors, 2] = $3;
- printf("#define\tSDMMC_VENDOR_%s\t%s\t", vendors[nvendors, 1],
- vendors[nvendors, 2]) > hfile
- vendors[nvendors, 3] = collectline(4, line)
- printf("/* %s */\n", vendors[nvendors, 3]) > hfile
- next
- }
- $1 == "product" {
- nproducts++
- products[nproducts, 1] = $2;
- products[nproducts, 2] = $3;
- products[nproducts, 3] = $4;
- f = 5;
- if ($4 == "{") {
- products[nproducts, 3] = "SDMMC_PRODUCT_INVALID"
- 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++
- }
- else {
- if (i == 3)
- z = z "NULL "
- else
- z = z "NULL, "
- }
- }
- products[nproducts, 4] = z $f
- f++
- }
- else {
- products[nproducts, 4] = "{ NULL, NULL, NULL, NULL }"
- }
- printf("#define\tSDMMC_CIS_%s_%s\t%s\n",
- products[nproducts, 1], products[nproducts, 2],
- products[nproducts, 4]) > hfile
- printf("#define\tSDMMC_PRODUCT_%s_%s\t%s\n", products[nproducts, 1],
- products[nproducts, 2], products[nproducts, 3]) > hfile
- next
- }
- {
- if ($0 == "")
- blanklines++
- print $0 > hfile
- }
|