diff options
author | dgp <dgp@noemail.net> | 2010-01-05 18:58:12 (GMT) |
---|---|---|
committer | dgp <dgp@noemail.net> | 2010-01-05 18:58:12 (GMT) |
commit | 6cbc7dfe30d158f9d3c06973dee976b2659e3c91 (patch) | |
tree | ef190eb25737fc57bc8e1ba3c90d8835649e6857 /generic/tclPathObj.c | |
parent | 0a20197737195db559b45757b7dbed9d6192f970 (diff) | |
download | tcl-6cbc7dfe30d158f9d3c06973dee976b2659e3c91.zip tcl-6cbc7dfe30d158f9d3c06973dee976b2659e3c91.tar.gz tcl-6cbc7dfe30d158f9d3c06973dee976b2659e3c91.tar.bz2 |
* generic/tclPathObj.c (TclPathPart): Correct inconsistency between
* tests/fileName.test (filename-14.31): the string rep and the intrep
of a path value created by [file rootname]. Thanks to Vitaly Magerya
for reporting. [Bug 2918610]
FossilOrigin-Name: dc8d903cb763ca5c8c8092f7844b74132e2880c0
Diffstat (limited to 'generic/tclPathObj.c')
-rw-r--r-- | generic/tclPathObj.c | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c index bd69f09..13eeb2b 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.10 2009/10/27 20:30:48 dgp Exp $ + * RCS: @(#) $Id: tclPathObj.c,v 1.66.2.11 2010/01/05 18:58:12 dgp Exp $ */ #include "tclInt.h" @@ -660,34 +660,18 @@ TclPathPart( return pathPtr; } else { /* - * Duplicate the object we were given and then trim off - * the extension of the tail component of the path. + * Need to return the whole path with the extension + * suffix removed. Do that by joining our "head" to + * our "tail" with the extension suffix removed from + * the tail. */ - FsPath *fsDupPtr; - Tcl_Obj *root = Tcl_DuplicateObj(pathPtr); + Tcl_Obj *resultPtr = + TclNewFSPathObj(fsPathPtr->cwdPtr, fileName, + (int)(length - strlen(extension))); - Tcl_IncrRefCount(root); - fsDupPtr = PATHOBJ(root); - if (Tcl_IsShared(fsDupPtr->normPathPtr)) { - TclDecrRefCount(fsDupPtr->normPathPtr); - fsDupPtr->normPathPtr = Tcl_NewStringObj(fileName, - (int)(length - strlen(extension))); - Tcl_IncrRefCount(fsDupPtr->normPathPtr); - } else { - Tcl_SetObjLength(fsDupPtr->normPathPtr, - (int)(length - strlen(extension))); - } - - /* - * Must also trim the string representation if we have it. - */ - - if (root->bytes != NULL && root->length > 0) { - root->length -= strlen(extension); - root->bytes[root->length] = 0; - } - return root; + Tcl_IncrRefCount(resultPtr); + return resultPtr; } } default: |