genman revision 1.4
11.1Sroy#!/bin/sh 21.4Schristos# $NetBSD: genman,v 1.4 2010/10/12 12:57:51 christos Exp $ 31.1Sroy 41.1Sroy# Copyright (c) 2009 The NetBSD Foundation, Inc. 51.1Sroy# 61.1Sroy# This code is derived from software contributed to The NetBSD Foundation 71.1Sroy# by Roy Marples. 81.1Sroy# 91.1Sroy# Redistribution and use in source and binary forms, with or without 101.1Sroy# modification, are permitted provided that the following conditions 111.1Sroy# are met: 121.1Sroy# 1. Redistributions of source code must retain the above copyright 131.1Sroy# notice, this list of conditions and the following disclaimer. 141.1Sroy# 2. Redistributions in binary form must reproduce the above copyright 151.1Sroy# notice, this list of conditions and the following disclaimer in the 161.1Sroy# documentation and/or other materials provided with the distribution. 171.1Sroy# 181.1Sroy# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 191.1Sroy# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 201.1Sroy# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 211.1Sroy# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 221.1Sroy# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 231.1Sroy# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 241.1Sroy# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 251.1Sroy# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 261.1Sroy# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 271.1Sroy# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 281.1Sroy 291.1Sroy 301.1Sroy# Generate variable tables for terminfo.5 from our source files. 311.1Sroy 321.3Sroyset -e 331.1Sroy: ${TOOL_SED:=sed} 341.1Sroy: ${TOOL_SORT:=sort} 351.1Sroy 361.1SroyTERMM=${1:-terminfo.5.in} 371.1SroyTERMH=${2:-term.h} 381.1SroyTERMC=${3:-termcap_map.c} 391.1Sroy 401.1Sroygentab() 411.1Sroy{ 421.1Sroy local ti=$1 tc=$2 tab=$3 431.1Sroy 441.1Sroy # Generate a list of long names and codes 451.1Sroy $TOOL_SED -n \ 461.1Sroy -e "s/#define t_\([^(]*\).*>$tab\[TICODE_\([^]]*\).*/\1 \2/p" \ 471.1Sroy $ti | $TOOL_SORT | while read name code foo; do 481.4Schristos cap=$($TOOL_SED -ne "s/.*{ \"\(..\)\", TICODE_$code }.*/\1/p" \ 491.4Schristos $tc | head -n 1) 501.1Sroy echo ".It Li \"$name\" Ta Sy \"\\&$code\" Ta Sy \"\\&$cap\"" 511.1Sroy done 521.1Sroy} 531.1Sroy 541.4Schristosboolcaps=$(gentab $TERMH $TERMC flags) 551.4Schristosnumcaps=$(gentab $TERMH $TERMC nums) 561.4Schristosstrcaps=$(gentab $TERMH $TERMC strs) 571.1Sroy 581.2Sroyecho ".\\\"DO NOT EDIT" 591.2Sroyecho ".\\\"Automatically generated from termcap.5.in" 601.2Sroyecho ".\\\"" 611.2Sroy 621.1Sroywhile read -r line; do 631.1Sroy case "$line" in 641.1Sroy "@BOOLCAPS@") echo "$boolcaps";; 651.1Sroy "@NUMCAPS@") echo "$numcaps";; 661.1Sroy "@STRCAPS@") echo "$strcaps";; 671.1Sroy *) echo "$line";; 681.1Sroy esac 691.1Sroydone <$TERMM 70