summaryrefslogtreecommitdiffstats
path: root/generic/tclEnv.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclEnv.c')
-rw-r--r--generic/tclEnv.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/generic/tclEnv.c b/generic/tclEnv.c
index 49238a2..72a8266 100644
--- a/generic/tclEnv.c
+++ b/generic/tclEnv.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclEnv.c,v 1.37 2007/12/13 15:23:16 dgp Exp $
+ * RCS: @(#) $Id: tclEnv.c,v 1.37.2.1 2010/01/06 22:02:04 nijtmans Exp $
*/
#include "tclInt.h"
@@ -45,8 +45,13 @@ static char * EnvTraceProc(ClientData clientData, Tcl_Interp *interp,
static void ReplaceString(const char *oldStr, char *newStr);
MODULE_SCOPE void TclSetEnv(const char *name, const char *value);
MODULE_SCOPE void TclUnsetEnv(const char *name);
-#if defined(__CYGWIN__) && defined(__WIN32__)
-static void TclCygwinPutenv(const char *string);
+
+#if defined(__CYGWIN__)
+/* On Cygwin, the environment is imported from the Cygwin DLL. */
+ DLLIMPORT extern int cygwin_posix_to_win32_path_list_buf_size(char *value);
+ DLLIMPORT extern void cygwin_posix_to_win32_path_list(char *buf, char *value);
+# define putenv TclCygwinPutenv
+static void TclCygwinPutenv(char *string);
#endif
/*
@@ -111,7 +116,8 @@ TclSetupEnv(
if (p2 == NULL) {
/*
* This condition seem to happen occasionally under some
- * versions of Solaris; ignore the entry.
+ * versions of Solaris, or when encoding accidents swallow the
+ * '='; ignore the entry.
*/
continue;
@@ -393,7 +399,7 @@ TclUnsetEnv(
* that no = should be included, and Windows requires it.
*/
-#ifdef WIN32
+#if defined(__WIN32__) || defined(__CYGWIN__)
string = ckalloc((unsigned) length+2);
memcpy(string, name, (size_t) length);
string[length] = '=';
@@ -687,9 +693,7 @@ TclFinalizeEnvironment(void)
}
}
-#if defined(__CYGWIN__) && defined(__WIN32__)
-
-#include <windows.h>
+#if defined(__CYGWIN__)
/*
* When using cygwin, when an environment variable changes, we need to synch
@@ -700,7 +704,7 @@ TclFinalizeEnvironment(void)
static void
TclCygwinPutenv(
- const char *str)
+ char *str)
{
char *name, *value;
@@ -751,11 +755,15 @@ TclCygwinPutenv(
*/
if (strcmp(name, "Path") == 0) {
+#ifdef __WIN32__
SetEnvironmentVariable("PATH", NULL);
+#endif
unsetenv("PATH");
}
+#ifdef __WIN32__
SetEnvironmentVariable(name, value);
+#endif
} else {
char *buf;
@@ -763,7 +771,9 @@ TclCygwinPutenv(
* Eliminate any Path variable, to prevent any confusion.
*/
+#ifdef __WIN32__
SetEnvironmentVariable("Path", NULL);
+#endif
unsetenv("Path");
if (value == NULL) {
@@ -776,10 +786,12 @@ TclCygwinPutenv(
cygwin_posix_to_win32_path_list(value, buf);
}
+#ifdef __WIN32__
SetEnvironmentVariable(name, buf);
+#endif
}
}
-#endif /* __CYGWIN__ && __WIN32__ */
+#endif /* __CYGWIN__ */
/*
* Local Variables: