3 # MKtermsort.sh -- generate indirection vectors for the various sort methods
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.
9 DATA=${2-../include/Caps}
12 echo " * termsort.c --- sort order arrays for use by infocmp.";
14 echo " * Note: this file is generated using termsort.sh, do not edit by hand.";
17 echo "static const int bool_terminfo_sort[] = {";
21 $3 == "bool" {printf("%s\t%d\n", $2, i++);}
22 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
26 echo "static const int num_terminfo_sort[] = {";
30 $3 == "num" {printf("%s\t%d\n", $2, i++);}
31 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
35 echo "static const int str_terminfo_sort[] = {";
39 $3 == "str" {printf("%s\t%d\n", $2, i++);}
40 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
44 echo "static const int bool_variable_sort[] = {";
48 $3 == "bool" {printf("%s\t%d\n", $1, i++);}
49 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
53 echo "static const int num_variable_sort[] = {";
57 $3 == "num" {printf("%s\t%d\n", $1, i++);}
58 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
62 echo "static const int str_variable_sort[] = {";
66 $3 == "str" {printf("%s\t%d\n", $1, i++);}
67 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
71 echo "static const int bool_termcap_sort[] = {";
75 $3 == "bool" {printf("%s\t%d\n", $4, i++);}
76 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
80 echo "static const int num_termcap_sort[] = {";
84 $3 == "num" {printf("%s\t%d\n", $4, i++);}
85 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
89 echo "static const int str_termcap_sort[] = {";
93 $3 == "str" {printf("%s\t%d\n", $4, i++);}
94 ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
98 echo "static const int bool_from_termcap[] = {";
100 $3 == "bool" && substr($5, 1, 1) == "-" {print "0,\t/* ", $2, " */";}
101 $3 == "bool" && substr($5, 1, 1) == "Y" {print "1,\t/* ", $2, " */";}
106 echo "static const int num_from_termcap[] = {";
108 $3 == "num" && substr($5, 1, 1) == "-" {print "0,\t/* ", $2, " */";}
109 $3 == "num" && substr($5, 1, 1) == "Y" {print "1,\t/* ", $2, " */";}
114 echo "static const int str_from_termcap[] = {";
116 $3 == "str" && substr($5, 1, 1) == "-" {print "0,\t/* ", $2, " */";}
117 $3 == "str" && substr($5, 1, 1) == "Y" {print "1,\t/* ", $2, " */";}