From df3730247f93a1787d0ee43349ab60b1cda06dfb Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 30 Apr 2007 02:25:02 +0000 Subject: 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). --- lib/libc/stdlib/putenv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/libc/stdlib/putenv.c') 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 __FBSDID("$FreeBSD$"); +#include #include #include 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); } -- cgit v1.1