dovecot-2.0: Compile fix for systems where unsetenv() returns void.

dovecot at dovecot.org dovecot at dovecot.org
Tue Dec 15 21:01:25 EET 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/617fa0739538
changeset: 10491:617fa0739538
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Dec 15 14:01:20 2009 -0500
description:
Compile fix for systems where unsetenv() returns void.
FreeBSD 6.4, for example.

diffstat:

2 files changed, 19 insertions(+)
configure.in       |   15 +++++++++++++++
src/lib/env-util.c |    4 ++++

diffs (41 lines):

diff -r 1aea146d39e1 -r 617fa0739538 configure.in
--- a/configure.in	Tue Dec 15 13:44:15 2009 -0500
+++ b/configure.in	Tue Dec 15 14:01:20 2009 -0500
@@ -1301,6 +1301,21 @@ AC_CHECK_LIB(sendfile, sendfile, [
   fi
 ])
 
+AC_CACHE_CHECK([if unsetenv returns int],i_cv_unsetenv_ret_int,[
+  AC_TRY_COMPILE([
+    #include <stdlib.h>
+  ], [
+    if (unsetenv("env") < 0) ;
+  ], [
+    i_cv_unsetenv_ret_int=yes
+  ], [
+    i_cv_unsetenv_ret_int=no
+  ])
+])
+if test $i_cv_unsetenv_ret_int = yes; then
+  AC_DEFINE(UNSETENV_RET_INT,, Define if unsetenv() returns int)
+fi
+
 dnl * Check for crypt() if unistd.h compiles with _XOPEN_SOURCE + _XPG6
 dnl * Add other macros there too "just in case".
 AC_CACHE_CHECK([if we should use _XPG6 macro for crypt()],i_cv_use_xpg6_crypt,[
diff -r 1aea146d39e1 -r 617fa0739538 src/lib/env-util.c
--- a/src/lib/env-util.c	Tue Dec 15 13:44:15 2009 -0500
+++ b/src/lib/env-util.c	Tue Dec 15 14:01:20 2009 -0500
@@ -25,8 +25,12 @@ void env_remove(const char *name)
 void env_remove(const char *name)
 {
 #ifdef HAVE_UNSETENV
+#ifdef UNSETENV_RET_INT
 	if (unsetenv(name) < 0)
 		i_fatal("unsetenv(%s) failed: %m", name);
+#else
+	unsetenv(name);
+#endif
 #else
 	extern char **environ;
 	unsigned int len;


More information about the dovecot-cvs mailing list