changeset 8600:7c12e20f1eee HEAD

env_remove(): Implement a fallback method if unsetenv() doesn't exist. Fixes compiling at least with Solaris 8.
author Timo Sirainen <tss@iki.fi>
date Thu, 08 Jan 2009 11:52:21 -0500
parents 812a977d7c1a
children da02a1d15783
files configure.in src/lib/env-util.c
diffstat 2 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/configure.in	Thu Jan 08 11:41:30 2009 -0500
+++ b/configure.in	Thu Jan 08 11:52:21 2009 -0500
@@ -368,7 +368,7 @@
 
 dnl * after -lsocket and -lnsl tests, inet_aton() may be in them
 AC_CHECK_FUNCS(fcntl flock lockf inet_aton sigaction getpagesize madvise \
-               strcasecmp stricmp vsyslog writev pread uname \
+               strcasecmp stricmp vsyslog writev pread uname unsetenv \
 	       setrlimit setproctitle seteuid setreuid setegid setresgid \
 	       strtoull strtoll strtouq strtoq \
 	       setpriority quotactl getmntent kqueue kevent backtrace_symbols \
--- a/src/lib/env-util.c	Thu Jan 08 11:41:30 2009 -0500
+++ b/src/lib/env-util.c	Thu Jan 08 11:52:21 2009 -0500
@@ -19,7 +19,24 @@
 
 void env_remove(const char *name)
 {
+#ifdef HAVE_UNSETENV
 	unsetenv(name);
+#else
+	extern char **environ;
+	unsigned int len;
+	char **envp;
+
+	len = strlen(name);
+	for (envp = environ; *envp != NULL; envp++) {
+		if (strncmp(name, *envp, len) == 0 &&
+		    (*envp)[len] == '=') {
+			do {
+				envp[0] = envp[1];
+			} while (*++envp != NULL);
+			break;
+		}
+	}
+#endif
 }
 
 void env_clean(void)