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