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