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