1#! /usr/bin/sh
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License, Version 1.0 only
7# (the "License").  You may not use this file except in compliance
8# with the License.
9#
10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11# or http://www.opensolaris.org/os/licensing.
12# See the License for the specific language governing permissions
13# and limitations under the License.
14#
15# When distributing Covered Code, include this CDDL HEADER in each
16# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17# If applicable, add the following below this CDDL HEADER, with the
18# fields enclosed by brackets "[]" replaced with your own identifying
19# information: Portions Copyright [yyyy] [name of copyright owner]
20#
21# CDDL HEADER END
22#
23# Copyright (c) 1999 by Sun Microsystems, Inc.
24# All rights reserved.
25#
26
27markrow()
28{
29	# markrow file begin end label
30	file="$1"
31	begin="$2"
32	end="$3"
33	label="$4"
34
35	awk -f - $file <<-EOT > $file.$$
36	    \$2 >= $begin && \$2 <= $end && done == 0	{
37			print "";
38			print "# $label";
39			done = 1;
40		}
41		{
42			print \$0;
43		}
44	EOT
45	mv -f $file.$$ $file
46}
47
48header=/tmp/header.$$
49sorted=/tmp/sorted.$$
50
51for i
52do
53	echo "#" > $header
54	echo "# Copyright (c) `date +%Y` by Sun Microsystems, Inc." >> $header
55	echo "# All rights reserved." >> $header
56	echo "#" >> $header
57	sed -n						\
58		-e '/^[^#]/q'				\
59		-e '/^[ 	]*$/q'			\
60		-e '/%\Z%/d'				\
61		-e '/@(#)/d'				\
62		-e '/Copyright/d'			\
63		-e '/[aA]ll [rR]ights [rR]eserved/d'	\
64		-e '/^#[ 	]*$/d'			\
65		-e p					\
66		$i >> $header
67	echo '#' >> $header
68	grep -v '^#' $i |
69	grep -v '^[ 	]*$' |
70	sed -e 's/[ 	][ 	]*/ /g' |
71	sort -n +1 -o $sorted
72	# The following are specific to PC keyboards, but similar
73	# schemes should work for many other types.
74	markrow $sorted 0 0 "??? Unknown keys ???"
75	markrow $sorted 1 15 "Main Pad Row 1:  digits, Backspace"
76	markrow $sorted 16 29 "Main Pad Row 2:  Tab, QWERTY..."
77	markrow $sorted 30 43 "Main Pad Row 3:  CapsLock, ASDFGH..., Enter"
78	markrow $sorted 44 57 "Main Pad Row 4:  Shift, ZXCVBN..., Shift"
79	markrow $sorted 58 65 "Main Pad Row 5:  Ctrl, Alt, Space, ..."
80	markrow $sorted 66 74 "??? Unknown keys ???"
81	markrow $sorted 75 89 "Arrow Pad"
82	markrow $sorted 90 108 "Numeric Pad"
83	markrow $sorted 109 109 "??? Unknown keys ???"
84	markrow $sorted 110 126 "Esc, Function Keys, PrintScreen/ScrollLock/Pause"
85	markrow $sorted 127 130 "??? Unknown keys ???"
86	markrow $sorted 131 133 "Japanese Keys"
87	markrow $sorted 134 149 "??? Unknown keys ???"
88	markrow $sorted 150 151 "Korean Keys"
89	markrow $sorted 152 99999 "??? Unknown keys ???"
90	cat $header $sorted > $i.neat
91	rm -f $header $sorted
92
93	echo "Neaten $i -> $i.neat"
94done
95