151e66a47SVivek Prakash#!/bin/sh 2*84d9c625SLionel Sambuc# $NetBSD: genman,v 1.5 2013/01/25 12:52:45 roy Exp $ 351e66a47SVivek Prakash 4*84d9c625SLionel Sambuc# Copyright (c) 2009, 2013 The NetBSD Foundation, Inc. 551e66a47SVivek Prakash# 651e66a47SVivek Prakash# This code is derived from software contributed to The NetBSD Foundation 751e66a47SVivek Prakash# by Roy Marples. 851e66a47SVivek Prakash# 951e66a47SVivek Prakash# Redistribution and use in source and binary forms, with or without 1051e66a47SVivek Prakash# modification, are permitted provided that the following conditions 1151e66a47SVivek Prakash# are met: 1251e66a47SVivek Prakash# 1. Redistributions of source code must retain the above copyright 1351e66a47SVivek Prakash# notice, this list of conditions and the following disclaimer. 1451e66a47SVivek Prakash# 2. Redistributions in binary form must reproduce the above copyright 1551e66a47SVivek Prakash# notice, this list of conditions and the following disclaimer in the 1651e66a47SVivek Prakash# documentation and/or other materials provided with the distribution. 1751e66a47SVivek Prakash# 1851e66a47SVivek Prakash# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1951e66a47SVivek Prakash# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2051e66a47SVivek Prakash# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2151e66a47SVivek Prakash# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2251e66a47SVivek Prakash# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2351e66a47SVivek Prakash# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2451e66a47SVivek Prakash# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2551e66a47SVivek Prakash# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2651e66a47SVivek Prakash# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2751e66a47SVivek Prakash# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2851e66a47SVivek Prakash 2951e66a47SVivek Prakash 3051e66a47SVivek Prakash# Generate variable tables for terminfo.5 from our source files. 3151e66a47SVivek Prakash 3251e66a47SVivek Prakashset -e 3351e66a47SVivek Prakash: ${TOOL_SED:=sed} 3451e66a47SVivek Prakash: ${TOOL_SORT:=sort} 3551e66a47SVivek Prakash 3651e66a47SVivek PrakashTERMM=${1:-terminfo.5.in} 3751e66a47SVivek PrakashTERMH=${2:-term.h} 3851e66a47SVivek PrakashTERMC=${3:-termcap_map.c} 3951e66a47SVivek Prakash 4051e66a47SVivek Prakashgentab() 4151e66a47SVivek Prakash{ 4251e66a47SVivek Prakash local ti=$1 tc=$2 tab=$3 4351e66a47SVivek Prakash 4451e66a47SVivek Prakash # Generate a list of long names and codes 4551e66a47SVivek Prakash $TOOL_SED -n \ 4651e66a47SVivek Prakash -e "s/#define t_\([^(]*\).*>$tab\[TICODE_\([^]]*\).*/\1 \2/p" \ 4751e66a47SVivek Prakash $ti | $TOOL_SORT | while read name code foo; do 4851e66a47SVivek Prakash cap=$($TOOL_SED -ne "s/.*{ \"\(..\)\", TICODE_$code }.*/\1/p" \ 4951e66a47SVivek Prakash $tc | head -n 1) 50*84d9c625SLionel Sambuc desc=$($TOOL_SED -ne "s/ \* $name\: \(.*\)/\1/p" $ti) 51*84d9c625SLionel Sambuc echo ".It \"\\&$name\" Ta Sy \"\\&$code\" Ta Sy \"\\&$cap\" Ta \"\\&$desc\"" 5251e66a47SVivek Prakash done 5351e66a47SVivek Prakash} 5451e66a47SVivek Prakash 5551e66a47SVivek Prakashboolcaps=$(gentab $TERMH $TERMC flags) 5651e66a47SVivek Prakashnumcaps=$(gentab $TERMH $TERMC nums) 5751e66a47SVivek Prakashstrcaps=$(gentab $TERMH $TERMC strs) 5851e66a47SVivek Prakash 5951e66a47SVivek Prakashecho ".\\\"DO NOT EDIT" 6051e66a47SVivek Prakashecho ".\\\"Automatically generated from termcap.5.in" 6151e66a47SVivek Prakashecho ".\\\"" 6251e66a47SVivek Prakash 6351e66a47SVivek Prakashwhile read -r line; do 6451e66a47SVivek Prakash case "$line" in 6551e66a47SVivek Prakash "@BOOLCAPS@") echo "$boolcaps";; 6651e66a47SVivek Prakash "@NUMCAPS@") echo "$numcaps";; 6751e66a47SVivek Prakash "@STRCAPS@") echo "$strcaps";; 6851e66a47SVivek Prakash *) echo "$line";; 6951e66a47SVivek Prakash esac 7051e66a47SVivek Prakashdone <$TERMM 71