missing ncurses sources
[tomato.git] / release / src / router / libncurses / man / MKterminfo.sh
blob3a996095656759fc916a5bbf945abc6d78070b79
1 #!/bin/sh
2 # $Id: MKterminfo.sh,v 1.12 2003/01/11 21:42:12 tom Exp $
4 # MKterminfo.sh -- generate terminfo.5 from Caps tabular data
6 #***************************************************************************
7 # Copyright (c) 1998,2002,2003 Free Software Foundation, Inc. *
8 # *
9 # Permission is hereby granted, free of charge, to any person obtaining a *
10 # copy of this software and associated documentation files (the *
11 # "Software"), to deal in the Software without restriction, including *
12 # without limitation the rights to use, copy, modify, merge, publish, *
13 # distribute, distribute with modifications, sublicense, and/or sell *
14 # copies of the Software, and to permit persons to whom the Software is *
15 # furnished to do so, subject to the following conditions: *
16 # *
17 # The above copyright notice and this permission notice shall be included *
18 # in all copies or substantial portions of the Software. *
19 # *
20 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
21 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
22 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
23 # IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
24 # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
25 # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
26 # THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
27 # *
28 # Except as contained in this notice, the name(s) of the above copyright *
29 # holders shall not be used in advertising or otherwise to promote the *
30 # sale, use or other dealings in this Software without prior written *
31 # authorization. *
32 #***************************************************************************
34 # This script takes terminfo.head and terminfo.tail and splices in between
35 # them a table derived from the Caps data file. Besides avoiding having
36 # the docs fall out of sync with the table, this also lets us set up tbl
37 # commands for better formatting of the table.
39 # NOTE: The \x05s in this script really are control characters. It translates
40 # \x05 to \n because I couldn't get used to inserting linefeeds directly. There
41 # had better be no \x05s in the table source text.
43 # keep the order independent of locale:
44 if test "${LANGUAGE+set}" = set; then LANGUAGE=C; export LANGUAGE; fi
45 if test "${LANG+set}" = set; then LANG=C; export LANG; fi
46 if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
47 if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
48 if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
49 if test "${LC_COLLATE+set}" = set; then LC_COLLATE=C; export LC_COLLATE; fi
52 head=$1
53 caps=$2
54 tail=$3
55 cat <<'EOF'
56 '\" t
57 .\" DO NOT EDIT THIS FILE BY HAND!
58 .\" It is generated from terminfo.head, Caps, and terminfo.tail.
59 .\"
60 .\" Note: this must be run through tbl before nroff.
61 .\" The magic cookie on the first line triggers this under some man programs.
62 EOF
63 cat $head
65 temp=temp$$
66 sorted=sorted$$
67 unsorted=unsorted$$
68 trap "rm -f $sorted $temp $unsorted; exit 99" 1 2 5 15
70 sed -n <$caps "\
71 /%%-STOP-HERE-%%/q
72 /^#%/s/#%//p
73 /^#/d
74 s/[ ][ ]*/ /g
75 s/$/\x05T}/
76 s/ [A-Z0-9_()\-][A-Z0-9_()\-]* [0-9\-][0-9\-]* [Y\-][B\-][C\-][G\-][EK\-]\** / T{\x05/
77 s/ bool / /p
78 s/ num / /p
79 s/ str / /p
80 " |sed -e 's/^$/../' | tr "\134" "\006" >$unsorted
82 rm -f $sorted
83 rm -f $temp
84 saved=no
85 while true
87 data=
88 read data
89 test -z "$data" && break
90 case "$data" in #(vi
91 *\x05*) #(vi
92 echo "$data" >>$temp
93 saved=yes
96 if test $saved = yes ; then
97 saved=no
98 sort $temp >>$sorted
99 rm -f $temp
101 echo "$data" >>$sorted
103 esac
104 done <$unsorted
105 test $saved = yes && sort $temp >>$sorted
107 sed -e 's/^\.\.$//' $sorted | tr "\005\006" "\012\134"
108 cat $tail
110 rm -f $sorted $temp $unsorted