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/putenv.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/putenv.c')
-rw-r--r-- | lib/libc/stdlib/putenv.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libc/stdlib/putenv.c b/lib/libc/stdlib/putenv.c index a5eea5d..b6c7ccb 100644 --- a/lib/libc/stdlib/putenv.c +++ b/lib/libc/stdlib/putenv.c @@ -33,24 +33,28 @@ static char sccsid[] = "@(#)putenv.c 8.2 (Berkeley) 3/27/94"; #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <errno.h> #include <stdlib.h> #include <string.h> int putenv(str) - const char *str; + char *str; { char *p, *equal; - int rval; + int rval, serrno; if ((p = strdup(str)) == NULL) return (-1); if ((equal = index(p, '=')) == NULL) { (void)free(p); + errno = EINVAL; return (-1); } *equal = '\0'; rval = setenv(p, equal + 1, 1); + serrno = errno; (void)free(p); + errno = serrno; return (rval); } |