Deleted Added
full compact
fake-gperf.awk (103591) fake-gperf.awk (119312)
1#!/usr/bin/awk -f
1#!/usr/bin/awk -f
2# $FreeBSD: head/usr.bin/getconf/fake-gperf.awk 103591 2002-09-19 03:39:03Z wollman $
2# $FreeBSD: head/usr.bin/getconf/fake-gperf.awk 119312 2003-08-22 17:32:07Z markm $
3BEGIN {
4 state = 0;
5 struct_seen = "";
6}
7/^%{$/ && state == 0 {
8 state = 1;
9 next;
10}

--- 4 unchanged lines hidden (view full) ---

15state == 1 { print; next; }
16/^struct/ && state == 0 {
17 print;
18 struct_seen = $2;
19 next;
20}
21/^%%$/ && state == 0 {
22 state = 2;
3BEGIN {
4 state = 0;
5 struct_seen = "";
6}
7/^%{$/ && state == 0 {
8 state = 1;
9 next;
10}

--- 4 unchanged lines hidden (view full) ---

15state == 1 { print; next; }
16/^struct/ && state == 0 {
17 print;
18 struct_seen = $2;
19 next;
20}
21/^%%$/ && state == 0 {
22 state = 2;
23 print "#include <stddef.h>";
24 print "#include <string.h>";
25 if (struct_seen !~ /^$/) {
26 print "static const struct", struct_seen, "wordlist[] = {";
27 } else {
28 print "static const struct map {";
29 print "\tconst char *name;";
30 print "\tint key;";
31 print "\tint valid;";
32 print "} wordlist[] = {";
33 struct_seen = "map";
34 }
35 next;
36}
37/^%%$/ && state == 2 {
38 state = 3;
23 if (struct_seen !~ /^$/) {
24 print "static const struct", struct_seen, "wordlist[] = {";
25 } else {
26 print "static const struct map {";
27 print "\tconst char *name;";
28 print "\tint key;";
29 print "\tint valid;";
30 print "} wordlist[] = {";
31 struct_seen = "map";
32 }
33 next;
34}
35/^%%$/ && state == 2 {
36 state = 3;
39 print "\t{ NULL }";
37 print "\t{ NULL, 0, 0 }";
40 print "};";
41 print "#define\tNWORDS\t(sizeof(wordlist)/sizeof(wordlist[0]) - 1)";
42 print "static const struct map *";
38 print "};";
39 print "#define\tNWORDS\t(sizeof(wordlist)/sizeof(wordlist[0]) - 1)";
40 print "static const struct map *";
43 print "in_word_set(const char *word, unsigned int len)";
41 print "in_word_set(const char *word)";
44 print "{";
45 print "\tconst struct", struct_seen, "*mp;";
46 print "";
47 print "\tfor (mp = wordlist; mp < &wordlist[NWORDS]; mp++) {";
48 print "\t\tif (strcmp(word, mp->name) == 0)";
49 print "\t\t\treturn (mp);";
50 print "\t}";
51 print "\treturn (NULL);";

--- 17 unchanged lines hidden ---
42 print "{";
43 print "\tconst struct", struct_seen, "*mp;";
44 print "";
45 print "\tfor (mp = wordlist; mp < &wordlist[NWORDS]; mp++) {";
46 print "\t\tif (strcmp(word, mp->name) == 0)";
47 print "\t\t\treturn (mp);";
48 print "\t}";
49 print "\treturn (NULL);";

--- 17 unchanged lines hidden ---