From 96542c36786fb4dd6a94d0b83834f267478f2241 Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 26 Jan 2010 12:41:43 +0000 Subject: [PATCH] * configure.in: test unsetenv returns a value. unsetenv is void in older BSDs (FreeBSD 6 and OpenBSD 4.5 at least). * hash.c (ruby_setenv): don't use the result of unsetenv if unsetenv doesn't return a value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ configure.in | 10 ++++++++++ hash.c | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/ChangeLog b/ChangeLog index 23a93ed58e..080c2b3bc1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Tue Jan 26 21:36:22 2010 Tanaka Akira + + * configure.in: test unsetenv returns a value. + unsetenv is void in older BSDs (FreeBSD 6 and OpenBSD 4.5 at least). + + * hash.c (ruby_setenv): don't use the result of unsetenv if unsetenv + doesn't return a value. + Tue Jan 26 21:32:03 2010 Tanaka Akira * ext/socket/extconf.rb: suppress a warning. diff --git a/configure.in b/configure.in index 6709122613..791389f4b7 100644 --- a/configure.in +++ b/configure.in @@ -1121,6 +1121,16 @@ AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall chroot getcwd eacce mktime timegm gmtime_r clock_gettime gettimeofday\ pread sendfile shutdown sigaltstack) +AC_CACHE_CHECK(for unsetenv returns a value, rb_cv_unsetenv_return_value, + [AC_TRY_COMPILE([ +#include +], [int v = unsetenv("foo");], + rb_cv_unsetenv_return_value=yes, + rb_cv_unsetenv_return_value=no)]) +if test "$rb_cv_unsetenv_return_value" = no; then + AC_DEFINE(VOID_UNSETENV) +fi + AC_CACHE_CHECK(for __builtin_setjmp, ac_cv_func___builtin_setjmp, [AC_TRY_LINK([@%:@include jmp_buf jb; void t(v) int v; {__builtin_longjmp(jb, v);}], diff --git a/hash.c b/hash.c index 124df01385..7a6bfe8134 100644 --- a/hash.c +++ b/hash.c @@ -2073,8 +2073,12 @@ ruby_setenv(const char *name, const char *value) if (setenv(name, value, 1)) rb_sys_fail("setenv"); } else { +#ifdef VOID_UNSETENV + unsetenv(name); +#else if (unsetenv(name)) rb_sys_fail("unsetenv"); +#endif } #elif defined __sun__ size_t len;