diff -uNr tcl8.0.5.ORIG/generic/tclEnv.c tcl8.0.5/generic/tclEnv.c --- tcl8.0.5.ORIG/generic/tclEnv.c Wed Feb 3 08:01:59 1999 +++ tcl8.0.5/generic/tclEnv.c Thu Oct 11 13:39:25 2001 @@ -15,6 +15,7 @@ * RCS: @(#) $Id: tclEnv.c,v 1.3 1999/02/02 23:01:59 stanton Exp $ */ +#define __IN_TCLENV__ #include "tclInt.h" #include "tclPort.h" @@ -101,6 +102,9 @@ if (environ == NULL) { environSize = TclMacCreateEnv(); } +#endif +#ifdef __APPLE__ + environ = *_NSGetEnviron(); #endif /* diff -uNr tcl8.0.5.ORIG/unix/tclUnixPort.h tcl8.0.5/unix/tclUnixPort.h --- tcl8.0.5.ORIG/unix/tclUnixPort.h Wed Sep 30 03:22:39 1998 +++ tcl8.0.5/unix/tclUnixPort.h Thu Oct 11 14:06:13 2001 @@ -99,6 +99,16 @@ #include /* gethostbyname() */ /* + * On MacOS X, extern char** environ is in crt1.o which * cannot be linked + * into any dynamiclib as requested by -twolevel_namespace. + * One should use NSGetEnviron() to set it. + */ + +#ifdef __APPLE__ +#include +#endif + +/* * Some platforms (e.g. SunOS) don't define FLT_MAX and FLT_MIN, so we * look for an alternative definition. If no other alternative is available * we use a reasonable guess. @@ -452,10 +462,14 @@ * Variables provided by the C library: */ -#if defined(_sgi) || defined(__sgi) +#if defined(_sgi) || defined(__sgi) || defined(__APPLE__) #define environ _environ #endif +#if defined(__IN_TCLENV__) && defined(__APPLE__) +char **environ; +#else extern char **environ; +#endif /* * At present (12/91) not all stdlib.h implementations declare strtod.