summaryrefslogtreecommitdiffstats
path: root/usr.bin/getconf
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>2002-09-18 03:15:25 +0000
committerwollman <wollman@FreeBSD.org>2002-09-18 03:15:25 +0000
commite90b0d538172fcbc68cdb4113236892176a092dc (patch)
treeb9a2e3d0decc0b7eba2fcec311bc5fda69414d68 /usr.bin/getconf
parent4a39538d4e66467504cb81cb38dcaf92965e9f99 (diff)
downloadFreeBSD-src-e90b0d538172fcbc68cdb4113236892176a092dc.zip
FreeBSD-src-e90b0d538172fcbc68cdb4113236892176a092dc.tar.gz
Make obrien happy. Add a bad awk script which emulates as much of
gperf's behavior as we ever actually needed here. This generates a much-less-efficient keyword recognizer, but it's not like that matters in this application. Makefile changes coming once this passes the world test.
Diffstat (limited to 'usr.bin/getconf')
-rw-r--r--usr.bin/getconf/fake-gperf.awk57
1 files changed, 57 insertions, 0 deletions
diff --git a/usr.bin/getconf/fake-gperf.awk b/usr.bin/getconf/fake-gperf.awk
new file mode 100644
index 0000000..bffa508
--- /dev/null
+++ b/usr.bin/getconf/fake-gperf.awk
@@ -0,0 +1,57 @@
+#!/usr/bin/awk -f
+#
+# This file is in the public domain. Written by Garrett A. Wollman,
+# 2002-09-17.
+#
+# $FreeBSD$
+#
+BEGIN {
+ state = 0;
+}
+/^%{$/ && state == 0 {
+ state = 1;
+ next;
+}
+/^%}$/ && state == 1 {
+ state = 0;
+ next;
+}
+state == 1 { print; next; }
+/^%%$/ && state == 0 {
+ state = 2;
+ print "#include <stddef.h>";
+ print "#include <string.h>";
+ print "static const struct map {";
+ print "\tconst char *name;";
+ print "\tint key;";
+ print "} wordlist[] = {";
+ next;
+}
+/^%%$/ && state == 2 {
+ state = 3;
+ print "\t{ NULL }";
+ print "};";
+ print "#define\tNWORDS\t(sizeof(wordlist)/sizeof(wordlist[0]))";
+ print "static const struct map *";
+ print "in_word_set(const char *word, unsigned int len)";
+ print "{";
+ print "\tconst struct map *mp;";
+ print "";
+ print "\tfor (mp = wordlist; mp < &wordlist[NWORDS]; mp++) {";
+ print "\t\tif (strcmp(word, mp->name) == 0)";
+ print "\t\t\treturn (mp);";
+ print "\t}";
+ print "\treturn (NULL);";
+ print "}";
+ print "";
+ next;
+}
+state == 2 && NF == 2 {
+ name = substr($1, 1, length($1) - 1);
+ printf "\t{ \"%s\", %s },\n", name, $2;
+ next;
+}
+state == 3 { print; next; }
+{
+ # eat anything not matched.
+}
OpenPOWER on IntegriCloud