1 --- setenv.c.orig Mon Apr 28 16:37:26 2003
2 +++ setenv.c Tue May 6 16:55:50 2003
7 +#include <crt_externs.h>
9 char *__findenv(const char *, int *);
15 - extern char **environ;
16 + char ***environp = _NSGetEnviron();
17 static char **alloced; /* if allocated space before */
24 - for (p = environ, cnt = 0; *p; ++p, ++cnt);
25 - if (alloced == environ) { /* just increase size */
26 - p = (char **)realloc((char *)environ,
27 + for (p = *environp, cnt = 0; *p; ++p, ++cnt);
28 + if (alloced == *environp) { /* just increase size */
29 + p = (char **)realloc((char *)*environp,
30 (size_t)(sizeof(char *) * (cnt + 2)));
33 - alloced = environ = p;
34 + alloced = *environp = p;
36 else { /* get new space */
37 /* copy old entries into it */
38 p = malloc((size_t)(sizeof(char *) * (cnt + 2)));
41 - bcopy(environ, p, cnt * sizeof(char *));
42 - alloced = environ = p;
43 + bcopy(*environp, p, cnt * sizeof(char *));
44 + alloced = *environp = p;
46 - environ[cnt + 1] = NULL;
47 + (*environp)[cnt + 1] = NULL;
50 for (c = (char *)name; *c && *c != '='; ++c); /* no `=' in name */
51 - if (!(environ[offset] = /* name + `=' + value */
52 + if (!((*environp)[offset] = /* name + `=' + value */
53 malloc((size_t)((int)(c - name) + l_value + 2))))
55 - for (c = environ[offset]; (*c = *name++) && *c != '='; ++c);
56 + for (c = (*environp)[offset]; (*c = *name++) && *c != '='; ++c);
57 for (*c++ = '='; (*c++ = *value++); );
64 - extern char **environ;
65 + char **environ = *_NSGetEnviron();