diff options
author | hobbs <hobbs> | 2003-07-17 00:16:03 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2003-07-17 00:16:03 (GMT) |
commit | fd3cca0fed42222f341474fe7ecb9843dc8fb15b (patch) | |
tree | 3df9d68233c4378f6a835b853ec41a9d581fdf69 | |
parent | 3389435994d42db2b637d34fbae876f1e36e4520 (diff) | |
download | tcl-fd3cca0fed42222f341474fe7ecb9843dc8fb15b.zip tcl-fd3cca0fed42222f341474fe7ecb9843dc8fb15b.tar.gz tcl-fd3cca0fed42222f341474fe7ecb9843dc8fb15b.tar.bz2 |
2003-07-16 Mumit Khan <khan@nanotech.wisc.edu>
* generic/tclIOUtil.c (SetFsPathFromAny): Add Cygwin specific
code to convert POSIX filename to native format.
* generic/tclFileName.c (Tcl_TranslateFileName): And remove from here.
(TclDoGlob): Adjust for cygwin and append / for dirs instead of \
* win/tclWinFile.c (TclpObjChdir): Use chdir on Cygwin.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | generic/tclFileName.c | 53 | ||||
-rw-r--r-- | generic/tclIOUtil.c | 22 | ||||
-rw-r--r-- | win/tclWinFile.c | 17 |
4 files changed, 60 insertions, 42 deletions
@@ -1,5 +1,15 @@ +2003-07-16 Mumit Khan <khan@nanotech.wisc.edu> + + * generic/tclIOUtil.c (SetFsPathFromAny): Add Cygwin specific + code to convert POSIX filename to native format. + * generic/tclFileName.c (Tcl_TranslateFileName): And remove from here. + (TclDoGlob): Adjust for cygwin and append / for dirs instead of \ + * win/tclWinFile.c (TclpObjChdir): Use chdir on Cygwin. + 2003-07-16 Jeff Hobbs <jeffh@ActiveState.com> + * win/tclWinFile.c (TclpObjChdir): + * library/safe.tcl (FileInAccessPath): normalize paths before comparison. [Bug 759607] (myers) diff --git a/generic/tclFileName.c b/generic/tclFileName.c index 79acfd2..ea7ee05 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.40.2.2 2003/07/16 15:28:29 dgp Exp $ + * RCS: @(#) $Id: tclFileName.c,v 1.40.2.3 2003/07/17 00:16:04 hobbs Exp $ */ #include "tclInt.h" @@ -1398,31 +1398,12 @@ 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); } @@ -2388,25 +2369,6 @@ 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) { @@ -2619,11 +2581,22 @@ TclDoGlob(interp, separators, headPtr, tail, types) if (Tcl_DStringLength(headPtr) == 0) { if (((*name == '\\') && (name[1] == '/' || name[1] == '\\')) || (*name == '/')) { - Tcl_DStringAppend(headPtr, "\\", 1); + Tcl_DStringAppend(headPtr, "/", 1); } else { Tcl_DStringAppend(headPtr, ".", 1); } } +#if defined(__CYGWIN__) && defined(__WIN32__) + { + extern int cygwin_conv_to_win32_path + _ANSI_ARGS_((CONST char *, char *)); + char winbuf[MAX_PATH+1]; + + cygwin_conv_to_win32_path(Tcl_DStringValue(headPtr), winbuf); + Tcl_DStringFree(headPtr); + Tcl_DStringAppend(headPtr, winbuf, -1); + } +#endif /* __CYGWIN__ && __WIN32__ */ /* * Convert to forward slashes. This is required to pass * some Tcl tests. We should probably remove the conversions diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index ca250f6..0fe38e2 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -17,7 +17,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIOUtil.c,v 1.77.2.5 2003/07/16 15:28:29 dgp Exp $ + * RCS: @(#) $Id: tclIOUtil.c,v 1.77.2.6 2003/07/17 00:16:04 hobbs Exp $ */ #include "tclInt.h" @@ -5697,6 +5697,26 @@ SetFsPathFromAny(interp, objPtr) transPtr = Tcl_FSJoinToPath(objPtr,0,NULL); } +#if defined(__CYGWIN__) && defined(__WIN32__) + { + extern int cygwin_conv_to_win32_path + _ANSI_ARGS_((CONST char *, char *)); + char winbuf[MAX_PATH+1]; + + /* + * 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! + */ + name = Tcl_GetStringFromObj(transPtr, &len); + if (len > 0) { + cygwin_conv_to_win32_path(name, winbuf); + TclWinNoBackslash(winbuf); + Tcl_SetStringObj(transPtr, winbuf, -1); + } + } +#endif /* __CYGWIN__ && __WIN32__ */ + /* * Now we have a translated filename in 'transPtr'. This will have * forward slashes on Windows, and will not contain any ~user diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 96ebbb2..f1f1ffa 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -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: tclWinFile.c,v 1.44.2.4 2003/05/16 01:43:01 hobbs Exp $ + * RCS: @(#) $Id: tclWinFile.c,v 1.44.2.5 2003/07/17 00:16:04 hobbs Exp $ */ //#define _WIN32_WINNT 0x0500 @@ -1395,9 +1395,24 @@ TclpObjChdir(pathPtr) { int result; CONST TCHAR *nativePath; +#ifdef __CYGWIN__ + extern int cygwin_conv_to_posix_path + _ANSI_ARGS_((CONST char *, char *)); + char posixPath[MAX_PATH+1]; + CONST char *path; + Tcl_DString ds; +#endif /* __CYGWIN__ */ nativePath = (CONST TCHAR *) Tcl_FSGetNativePath(pathPtr); +#ifdef __CYGWIN__ + /* Cygwin chdir only groks POSIX path. */ + path = Tcl_WinTCharToUtf(nativePath, -1, &ds); + cygwin_conv_to_posix_path(path, posixPath); + result = (chdir(posixPath) == 0 ? 1 : 0); + Tcl_DStringFree(&ds); +#else /* __CYGWIN__ */ result = (*tclWinProcs->setCurrentDirectoryProc)(nativePath); +#endif /* __CYGWIN__ */ if (result == 0) { TclWinConvertError(GetLastError()); |