]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/MKfallback.sh
ncurses 4.1
[ncurses.git] / ncurses / MKfallback.sh
1 #!/bin/sh
2 # $Id: MKfallback.sh,v 1.8 1996/09/15 01:44:13 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
28 static const TERMTYPE fallbacks[$#] =
29 {
30 EOF
31         comma=""
32         for x in $*
33         do
34                 echo "$comma /* $x */"
35                 infocmp -e $x
36                 comma=","
37         done
38
39         cat <<EOF
40 };
41
42 EOF
43 fi
44
45 cat <<EOF
46 const TERMTYPE *_nc_fallback(const char *name GCC_UNUSED)
47 {
48 EOF
49
50 if [ "$*" ]
51 then
52         cat <<EOF
53     const TERMTYPE      *tp;
54
55     for (tp = fallbacks;
56                 tp < fallbacks + sizeof(fallbacks)/sizeof(TERMTYPE);
57                 tp++)
58         if (_nc_name_match(tp->term_names, name, "|"))
59             return(tp);
60 EOF
61 else
62         echo "  /* the fallback list is empty */";
63 fi
64
65 cat <<EOF
66         return((TERMTYPE *)0);
67 }
68 EOF