dovecot-1.1: env_remove(): Implement a fallback method if unsete...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Jan 8 18:52:29 EET 2009
details: http://hg.dovecot.org/dovecot-1.1/rev/fec8412dc1c5
changeset: 8076:fec8412dc1c5
user: Timo Sirainen <tss at iki.fi>
date: Thu Jan 08 11:51:50 2009 -0500
description:
env_remove(): Implement a fallback method if unsetenv() doesn't exist.
Fixes compiling at least with Solaris 8.
diffstat:
2 files changed, 18 insertions(+), 1 deletion(-)
configure.in | 2 +-
src/lib/env-util.c | 17 +++++++++++++++++
diffs (40 lines):
diff -r 30207243a4f4 -r fec8412dc1c5 configure.in
--- a/configure.in Thu Jan 08 11:41:30 2009 -0500
+++ b/configure.in Thu Jan 08 11:51:50 2009 -0500
@@ -459,7 +459,7 @@ AC_CHECK_FUNCS(fcntl flock lockf inet_at
setrlimit setproctitle seteuid setreuid setegid setresgid \
strtoull strtoll strtouq strtoq \
setpriority quotactl getmntent kqueue kevent backtrace_symbols \
- walkcontext dirfd clearenv malloc_usable_size)
+ walkcontext dirfd clearenv malloc_usable_size unsetenv)
dnl strtoimax and strtoumax are macros in HP-UX, so inttypes.h must be included
AC_MSG_CHECKING([for strtoimax])
diff -r 30207243a4f4 -r fec8412dc1c5 src/lib/env-util.c
--- a/src/lib/env-util.c Thu Jan 08 11:41:30 2009 -0500
+++ b/src/lib/env-util.c Thu Jan 08 11:51:50 2009 -0500
@@ -19,7 +19,24 @@ void env_put(const char *env)
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)
More information about the dovecot-cvs
mailing list