MKfallback.sh revision 97049
1#!/bin/sh
2# $Id: MKfallback.sh,v 1.11 2001/12/02 01:55:30 tom Exp $
3#
4# MKfallback.sh -- create fallback table for entry reads
5#
6# This script generates source code for a custom version of read_entry.c
7# that (instead of reading capabilities for an argument terminal type
8# from an on-disk terminfo tree) tries to match the type with one of a
9# specified list of types generated in.
10#
11
12terminfo_dir=$1
13shift
14
15terminfo_src=$1
16shift
17
18if test $# != 0 ; then
19	tmp_info=tmp_info
20	echo creating temporary terminfo directory... >&2
21
22	TERMINFO=`pwd`/$tmp_info
23	export TERMINFO
24
25	TERMINFO_DIRS=$TERMINFO:$terminfo_dir
26	export TERMINFO_DIRS
27
28	tic $terminfo_src >&2
29else
30	tmp_info=
31fi
32
33cat <<EOF
34/*
35 * DO NOT EDIT THIS FILE BY HAND!  It is generated by MKfallback.sh.
36 */
37
38#include <curses.priv.h>
39#include <term.h>
40
41EOF
42
43if [ "$*" ]
44then
45	cat <<EOF
46#include <tic.h>
47
48/* fallback entries for: $* */
49EOF
50	for x in $*
51	do
52		echo "/* $x */"
53		infocmp -E $x
54	done
55
56	cat <<EOF
57static const TERMTYPE fallbacks[$#] =
58{
59EOF
60	comma=""
61	for x in $*
62	do
63		echo "$comma /* $x */"
64		infocmp -e $x
65		comma=","
66	done
67
68	cat <<EOF
69};
70
71EOF
72fi
73
74cat <<EOF
75NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *name GCC_UNUSED)
76{
77EOF
78
79if [ "$*" ]
80then
81	cat <<EOF
82    const TERMTYPE	*tp;
83
84    for (tp = fallbacks;
85	 	tp < fallbacks + sizeof(fallbacks)/sizeof(TERMTYPE);
86	 	tp++)
87	if (_nc_name_match(tp->term_names, name, "|"))
88	    return(tp);
89EOF
90else
91	echo "	/* the fallback list is empty */";
92fi
93
94cat <<EOF
95	return((TERMTYPE *)0);
96}
97EOF
98
99if test -n "$tmp_info" ; then
100	echo removing temporary terminfo directory... >&2
101	rm -rf $tmp_info
102fi
103