X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fputenv.c;h=47f7256e581ef1f012c256e29824ce87bcd05259;hb=fb2a33bb98f09325349f84f1007035e415d8175f;hp=512878c478e869cd2e716246358b2f9a69e808b7;hpb=43e78b970f396160a887c9da94531569faeda8a0;p=gnulib.git diff --git a/lib/putenv.c b/lib/putenv.c index 512878c47..47f7256e5 100644 --- a/lib/putenv.c +++ b/lib/putenv.c @@ -16,21 +16,45 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifdef HAVE_CONFIG_H +#if defined (CONFIG_BROKETS) +/* We use instead of "config.h" so that a compilation + using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h + (which it would do because it found this file in $srcdir). */ +#include +#else +#include "config.h" +#endif +#endif + #include #include -#ifdef STDC_HEADERS + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +/* Don't include stdlib.h for non-GNU C libraries because some of them + contain conflicting prototypes for getopt. */ #include #else +char *malloc (); +#endif /* GNU C library. */ + +#ifndef STDC_HEADERS extern int errno; #endif -#if defined(STDC_HEADERS) || defined(USG) +#if defined(STDC_HEADERS) || defined(HAVE_STRING_H) #include +#ifndef index #define index strchr +#endif +#ifndef bcopy #define bcopy(s, d, n) memcpy((d), (s), (n)) -#else /* not (STDC_HEADERS or USG) */ +#endif +#else #include -#endif /* STDC_HEADERS or USG */ +#endif #ifdef HAVE_UNISTD_H #include @@ -40,10 +64,6 @@ extern int errno; #define NULL 0 #endif -#if !__STDC__ -#define const -#endif - extern char **environ; /* Put STRING, which is of the form "NAME=VALUE", in the environment. */ @@ -86,7 +106,8 @@ putenv (string) char **new_environ = (char **) malloc ((size + 2) * sizeof (char *)); if (new_environ == NULL) return -1; - (void) bcopy ((char *) environ, (char *) new_environ, size * sizeof (char *)); + (void) bcopy ((char *) environ, (char *) new_environ, + size * sizeof (char *)); new_environ[size] = (char *) string; new_environ[size + 1] = NULL; if (last_environ != NULL)