summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2004-01-23 10:59:57 (GMT)
committervincentdarley <vincentdarley>2004-01-23 10:59:57 (GMT)
commit532cf499694027af6614c6a70eeb557bb6d29a6a (patch)
treea0c28b5eaba664ae2cf954de2a8c8c836e74c31a /generic
parentba9706852dcaec5a693270fd54a02746625b0a27 (diff)
downloadtcl-532cf499694027af6614c6a70eeb557bb6d29a6a.zip
tcl-532cf499694027af6614c6a70eeb557bb6d29a6a.tar.gz
tcl-532cf499694027af6614c6a70eeb557bb6d29a6a.tar.bz2
file normalize bug fixes for .. and .
Diffstat (limited to 'generic')
-rw-r--r--generic/tclIOUtil.c41
-rw-r--r--generic/tclPathObj.c5
2 files changed, 38 insertions, 8 deletions
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index 738f182..b06885c 100644
--- a/generic/tclIOUtil.c
+++ b/generic/tclIOUtil.c
@@ -17,7 +17,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIOUtil.c,v 1.93 2004/01/21 19:59:33 vincentdarley Exp $
+ * RCS: @(#) $Id: tclIOUtil.c,v 1.94 2004/01/23 11:03:33 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -2628,13 +2628,40 @@ Tcl_FSChdir(pathPtr)
* will have been cached as a result of the
* Tcl_FSGetFileSystemForPath call above anyway).
*/
- ClientData cd;
Tcl_Obj *normDirName = Tcl_FSGetNormalizedPath(NULL, pathPtr);
if (normDirName == NULL) {
return TCL_ERROR;
}
- cd = (ClientData) Tcl_FSGetNativePath(pathPtr);
- FsUpdateCwd(normDirName, TclNativeDupInternalRep(cd));
+ if (fsPtr == &tclNativeFilesystem) {
+ /*
+ * For the native filesystem, we keep a cache of the
+ * native representation of the cwd. But, we want to do
+ * that for the exact format that is returned by
+ * 'getcwd' (so that we can later compare the two
+ * representations for equality), which might not be
+ * exactly the same char-string as the native
+ * representation of the fully normalized path (e.g. on
+ * Windows there's a forward-slash vs backslash
+ * difference). Hence we ask for this again here. On
+ * Unix it might actually be true that we always have
+ * the correct form in the native rep in which case we
+ * could simply use:
+ *
+ * cd = Tcl_FSGetNativePath(pathPtr);
+ *
+ * instead. This should be examined by someone on
+ * Unix.
+ */
+ ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&tclFsDataKey);
+ ClientData cd;
+
+ /* Assumption we are using a filesystem version 2 */
+ TclFSGetCwdProc2 *proc2 = (TclFSGetCwdProc2*)fsPtr->getCwdProc;
+ cd = (*proc2)(tsdPtr->cwdClientData);
+ FsUpdateCwd(normDirName, TclNativeDupInternalRep(cd));
+ } else {
+ FsUpdateCwd(normDirName, NULL);
+ }
}
} else {
Tcl_SetErrno(ENOENT);
@@ -4100,7 +4127,7 @@ ClientData
TclNativeDupInternalRep(clientData)
ClientData clientData;
{
- ClientData copy;
+ char *copy;
size_t len;
if (clientData == NULL) {
@@ -4120,9 +4147,9 @@ TclNativeDupInternalRep(clientData)
len = sizeof(char) + (strlen((CONST char*)clientData) * sizeof(char));
#endif
- copy = (ClientData) ckalloc(len);
+ copy = (char *) ckalloc(len);
memcpy((VOID*)copy, (VOID*)clientData, len);
- return copy;
+ return (ClientData)copy;
}
/*
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c
index acb16b7..42dfaa3 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.20 2004/01/21 19:59:33 vincentdarley Exp $
+ * RCS: @(#) $Id: tclPathObj.c,v 1.21 2004/01/23 11:04:11 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -216,6 +216,7 @@ TclFSNormalizeAbsolutePath(interp, pathPtr, clientDataPtr)
if (dirSep[1] == '.') {
if (retVal != NULL) {
Tcl_AppendToObj(retVal, oldDirSep, dirSep - oldDirSep);
+ oldDirSep = dirSep;
}
again:
if (IsSeparatorOrNull(dirSep[2])) {
@@ -226,6 +227,7 @@ TclFSNormalizeAbsolutePath(interp, pathPtr, clientDataPtr)
Tcl_IncrRefCount(retVal);
}
dirSep += 2;
+ oldDirSep = dirSep;
if (dirSep[0] != 0 && dirSep[1] == '.') {
goto again;
}
@@ -269,6 +271,7 @@ TclFSNormalizeAbsolutePath(interp, pathPtr, clientDataPtr)
}
}
dirSep += 3;
+ oldDirSep = dirSep;
if (dirSep[0] != 0 && dirSep[1] == '.') {
goto again;
}