summaryrefslogtreecommitdiffstats
path: root/gl/m4/setenv.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/setenv.m4')
-rw-r--r--gl/m4/setenv.m476
1 files changed, 41 insertions, 35 deletions
diff --git a/gl/m4/setenv.m4 b/gl/m4/setenv.m4
index cb5351a..16f9eb5 100644
--- a/gl/m4/setenv.m4
+++ b/gl/m4/setenv.m4
@@ -1,5 +1,5 @@
1# setenv.m4 serial 26 1# setenv.m4 serial 30
2dnl Copyright (C) 2001-2004, 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2004, 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -35,10 +35,12 @@ AC_DEFUN([gl_FUNC_SETENV],
35 ]])], 35 ]])],
36 [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no], 36 [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no],
37 [case "$host_os" in 37 [case "$host_os" in
38 # Guess yes on glibc systems. 38 # Guess yes on glibc systems.
39 *-gnu*) gl_cv_func_setenv_works="guessing yes" ;; 39 *-gnu* | gnu*) gl_cv_func_setenv_works="guessing yes" ;;
40 # If we don't know, assume the worst. 40 # Guess yes on musl systems.
41 *) gl_cv_func_setenv_works="guessing no" ;; 41 *-musl*) gl_cv_func_setenv_works="guessing yes" ;;
42 # If we don't know, obey --enable-cross-guesses.
43 *) gl_cv_func_setenv_works="$gl_cross_guess_normal" ;;
42 esac 44 esac
43 ])]) 45 ])])
44 case "$gl_cv_func_setenv_works" in 46 case "$gl_cv_func_setenv_works" in
@@ -104,35 +106,39 @@ int unsetenv (const char *name);
104 dnl OpenBSD 4.7 unsetenv("") does not fail. 106 dnl OpenBSD 4.7 unsetenv("") does not fail.
105 AC_CACHE_CHECK([whether unsetenv obeys POSIX], 107 AC_CACHE_CHECK([whether unsetenv obeys POSIX],
106 [gl_cv_func_unsetenv_works], 108 [gl_cv_func_unsetenv_works],
107 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 109 [AC_RUN_IFELSE(
108 #include <stdlib.h> 110 [AC_LANG_PROGRAM([[
109 #include <errno.h> 111 #include <stdlib.h>
110 extern char **environ; 112 #include <errno.h>
111 ]], [[ 113 extern char **environ;
112 char entry1[] = "a=1"; 114 ]GL_MDA_DEFINES],
113 char entry2[] = "b=2"; 115 [[
114 char *env[] = { entry1, entry2, NULL }; 116 char entry1[] = "a=1";
115 if (putenv ((char *) "a=1")) return 1; 117 char entry2[] = "b=2";
116 if (putenv (entry2)) return 2; 118 char *env[] = { entry1, entry2, NULL };
117 entry2[0] = 'a'; 119 if (putenv ((char *) "a=1")) return 1;
118 unsetenv ("a"); 120 if (putenv (entry2)) return 2;
119 if (getenv ("a")) return 3; 121 entry2[0] = 'a';
120 if (!unsetenv ("") || errno != EINVAL) return 4; 122 unsetenv ("a");
121 entry2[0] = 'b'; 123 if (getenv ("a")) return 3;
122 environ = env; 124 if (!unsetenv ("") || errno != EINVAL) return 4;
123 if (!getenv ("a")) return 5; 125 entry2[0] = 'b';
124 entry2[0] = 'a'; 126 environ = env;
125 unsetenv ("a"); 127 if (!getenv ("a")) return 5;
126 if (getenv ("a")) return 6; 128 entry2[0] = 'a';
127 ]])], 129 unsetenv ("a");
128 [gl_cv_func_unsetenv_works=yes], [gl_cv_func_unsetenv_works=no], 130 if (getenv ("a")) return 6;
129 [case "$host_os" in 131 ]])],
130 # Guess yes on glibc systems. 132 [gl_cv_func_unsetenv_works=yes],
131 *-gnu*) gl_cv_func_unsetenv_works="guessing yes" ;; 133 [gl_cv_func_unsetenv_works=no],
132 # If we don't know, assume the worst. 134 [case "$host_os" in
133 *) gl_cv_func_unsetenv_works="guessing no" ;; 135 # Guess yes on glibc systems.
134 esac 136 *-gnu*) gl_cv_func_unsetenv_works="guessing yes" ;;
135 ])]) 137 # If we don't know, obey --enable-cross-guesses.
138 *) gl_cv_func_unsetenv_works="$gl_cross_guess_normal" ;;
139 esac
140 ])
141 ])
136 case "$gl_cv_func_unsetenv_works" in 142 case "$gl_cv_func_unsetenv_works" in
137 *yes) ;; 143 *yes) ;;
138 *) 144 *)