diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | generic/tclIOUtil.c | 16 | ||||
-rw-r--r-- | tests/fileSystem.test | 8 |
3 files changed, 27 insertions, 3 deletions
@@ -1,3 +1,9 @@ +2004-11-23 Vince Darley <vincentdarley@users.sourceforge.net> + + * generic/tclPathObj.c: fix and new test for [Bug 1043129] in + * tests/fileSystem.test: the treatment of backslashes in file + join on Windows. + 2004-11-22 Mo DeJong <mdejong@users.sourceforge.net> * unix/configure: Regen. diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index 33884e0..3b0ed7c 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.18 2004/06/10 14:05:24 vasiljevic Exp $ + * RCS: @(#) $Id: tclIOUtil.c,v 1.77.2.19 2004/11/23 15:23:13 vincentdarley Exp $ */ #include "tclInt.h" @@ -4776,8 +4776,18 @@ Tcl_FSJoinPath(listObj, elements) */ if (str[0] != '.' && ((tclPlatform != TCL_PLATFORM_WINDOWS) || (strchr(str, '\\') == NULL))) { - Tcl_DecrRefCount(res); - return TclNewFSPathObj(elt, str, len); + /* + * Finally, on Windows, 'file join' is defined to + * convert all backslashes to forward slashes, + * so the base part cannot have backslashes either. + */ + if ((tclPlatform != TCL_PLATFORM_WINDOWS) + || (strchr(Tcl_GetString(elt), '\\') == NULL)) { + if (res != NULL) { + TclDecrRefCount(res); + } + return TclNewFSPathObj(elt, str, len); + } } /* * Otherwise we don't have an easy join, and diff --git a/tests/fileSystem.test b/tests/fileSystem.test index 7ce7746..20c04ae 100644 --- a/tests/fileSystem.test +++ b/tests/fileSystem.test @@ -555,6 +555,14 @@ test filesystem-9.5 {path objects and file tail and object rep} { set res } {test test} +test filesystem-9.6 {path objects and file join and object rep} {winOnly} { + set res {} + set p "C:\\toto" + lappend res [file join $p toto] + file isdirectory $p + lappend res [file join $p toto] +} {C:/toto/toto C:/toto/toto} + cleanupTests } namespace delete ::tcl::test::fileSystem |