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