/usr.bin/tic/MKtermsort.sh

https://bitbucket.org/kmv/aeriebsd-src · Shell · 127 lines · 104 code · 13 blank · 10 comment · 1 complexity · c794a56ea763ffab6572f9409957f9b4 MD5 · raw file

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