diff options
author | Ton Voon <ton.voon@opsera.com> | 2010-06-24 09:02:31 (GMT) |
---|---|---|
committer | Ton Voon <ton.voon@opsera.com> | 2010-06-24 09:02:31 (GMT) |
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 0000000..63dd920 --- /dev/null +++ b/gl/m4/eealloc.m4 | |||
@@ -0,0 +1,32 @@ | |||
1 | # eealloc.m4 serial 2 | ||
2 | dnl Copyright (C) 2003, 2009, 2010 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | AC_DEFUN([gl_EEALLOC], | ||
8 | [ | ||
9 | AC_REQUIRE([gl_EEMALLOC]) | ||
10 | AC_REQUIRE([gl_EEREALLOC]) | ||
11 | AC_REQUIRE([AC_C_INLINE]) | ||
12 | ]) | ||
13 | |||
14 | AC_DEFUN([gl_EEMALLOC], | ||
15 | [ | ||
16 | _AC_FUNC_MALLOC_IF( | ||
17 | [gl_cv_func_malloc_0_nonnull=1], | ||
18 | [gl_cv_func_malloc_0_nonnull=0]) | ||
19 | AC_DEFINE_UNQUOTED([MALLOC_0_IS_NONNULL], [$gl_cv_func_malloc_0_nonnull], | ||
20 | [If malloc(0) is != NULL, define this to 1. Otherwise define this | ||
21 | to 0.]) | ||
22 | ]) | ||
23 | |||
24 | AC_DEFUN([gl_EEREALLOC], | ||
25 | [ | ||
26 | _AC_FUNC_REALLOC_IF( | ||
27 | [gl_cv_func_realloc_0_nonnull=1], | ||
28 | [gl_cv_func_realloc_0_nonnull=0]) | ||
29 | AC_DEFINE_UNQUOTED([REALLOC_0_IS_NONNULL], [$gl_cv_func_realloc_0_nonnull], | ||
30 | [If realloc(NULL,0) is != NULL, define this to 1. Otherwise define this | ||
31 | to 0.]) | ||
32 | ]) | ||
diff --git a/gl/m4/environ.m4 b/gl/m4/environ.m4 new file mode 100644 index 0000000..4c6849a --- /dev/null +++ b/gl/m4/environ.m4 | |||
@@ -0,0 +1,36 @@ | |||
1 | # environ.m4 serial 4 | ||
2 | dnl Copyright (C) 2001-2004, 2006-2010 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | AC_DEFUN_ONCE([gl_ENVIRON], | ||
8 | [ | ||
9 | AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) | ||
10 | dnl Persuade glibc <unistd.h> to declare environ. | ||
11 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | ||
12 | gt_CHECK_VAR_DECL([#include <unistd.h>], environ) | ||
13 | if test $gt_cv_var_environ_declaration != yes; then | ||
14 | HAVE_DECL_ENVIRON=0 | ||
15 | fi | ||
16 | ]) | ||
17 | |||
18 | # Check if a variable is properly declared. | ||
19 | # gt_CHECK_VAR_DECL(includes,variable) | ||
20 | AC_DEFUN([gt_CHECK_VAR_DECL], | ||
21 | [ | ||
22 | define([gt_cv_var], [gt_cv_var_]$2[_declaration]) | ||
23 | AC_MSG_CHECKING([if $2 is properly declared]) | ||
24 | AC_CACHE_VAL([gt_cv_var], [ | ||
25 | AC_TRY_COMPILE([$1 | ||
26 | extern struct { int foo; } $2;], | ||
27 | [$2.foo = 1;], | ||
28 | gt_cv_var=no, | ||
29 | gt_cv_var=yes)]) | ||
30 | AC_MSG_RESULT([$gt_cv_var]) | ||
31 | if test $gt_cv_var = yes; then | ||
32 | AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1, | ||
33 | [Define if you have the declaration of $2.]) | ||
34 | fi | ||
35 | undefine([gt_cv_var]) | ||
36 | ]) | ||
diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4 index f23cb51..22e6133 100644 --- a/gl/m4/gnulib-cache.m4 +++ b/gl/m4/gnulib-cache.m4 | |||
@@ -15,7 +15,7 @@ | |||
15 | 15 | ||
16 | 16 | ||
17 | # Specification in the form of a command-line invocation: | 17 | # Specification in the form of a command-line invocation: |
18 | # 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 | 18 | # 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 |
19 | 19 | ||
20 | # Specification in the form of a few gnulib-tool.m4 macro invocations: | 20 | # Specification in the form of a few gnulib-tool.m4 macro invocations: |
21 | gl_LOCAL_DIR([]) | 21 | gl_LOCAL_DIR([]) |
@@ -32,8 +32,10 @@ gl_MODULES([ | |||
32 | gettext | 32 | gettext |
33 | mountlist | 33 | mountlist |
34 | regex | 34 | regex |
35 | setenv | ||
35 | strsep | 36 | strsep |
36 | timegm | 37 | timegm |
38 | unsetenv | ||
37 | vasprintf | 39 | vasprintf |
38 | vsnprintf | 40 | vsnprintf |
39 | ]) | 41 | ]) |
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index 73e6365..fc3f353 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 | |||
@@ -41,6 +41,7 @@ AC_DEFUN([gl_EARLY], | |||
41 | # Code from module dirname-lgpl: | 41 | # Code from module dirname-lgpl: |
42 | # Code from module double-slash-root: | 42 | # Code from module double-slash-root: |
43 | # Code from module dup2: | 43 | # Code from module dup2: |
44 | # Code from module environ: | ||
44 | # Code from module errno: | 45 | # Code from module errno: |
45 | # Code from module error: | 46 | # Code from module error: |
46 | # Code from module exitfail: | 47 | # Code from module exitfail: |
@@ -74,6 +75,7 @@ AC_DEFUN([gl_EARLY], | |||
74 | # Code from module locale: | 75 | # Code from module locale: |
75 | # Code from module malloc: | 76 | # Code from module malloc: |
76 | # Code from module malloc-posix: | 77 | # Code from module malloc-posix: |
78 | # Code from module malloca: | ||
77 | # Code from module math: | 79 | # Code from module math: |
78 | # Code from module mbrtowc: | 80 | # Code from module mbrtowc: |
79 | # Code from module mbsinit: | 81 | # Code from module mbsinit: |
@@ -89,6 +91,7 @@ AC_DEFUN([gl_EARLY], | |||
89 | # Code from module safe-read: | 91 | # Code from module safe-read: |
90 | # Code from module safe-write: | 92 | # Code from module safe-write: |
91 | # Code from module servent: | 93 | # Code from module servent: |
94 | # Code from module setenv: | ||
92 | # Code from module size_max: | 95 | # Code from module size_max: |
93 | # Code from module snprintf: | 96 | # Code from module snprintf: |
94 | # Code from module sockets: | 97 | # Code from module sockets: |
@@ -115,6 +118,7 @@ AC_DEFUN([gl_EARLY], | |||
115 | # Code from module timegm: | 118 | # Code from module timegm: |
116 | # Code from module unistd: | 119 | # Code from module unistd: |
117 | # Code from module unistd-safer: | 120 | # Code from module unistd-safer: |
121 | # Code from module unsetenv: | ||
118 | # Code from module vasnprintf: | 122 | # Code from module vasnprintf: |
119 | # Code from module vasprintf: | 123 | # Code from module vasprintf: |
120 | # Code from module verify: | 124 | # Code from module verify: |
@@ -178,6 +182,9 @@ AC_DEFUN([gl_INIT], | |||
178 | # Code from module dup2: | 182 | # Code from module dup2: |
179 | gl_FUNC_DUP2 | 183 | gl_FUNC_DUP2 |
180 | gl_UNISTD_MODULE_INDICATOR([dup2]) | 184 | gl_UNISTD_MODULE_INDICATOR([dup2]) |
185 | # Code from module environ: | ||
186 | gl_ENVIRON | ||
187 | gl_UNISTD_MODULE_INDICATOR([environ]) | ||
181 | # Code from module errno: | 188 | # Code from module errno: |
182 | gl_HEADER_ERRNO_H | 189 | gl_HEADER_ERRNO_H |
183 | # Code from module error: | 190 | # Code from module error: |
@@ -252,6 +259,8 @@ AC_DEFUN([gl_INIT], | |||
252 | # Code from module malloc-posix: | 259 | # Code from module malloc-posix: |
253 | gl_FUNC_MALLOC_POSIX | 260 | gl_FUNC_MALLOC_POSIX |
254 | gl_STDLIB_MODULE_INDICATOR([malloc-posix]) | 261 | gl_STDLIB_MODULE_INDICATOR([malloc-posix]) |
262 | # Code from module malloca: | ||
263 | gl_MALLOCA | ||
255 | # Code from module math: | 264 | # Code from module math: |
256 | gl_MATH_H | 265 | gl_MATH_H |
257 | # Code from module mbrtowc: | 266 | # Code from module mbrtowc: |
@@ -289,6 +298,9 @@ AC_DEFUN([gl_INIT], | |||
289 | gl_SAFE_WRITE | 298 | gl_SAFE_WRITE |
290 | # Code from module servent: | 299 | # Code from module servent: |
291 | gl_SERVENT | 300 | gl_SERVENT |
301 | # Code from module setenv: | ||
302 | gl_FUNC_SETENV | ||
303 | gl_STDLIB_MODULE_INDICATOR([setenv]) | ||
292 | # Code from module size_max: | 304 | # Code from module size_max: |
293 | gl_SIZE_MAX | 305 | gl_SIZE_MAX |
294 | # Code from module snprintf: | 306 | # Code from module snprintf: |
@@ -352,6 +364,9 @@ AC_DEFUN([gl_INIT], | |||
352 | gl_UNISTD_H | 364 | gl_UNISTD_H |
353 | # Code from module unistd-safer: | 365 | # Code from module unistd-safer: |
354 | gl_UNISTD_SAFER | 366 | gl_UNISTD_SAFER |
367 | # Code from module unsetenv: | ||
368 | gl_FUNC_UNSETENV | ||
369 | gl_STDLIB_MODULE_INDICATOR([unsetenv]) | ||
355 | # Code from module vasnprintf: | 370 | # Code from module vasnprintf: |
356 | gl_FUNC_VASNPRINTF | 371 | gl_FUNC_VASNPRINTF |
357 | # Code from module vasprintf: | 372 | # Code from module vasprintf: |
@@ -586,6 +601,9 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
586 | lib/localcharset.h | 601 | lib/localcharset.h |
587 | lib/locale.in.h | 602 | lib/locale.in.h |
588 | lib/malloc.c | 603 | lib/malloc.c |
604 | lib/malloca.c | ||
605 | lib/malloca.h | ||
606 | lib/malloca.valgrind | ||
589 | lib/math.in.h | 607 | lib/math.in.h |
590 | lib/mbrtowc.c | 608 | lib/mbrtowc.c |
591 | lib/mbsinit.c | 609 | lib/mbsinit.c |
@@ -617,6 +635,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
617 | lib/safe-read.h | 635 | lib/safe-read.h |
618 | lib/safe-write.c | 636 | lib/safe-write.c |
619 | lib/safe-write.h | 637 | lib/safe-write.h |
638 | lib/setenv.c | ||
620 | lib/sha1.c | 639 | lib/sha1.c |
621 | lib/sha1.h | 640 | lib/sha1.h |
622 | lib/size_max.h | 641 | lib/size_max.h |
@@ -648,6 +667,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
648 | lib/unistd--.h | 667 | lib/unistd--.h |
649 | lib/unistd-safer.h | 668 | lib/unistd-safer.h |
650 | lib/unistd.in.h | 669 | lib/unistd.in.h |
670 | lib/unsetenv.c | ||
651 | lib/vasnprintf.c | 671 | lib/vasnprintf.c |
652 | lib/vasnprintf.h | 672 | lib/vasnprintf.h |
653 | lib/vasprintf.c | 673 | lib/vasprintf.c |
@@ -677,6 +697,8 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
677 | m4/dos.m4 | 697 | m4/dos.m4 |
678 | m4/double-slash-root.m4 | 698 | m4/double-slash-root.m4 |
679 | m4/dup2.m4 | 699 | m4/dup2.m4 |
700 | m4/eealloc.m4 | ||
701 | m4/environ.m4 | ||
680 | m4/errno_h.m4 | 702 | m4/errno_h.m4 |
681 | m4/error.m4 | 703 | m4/error.m4 |
682 | m4/extensions.m4 | 704 | m4/extensions.m4 |
@@ -724,6 +746,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
724 | m4/longlong.m4 | 746 | m4/longlong.m4 |
725 | m4/ls-mntd-fs.m4 | 747 | m4/ls-mntd-fs.m4 |
726 | m4/malloc.m4 | 748 | m4/malloc.m4 |
749 | m4/malloca.m4 | ||
727 | m4/math_h.m4 | 750 | m4/math_h.m4 |
728 | m4/mbrtowc.m4 | 751 | m4/mbrtowc.m4 |
729 | m4/mbsinit.m4 | 752 | m4/mbsinit.m4 |
@@ -748,6 +771,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
748 | m4/safe-read.m4 | 771 | m4/safe-read.m4 |
749 | m4/safe-write.m4 | 772 | m4/safe-write.m4 |
750 | m4/servent.m4 | 773 | m4/servent.m4 |
774 | m4/setenv.m4 | ||
751 | m4/sha1.m4 | 775 | m4/sha1.m4 |
752 | m4/size_max.m4 | 776 | m4/size_max.m4 |
753 | m4/snprintf.m4 | 777 | m4/snprintf.m4 |
diff --git a/gl/m4/malloca.m4 b/gl/m4/malloca.m4 new file mode 100644 index 0000000..e07c6d9 --- /dev/null +++ b/gl/m4/malloca.m4 | |||
@@ -0,0 +1,15 @@ | |||
1 | # malloca.m4 serial 1 | ||
2 | dnl Copyright (C) 2003-2004, 2006-2007, 2009-2010 Free Software Foundation, | ||
3 | dnl Inc. | ||
4 | dnl This file is free software; the Free Software Foundation | ||
5 | dnl gives unlimited permission to copy and/or distribute it, | ||
6 | dnl with or without modifications, as long as this notice is preserved. | ||
7 | |||
8 | AC_DEFUN([gl_MALLOCA], | ||
9 | [ | ||
10 | dnl Use the autoconf tests for alloca(), but not the AC_SUBSTed variables | ||
11 | dnl @ALLOCA@ and @LTALLOCA@. | ||
12 | dnl gl_FUNC_ALLOCA dnl Already brought in by the module dependencies. | ||
13 | AC_REQUIRE([gl_EEMALLOC]) | ||
14 | AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) | ||
15 | ]) | ||
diff --git a/gl/m4/setenv.m4 b/gl/m4/setenv.m4 new file mode 100644 index 0000000..58f6d13 --- /dev/null +++ b/gl/m4/setenv.m4 | |||
@@ -0,0 +1,111 @@ | |||
1 | # setenv.m4 serial 16 | ||
2 | dnl Copyright (C) 2001-2004, 2006-2010 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | AC_DEFUN([gl_FUNC_SETENV], | ||
8 | [ | ||
9 | AC_REQUIRE([gl_FUNC_SETENV_SEPARATE]) | ||
10 | if test $HAVE_SETENV$REPLACE_SETENV != 10; then | ||
11 | AC_LIBOBJ([setenv]) | ||
12 | fi | ||
13 | ]) | ||
14 | |||
15 | # Like gl_FUNC_SETENV, except prepare for separate compilation (no AC_LIBOBJ). | ||
16 | AC_DEFUN([gl_FUNC_SETENV_SEPARATE], | ||
17 | [ | ||
18 | AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) | ||
19 | AC_CHECK_FUNCS_ONCE([setenv]) | ||
20 | if test $ac_cv_func_setenv = no; then | ||
21 | HAVE_SETENV=0 | ||
22 | else | ||
23 | AC_CACHE_CHECK([whether setenv validates arguments], | ||
24 | [gl_cv_func_setenv_works], | ||
25 | [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ | ||
26 | #include <stdlib.h> | ||
27 | #include <errno.h> | ||
28 | #include <string.h> | ||
29 | ]], [[ | ||
30 | if (setenv ("", "", 0) != -1) return 1; | ||
31 | if (errno != EINVAL) return 2; | ||
32 | if (setenv ("a", "=", 1) != 0) return 3; | ||
33 | if (strcmp (getenv ("a"), "=") != 0) return 4; | ||
34 | ]])], | ||
35 | [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no], | ||
36 | [gl_cv_func_setenv_works="guessing no"])]) | ||
37 | if test "$gl_cv_func_setenv_works" != yes; then | ||
38 | REPLACE_SETENV=1 | ||
39 | AC_LIBOBJ([setenv]) | ||
40 | fi | ||
41 | fi | ||
42 | gl_PREREQ_SETENV | ||
43 | ]) | ||
44 | |||
45 | AC_DEFUN([gl_FUNC_UNSETENV], | ||
46 | [ | ||
47 | AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) | ||
48 | AC_CHECK_FUNCS([unsetenv]) | ||
49 | if test $ac_cv_func_unsetenv = no; then | ||
50 | HAVE_UNSETENV=0 | ||
51 | AC_LIBOBJ([unsetenv]) | ||
52 | gl_PREREQ_UNSETENV | ||
53 | else | ||
54 | dnl Some BSDs return void, failing to do error checking. | ||
55 | AC_CACHE_CHECK([for unsetenv() return type], [gt_cv_func_unsetenv_ret], | ||
56 | [AC_TRY_COMPILE([#include <stdlib.h> | ||
57 | extern | ||
58 | #ifdef __cplusplus | ||
59 | "C" | ||
60 | #endif | ||
61 | #if defined(__STDC__) || defined(__cplusplus) | ||
62 | int unsetenv (const char *name); | ||
63 | #else | ||
64 | int unsetenv(); | ||
65 | #endif | ||
66 | ], , gt_cv_func_unsetenv_ret='int', gt_cv_func_unsetenv_ret='void')]) | ||
67 | if test $gt_cv_func_unsetenv_ret = 'void'; then | ||
68 | AC_DEFINE([VOID_UNSETENV], [1], [Define to 1 if unsetenv returns void | ||
69 | instead of int.]) | ||
70 | REPLACE_UNSETENV=1 | ||
71 | AC_LIBOBJ([unsetenv]) | ||
72 | fi | ||
73 | |||
74 | dnl Solaris 10 unsetenv does not remove all copies of a name. | ||
75 | AC_CACHE_CHECK([whether unsetenv works on duplicates], | ||
76 | [gl_cv_func_unsetenv_works], | ||
77 | [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ | ||
78 | #include <stdlib.h> | ||
79 | ]], [[ | ||
80 | char entry[] = "b=2"; | ||
81 | if (putenv ((char *) "a=1")) return 1; | ||
82 | if (putenv (entry)) return 2; | ||
83 | entry[0] = 'a'; | ||
84 | unsetenv ("a"); | ||
85 | if (getenv ("a")) return 3; | ||
86 | ]])], | ||
87 | [gl_cv_func_unsetenv_works=yes], [gl_cv_func_unsetenv_works=no], | ||
88 | [gl_cv_func_unsetenv_works="guessing no"])]) | ||
89 | if test "$gl_cv_func_unsetenv_works" != yes; then | ||
90 | REPLACE_UNSETENV=1 | ||
91 | AC_LIBOBJ([unsetenv]) | ||
92 | fi | ||
93 | fi | ||
94 | ]) | ||
95 | |||
96 | # Prerequisites of lib/setenv.c. | ||
97 | AC_DEFUN([gl_PREREQ_SETENV], | ||
98 | [ | ||
99 | AC_REQUIRE([AC_FUNC_ALLOCA]) | ||
100 | AC_REQUIRE([gl_ENVIRON]) | ||
101 | AC_CHECK_HEADERS_ONCE([unistd.h]) | ||
102 | AC_CHECK_HEADERS([search.h]) | ||
103 | AC_CHECK_FUNCS([tsearch]) | ||
104 | ]) | ||
105 | |||
106 | # Prerequisites of lib/unsetenv.c. | ||
107 | AC_DEFUN([gl_PREREQ_UNSETENV], | ||
108 | [ | ||
109 | AC_REQUIRE([gl_ENVIRON]) | ||
110 | AC_CHECK_HEADERS_ONCE([unistd.h]) | ||
111 | ]) | ||