diff options
author | ache <ache@FreeBSD.org> | 2007-04-30 02:25:02 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2007-04-30 02:25:02 +0000 |
commit | df3730247f93a1787d0ee43349ab60b1cda06dfb (patch) | |
tree | f3c51d97304bef50f993149ee17487bb6c86505e /lib/libc/stdlib/getenv.c | |
parent | 142746f314eb83d957199603e2b6b281b0985625 (diff) | |
download | FreeBSD-src-df3730247f93a1787d0ee43349ab60b1cda06dfb.zip FreeBSD-src-df3730247f93a1787d0ee43349ab60b1cda06dfb.tar.gz |
Make setenv, putenv, getenv and unsetenv conforming to Open Group specs
Issue 6 (also IEEE Std 1003.1-2001) in following areas:
args, return, errors.
Putenv still needs rewriting because specs explicitly says that
altering passed string later should change the environment (currently we
copy the string so can't provide that).
Diffstat (limited to 'lib/libc/stdlib/getenv.c')
-rw-r--r-- | lib/libc/stdlib/getenv.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libc/stdlib/getenv.c b/lib/libc/stdlib/getenv.c index 306b6a1..73ac407 100644 --- a/lib/libc/stdlib/getenv.c +++ b/lib/libc/stdlib/getenv.c @@ -44,7 +44,6 @@ inline char *__findenv(const char *, int *); * Returns pointer to value associated with name, if any, else NULL. * Sets offset to be the offset of the name/value combination in the * environmental array, for use by setenv(3) and unsetenv(3). - * Explicitly removes '=' in argument name. * * This routine *should* be a static; don't use it. */ @@ -58,11 +57,9 @@ __findenv(name, offset) const char *np; char **p, *cp; - if (name == NULL || environ == NULL) + if (environ == NULL) return (NULL); - for (np = name; *np && *np != '='; ++np) - continue; - len = np - name; + len = strlen(name); for (p = environ; (cp = *p) != NULL; ++p) { for (np = name, i = len; i && *cp; i--) if (*cp++ != *np++) @@ -85,5 +82,8 @@ getenv(name) { int offset; + if (name == NULL || !*name || strchr(name, '=') != NULL) + return (NULL); + return (__findenv(name, &offset)); } |