]> git.saurik.com Git - apple/libc.git/blob - stdlib/FreeBSD/putenv.c.patch
Libc-391.5.22.tar.gz
[apple/libc.git] / stdlib / FreeBSD / putenv.c.patch
1 --- putenv.c.orig 2003-05-20 15:23:25.000000000 -0700
2 +++ putenv.c 2004-10-24 01:10:20.000000000 -0700
3 @@ -40,10 +40,22 @@
4 #include <stdlib.h>
5 #include <string.h>
6
7 +#if __DARWIN_UNIX03
8 +#include <errno.h>
9 +__private_extern__ int __setenv(const char *, const char *, int, int);
10 +#endif /* __DARWIN_UNIX03 */
11 +
12 int
13 putenv(str)
14 - const char *str;
15 + char *str;
16 {
17 +#if __DARWIN_UNIX03
18 + if (str == NULL || *str == 0 || index(str, '=') == NULL) {
19 + errno = EINVAL;
20 + return (-1);
21 + }
22 + return (__setenv(str, NULL, 1, 0));
23 +#else /* !__DARWIN_UNIX03 */
24 char *p, *equal;
25 int rval;
26
27 @@ -57,4 +69,5 @@
28 rval = setenv(p, equal + 1, 1);
29 (void)free(p);
30 return (rval);
31 +#endif /* __DARWIN_UNIX03 */
32 }