1#!/bin/sh 2#*************************************************************************** 3# Copyright (c) 1998,2000,2001 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.9 2001/09/01 23:06:18 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 s in this script really are control characters. It translates 40# to \n because I couldn't get used to inserting linefeeds directly. There 41# had better be no s in the table source text. 42# 43# keep the order independent of locale: 44LANGUAGE=C 45LC_ALL=C 46export LANGUAGE 47export LC_ALL 48# 49head=$1 50caps=$2 51tail=$3 52cat <<'EOF' 53'\" t 54.\" DO NOT EDIT THIS FILE BY HAND! 55.\" It is generated from terminfo.head, Caps, and terminfo.tail. 56.\" 57.\" Note: this must be run through tbl before nroff. 58.\" The magic cookie on the first line triggers this under some man programs. 59EOF 60cat $head 61 62temp=temp$$ 63sorted=sorted$$ 64unsorted=unsorted$$ 65trap "rm -f $sorted $temp $unsorted; exit 99" 1 2 5 15 66 67sed -n <$caps "\ 68/%%-STOP-HERE-%%/q 69/^#%/s///p 70/^#/d 71s/[ ]\+/ /g 72s/$/T}/ 73s/ [A-Z0-9_()\-]\+ [0-9\-]\+ [Y\-][B\-][C\-][G\-][EK\-]\** / T{/ 74s/ bool / /p 75s/ num / /p 76s/ str / /p 77" |sed -e 's/^$/../' | tr "\134" "\006" >$unsorted 78 79rm -f $sorted 80rm -f $temp 81saved=no 82while true 83do 84 data= 85 read data 86 test -z "$data" && break 87 case "$data" in #(vi 88 **) #(vi 89 echo "$data" >>$temp 90 saved=yes 91 ;; 92 *) 93 if test $saved = yes ; then 94 saved=no 95 sort $temp >>$sorted 96 rm -f $temp 97 fi 98 echo "$data" >>$sorted 99 ;; 100 esac 101done <$unsorted 102test $saved = yes && sort $temp >>$sorted 103 104sed -e 's/^\.\.$//' $sorted | tr "\005\006" "\012\134" 105cat $tail 106 107rm -f $sorted $temp $unsorted 108