2 # $FreeBSD: head/usr.bin/getconf/fake-gperf.awk 119312 2003-08-22 17:32:07Z markm $
11 /^%}$/ && state == 1 {
15 state == 1 { print; next; }
16 /^struct/ && state == 0 {
21 /^%%$/ && state == 0 {
23 if (struct_seen !~ /^$/) {
24 print "static const struct", struct_seen, "wordlist[] = {";
26 print "static const struct map {";
27 print "\tconst char *name;";
30 print "} wordlist[] = {";
35 /^%%$/ && state == 2 {
37 print "\t{ NULL, 0, 0 }";
39 print "#define\tNWORDS\t(sizeof(wordlist)/sizeof(wordlist[0]) - 1)";
40 print "static const struct map *";
41 print "in_word_set(const char *word)";
43 print "\tconst struct", struct_seen, "*mp;";
45 print "\tfor (mp = wordlist; mp < &wordlist[NWORDS]; mp++) {";
46 print "\t\tif (strcmp(word, mp->name) == 0)";
47 print "\t\t\treturn (mp);";
49 print "\treturn (NULL);";
54 state == 2 && NF == 2 {
55 name = substr($1, 1, length($1) - 1);
56 printf "#ifdef %s\n", $2;
57 printf "\t{ \"%s\", %s, 1 },\n", name, $2;
59 printf "\t{ \"%s\", 0, 0 },\n", name, $2;
63 state == 3 { print; next; }
65 # eat anything not matched.