From 5264c8ea7beb50e85b079617502d7ef7296a5188 Mon Sep 17 00:00:00 2001 From: vincentdarley Date: Mon, 22 Nov 2004 12:53:04 +0000 Subject: fix to windows file join bug --- ChangeLog | 6 ++++++ generic/tclPathObj.c | 16 ++++++++++++---- tests/fileSystem.test | 7 +++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index e80ea65..c1bcda1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-11-22 Vince Darley + + * 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 * 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 -- cgit v0.12