diff options
| author | Mark Murray <markm@FreeBSD.org> | 2003-08-22 17:32:07 +0000 |
|---|---|---|
| committer | Mark Murray <markm@FreeBSD.org> | 2003-08-22 17:32:07 +0000 |
| commit | a272cd3af01720eab4b74693f31a8dbe3c66b870 (patch) | |
| tree | 1eb050875892779ca4712d66dce6d99317516b72 /usr.bin | |
| parent | b842ac21d62a6f750dfd22b4e0297d88366933e6 (diff) | |
Notes
Diffstat (limited to 'usr.bin')
| -rw-r--r-- | usr.bin/getconf/confstr.gperf | 4 | ||||
| -rw-r--r-- | usr.bin/getconf/fake-gperf.awk | 6 | ||||
| -rw-r--r-- | usr.bin/getconf/getconf.c | 17 | ||||
| -rw-r--r-- | usr.bin/getconf/limits.gperf | 4 | ||||
| -rw-r--r-- | usr.bin/getconf/pathconf.gperf | 7 | ||||
| -rw-r--r-- | usr.bin/getconf/progenv.gperf | 4 | ||||
| -rw-r--r-- | usr.bin/getconf/sysconf.gperf | 5 |
7 files changed, 19 insertions, 28 deletions
diff --git a/usr.bin/getconf/confstr.gperf b/usr.bin/getconf/confstr.gperf index 14ad5f2eb9812..c629987e5caf8 100644 --- a/usr.bin/getconf/confstr.gperf +++ b/usr.bin/getconf/confstr.gperf @@ -15,7 +15,7 @@ /* * Override gperf's built-in external scope. */ -static const struct map *in_word_set(const char *str, unsigned int len); +static const struct map *in_word_set(const char *str); /* * The Standard seems a bit ambiguous over whether the POSIX_V6_* @@ -58,7 +58,7 @@ find_confstr(const char *name, int *key) { const struct map *rv; - rv = in_word_set(name, strlen(name)); + rv = in_word_set(name); if (rv != NULL) { if (rv->valid) { *key = rv->key; diff --git a/usr.bin/getconf/fake-gperf.awk b/usr.bin/getconf/fake-gperf.awk index 2705d6a03450e..96fcd3c9977c2 100644 --- a/usr.bin/getconf/fake-gperf.awk +++ b/usr.bin/getconf/fake-gperf.awk @@ -20,8 +20,6 @@ state == 1 { print; next; } } /^%%$/ && state == 0 { state = 2; - print "#include <stddef.h>"; - print "#include <string.h>"; if (struct_seen !~ /^$/) { print "static const struct", struct_seen, "wordlist[] = {"; } else { @@ -36,11 +34,11 @@ state == 1 { print; next; } } /^%%$/ && state == 2 { state = 3; - print "\t{ NULL }"; + print "\t{ NULL, 0, 0 }"; print "};"; print "#define\tNWORDS\t(sizeof(wordlist)/sizeof(wordlist[0]) - 1)"; print "static const struct map *"; - print "in_word_set(const char *word, unsigned int len)"; + print "in_word_set(const char *word)"; print "{"; print "\tconst struct", struct_seen, "*mp;"; print ""; diff --git a/usr.bin/getconf/getconf.c b/usr.bin/getconf/getconf.c index 61c18534b7302..0ba45a0e3ce30 100644 --- a/usr.bin/getconf/getconf.c +++ b/usr.bin/getconf/getconf.c @@ -138,24 +138,19 @@ main(int argc, char **argv) static void do_confstr(const char *name, int key) { - char *buf; size_t len; len = confstr(key, 0, 0); if (len == (size_t)-1) err(EX_OSERR, "confstr: %s", name); - if (len == 0) { + if (len == 0) printf("undefined\n"); - } else { - buf = malloc(len); - if (buf != NULL) { - confstr(key, buf, len); - printf("%s\n", buf); - free(buf); - } - else - err(EX_OSERR, "malloc: confstr"); + else { + char buf[len + 1]; + + confstr(key, buf, len); + printf("%s\n", buf); } } diff --git a/usr.bin/getconf/limits.gperf b/usr.bin/getconf/limits.gperf index bb8ef0d09d87c..68e0d65e78ff5 100644 --- a/usr.bin/getconf/limits.gperf +++ b/usr.bin/getconf/limits.gperf @@ -15,7 +15,7 @@ /* * Override gperf's built-in external scope. */ -static const struct map *in_word_set(const char *str, unsigned int len); +static const struct map *in_word_set(const char *str); %} struct map { const char *name; intmax_t value; int valid; }; @@ -106,7 +106,7 @@ find_limit(const char *name, intmax_t *value) { const struct map *rv; - rv = in_word_set(name, strlen(name)); + rv = in_word_set(name); if (rv != NULL) { if (rv->valid) { *value = rv->value; diff --git a/usr.bin/getconf/pathconf.gperf b/usr.bin/getconf/pathconf.gperf index 60c05d45580d3..e8b83659d80f4 100644 --- a/usr.bin/getconf/pathconf.gperf +++ b/usr.bin/getconf/pathconf.gperf @@ -7,7 +7,6 @@ #include <sys/types.h> -#include <limits.h> #include <string.h> #include <unistd.h> @@ -16,10 +15,10 @@ /* * Override gperf's built-in external scope. */ -static const struct map *in_word_set(const char *str, unsigned int len); +static const struct map *in_word_set(const char *str); %} -struct map { char *name; int key; int valid; }; +struct map { const char *name; int key; int valid; }; %% FILESIZEBITS, _PC_FILESIZEBITS LINK_MAX, _PC_LINK_MAX @@ -51,7 +50,7 @@ find_pathconf(const char *name, int *key) { const struct map *rv; - rv = in_word_set(name, strlen(name)); + rv = in_word_set(name); if (rv != NULL) { if (rv->valid) { *key = rv->key; diff --git a/usr.bin/getconf/progenv.gperf b/usr.bin/getconf/progenv.gperf index 64c9b4ca19980..cfbde6610cdb1 100644 --- a/usr.bin/getconf/progenv.gperf +++ b/usr.bin/getconf/progenv.gperf @@ -15,7 +15,7 @@ /* * Override gperf's built-in external scope. */ -static const struct map *in_word_set(const char *str, unsigned int len); +static const struct map *in_word_set(const char *str); /* * The Standard seems a bit ambiguous over whether the POSIX_V6_* @@ -55,7 +55,7 @@ find_progenv(const char *name, const char **alt_path) { const struct map *rv; - rv = in_word_set(name, strlen(name)); + rv = in_word_set(name); if (rv != NULL) { if (rv->valid) { *alt_path = rv->alt_path; diff --git a/usr.bin/getconf/sysconf.gperf b/usr.bin/getconf/sysconf.gperf index 1c9d2bc280459..ae88464a0b742 100644 --- a/usr.bin/getconf/sysconf.gperf +++ b/usr.bin/getconf/sysconf.gperf @@ -7,7 +7,6 @@ #include <sys/types.h> -#include <limits.h> #include <string.h> #include <unistd.h> @@ -16,7 +15,7 @@ /* * Override gperf's built-in external scope. */ -static const struct map *in_word_set(const char *str, unsigned int len); +static const struct map *in_word_set(const char *str); %} struct map { const char *name; int key; int valid; }; @@ -138,7 +137,7 @@ find_sysconf(const char *name, int *key) { const struct map *rv; - rv = in_word_set(name, strlen(name)); + rv = in_word_set(name); if (rv != NULL) { if (rv->valid) { *key = rv->key; |
