mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-07-12 04:00:28 +02:00
(scm_putenv): Handle removing variables explicitely by calling
unsetenv.
This commit is contained in:
parent
1d8c3cad87
commit
002409fe6f
1 changed files with 20 additions and 9 deletions
|
@ -1189,6 +1189,16 @@ SCM_DEFINE (scm_putenv, "putenv", 1, 0, 0,
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
SCM_VALIDATE_STRING (1, str);
|
SCM_VALIDATE_STRING (1, str);
|
||||||
|
|
||||||
|
if (strchr (SCM_STRING_CHARS (str), '=') == NULL)
|
||||||
|
{
|
||||||
|
/* No '=' in argument means we should remove the variable from
|
||||||
|
the environment. Not all putenvs understand this. To be
|
||||||
|
safe, we do it explicitely using unsetenv. */
|
||||||
|
unsetenv (SCM_STRING_CHARS (str));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* must make a new copy to be left in the environment, safe from gc. */
|
/* must make a new copy to be left in the environment, safe from gc. */
|
||||||
ptr = malloc (SCM_STRING_LENGTH (str) + 1);
|
ptr = malloc (SCM_STRING_LENGTH (str) + 1);
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
|
@ -1198,6 +1208,7 @@ SCM_DEFINE (scm_putenv, "putenv", 1, 0, 0,
|
||||||
rv = putenv (ptr);
|
rv = putenv (ptr);
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
SCM_SYSERROR;
|
SCM_SYSERROR;
|
||||||
|
}
|
||||||
return SCM_UNSPECIFIED;
|
return SCM_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue