diff options
author | vincentdarley <vincentdarley> | 2004-11-22 12:53:04 (GMT) |
---|---|---|
committer | vincentdarley <vincentdarley> | 2004-11-22 12:53:04 (GMT) |
commit | 5264c8ea7beb50e85b079617502d7ef7296a5188 (patch) | |
tree | 3637c6ed0321468290c7f2b3e0c04c7bf2ece6e8 | |
parent | c5de95ef4f7261b14f8ff65e8bef6ec08967f12d (diff) | |
download | tcl-5264c8ea7beb50e85b079617502d7ef7296a5188.zip tcl-5264c8ea7beb50e85b079617502d7ef7296a5188.tar.gz tcl-5264c8ea7beb50e85b079617502d7ef7296a5188.tar.bz2 |
fix to windows file join bug
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | generic/tclPathObj.c | 16 | ||||
-rw-r--r-- | tests/fileSystem.test | 7 |
3 files changed, 25 insertions, 4 deletions
@@ -1,3 +1,9 @@ +2004-11-22 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-21 Don Porter <dgp@users.sourceforge.net> * doc/AddErrInfo.3: Typo corrections (Thanks Daniel South). diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c index 26d5e70..2ed8eed 100644 --- a/generic/tclPathObj.c +++ b/generic/tclPathObj.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: tclPathObj.c,v 1.37 2004/10/07 14:50:23 vincentdarley Exp $ + * RCS: @(#) $Id: tclPathObj.c,v 1.38 2004/11/22 12:53:06 vincentdarley Exp $ */ #include "tclInt.h" @@ -842,10 +842,18 @@ Tcl_FSJoinPath(listObj, elements) if (str[0] != '.' && ((tclPlatform != TCL_PLATFORM_WINDOWS) || (strchr(str, '\\') == NULL))) { - if (res != NULL) { - TclDecrRefCount(res); + /* + * 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); } - return TclNewFSPathObj(elt, str, len); } /* diff --git a/tests/fileSystem.test b/tests/fileSystem.test index 44ba612..17cc0dd 100644 --- a/tests/fileSystem.test +++ b/tests/fileSystem.test @@ -913,6 +913,13 @@ test filesystem-9.5 {path objects and file tail and object rep} { cd $origdir set res } {test test} +test filesystem-9.6 {path objects and file tail 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 unset -nocomplain drive |