aboutsummaryrefslogtreecommitdiff
path: root/src/env
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-10-21 18:37:15 -0400
committerRich Felker <dalias@aerifal.cx>2012-10-21 18:37:15 -0400
commit31a55f233b313030a787240b76c06f2d08cde29f (patch)
tree251b191eecac47f9ca026a00675fb5563ae7e753 /src/env
parent8489897e01b8a27c365c9c98b200ee25dc124cb4 (diff)
downloadmusl-31a55f233b313030a787240b76c06f2d08cde29f.zip
musl-31a55f233b313030a787240b76c06f2d08cde29f.tar.gz
musl-31a55f233b313030a787240b76c06f2d08cde29f.tar.bz2
as an extension, have putenv("VAR") behave as unsetenv("VAR")
the behavior of putenv is left undefined if the argument does not contain an equal sign, but traditional implementations behave this way and gnulib replaces putenv if it doesn't do this.
Diffstat (limited to 'src/env')
-rw-r--r--src/env/putenv.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/env/putenv.c b/src/env/putenv.c
index 181a418..d141db1 100644
--- a/src/env/putenv.c
+++ b/src/env/putenv.c
@@ -9,14 +9,14 @@ char **__env_map;
int __putenv(char *s, int a)
{
int i=0, j=0;
- char *end = strchr(s, '=');
- size_t l = end-s+1;
+ char *z = strchr(s, '=');
char **newenv = 0;
char **newmap = 0;
static char **oldenv;
-
- if (!end || l == 1) return -1;
- for (; __environ[i] && memcmp(s, __environ[i], l); i++);
+
+ if (!z) return unsetenv(s);
+ if (z==s) return -1;
+ for (; __environ[i] && memcmp(s, __environ[i], z-s+1); i++);
if (a) {
if (!__env_map) {
__env_map = calloc(2, sizeof(char *));