2 # $FreeBSD: src/usr.bin/getconf/fake-gperf.awk,v 1.2.2.1 2002/10/27 04:18:40 wollman Exp $
11 /^%}$/ && state == 1 {
15 state == 1 { print; next; }
16 /^struct/ && state == 0 {
21 /^%%$/ && state == 0 {
23 print "#include <stddef.h>";
24 print "#include <string.h>";
25 if (struct_seen !~ /^$/) {
26 print "static const struct", struct_seen, "wordlist[] = {";
28 print "static const struct map {";
29 print "\tconst char *name;";
32 print "} wordlist[] = {";
37 /^%%$/ && state == 2 {
41 print "#define\tNWORDS\t(sizeof(wordlist)/sizeof(wordlist[0]) - 1)";
42 print "static const struct map *";
43 print "in_word_set(const char *word, unsigned int len)";
45 print "\tconst struct", struct_seen, "*mp;";
47 print "\tfor (mp = wordlist; mp < &wordlist[NWORDS]; mp++) {";
48 print "\t\tif (strcmp(word, mp->name) == 0)";
49 print "\t\t\treturn (mp);";
51 print "\treturn (NULL);";
56 state == 2 && NF == 2 {
57 name = substr($1, 1, length($1) - 1);
58 printf "#ifdef %s\n", $2;
59 printf "\t{ \"%s\", %s, 1 },\n", name, $2;
61 printf "\t{ \"%s\", 0, 0 },\n", name, $2;
65 state == 3 { print; next; }
67 # eat anything not matched.