1999-08-24 01:06:48 +00:00
|
|
|
#!/bin/sh
|
2000-07-03 09:24:12 +00:00
|
|
|
# $Id: MKtermsort.sh,v 1.6 2000/01/25 11:35:36 tom Exp $
|
1999-08-24 01:06:48 +00:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2000-07-03 09:24:12 +00:00
|
|
|
# keep the order independent of locale:
|
|
|
|
LANGUAGE=C
|
|
|
|
LC_ALL=C
|
|
|
|
export LANGUAGE
|
|
|
|
export LC_ALL
|
|
|
|
#
|
1999-08-24 01:06:48 +00:00
|
|
|
AWK=${1-awk}
|
|
|
|
DATA=${2-../include/Caps}
|
|
|
|
|
|
|
|
echo "/*";
|
|
|
|
echo " * termsort.c --- sort order arrays for use by infocmp.";
|
|
|
|
echo " *";
|
2000-07-03 09:24:12 +00:00
|
|
|
echo " * Note: this file is generated using MKtermsort.sh, do not edit by hand.";
|
1999-08-24 01:06:48 +00:00
|
|
|
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 "";
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
echo "static const bool bool_from_termcap[] = {";
|
1999-08-24 01:06:48 +00:00
|
|
|
$AWK <$DATA '
|
2000-07-03 09:24:12 +00:00
|
|
|
$3 == "bool" && substr($5, 1, 1) == "-" {print "\tFALSE,\t/* ", $2, " */";}
|
|
|
|
$3 == "bool" && substr($5, 1, 1) == "Y" {print "\tTRUE,\t/* ", $2, " */";}
|
1999-08-24 01:06:48 +00:00
|
|
|
'
|
|
|
|
echo "};";
|
|
|
|
echo "";
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
echo "static const bool num_from_termcap[] = {";
|
1999-08-24 01:06:48 +00:00
|
|
|
$AWK <$DATA '
|
2000-07-03 09:24:12 +00:00
|
|
|
$3 == "num" && substr($5, 1, 1) == "-" {print "\tFALSE,\t/* ", $2, " */";}
|
|
|
|
$3 == "num" && substr($5, 1, 1) == "Y" {print "\tTRUE,\t/* ", $2, " */";}
|
1999-08-24 01:06:48 +00:00
|
|
|
'
|
|
|
|
echo "};";
|
|
|
|
echo "";
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
echo "static const bool str_from_termcap[] = {";
|
1999-08-24 01:06:48 +00:00
|
|
|
$AWK <$DATA '
|
2000-07-03 09:24:12 +00:00
|
|
|
$3 == "str" && substr($5, 1, 1) == "-" {print "\tFALSE,\t/* ", $2, " */";}
|
|
|
|
$3 == "str" && substr($5, 1, 1) == "Y" {print "\tTRUE,\t/* ", $2, " */";}
|
1999-08-24 01:06:48 +00:00
|
|
|
'
|
|
|
|
echo "};";
|
|
|
|
echo "";
|