Home | History | Annotate | Line # | Download | only in libterminfo
genman revision 1.4
      1  1.1       roy #!/bin/sh
      2  1.4  christos # $NetBSD: genman,v 1.4 2010/10/12 12:57:51 christos Exp $
      3  1.1       roy 
      4  1.1       roy # Copyright (c) 2009 The NetBSD Foundation, Inc.
      5  1.1       roy #
      6  1.1       roy # This code is derived from software contributed to The NetBSD Foundation
      7  1.1       roy # by Roy Marples.
      8  1.1       roy #
      9  1.1       roy # Redistribution and use in source and binary forms, with or without
     10  1.1       roy # modification, are permitted provided that the following conditions
     11  1.1       roy # are met:
     12  1.1       roy # 1. Redistributions of source code must retain the above copyright
     13  1.1       roy #    notice, this list of conditions and the following disclaimer.
     14  1.1       roy # 2. Redistributions in binary form must reproduce the above copyright
     15  1.1       roy #    notice, this list of conditions and the following disclaimer in the
     16  1.1       roy #    documentation and/or other materials provided with the distribution.
     17  1.1       roy #
     18  1.1       roy # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19  1.1       roy # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20  1.1       roy # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21  1.1       roy # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22  1.1       roy # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23  1.1       roy # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24  1.1       roy # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25  1.1       roy # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26  1.1       roy # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27  1.1       roy # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28  1.1       roy 
     29  1.1       roy 
     30  1.1       roy # Generate variable tables for terminfo.5 from our source files.
     31  1.1       roy 
     32  1.3       roy set -e
     33  1.1       roy : ${TOOL_SED:=sed}
     34  1.1       roy : ${TOOL_SORT:=sort}
     35  1.1       roy 
     36  1.1       roy TERMM=${1:-terminfo.5.in}
     37  1.1       roy TERMH=${2:-term.h}
     38  1.1       roy TERMC=${3:-termcap_map.c}
     39  1.1       roy 
     40  1.1       roy gentab()
     41  1.1       roy {
     42  1.1       roy 	local ti=$1 tc=$2 tab=$3
     43  1.1       roy 
     44  1.1       roy 	# Generate a list of long names and codes
     45  1.1       roy 	$TOOL_SED -n \
     46  1.1       roy 	-e "s/#define t_\([^(]*\).*>$tab\[TICODE_\([^]]*\).*/\1 \2/p" \
     47  1.1       roy 	$ti | $TOOL_SORT | while read name code foo; do
     48  1.4  christos 		cap=$($TOOL_SED -ne "s/.*{ \"\(..\)\", TICODE_$code }.*/\1/p" \
     49  1.4  christos 		    $tc | head -n 1)
     50  1.1       roy 		echo ".It Li \"$name\" Ta Sy \"\\&$code\" Ta Sy \"\\&$cap\""
     51  1.1       roy 	done
     52  1.1       roy }
     53  1.1       roy 
     54  1.4  christos boolcaps=$(gentab $TERMH $TERMC flags)
     55  1.4  christos numcaps=$(gentab $TERMH $TERMC nums)
     56  1.4  christos strcaps=$(gentab $TERMH $TERMC strs)
     57  1.1       roy 
     58  1.2       roy echo ".\\\"DO NOT EDIT"
     59  1.2       roy echo ".\\\"Automatically generated from termcap.5.in"
     60  1.2       roy echo ".\\\""
     61  1.2       roy 
     62  1.1       roy while read -r line; do
     63  1.1       roy 	case "$line" in
     64  1.1       roy 	"@BOOLCAPS@")	echo "$boolcaps";;
     65  1.1       roy 	"@NUMCAPS@")	echo "$numcaps";;
     66  1.1       roy 	"@STRCAPS@")	echo "$strcaps";;
     67  1.1       roy 	*)		echo "$line";;
     68  1.1       roy 	esac
     69  1.1       roy done <$TERMM
     70