]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/tinfo/MKfallback.sh
ncurses 5.0
[ncurses.git] / ncurses / tinfo / MKfallback.sh
1 #!/bin/sh
2 # $Id: MKfallback.sh,v 1.9 1999/06/15 22:57:45 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 cat <<EOF
12 /*
13  * DO NOT EDIT THIS FILE BY HAND!  It is generated by MKfallback.sh.
14  */
15
16 #include <curses.priv.h>
17 #include <term.h>
18
19 EOF
20
21 if [ "$*" ]
22 then
23         cat <<EOF
24 #include <tic.h>
25
26 /* fallback entries for: $* */
27 EOF
28         for x in $*
29         do
30                 echo "/* $x */"
31                 infocmp -E $x
32         done
33
34         cat <<EOF
35 static const TERMTYPE fallbacks[$#] =
36 {
37 EOF
38         comma=""
39         for x in $*
40         do
41                 echo "$comma /* $x */"
42                 infocmp -e $x
43                 comma=","
44         done
45
46         cat <<EOF
47 };
48
49 EOF
50 fi
51
52 cat <<EOF
53 const TERMTYPE *_nc_fallback(const char *name GCC_UNUSED)
54 {
55 EOF
56
57 if [ "$*" ]
58 then
59         cat <<EOF
60     const TERMTYPE      *tp;
61
62     for (tp = fallbacks;
63                 tp < fallbacks + sizeof(fallbacks)/sizeof(TERMTYPE);
64                 tp++)
65         if (_nc_name_match(tp->term_names, name, "|"))
66             return(tp);
67 EOF
68 else
69         echo "  /* the fallback list is empty */";
70 fi
71
72 cat <<EOF
73         return((TERMTYPE *)0);
74 }
75 EOF