From bb1c5fe83355d454d63db62da5797204c6cec06e Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 6 Dec 2017 13:02:32 +0000 Subject: [ce3a211dcb] Failed file normalize when tail is empty string. --- generic/tclPathObj.c | 5 ++--- tests/fileSystem.test | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c index a306853..87ddfb7 100644 --- a/generic/tclPathObj.c +++ b/generic/tclPathObj.c @@ -1869,7 +1869,6 @@ Tcl_FSGetNormalizedPath( */ (void) Tcl_GetStringFromObj(dir, &cwdLen); - cwdLen += (Tcl_GetString(copy)[cwdLen] == '/'); /* Normalize the combined string. */ @@ -1890,13 +1889,13 @@ Tcl_FSGetNormalizedPath( * to a normalized head, we can more efficiently normalize the * combined path by passing over only the unnormalized tail * portion. When this is sufficient, prior developers claim - * this should be much faster. We use 'cwdLen-1' so that we are + * this should be much faster. We use 'cwdLen' so that we are * already pointing at the dir-separator that we know about. * The normalization code will actually start off directly * after that separator. */ - TclFSNormalizeToUniquePath(interp, copy, cwdLen-1); + TclFSNormalizeToUniquePath(interp, copy, cwdLen); } /* Now we need to construct the new path object. */ diff --git a/tests/fileSystem.test b/tests/fileSystem.test index d34de8f..1c507e1 100644 --- a/tests/fileSystem.test +++ b/tests/fileSystem.test @@ -508,6 +508,22 @@ test filesystem-1.52.1 {bug f9f390d0fa: file join where strep is not canonical} file normalize $x file join $x } -result /foo +test filesystem-1.53 {[Bug 3559678] - normalize when tail is empty} { + string match */ [file normalize [lindex [glob -dir [pwd] {{}}] 0]] +} 0 +test filesystem-1.54 {[Bug ce3a211dcb] - normalize when tail is empty} -setup { + set save [pwd] + cd [set home [makeDirectory ce3a211dcb]] + makeDirectory A $home + cd [lindex [glob */] 0] +} -body { + string match */A [pwd] +} -cleanup { + cd $home + removeDirectory A $home + cd $save + removeDirectory ce3a211dcb +} -result 1 test filesystem-2.0 {new native path} {unix} { foreach f [lsort [glob -nocomplain /usr/bin/c*]] { -- cgit v0.12