diff options
author | dgp <dgp@users.sourceforge.net> | 2017-05-01 20:25:27 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2017-05-01 20:25:27 (GMT) |
commit | cebc6d8e934fb4416742c51d2a59bccd95e66c17 (patch) | |
tree | 83fdf7f47d86b8f2e75f3c5266cc29e1ea29e496 | |
parent | af6bdabef606d9aefa0cc8c4755c98b1445203d2 (diff) | |
parent | cfdf3d1f29001198f2afdea91a595527acdc2802 (diff) | |
download | tcl-cebc6d8e934fb4416742c51d2a59bccd95e66c17.zip tcl-cebc6d8e934fb4416742c51d2a59bccd95e66c17.tar.gz tcl-cebc6d8e934fb4416742c51d2a59bccd95e66c17.tar.bz2 |
[f9fe90d0fa] [file join] normalization. See filesystem-1.52*
-rw-r--r-- | generic/tclPathObj.c | 22 | ||||
-rw-r--r-- | tests/fileSystem.test | 10 |
2 files changed, 29 insertions, 3 deletions
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c index 43a3c85..ffeb688 100644 --- a/generic/tclPathObj.c +++ b/generic/tclPathObj.c @@ -921,7 +921,17 @@ TclJoinPath( if (res != NULL) { TclDecrRefCount(res); } - return TclNewFSPathObj(elt, str, len); + + if (PATHFLAGS(elt)) { + return TclNewFSPathObj(elt, str, len); + } + if (TCL_PATH_ABSOLUTE != Tcl_FSGetPathType(elt)) { + return TclNewFSPathObj(elt, str, len); + } + (void) Tcl_FSGetNormalizedPath(NULL, elt); + if (elt == PATHOBJ(elt)->normPathPtr) { + return TclNewFSPathObj(elt, str, len); + } } } @@ -1312,8 +1322,14 @@ TclNewFSPathObj( fsPathPtr->translatedPathPtr = NULL; fsPathPtr->normPathPtr = Tcl_NewStringObj(addStrRep, len); Tcl_IncrRefCount(fsPathPtr->normPathPtr); - fsPathPtr->cwdPtr = dirPtr; - Tcl_IncrRefCount(dirPtr); + + if (TCL_PATH_ABSOLUTE == Tcl_FSGetPathType(dirPtr)) { + fsPathPtr->cwdPtr = Tcl_FSGetNormalizedPath(NULL, dirPtr); + } else { +fprintf(stdout, "FUCKING BROKEN!\n"); fflush(stdout); + fsPathPtr->cwdPtr = dirPtr; + } + Tcl_IncrRefCount(fsPathPtr->cwdPtr); fsPathPtr->nativePathPtr = NULL; fsPathPtr->fsPtr = NULL; fsPathPtr->filesystemEpoch = 0; diff --git a/tests/fileSystem.test b/tests/fileSystem.test index 1941936..4513fcb 100644 --- a/tests/fileSystem.test +++ b/tests/fileSystem.test @@ -367,6 +367,16 @@ test filesystem-1.51 {file normalisation .. beyond root (Bug 1379287)} { test filesystem-1.51.1 {file normalisation .. beyond root (Bug 1379287)} { testPathEqual [file norm /../../] [file norm /] } ok +test filesystem-1.52 {bug f9f390d0fa: file join where strep is not canonical} -body { + set x //foo + file normalize $x + file join $x bar +} -result /foo/bar +test filesystem-1.52.1 {bug f9f390d0fa: file join where strep is not canonical} -body { + set x //foo + file normalize $x + file join $x +} -result /foo test filesystem-2.0 {new native path} {unix} { foreach f [lsort [glob -nocomplain /usr/bin/c*]] { |