]> ncurses.scripts.mit.edu Git - ncurses.git/blob - progs/MKtermsort.sh
ncurses 5.1
[ncurses.git] / progs / MKtermsort.sh
1 #!/bin/sh
2 # $Id: MKtermsort.sh,v 1.6 2000/01/25 11:35:36 tom Exp $
3 #
4 # MKtermsort.sh -- generate indirection vectors for the various sort methods
5 #
6 # The output of this script is C source for nine arrays that list three sort
7 # orders for each of the three different classes of terminfo capabilities.
8 #
9 # keep the order independent of locale:
10 LANGUAGE=C
11 LC_ALL=C
12 export LANGUAGE
13 export LC_ALL
14 #
15 AWK=${1-awk}
16 DATA=${2-../include/Caps}
17
18 echo "/*";
19 echo " * termsort.c --- sort order arrays for use by infocmp.";
20 echo " *";
21 echo " * Note: this file is generated using MKtermsort.sh, do not edit by hand.";
22 echo " */";
23
24 echo "static const int bool_terminfo_sort[] = {";
25 $AWK <$DATA '
26 BEGIN           {i = 0;}
27 /^#/            {next;}
28 $3 == "bool"    {printf("%s\t%d\n", $2, i++);}
29 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
30 echo "};";
31 echo "";
32
33 echo "static const int num_terminfo_sort[] = {";
34 $AWK <$DATA '
35 BEGIN           {i = 0;}
36 /^#/            {next;}
37 $3 == "num"     {printf("%s\t%d\n", $2, i++);}
38 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
39 echo "};";
40 echo "";
41
42 echo "static const int str_terminfo_sort[] = {";
43 $AWK <$DATA '
44 BEGIN           {i = 0;}
45 /^#/            {next;}
46 $3 == "str"     {printf("%s\t%d\n", $2, i++);}
47 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
48 echo "};";
49 echo "";
50
51 echo "static const int bool_variable_sort[] = {";
52 $AWK <$DATA '
53 BEGIN           {i = 0;}
54 /^#/            {next;}
55 $3 == "bool"    {printf("%s\t%d\n", $1, i++);}
56 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
57 echo "};";
58 echo "";
59
60 echo "static const int num_variable_sort[] = {";
61 $AWK <$DATA '
62 BEGIN           {i = 0;}
63 /^#/            {next;}
64 $3 == "num"     {printf("%s\t%d\n", $1, i++);}
65 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
66 echo "};";
67 echo "";
68
69 echo "static const int str_variable_sort[] = {";
70 $AWK <$DATA '
71 BEGIN           {i = 0;}
72 /^#/            {next;}
73 $3 == "str"     {printf("%s\t%d\n", $1, i++);}
74 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
75 echo "};";
76 echo "";
77
78 echo "static const int bool_termcap_sort[] = {";
79 $AWK <$DATA '
80 BEGIN           {i = 0;}
81 /^#/            {next;}
82 $3 == "bool"    {printf("%s\t%d\n", $4, i++);}
83 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
84 echo "};";
85 echo "";
86
87 echo "static const int num_termcap_sort[] = {";
88 $AWK <$DATA '
89 BEGIN           {i = 0;}
90 /^#/            {next;}
91 $3 == "num"     {printf("%s\t%d\n", $4, i++);}
92 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
93 echo "};";
94 echo "";
95
96 echo "static const int str_termcap_sort[] = {";
97 $AWK <$DATA '
98 BEGIN           {i = 0;}
99 /^#/            {next;}
100 $3 == "str"     {printf("%s\t%d\n", $4, i++);}
101 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
102 echo "};";
103 echo "";
104
105 echo "static const bool bool_from_termcap[] = {";
106 $AWK <$DATA '
107 $3 == "bool" && substr($5, 1, 1) == "-"       {print "\tFALSE,\t/* ", $2, " */";}
108 $3 == "bool" && substr($5, 1, 1) == "Y"       {print "\tTRUE,\t/* ", $2, " */";}
109 '
110 echo "};";
111 echo "";
112
113 echo "static const bool num_from_termcap[] = {";
114 $AWK <$DATA '
115 $3 == "num" && substr($5, 1, 1) == "-"        {print "\tFALSE,\t/* ", $2, " */";}
116 $3 == "num" && substr($5, 1, 1) == "Y"        {print "\tTRUE,\t/* ", $2, " */";}
117 '
118 echo "};";
119 echo "";
120
121 echo "static const bool str_from_termcap[] = {";
122 $AWK <$DATA '
123 $3 == "str" && substr($5, 1, 1) == "-"        {print "\tFALSE,\t/* ", $2, " */";}
124 $3 == "str" && substr($5, 1, 1) == "Y"        {print "\tTRUE,\t/* ", $2, " */";}
125 '
126 echo "};";
127 echo "";