mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-20 18:50:21 +02:00
(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.
This commit is contained in:
parent
dc23abab09
commit
5cb0151510
1 changed files with 12 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue