diff options
author | dgp <dgp@users.sourceforge.net> | 2009-03-27 19:16:49 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2009-03-27 19:16:49 (GMT) |
commit | a8b9faafc0542a8833712172d50d9c00fe574c9f (patch) | |
tree | b7b5d48e93533f9fba48a87c0a42a2eb9be2e81d /generic/tclPathObj.c | |
parent | 73941c99e7635c6a7f6587eebe0498466aeb719e (diff) | |
download | tcl-a8b9faafc0542a8833712172d50d9c00fe574c9f.zip tcl-a8b9faafc0542a8833712172d50d9c00fe574c9f.tar.gz tcl-a8b9faafc0542a8833712172d50d9c00fe574c9f.tar.bz2 |
* generic/tclPathObj.c (TclPathPart): TclPathPart() was computing
* tests/fileName.test: the wrong results for both [file dirname] and
[file tail] on "path" arguments with the PATHFLAGS != 0 intrep and
with an empty string for the "joined-on" part. [Bug 2710920]
Diffstat (limited to 'generic/tclPathObj.c')
-rw-r--r-- | generic/tclPathObj.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c index 28345da..bb7b0f4 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.66.2.6 2009/02/20 18:19:32 dgp Exp $ + * RCS: @(#) $Id: tclPathObj.c,v 1.66.2.7 2009/03/27 19:16:49 dgp Exp $ */ #include "tclInt.h" @@ -577,11 +577,24 @@ TclPathPart( * the standardPath code. */ - const char *rest = TclGetString(fsPathPtr->normPathPtr); + int numBytes; + const char *rest = + Tcl_GetStringFromObj(fsPathPtr->normPathPtr, &numBytes); if (strchr(rest, '/') != NULL) { goto standardPath; } + /* + * If the joined-on bit is empty, then [file dirname] is + * documented to return all but the last non-empty element + * of the path, so we need to split apart the main part to + * get the right answer. We could do that here, but it's + * simpler to fall back to the standardPath code. + * [Bug 2710920] + */ + if (numBytes == 0) { + goto standardPath; + } if (tclPlatform == TCL_PLATFORM_WINDOWS && strchr(rest, '\\') != NULL) { goto standardPath; @@ -602,11 +615,24 @@ TclPathPart( * we don't, and instead just use the standardPath code. */ - const char *rest = TclGetString(fsPathPtr->normPathPtr); + int numBytes; + const char *rest = + Tcl_GetStringFromObj(fsPathPtr->normPathPtr, &numBytes); if (strchr(rest, '/') != NULL) { goto standardPath; } + /* + * If the joined-on bit is empty, then [file tail] is + * documented to return the last non-empty element + * of the path, so we need to split off the last element + * of the main part to get the right answer. We could do + * that here, but it's simpler to fall back to the + * standardPath code. [Bug 2710920] + */ + if (numBytes == 0) { + goto standardPath; + } if (tclPlatform == TCL_PLATFORM_WINDOWS && strchr(rest, '\\') != NULL) { goto standardPath; |