From 5cb0151510c8b85476d2de1d3c036927a0341a22 Mon Sep 17 00:00:00 2001 From: Kevin Ryde Date: Tue, 10 Aug 2004 00:19:47 +0000 Subject: [PATCH] (scm_putenv): Use unsetenv to remove entries (ie. no "="), when available, for the benefit of FreeBSD and other systems where putenv() doesn't do that itself. --- libguile/posix.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libguile/posix.c b/libguile/posix.c index 9589526fc..6fccb1788 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1238,6 +1238,18 @@ SCM_DEFINE (scm_putenv, "putenv", 1, 0, 0, char *ptr; SCM_VALIDATE_STRING (1, str); + + /* No '=' in the argument means we should remove the variable from the + environment. Not all putenv()s understand this (for instance FreeBSD + 4.8 doesn't). To be safe, we do it explicitely using unsetenv. */ +#ifdef HAVE_UNSETENV + if (strchr (SCM_STRING_CHARS (str), '=') == NULL) + { + unsetenv (SCM_STRING_CHARS (str)); + return SCM_UNSPECIFIED; + } +#endif + /* must make a new copy to be left in the environment, safe from gc. */ ptr = malloc (SCM_STRING_LENGTH (str) + 1); if (ptr == NULL)