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