diff options
author | vincentdarley <vincentdarley> | 2004-05-19 16:56:35 (GMT) |
---|---|---|
committer | vincentdarley <vincentdarley> | 2004-05-19 16:56:35 (GMT) |
commit | e8f6e134d9fe78331b2ee9696941ad0d20683403 (patch) | |
tree | 94dde45090003bf42f08259bde76226467fb2e62 /generic | |
parent | 645435663a5c2ba8dcdc3be20f50410cae48a629 (diff) | |
download | tcl-e8f6e134d9fe78331b2ee9696941ad0d20683403.zip tcl-e8f6e134d9fe78331b2ee9696941ad0d20683403.tar.gz tcl-e8f6e134d9fe78331b2ee9696941ad0d20683403.tar.bz2 |
fix to 'file dirname' and to fs refCount documentation
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclPathObj.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c index bcb1500..df9963a 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.30 2004/04/23 12:09:37 vincentdarley Exp $ + * RCS: @(#) $Id: tclPathObj.c,v 1.31 2004/05/19 16:56:39 vincentdarley Exp $ */ #include "tclInt.h" @@ -494,6 +494,26 @@ TclPathPart(interp, pathPtr, portion) if (PATHFLAGS(pathPtr) != 0) { switch (portion) { case TCL_PATH_DIRNAME: { + /* + * Check if the joined-on bit has any directory + * delimiters in it. If so, the 'dirname' would + * be a joining of the main part with the dirname + * of the joined-on bit. We could handle that + * special case here, but we don't, and instead + * just use the standardPath code. + */ + CONST char *rest = Tcl_GetString(fsPathPtr->normPathPtr); + if (strchr(rest, '/') != NULL) { + goto standardPath; + } + if ((tclPlatform == TCL_PLATFORM_WINDOWS) + && (strchr(rest, '\\') != NULL)) { + goto standardPath; + } + /* + * The joined-on path is simple, so we can just + * return here. + */ Tcl_IncrRefCount(fsPathPtr->cwdPtr); return fsPathPtr->cwdPtr; } @@ -662,8 +682,13 @@ GetExtension(pathPtr) * * This function takes the given Tcl_Obj, which should be a valid * list, and returns the path object given by considering the - * first 'elements' elements as valid path segments. If elements < 0, - * we use the entire list. + * first 'elements' elements as valid path segments (each path + * segment may be a complete path, a partial path or just a single + * possible directory or file name). If any path segment is + * actually an absolute path, then all prior path segments are + * discarded. + * + * If elements < 0, we use the entire list that was given. * * It is possible that the returned object is actually an element * of the given list, so the caller should be careful to store a |