summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authornijtmans <nijtmans>2010-01-06 22:02:04 (GMT)
committernijtmans <nijtmans>2010-01-06 22:02:04 (GMT)
commitb849702961a75aea821820214c8aac96f91a6c7d (patch)
treeab754c96e6eaf101337648b0333d2b873ecb83c8 /generic
parent0ca164f2c3f073eea996040b76aa89e44fe81e1a (diff)
downloadtcl-b849702961a75aea821820214c8aac96f91a6c7d.zip
tcl-b849702961a75aea821820214c8aac96f91a6c7d.tar.gz
tcl-b849702961a75aea821820214c8aac96f91a6c7d.tar.bz2
Fix environment tests under CYGWIN
Diffstat (limited to 'generic')
-rw-r--r--generic/tclEnv.c32
-rw-r--r--generic/tclPort.h12
2 files changed, 33 insertions, 11 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:
diff --git a/generic/tclPort.h b/generic/tclPort.h
index efc5a73..f2cdfb4 100644
--- a/generic/tclPort.h
+++ b/generic/tclPort.h
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclPort.h,v 1.15.10.1 2008/11/04 23:56:59 hobbs Exp $
+ * RCS: @(#) $Id: tclPort.h,v 1.15.10.2 2010/01/06 22:02:05 nijtmans Exp $
*/
#ifndef _TCLPORT
@@ -27,6 +27,16 @@
# include "tclUnixPort.h"
#endif
+#if defined(__CYGWIN__)
+# define USE_PUTENV 1
+# define USE_PUTENV_FOR_UNSET 1
+/* On Cygwin, the environment is imported from the Cygwin DLL. */
+ DLLIMPORT extern char **__cygwin_environ;
+ DLLIMPORT extern int cygwin_conv_to_win32_path(const char *, char *);
+# define environ __cygwin_environ
+# define timezone _timezone
+#endif
+
#if !defined(LLONG_MIN)
# ifdef TCL_WIDE_INT_IS_LONG
# define LLONG_MIN LONG_MIN