2 # $FreeBSD: src/usr.bin/getconf/fake-gperf.awk,v 1.2.2.1 2002/10/27 04:18:40 wollman Exp $
3 # $DragonFly: src/usr.bin/getconf/fake-gperf.awk,v 1.2 2003/06/17 04:29:27 dillon Exp $
12 /^%}$/ && state == 1 {
16 state == 1 { print; next; }
17 /^struct/ && state == 0 {
22 /^%%$/ && state == 0 {
24 print "#include <stddef.h>";
25 print "#include <string.h>";
26 if (struct_seen !~ /^$/) {
27 print "static const struct", struct_seen, "wordlist[] = {";
29 print "static const struct map {";
30 print "\tconst char *name;";
33 print "} wordlist[] = {";
38 /^%%$/ && state == 2 {
42 print "#define\tNWORDS\t(sizeof(wordlist)/sizeof(wordlist[0]) - 1)";
43 print "static const struct map *";
44 print "in_word_set(const char *word, unsigned int len)";
46 print "\tconst struct", struct_seen, "*mp;";
48 print "\tfor (mp = wordlist; mp < &wordlist[NWORDS]; mp++) {";
49 print "\t\tif (strcmp(word, mp->name) == 0)";
50 print "\t\t\treturn (mp);";
52 print "\treturn (NULL);";
57 state == 2 && NF == 2 {
58 name = substr($1, 1, length($1) - 1);
59 printf "#ifdef %s\n", $2;
60 printf "\t{ \"%s\", %s, 1 },\n", name, $2;
62 printf "\t{ \"%s\", 0, 0 },\n", name, $2;
66 state == 3 { print; next; }
68 # eat anything not matched.