summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--generic/tclEnv.c32
-rw-r--r--generic/tclPort.h12
-rw-r--r--tests/env.test6
4 files changed, 39 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index cc38f55..0c2aaaa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,9 @@
* unix/.cvsignore
* tests/stack.test Reduced minimum required C-stack size to 2034:
CYGWIN has this stack size and the test runs fine!
+ * generic/tclEnv.c Fix environment tests under CYGWIN
+ * generic/tclPort.h
+ * tests/env.test
2010-01-05 Don Porter <dgp@users.sourceforge.net>
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
diff --git a/tests/env.test b/tests/env.test
index e417db2..e73ca52 100644
--- a/tests/env.test
+++ b/tests/env.test
@@ -11,7 +11,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: env.test,v 1.28 2007/01/19 01:04:00 das Exp $
+# RCS: @(#) $Id: env.test,v 1.28.4.1 2010/01/06 22:02:05 nijtmans Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -80,7 +80,7 @@ set printenvScript [makeFile {
TCL_LIBRARY PATH LD_LIBRARY_PATH LIBPATH PURE_PROG_NAME DISPLAY
SHLIB_PATH SYSTEMDRIVE SYSTEMROOT DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH
DYLD_NEW_LOCAL_SHARED_REGIONS DYLD_NO_FIX_PREBINDING
- __CF_USER_TEXT_ENCODING SECURITYSESSIONID
+ __CF_USER_TEXT_ENCODING SECURITYSESSIONID LANG WINDIR TERM
} {
lrem names $name
}
@@ -112,7 +112,7 @@ foreach name [array names env] {
TCL_LIBRARY PATH LD_LIBRARY_PATH LIBPATH DISPLAY SHLIB_PATH
SYSTEMDRIVE SYSTEMROOT DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH
DYLD_NEW_LOCAL_SHARED_REGIONS DYLD_NO_FIX_PREBINDING
- SECURITYSESSIONID
+ SECURITYSESSIONID LANG WINDIR TERM
}} {
unset env($name)
}