150276Speter#!/bin/sh 2163356Sru# $Id: MKterminfo.sh,v 1.12 2003/01/11 21:42:12 tom Exp $ 3163356Sru# 4163356Sru# MKterminfo.sh -- generate terminfo.5 from Caps tabular data 5163356Sru# 650276Speter#*************************************************************************** 7163356Sru# Copyright (c) 1998,2002,2003 Free Software Foundation, Inc. * 850276Speter# * 950276Speter# Permission is hereby granted, free of charge, to any person obtaining a * 1050276Speter# copy of this software and associated documentation files (the * 1150276Speter# "Software"), to deal in the Software without restriction, including * 1250276Speter# without limitation the rights to use, copy, modify, merge, publish, * 1350276Speter# distribute, distribute with modifications, sublicense, and/or sell * 1450276Speter# copies of the Software, and to permit persons to whom the Software is * 1550276Speter# furnished to do so, subject to the following conditions: * 1650276Speter# * 1750276Speter# The above copyright notice and this permission notice shall be included * 1850276Speter# in all copies or substantial portions of the Software. * 1950276Speter# * 2050276Speter# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 2150276Speter# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 2250276Speter# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 2350276Speter# IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 2450276Speter# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2550276Speter# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2650276Speter# THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2750276Speter# * 2850276Speter# Except as contained in this notice, the name(s) of the above copyright * 2950276Speter# holders shall not be used in advertising or otherwise to promote the * 3050276Speter# sale, use or other dealings in this Software without prior written * 3150276Speter# authorization. * 3250276Speter#*************************************************************************** 3350276Speter# 3450276Speter# This script takes terminfo.head and terminfo.tail and splices in between 3550276Speter# them a table derived from the Caps data file. Besides avoiding having 3650276Speter# the docs fall out of sync with the table, this also lets us set up tbl 3750276Speter# commands for better formatting of the table. 3850276Speter# 3950276Speter# NOTE: The s in this script really are control characters. It translates 4050276Speter# to \n because I couldn't get used to inserting linefeeds directly. There 4150276Speter# had better be no s in the table source text. 4250276Speter# 4362449Speter# keep the order independent of locale: 44163356Sruif test "${LANGUAGE+set}" = set; then LANGUAGE=C; export LANGUAGE; fi 45163356Sruif test "${LANG+set}" = set; then LANG=C; export LANG; fi 46163356Sruif test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi 47163356Sruif test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi 48163356Sruif test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi 49163356Sruif test "${LC_COLLATE+set}" = set; then LC_COLLATE=C; export LC_COLLATE; fi 50163356Sru 5162449Speter# 5250276Speterhead=$1 5350276Spetercaps=$2 5450276Spetertail=$3 5550276Spetercat <<'EOF' 5650276Speter'\" t 5750276Speter.\" DO NOT EDIT THIS FILE BY HAND! 5850276Speter.\" It is generated from terminfo.head, Caps, and terminfo.tail. 5950276Speter.\" 6050276Speter.\" Note: this must be run through tbl before nroff. 6150276Speter.\" The magic cookie on the first line triggers this under some man programs. 6250276SpeterEOF 6350276Spetercat $head 6450276Speter 6550276Spetertemp=temp$$ 6650276Spetersorted=sorted$$ 6750276Speterunsorted=unsorted$$ 6850276Spetertrap "rm -f $sorted $temp $unsorted; exit 99" 1 2 5 15 6950276Speter 7050276Spetersed -n <$caps "\ 7150276Speter/%%-STOP-HERE-%%/q 72163356Sru/^#%/s/#%//p 7350276Speter/^#/d 74163356Srus/[ ][ ]*/ /g 7550276Speters/$/T}/ 76163356Srus/ [A-Z0-9_()\-][A-Z0-9_()\-]* [0-9\-][0-9\-]* [Y\-][B\-][C\-][G\-][EK\-]\** / T{/ 7750276Speters/ bool / /p 7850276Speters/ num / /p 7950276Speters/ str / /p 8050276Speter" |sed -e 's/^$/../' | tr "\134" "\006" >$unsorted 8150276Speter 8250276Speterrm -f $sorted 8350276Speterrm -f $temp 8450276Spetersaved=no 8550276Speterwhile true 8650276Speterdo 8797049Speter data= 8850276Speter read data 8950276Speter test -z "$data" && break 9050276Speter case "$data" in #(vi 9150276Speter **) #(vi 9250276Speter echo "$data" >>$temp 9350276Speter saved=yes 9450276Speter ;; 9550276Speter *) 9650276Speter if test $saved = yes ; then 9750276Speter saved=no 9850276Speter sort $temp >>$sorted 9950276Speter rm -f $temp 10050276Speter fi 10150276Speter echo "$data" >>$sorted 10250276Speter ;; 10350276Speter esac 10450276Speterdone <$unsorted 10550276Spetertest $saved = yes && sort $temp >>$sorted 10650276Speter 10750276Spetersed -e 's/^\.\.$//' $sorted | tr "\005\006" "\012\134" 10850276Spetercat $tail 10950276Speter 11050276Speterrm -f $sorted $temp $unsorted 111