1 ##############################################################################
2 # Copyright 2020 Thomas E. Dickey #
3 # Copyright 1998-2006,2007 Free Software Foundation, Inc. #
5 # Permission is hereby granted, free of charge, to any person obtaining a #
6 # copy of this software and associated documentation files (the "Software"), #
7 # to deal in the Software without restriction, including without limitation #
8 # the rights to use, copy, modify, merge, publish, distribute, distribute #
9 # with modifications, sublicense, and/or sell copies of the Software, and to #
10 # permit persons to whom the Software is furnished to do so, subject to the #
11 # following conditions: #
13 # The above copyright notice and this permission notice shall be included in #
14 # all copies or substantial portions of the Software. #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
19 # THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
21 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
22 # DEALINGS IN THE SOFTWARE. #
24 # Except as contained in this notice, the name(s) of the above copyright #
25 # holders shall not be used in advertising or otherwise to promote the sale, #
26 # use or other dealings in this Software without prior written #
28 ##############################################################################
29 # $Id: MKcaptab.awk,v 1.21 2020/02/02 23:34:34 tom Exp $
30 function add_string(text) {
31 if (text != "IGNORE") {
32 offsets[num_strings] = offset;
33 offset = offset + length(text) + 1;
36 offsets[num_strings] = -1;
38 num_strings = num_strings + 1;
39 if ((num_strings % 3) == 0) {
42 return offsets[num_strings - 1];
53 printf "/* generated by MKcaptab.awk %s(%d) */\n", tablename, bigstrings;
56 printf "static struct alias *_nc_%s_table = 0;\n", tablename;
58 printf "static const char %s_text[] = \"\\\n", tablename;
60 printf "static const struct alias _nc_%s_table[] =\n", tablename;
65 if ($1 == tablename) {
75 aliases[num_aliases] = sprintf("\t{%5d, %5d, %5d},\t /* %s */", c1, c2, c3, $5);
76 num_aliases = num_aliases + 1;
78 printf "\t{\"%s\", %s, \"%s\"},\t /* %s */\n", $2, to, $4, $5;
85 printf "static const alias_table_data %s_data[] = {\n", tablename;
86 for (n = 0; n < num_aliases; ++n) {
87 printf "%s\n", aliases[n];
91 printf "\t{(char *)NULL, (char *)NULL, (char *)NULL}\n";