summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2005-05-09 05:07:26 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2005-05-09 05:07:26 +0000
commit390cefe37f76ca23f744b06c841573df39c5404b (patch)
tree19317ff5e21523f349e3442fcb24ad44d085c4a5
parentd66aeef4258ea7d58ae2a6769926223aa105f547 (diff)
Sort the output tables, and mention the rcsid of the converter script in
the output as well.
-rw-r--r--sys/arch/hppa/gsc/makemap.awk85
1 files changed, 80 insertions, 5 deletions
diff --git a/sys/arch/hppa/gsc/makemap.awk b/sys/arch/hppa/gsc/makemap.awk
index 6da7ac811cd..2f1281f6e11 100644
--- a/sys/arch/hppa/gsc/makemap.awk
+++ b/sys/arch/hppa/gsc/makemap.awk
@@ -1,5 +1,5 @@
#! /usr/bin/awk -f
-# $OpenBSD: makemap.awk,v 1.4 2005/05/06 18:04:37 mickey Exp $
+# $OpenBSD: makemap.awk,v 1.5 2005/05/09 05:07:25 miod Exp $
#
# Copyright (c) 2003, Miodrag Vallat.
# All rights reserved.
@@ -33,6 +33,9 @@
#
BEGIN {
+ rcsid = "$OpenBSD: makemap.awk,v 1.5 2005/05/09 05:07:25 miod Exp $"
+ ifdepth = 0
+ ignore = 0
mapnum = 0
declk = 0
@@ -154,18 +157,52 @@ BEGIN {
NR == 1 {
VERSION = $0
gsub("\\$", "", VERSION)
+ gsub("\\$", "", rcsid)
printf("/*\t\$OpenBSD\$\t*/\n\n")
printf("/*\n")
- printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n")
+ printf(" * THIS FILE IS AUTOMAGICALLY GENERATED. DO NOT EDIT.\n")
printf(" *\n")
+ printf(" * generated by:\n")
+ printf(" *\t%s\n", rcsid)
printf(" * generated from:\n")
printf(" */\n")
print VERSION
next
}
+
+#
+# A very limited #if ... #endif parser. We only want to correctly detect
+# ``#if 0'' constructs, so as not to process their contents. This is necessary
+# since our output is out-of-order from our input.
+#
+# Note that this does NOT handle ``#ifdef notyet'' correctly - please only use
+# ``#if 0'' constructs in the input.
+#
+
+/^#if/ {
+ ignores[ifdepth] = ignore
+ if ($2 == "0")
+ ignore = 1
+ else
+ ignore = 0
+ ifdepth++
+ if (ignore)
+ next
+}
+/^#endif/ {
+ oldignore = ignore
+ ifdepth--
+ ignore = ignores[ifdepth]
+ ignores[ifdepth] = 0
+ if (oldignore)
+ next
+}
+
$1 == "#include" {
+ if (ignore)
+ next
if ($2 == "<dev/pckbc/wskbdmap_mfii.h>")
print "#include <hppa/gsc/gsckbdmap.h>"
else
@@ -174,9 +211,12 @@ $1 == "#include" {
next
}
$1 == "#define" || $1 == "#undef" {
+ if (ignore)
+ next
print $0
next
}
+
# Don't bother converting the DEC LK layout.
/declk\[/ {
declk = 1
@@ -185,12 +225,19 @@ $1 == "#define" || $1 == "#undef" {
/declk/ {
next
}
+
/pckbd/ {
+ if (ignore)
+ next
gsub("pckbd", "gsckbd", $0)
print $0
next
}
+
/KC/ {
+ if (ignore)
+ next
+
if (declk)
next
@@ -210,20 +257,46 @@ $1 == "#define" || $1 == "#undef" {
}
printf("\t*/\n")
} else {
- printf(" KC(%d),", id)
+ lines[id] = sprintf(" KC(%d),", id)
+ #
+ # This makes sure that the non-comment part of the output
+ # ends up with a trailing comma. This is necessary since
+ # the last line of an input block might not have a trailing
+ # comma, but might not be the last line of an output block
+ # due to sorting.
+ #
+ comma = 0
for (f = 2; f <= NF; f++) {
- printf("\t%s", $f)
+ if ($f == "/*")
+ comma++
+ if (comma == 0 &&
+ substr($f, length($f)) != ",") {
+ lines[id] = sprintf("%s\t%s,", lines[id], $f)
+ } else {
+ lines[id] = sprintf("%s\t%s", lines[id], $f)
+ }
+ if ($f == "*/")
+ comma--
}
- printf("\n")
}
next
}
/};/ {
+ if (ignore)
+ next
+
if (declk) {
declk = 0
next
}
+
+ for (i = 0; i < 256; i++)
+ if (lines[i]) {
+ print lines[i]
+ lines[i] = ""
+ }
+
if (mapnum == 0) {
# Add 241 to the US map...
print " KC(241),\tKS_Delete"
@@ -271,6 +344,8 @@ $1 == "#define" || $1 == "#undef" {
printf("\tKBD_MAP(KB_US | KB_MACHDEP,\tKB_US,\tgsckbd_keydesc_precisionbook),\n");
}
{
+ if (ignore)
+ next
if (declk)
next
print $0