diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-05-30 23:49:43 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-05-30 23:49:43 +0000 |
commit | ad28b52f542ff06c24f05d04b33707cefced9ea5 (patch) | |
tree | 24c74619426601381c6f6be828a0bd5b4f0025be /libc/stdlib/getenv.c | |
parent | af562a23724d27b16c4872590886c96554bba68a (diff) |
Rework setenv, getenv and friends per the latest glibc code, but cleaned
up for readability. Merge in putenv. Add clearenv as a side effect.
-Erik
Diffstat (limited to 'libc/stdlib/getenv.c')
-rw-r--r-- | libc/stdlib/getenv.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/libc/stdlib/getenv.c b/libc/stdlib/getenv.c index ca50402b9..588f696ee 100644 --- a/libc/stdlib/getenv.c +++ b/libc/stdlib/getenv.c @@ -7,20 +7,19 @@ #include <unistd.h> #include <malloc.h> -char *getenv(var) -const char *var; +char *getenv(const char *var) { - char **p; - int len; + char **p; + int len; - len = strlen(var); + len = strlen(var); - if (!__environ) - return 0; + if (!__environ) + return NULL; - for (p = __environ; *p; p++) { - if (memcmp(var, *p, len) == 0 && (*p)[len] == '=') - return *p + len + 1; - } - return 0; + for (p = __environ; *p; p++) { + if (memcmp(var, *p, len) == 0 && (*p)[len] == '=') + return *p + len + 1; + } + return NULL; } |