freebsd-dev/usr.bin/getconf/progenv.gperf

68 lines
1.5 KiB
Plaintext
Raw Normal View History

Completely revamp the way getconf(1) works, for better adherence to the intent of the Standard. - Make getconf able to distinguish between configuration variables which are entirely unknown and those which are merely not defined in the compilation environment. The latter now get a more appropriate "undefined\n" result rather than a diagnostic. This may not be exactly right, but it's closer to the intent of the Standard than the previous behavior. - Support ``programming environments'' by validating that the environment requested with the `-v' flag is the one-and-only execution environment. (If more environments are supported for some platforms in the future, multiple getconf(1) executables will be required, but a simple edit in progenv.gperf will enable automatic support for it.) Document POSIX standard programming environments. - Add all of the 1003.1-2001 configuration variables. FreeBSD does not support all of these (including some that are mandatory); getconf will later be fixed to break the world should a required variable not be defined. As a result of all these changes, gperf is no longer adequate. Keep the overall format and names of the files for now, to preserve revision history. Use an awk script to process the .gperf files into C source, which does a few things that gperf, as a more general tool, cannot do. The keyword recognition function is no longer a perfect hash function. This may obviate the need for gperf in the source tree. - Add a small compile-time regression test to break the build if any of the .gperf files declare conflicting token sets. (gperf itself would have done this for the simple case of duplicate tokens in the same input file.)
2002-09-19 03:39:03 +00:00
%{
/*
* Copyright is disclaimed as to the contents of this file.
*
* $FreeBSD$
*/
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include "getconf.h"
/*
* Override gperf's built-in external scope.
*/
static const struct map *in_word_set(const char *str);
Completely revamp the way getconf(1) works, for better adherence to the intent of the Standard. - Make getconf able to distinguish between configuration variables which are entirely unknown and those which are merely not defined in the compilation environment. The latter now get a more appropriate "undefined\n" result rather than a diagnostic. This may not be exactly right, but it's closer to the intent of the Standard than the previous behavior. - Support ``programming environments'' by validating that the environment requested with the `-v' flag is the one-and-only execution environment. (If more environments are supported for some platforms in the future, multiple getconf(1) executables will be required, but a simple edit in progenv.gperf will enable automatic support for it.) Document POSIX standard programming environments. - Add all of the 1003.1-2001 configuration variables. FreeBSD does not support all of these (including some that are mandatory); getconf will later be fixed to break the world should a required variable not be defined. As a result of all these changes, gperf is no longer adequate. Keep the overall format and names of the files for now, to preserve revision history. Use an awk script to process the .gperf files into C source, which does a few things that gperf, as a more general tool, cannot do. The keyword recognition function is no longer a perfect hash function. This may obviate the need for gperf in the source tree. - Add a small compile-time regression test to break the build if any of the .gperf files declare conflicting token sets. (gperf itself would have done this for the simple case of duplicate tokens in the same input file.)
2002-09-19 03:39:03 +00:00
/*
* The Standard seems a bit ambiguous over whether the POSIX_V6_*
* are specified with or without a leading underscore, so we just
* use both.
*/
/*
* The alt_path member gives the path containing another `getconf'
* executable which was compiled using the specified programming
* environment. If it is NULL, the current executable is good enough.
* If we ever support multiple environments, this table will need to
* be updated. (We cheat here and define the supported environments
* statically.)
*/
#if defined(__alpha__) || defined(__sparc64__)
#define have_LP64_OFF64 NULL
#endif
#if defined(__i386__) || defined(__powerpc__)
#define have_ILP32_OFFBIG NULL
#endif
%}
struct map { const char *name; const char *alt_path; int valid; };
%%
POSIX_V6_ILP32_OFF32, notdef
POSIX_V6_ILP32_OFFBIG, have_ILP32_OFFBIG
POSIX_V6_LP64_OFF64, have_LP64_OFF64
POSIX_V6_LPBIG_OFFBIG, notdef
_POSIX_V6_ILP32_OFF32, notdef
_POSIX_V6_ILP32_OFFBIG, have_ILP32_OFFBIG
_POSIX_V6_LP64_OFF64, have_LP64_OFF64
_POSIX_V6_LPBIG_OFFBIG, notdef
%%
int
find_progenv(const char *name, const char **alt_path)
{
const struct map *rv;
rv = in_word_set(name);
Completely revamp the way getconf(1) works, for better adherence to the intent of the Standard. - Make getconf able to distinguish between configuration variables which are entirely unknown and those which are merely not defined in the compilation environment. The latter now get a more appropriate "undefined\n" result rather than a diagnostic. This may not be exactly right, but it's closer to the intent of the Standard than the previous behavior. - Support ``programming environments'' by validating that the environment requested with the `-v' flag is the one-and-only execution environment. (If more environments are supported for some platforms in the future, multiple getconf(1) executables will be required, but a simple edit in progenv.gperf will enable automatic support for it.) Document POSIX standard programming environments. - Add all of the 1003.1-2001 configuration variables. FreeBSD does not support all of these (including some that are mandatory); getconf will later be fixed to break the world should a required variable not be defined. As a result of all these changes, gperf is no longer adequate. Keep the overall format and names of the files for now, to preserve revision history. Use an awk script to process the .gperf files into C source, which does a few things that gperf, as a more general tool, cannot do. The keyword recognition function is no longer a perfect hash function. This may obviate the need for gperf in the source tree. - Add a small compile-time regression test to break the build if any of the .gperf files declare conflicting token sets. (gperf itself would have done this for the simple case of duplicate tokens in the same input file.)
2002-09-19 03:39:03 +00:00
if (rv != NULL) {
if (rv->valid) {
*alt_path = rv->alt_path;
return 1;
}
return -1;
}
return 0;
}