dovecot-1.2: env_remove(): Implement a fallback method if unsete...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Jan 8 18:52:28 EET 2009
details: http://hg.dovecot.org/dovecot-1.2/rev/7c12e20f1eee
changeset: 8600:7c12e20f1eee
user: Timo Sirainen <tss at iki.fi>
date: Thu Jan 08 11:52:21 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 812a977d7c1a -r 7c12e20f1eee configure.in
--- 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 @@ AC_DEFINE(PACKAGE_WEBPAGE, "http://www.d
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 \
diff -r 812a977d7c1a -r 7c12e20f1eee 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:52:21 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