ncurses 4.2
[ncurses.git] / ncurses / MKnames.awk
1 # $Id: MKnames.awk,v 1.9 1997/10/18 19:57:23 tom Exp $
2 BEGIN           {
3                         print  "/* This file was generated by MKnames.awk */" > "namehdr"
4                         print  ""                               > "namehdr"
5                         print  "#include <curses.priv.h>"       > "namehdr"
6                         print  ""                               > "namehdr"
7                         print  "#ifdef __cplusplus"             > "namehdr"
8                         print  "#define extern IT NCURSES_CONST char * const"   > "namehdr"
9                         print  "#else"                          > "namehdr"
10                         print  "#define IT NCURSES_CONST char * const"  > "namehdr"
11                         print  "#endif"                         > "namehdr"
12                         print  ""                               > "namehdr"
13                         print  "#if BROKEN_LINKER"              > "namehdr"
14                         print  "#include <term.h>"              > "namehdr"
15                         print  "#define DCL(it) static IT data##it[]" > "namehdr"
16                         print  "#else"                          > "namehdr"
17                         print  "#define DCL(it) IT it[]"        > "namehdr"
18                         print  "#endif"                         > "namehdr"
19                         print  ""                               > "namehdr"
20                         print  "/*"                             > "boolnames"
21                         print  " *      names.c - Arrays of capability names and codes"  > "boolnames"
22                         print  " *"                             > "boolnames"
23                         print  " */"                            > "boolnames"
24                         print  ""                               > "boolnames"
25                         print  "DCL(boolnames)  = {"            > "boolnames"
26                         print  "DCL(boolfnames) = {"            > "boolfnames"
27                         print  "DCL(boolcodes)  = {"            > "boolcodes"
28                         print  "DCL(numnames)   = {"            > "numnames"
29                         print  "DCL(numfnames)  = {"            > "numfnames"
30                         print  "DCL(numcodes)   = {"            > "numcodes"
31                         print  "DCL(strnames)   = {"            > "strnames"
32                         print  "DCL(strfnames)  = {"            > "strfnames"
33                         print  "DCL(strcodes)   = {"            > "strcodes"
34                 }
35
36 $1 ~ /^#/               {next;}
37
38 $1 == "SKIPWARN"        {next;}
39
40 $3 == "bool"    {
41                         printf "\t\t\"%s\",\n", $2 > "boolnames"
42                         printf "\t\t\"%s\",\n", $1 > "boolfnames"
43                         printf "\t\t\"%s\",\n", $4 > "boolcodes"
44                 }
45
46 $3 == "num"     {
47                         printf "\t\t\"%s\",\n", $2 > "numnames"
48                         printf "\t\t\"%s\",\n", $1 > "numfnames"
49                         printf "\t\t\"%s\",\n", $4 > "numcodes"
50                 }
51
52 $3 == "str"     {
53                         printf "\t\t\"%s\",\n", $2 > "strnames"
54                         printf "\t\t\"%s\",\n", $1 > "strfnames"
55                         printf "\t\t\"%s\",\n", $4 > "strcodes"
56                 }
57
58 END             {
59                         print  "\t\t(NCURSES_CONST char *)0," > "boolnames"
60                         print  "};" > "boolnames"
61                         print  "" > "boolnames"
62                         print  "\t\t(NCURSES_CONST char *)0," > "boolfnames"
63                         print  "};" > "boolfnames"
64                         print  "" > "boolfnames"
65                         print  "\t\t(NCURSES_CONST char *)0," > "boolcodes"
66                         print  "};" > "boolcodes"
67                         print  "" > "boolcodes"
68                         print  "\t\t(NCURSES_CONST char *)0," > "numnames"
69                         print  "};" > "numnames"
70                         print  "" > "numnames"
71                         print  "\t\t(NCURSES_CONST char *)0," > "numfnames"
72                         print  "};" > "numfnames"
73                         print  "" > "numfnames"
74                         print  "\t\t(NCURSES_CONST char *)0," > "numcodes"
75                         print  "};" > "numcodes"
76                         print  "" > "numcodes"
77                         print  "\t\t(NCURSES_CONST char *)0," > "strnames"
78                         print  "};" > "strnames"
79                         print  "" > "strnames"
80                         print  "\t\t(NCURSES_CONST char *)0," > "strfnames"
81                         print  "};" > "strfnames"
82                         print  "" > "strfnames"
83                         print  "\t\t(NCURSES_CONST char *)0," > "strcodes"
84                         print  "};"                             > "strcodes"
85                         print  ""                               > "strcodes"
86                         print  "#if BROKEN_LINKER"              > "nameftr"
87                         print  "#define FIX(it) IT *_nc_##it(void) { return data##it; }" > "nameftr"
88                         print  "FIX(boolnames)"                 > "nameftr"
89                         print  "FIX(boolfnames)"                > "nameftr"
90                         print  "FIX(numnames)"                  > "nameftr"
91                         print  "FIX(numfnames)"                 > "nameftr"
92                         print  "FIX(strnames)"                  > "nameftr"
93                         print  "FIX(strfnames)"                 > "nameftr"
94                         print  "#endif /* BROKEN_LINKER */"     > "nameftr"
95                         print  ""                               > "codeftr"
96                         print  "#if BROKEN_LINKER"              > "codeftr"
97                         print  "#define FIX(it) IT *_nc_##it(void) { return data##it; }" > "codeftr"
98                         print  "FIX(boolcodes)"                 > "codeftr"
99                         print  "FIX(numcodes)"                  > "codeftr"
100                         print  "FIX(strcodes)"                  > "codeftr"
101                         print  "#endif /* BROKEN_LINKER */"     > "codeftr"
102                 }