diff options
author | Ton Voon <ton.voon@opsera.com> | 2010-06-24 10:02:31 +0100 |
---|---|---|
committer | Ton Voon <ton.voon@opsera.com> | 2010-06-24 10:02:31 +0100 |
commit | 342f3b403e888800fb1b0502bf4e0d8268358573 (patch) | |
tree | 47a0031fcf01edae3131fc147304d14f6f2aee20 /gl/m4 | |
parent | f789a37b057b6f34820ea4f95d63f53b5a84c980 (diff) | |
download | monitoring-plugins-342f3b403e888800fb1b0502bf4e0d8268358573.tar.gz |
Added unsetenv and setenv from gnulib
Diffstat (limited to 'gl/m4')
-rw-r--r-- | gl/m4/eealloc.m4 | 32 | ||||
-rw-r--r-- | gl/m4/environ.m4 | 36 | ||||
-rw-r--r-- | gl/m4/gnulib-cache.m4 | 4 | ||||
-rw-r--r-- | gl/m4/gnulib-comp.m4 | 24 | ||||
-rw-r--r-- | gl/m4/malloca.m4 | 15 | ||||
-rw-r--r-- | gl/m4/setenv.m4 | 111 |
6 files changed, 221 insertions, 1 deletions
diff --git a/gl/m4/eealloc.m4 b/gl/m4/eealloc.m4 new file mode 100644 index 00000000..63dd9202 --- /dev/null +++ b/gl/m4/eealloc.m4 @@ -0,0 +1,32 @@ +# eealloc.m4 serial 2 +dnl Copyright (C) 2003, 2009, 2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_EEALLOC], +[ + AC_REQUIRE([gl_EEMALLOC]) + AC_REQUIRE([gl_EEREALLOC]) + AC_REQUIRE([AC_C_INLINE]) +]) + +AC_DEFUN([gl_EEMALLOC], +[ + _AC_FUNC_MALLOC_IF( + [gl_cv_func_malloc_0_nonnull=1], + [gl_cv_func_malloc_0_nonnull=0]) + AC_DEFINE_UNQUOTED([MALLOC_0_IS_NONNULL], [$gl_cv_func_malloc_0_nonnull], + [If malloc(0) is != NULL, define this to 1. Otherwise define this + to 0.]) +]) + +AC_DEFUN([gl_EEREALLOC], +[ + _AC_FUNC_REALLOC_IF( + [gl_cv_func_realloc_0_nonnull=1], + [gl_cv_func_realloc_0_nonnull=0]) + AC_DEFINE_UNQUOTED([REALLOC_0_IS_NONNULL], [$gl_cv_func_realloc_0_nonnull], + [If realloc(NULL,0) is != NULL, define this to 1. Otherwise define this + to 0.]) +]) diff --git a/gl/m4/environ.m4 b/gl/m4/environ.m4 new file mode 100644 index 00000000..4c6849a3 --- /dev/null +++ b/gl/m4/environ.m4 @@ -0,0 +1,36 @@ +# environ.m4 serial 4 +dnl Copyright (C) 2001-2004, 2006-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_ENVIRON], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + dnl Persuade glibc <unistd.h> to declare environ. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + gt_CHECK_VAR_DECL([#include <unistd.h>], environ) + if test $gt_cv_var_environ_declaration != yes; then + HAVE_DECL_ENVIRON=0 + fi +]) + +# Check if a variable is properly declared. +# gt_CHECK_VAR_DECL(includes,variable) +AC_DEFUN([gt_CHECK_VAR_DECL], +[ + define([gt_cv_var], [gt_cv_var_]$2[_declaration]) + AC_MSG_CHECKING([if $2 is properly declared]) + AC_CACHE_VAL([gt_cv_var], [ + AC_TRY_COMPILE([$1 + extern struct { int foo; } $2;], + [$2.foo = 1;], + gt_cv_var=no, + gt_cv_var=yes)]) + AC_MSG_RESULT([$gt_cv_var]) + if test $gt_cv_var = yes; then + AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1, + [Define if you have the declaration of $2.]) + fi + undefine([gt_cv_var]) +]) diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4 index f23cb519..22e61333 100644 --- a/gl/m4/gnulib-cache.m4 +++ b/gl/m4/gnulib-cache.m4 @@ -15,7 +15,7 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex strsep timegm vasprintf vsnprintf +# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex setenv strsep timegm unsetenv vasprintf vsnprintf # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([]) @@ -32,8 +32,10 @@ gl_MODULES([ gettext mountlist regex + setenv strsep timegm + unsetenv vasprintf vsnprintf ]) diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index 73e63654..fc3f3538 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -41,6 +41,7 @@ AC_DEFUN([gl_EARLY], # Code from module dirname-lgpl: # Code from module double-slash-root: # Code from module dup2: + # Code from module environ: # Code from module errno: # Code from module error: # Code from module exitfail: @@ -74,6 +75,7 @@ AC_DEFUN([gl_EARLY], # Code from module locale: # Code from module malloc: # Code from module malloc-posix: + # Code from module malloca: # Code from module math: # Code from module mbrtowc: # Code from module mbsinit: @@ -89,6 +91,7 @@ AC_DEFUN([gl_EARLY], # Code from module safe-read: # Code from module safe-write: # Code from module servent: + # Code from module setenv: # Code from module size_max: # Code from module snprintf: # Code from module sockets: @@ -115,6 +118,7 @@ AC_DEFUN([gl_EARLY], # Code from module timegm: # Code from module unistd: # Code from module unistd-safer: + # Code from module unsetenv: # Code from module vasnprintf: # Code from module vasprintf: # Code from module verify: @@ -178,6 +182,9 @@ AC_DEFUN([gl_INIT], # Code from module dup2: gl_FUNC_DUP2 gl_UNISTD_MODULE_INDICATOR([dup2]) + # Code from module environ: + gl_ENVIRON + gl_UNISTD_MODULE_INDICATOR([environ]) # Code from module errno: gl_HEADER_ERRNO_H # Code from module error: @@ -252,6 +259,8 @@ AC_DEFUN([gl_INIT], # Code from module malloc-posix: gl_FUNC_MALLOC_POSIX gl_STDLIB_MODULE_INDICATOR([malloc-posix]) + # Code from module malloca: + gl_MALLOCA # Code from module math: gl_MATH_H # Code from module mbrtowc: @@ -289,6 +298,9 @@ AC_DEFUN([gl_INIT], gl_SAFE_WRITE # Code from module servent: gl_SERVENT + # Code from module setenv: + gl_FUNC_SETENV + gl_STDLIB_MODULE_INDICATOR([setenv]) # Code from module size_max: gl_SIZE_MAX # Code from module snprintf: @@ -352,6 +364,9 @@ AC_DEFUN([gl_INIT], gl_UNISTD_H # Code from module unistd-safer: gl_UNISTD_SAFER + # Code from module unsetenv: + gl_FUNC_UNSETENV + gl_STDLIB_MODULE_INDICATOR([unsetenv]) # Code from module vasnprintf: gl_FUNC_VASNPRINTF # Code from module vasprintf: @@ -586,6 +601,9 @@ AC_DEFUN([gl_FILE_LIST], [ lib/localcharset.h lib/locale.in.h lib/malloc.c + lib/malloca.c + lib/malloca.h + lib/malloca.valgrind lib/math.in.h lib/mbrtowc.c lib/mbsinit.c @@ -617,6 +635,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/safe-read.h lib/safe-write.c lib/safe-write.h + lib/setenv.c lib/sha1.c lib/sha1.h lib/size_max.h @@ -648,6 +667,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/unistd--.h lib/unistd-safer.h lib/unistd.in.h + lib/unsetenv.c lib/vasnprintf.c lib/vasnprintf.h lib/vasprintf.c @@ -677,6 +697,8 @@ AC_DEFUN([gl_FILE_LIST], [ m4/dos.m4 m4/double-slash-root.m4 m4/dup2.m4 + m4/eealloc.m4 + m4/environ.m4 m4/errno_h.m4 m4/error.m4 m4/extensions.m4 @@ -724,6 +746,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/longlong.m4 m4/ls-mntd-fs.m4 m4/malloc.m4 + m4/malloca.m4 m4/math_h.m4 m4/mbrtowc.m4 m4/mbsinit.m4 @@ -748,6 +771,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/safe-read.m4 m4/safe-write.m4 m4/servent.m4 + m4/setenv.m4 m4/sha1.m4 m4/size_max.m4 m4/snprintf.m4 diff --git a/gl/m4/malloca.m4 b/gl/m4/malloca.m4 new file mode 100644 index 00000000..e07c6d93 --- /dev/null +++ b/gl/m4/malloca.m4 @@ -0,0 +1,15 @@ +# malloca.m4 serial 1 +dnl Copyright (C) 2003-2004, 2006-2007, 2009-2010 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_MALLOCA], +[ + dnl Use the autoconf tests for alloca(), but not the AC_SUBSTed variables + dnl @ALLOCA@ and @LTALLOCA@. + dnl gl_FUNC_ALLOCA dnl Already brought in by the module dependencies. + AC_REQUIRE([gl_EEMALLOC]) + AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) +]) diff --git a/gl/m4/setenv.m4 b/gl/m4/setenv.m4 new file mode 100644 index 00000000..58f6d138 --- /dev/null +++ b/gl/m4/setenv.m4 @@ -0,0 +1,111 @@ +# setenv.m4 serial 16 +dnl Copyright (C) 2001-2004, 2006-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_SETENV], +[ + AC_REQUIRE([gl_FUNC_SETENV_SEPARATE]) + if test $HAVE_SETENV$REPLACE_SETENV != 10; then + AC_LIBOBJ([setenv]) + fi +]) + +# Like gl_FUNC_SETENV, except prepare for separate compilation (no AC_LIBOBJ). +AC_DEFUN([gl_FUNC_SETENV_SEPARATE], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_CHECK_FUNCS_ONCE([setenv]) + if test $ac_cv_func_setenv = no; then + HAVE_SETENV=0 + else + AC_CACHE_CHECK([whether setenv validates arguments], + [gl_cv_func_setenv_works], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ + #include <stdlib.h> + #include <errno.h> + #include <string.h> + ]], [[ + if (setenv ("", "", 0) != -1) return 1; + if (errno != EINVAL) return 2; + if (setenv ("a", "=", 1) != 0) return 3; + if (strcmp (getenv ("a"), "=") != 0) return 4; + ]])], + [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no], + [gl_cv_func_setenv_works="guessing no"])]) + if test "$gl_cv_func_setenv_works" != yes; then + REPLACE_SETENV=1 + AC_LIBOBJ([setenv]) + fi + fi + gl_PREREQ_SETENV +]) + +AC_DEFUN([gl_FUNC_UNSETENV], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_CHECK_FUNCS([unsetenv]) + if test $ac_cv_func_unsetenv = no; then + HAVE_UNSETENV=0 + AC_LIBOBJ([unsetenv]) + gl_PREREQ_UNSETENV + else + dnl Some BSDs return void, failing to do error checking. + AC_CACHE_CHECK([for unsetenv() return type], [gt_cv_func_unsetenv_ret], + [AC_TRY_COMPILE([#include <stdlib.h> +extern +#ifdef __cplusplus +"C" +#endif +#if defined(__STDC__) || defined(__cplusplus) +int unsetenv (const char *name); +#else +int unsetenv(); +#endif +], , gt_cv_func_unsetenv_ret='int', gt_cv_func_unsetenv_ret='void')]) + if test $gt_cv_func_unsetenv_ret = 'void'; then + AC_DEFINE([VOID_UNSETENV], [1], [Define to 1 if unsetenv returns void + instead of int.]) + REPLACE_UNSETENV=1 + AC_LIBOBJ([unsetenv]) + fi + + dnl Solaris 10 unsetenv does not remove all copies of a name. + AC_CACHE_CHECK([whether unsetenv works on duplicates], + [gl_cv_func_unsetenv_works], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ + #include <stdlib.h> + ]], [[ + char entry[] = "b=2"; + if (putenv ((char *) "a=1")) return 1; + if (putenv (entry)) return 2; + entry[0] = 'a'; + unsetenv ("a"); + if (getenv ("a")) return 3; + ]])], + [gl_cv_func_unsetenv_works=yes], [gl_cv_func_unsetenv_works=no], + [gl_cv_func_unsetenv_works="guessing no"])]) + if test "$gl_cv_func_unsetenv_works" != yes; then + REPLACE_UNSETENV=1 + AC_LIBOBJ([unsetenv]) + fi + fi +]) + +# Prerequisites of lib/setenv.c. +AC_DEFUN([gl_PREREQ_SETENV], +[ + AC_REQUIRE([AC_FUNC_ALLOCA]) + AC_REQUIRE([gl_ENVIRON]) + AC_CHECK_HEADERS_ONCE([unistd.h]) + AC_CHECK_HEADERS([search.h]) + AC_CHECK_FUNCS([tsearch]) +]) + +# Prerequisites of lib/unsetenv.c. +AC_DEFUN([gl_PREREQ_UNSETENV], +[ + AC_REQUIRE([gl_ENVIRON]) + AC_CHECK_HEADERS_ONCE([unistd.h]) +]) |