2008-09-24 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdlib/setenv_r.c (_unsetenv_r): Modify to return -1 only if name is NULL, empty, or contains equal sign.
This commit is contained in:
parent
37f996a2b2
commit
57d7cfcdb7
|
@ -1,3 +1,8 @@
|
||||||
|
2008-09-24 Jeff Johnston <jjohnstn@redhat.com>
|
||||||
|
|
||||||
|
* libc/stdlib/setenv_r.c (_unsetenv_r): Modify to return -1 only if
|
||||||
|
name is NULL, empty, or contains equal sign.
|
||||||
|
|
||||||
2008-09-24 Pawel Veselov <pawel.veselov@gmail.com>
|
2008-09-24 Pawel Veselov <pawel.veselov@gmail.com>
|
||||||
|
|
||||||
Fix setenv/getenv/unsetenv to be OpenGroup compliant:
|
Fix setenv/getenv/unsetenv to be OpenGroup compliant:
|
||||||
|
|
|
@ -146,9 +146,9 @@ _DEFUN (_unsetenv_r, (reent_ptr, name),
|
||||||
{
|
{
|
||||||
register char **P;
|
register char **P;
|
||||||
int offset;
|
int offset;
|
||||||
int rc;
|
|
||||||
|
/* Name cannot be NULL, empty, or contain an equal sign. */
|
||||||
if (strchr(name, '='))
|
if (name == NULL || name[0] == '\0' || strchr(name, '='))
|
||||||
{
|
{
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -156,16 +156,13 @@ _DEFUN (_unsetenv_r, (reent_ptr, name),
|
||||||
|
|
||||||
ENV_LOCK;
|
ENV_LOCK;
|
||||||
|
|
||||||
rc = -1;
|
|
||||||
|
|
||||||
while (_findenv_r (reent_ptr, name, &offset)) /* if set multiple times */
|
while (_findenv_r (reent_ptr, name, &offset)) /* if set multiple times */
|
||||||
{
|
{
|
||||||
rc = 0;
|
|
||||||
for (P = &(*p_environ)[offset];; ++P)
|
for (P = &(*p_environ)[offset];; ++P)
|
||||||
if (!(*P = *(P + 1)))
|
if (!(*P = *(P + 1)))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ENV_UNLOCK;
|
ENV_UNLOCK;
|
||||||
return (rc);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue