diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tcl.h | 11 | ||||
-rw-r--r-- | generic/tclEnv.c | 86 | ||||
-rw-r--r-- | generic/tclFileName.c | 40 | ||||
-rw-r--r-- | generic/tclPlatDecls.h | 6 |
4 files changed, 136 insertions, 7 deletions
diff --git a/generic/tcl.h b/generic/tcl.h index f16d84a..dcd14a0 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tcl.h,v 1.143 2002/09/12 17:33:20 das Exp $ + * RCS: @(#) $Id: tcl.h,v 1.144 2002/09/27 00:50:10 hobbs Exp $ */ #ifndef _TCL @@ -68,7 +68,7 @@ extern "C" { */ #ifndef __WIN32__ -# if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__) +# if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) || defined(__BORLANDC__) # define __WIN32__ # ifndef WIN32 # define WIN32 @@ -351,7 +351,12 @@ typedef long LONG; */ #if !defined(TCL_WIDE_INT_TYPE)&&!defined(TCL_WIDE_INT_IS_LONG) -# ifdef __WIN32__ +# ifdef __CYGWIN__ +# define TCL_WIDE_INT_TYPE long long +# define TCL_LL_MODIFIER "L" +typedef struct stat Tcl_StatBuf; +# define TCL_LL_MODIFIER_SIZE 1 +# elif defined(__WIN32__) # define TCL_WIDE_INT_TYPE __int64 # ifdef __BORLANDC__ typedef struct stati64 Tcl_StatBuf; diff --git a/generic/tclEnv.c b/generic/tclEnv.c index 75f5eab..3702ff4 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.17 2002/08/28 22:48:10 davygrvy Exp $ + * RCS: @(#) $Id: tclEnv.c,v 1.18 2002/09/27 00:50:10 hobbs Exp $ */ #include "tclInt.h" @@ -54,6 +54,9 @@ void TclSetEnv _ANSI_ARGS_((CONST char *name, CONST char *value)); void TclUnsetEnv _ANSI_ARGS_((CONST char *name)); +#if defined (__CYGWIN__) && defined(__WIN32__) +static void TclCygwinPutenv _ANSI_ARGS_((CONST char *string)); +#endif /* *---------------------------------------------------------------------- @@ -699,3 +702,84 @@ TclFinalizeEnvironment() #endif } } + +#if defined(__CYGWIN__) && defined(__WIN32__) + +#include <windows.h> + +/* + * When using cygwin, when an environment variable changes, we need to synch + * with both the cygwin environment (in case the application C code calls + * fork) and the Windows environment (in case the application TCL code calls + * exec, which calls the Windows CreateProcess function). + */ + +static void +TclCygwinPutenv(str) + const char *str; +{ + char *name, *value; + + /* Get the name and value, so that we can change the environment + variable for Windows. */ + name = (char *) alloca (strlen (str) + 1); + strcpy (name, str); + for (value = name; *value != '=' && *value != '\0'; ++value) + ; + if (*value == '\0') { + /* Can't happen. */ + return; + } + *value = '\0'; + ++value; + if (*value == '\0') { + value = NULL; + } + + /* Set the cygwin environment variable. */ +#undef putenv + if (value == NULL) { + unsetenv (name); + } else { + putenv(str); + } + + /* + * Before changing the environment variable in Windows, if this is PATH, + * we need to convert the value back to a Windows style path. + * + * FIXME: The calling program may know it is running under windows, and + * may have set the path to a Windows path, or, worse, appended or + * prepended a Windows path to PATH. + */ + if (strcmp (name, "PATH") != 0) { + /* If this is Path, eliminate any PATH variable, to prevent any + confusion. */ + if (strcmp (name, "Path") == 0) { + SetEnvironmentVariable ("PATH", (char *) NULL); + unsetenv ("PATH"); + } + + SetEnvironmentVariable (name, value); + } else { + char *buf; + + /* Eliminate any Path variable, to prevent any confusion. */ + SetEnvironmentVariable ("Path", (char *) NULL); + unsetenv ("Path"); + + if (value == NULL) { + buf = NULL; + } else { + int size; + + size = cygwin_posix_to_win32_path_list_buf_size (value); + buf = (char *) alloca (size + 1); + cygwin_posix_to_win32_path_list (value, buf); + } + + SetEnvironmentVariable (name, buf); + } +} + +#endif /* __CYGWIN__ && __WIN32__ */ diff --git a/generic/tclFileName.c b/generic/tclFileName.c index f5e7970..e3ec128 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -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: tclFileName.c,v 1.37 2002/06/05 11:59:33 das Exp $ + * RCS: @(#) $Id: tclFileName.c,v 1.38 2002/09/27 00:50:10 hobbs Exp $ */ #include "tclInt.h" @@ -1356,12 +1356,31 @@ Tcl_TranslateFileName(interp, name, bufferPtr) */ if (tclPlatform == TCL_PLATFORM_WINDOWS) { +#if defined(__CYGWIN__) && defined(__WIN32__) + + extern int cygwin_conv_to_win32_path + _ANSI_ARGS_((CONST char *, char *)); + char winbuf[MAX_PATH]; + + /* + * In the Cygwin world, call conv_to_win32_path in order to use the + * mount table to translate the file name into something Windows will + * understand. Take care when converting empty strings! + */ + if (Tcl_DStringLength(bufferPtr)) { + cygwin_conv_to_win32_path(Tcl_DStringValue(bufferPtr), winbuf); + Tcl_DStringFree(bufferPtr); + Tcl_DStringAppend(bufferPtr, winbuf, -1); + } +#else /* __CYGWIN__ && __WIN32__ */ + register char *p; for (p = Tcl_DStringValue(bufferPtr); *p != '\0'; p++) { if (*p == '/') { *p = '\\'; } } +#endif /* __CYGWIN__ && __WIN32__ */ } return Tcl_DStringValue(bufferPtr); } @@ -2317,6 +2336,25 @@ TclDoGlob(interp, separators, headPtr, tail, types) * element. Add an extra slash if this is a UNC path. */ +#if defined(__CYGWIN__) && defined(__WIN32__) + { + + extern int cygwin_conv_to_win32_path + _ANSI_ARGS_((CONST char *, char *)); + char winbuf[MAX_PATH]; + + /* + * In the Cygwin world, call conv_to_win32_path in order to use + * the mount table to translate the file name into something + * Windows will understand. + */ + cygwin_conv_to_win32_path(Tcl_DStringValue(headPtr), winbuf); + Tcl_DStringFree(headPtr); + Tcl_DStringAppend(headPtr, winbuf, -1); + + } +#endif /* __CYGWIN__ && __WIN32__ */ + if (*name == ':') { Tcl_DStringAppend(headPtr, ":", 1); if (count > 1) { diff --git a/generic/tclPlatDecls.h b/generic/tclPlatDecls.h index e0fed76..3404542 100644 --- a/generic/tclPlatDecls.h +++ b/generic/tclPlatDecls.h @@ -6,7 +6,7 @@ * Copyright (c) 1998-1999 by Scriptics Corporation. * All rights reserved. * - * RCS: @(#) $Id: tclPlatDecls.h,v 1.17 2002/08/31 06:09:45 das Exp $ + * RCS: @(#) $Id: tclPlatDecls.h,v 1.18 2002/09/27 00:50:10 hobbs Exp $ */ #ifndef _TCLPLATDECLS @@ -15,7 +15,9 @@ /* * Pull in the typedef of TCHAR for windows. */ -#if defined(__WIN32__) && !defined(_TCHAR_DEFINED) +#if defined(__CYGWIN__) + typedef char TCHAR; +#elif defined(__WIN32__) && !defined(_TCHAR_DEFINED) # include <tchar.h> # ifndef _TCHAR_DEFINED /* Borland seems to forget to set this. */ |