Index: generic/tclPathObj.c ================================================================== --- generic/tclPathObj.c +++ generic/tclPathObj.c @@ -82,12 +82,14 @@ * container. If that is NOT the case, we have * a refCount on the object. */ Tcl_Obj *cwdPtr; /* If null, path is absolute, else this points * to the cwd object used for this path. We * have a refCount on the object. */ +#if 0 int flags; /* Flags to describe interpretation - see * below. */ +#endif ClientData nativePathPtr; /* Native representation of this path, which * is filesystem dependent. */ int filesystemEpoch; /* Used to ensure the path representation was * generated during the correct filesystem * epoch. The epoch changes when @@ -95,26 +97,30 @@ struct FilesystemRecord *fsRecPtr; /* Pointer to the filesystem record entry to * use for this path. */ } FsPath; +#if 0 /* * Flag values for FsPath->flags. */ #define TCLPATH_APPENDED 1 #define TCLPATH_NEEDNORM 4 +#endif /* * Define some macros to give us convenient access to path-object specific * fields. */ #define PATHOBJ(pathPtr) ((FsPath *) (pathPtr)->internalRep.otherValuePtr) #define SETPATHOBJ(pathPtr,fsPathPtr) \ ((pathPtr)->internalRep.otherValuePtr = (void *) (fsPathPtr)) +#if 0 #define PATHFLAGS(pathPtr) (PATHOBJ(pathPtr)->flags) +#endif /* *--------------------------------------------------------------------------- * * TclFSNormalizeAbsolutePath -- @@ -509,24 +515,29 @@ if (fsPathPtr->cwdPtr == NULL) { return TclGetPathType(pathPtr, filesystemPtrPtr, driveNameLengthPtr, NULL); } +#if 0 if (PATHFLAGS(pathPtr) == 0) { +#endif /* The path is not absolute... */ + #ifdef __WIN32__ /* ... on Windows we must make another call to determine whether * it's relative or volumerelative [Bug 2571597]. */ return TclGetPathType(pathPtr, filesystemPtrPtr, driveNameLengthPtr, NULL); #else /* On other systems, quickly deduce !absolute -> relative */ return TCL_PATH_RELATIVE; #endif +#if 0 } return TclFSGetPathType(fsPathPtr->cwdPtr, filesystemPtrPtr, driveNameLengthPtr); +#endif } /* *--------------------------------------------------------------------------- * @@ -562,13 +573,13 @@ TclPathPart( Tcl_Interp *interp, /* Used for error reporting */ Tcl_Obj *pathPtr, /* Path to take dirname of */ Tcl_PathPart portion) /* Requested portion of name */ { +#if 0 if (pathPtr->typePtr == &tclFsPathType) { FsPath *fsPathPtr = PATHOBJ(pathPtr); - if (TclFSEpochOk(fsPathPtr->filesystemEpoch) && (PATHFLAGS(pathPtr) != 0)) { switch (portion) { case TCL_PATH_DIRNAME: { /* @@ -687,14 +698,16 @@ } else { /* Absolute path */ goto standardPath; } } else { +#endif int splitElements; Tcl_Obj *splitPtr, *resultPtr; - +#if 0 standardPath: +#endif resultPtr = NULL; if (portion == TCL_PATH_EXTENSION) { return GetExtension(pathPtr); } else if (portion == TCL_PATH_ROOT) { int length; @@ -763,11 +776,13 @@ } } Tcl_IncrRefCount(resultPtr); TclDecrRefCount(splitPtr); return resultPtr; +#if 0 } +#endif } /* * Simple helper function */ @@ -866,11 +881,11 @@ int driveNameLength, strEltLen, length; Tcl_PathType type; char *strElt, *ptr; Tcl_ListObjIndex(NULL, listObj, i, &elt); - +#if 0 /* * This is a special case where we can be much more efficient, where * we are joining a single relative path onto an object that is * already of path type. The 'TclNewFSPathObj' call below creates an * object which can be normalized more efficiently. Currently we only @@ -949,10 +964,11 @@ return tailObj; } } } } +#endif strElt = Tcl_GetStringFromObj(elt, &strEltLen); type = TclGetPathType(elt, &fsPtr, &driveNameLength, &driveName); if (type != TCL_PATH_RELATIVE) { /* * Zero out the current result. @@ -1262,10 +1278,26 @@ TclNewFSPathObj( Tcl_Obj *dirPtr, const char *addStrRep, int len) { +#if 1 + Tcl_Obj *newPath, *tail = Tcl_NewStringObj(addStrRep, len); + + Tcl_IncrRefCount(tail); + if (len == 0 || addStrRep[0] == '~') { + newPath = AppendPath(dirPtr, tail); + Tcl_DecrRefCount(tail); + return newPath; + } + + newPath = Tcl_FSJoinToPath(dirPtr, 1, &tail); + if (newPath != tail) { + Tcl_DecrRefCount(tail); + } + return newPath; +#else FsPath *fsPathPtr; Tcl_Obj *pathPtr; ThreadSpecificData *tsdPtr; const char *p; int state = 0, count = 0; @@ -1356,10 +1388,11 @@ if (len == 0 && count) { PATHFLAGS(pathPtr) |= TCLPATH_NEEDNORM; } return pathPtr; +#endif } static Tcl_Obj * AppendPath( Tcl_Obj *head, @@ -1432,18 +1465,20 @@ Tcl_Obj *cwdPtr) /* Make it relative to this. */ { int cwdLen, len; const char *tempStr; +#if 0 if (pathPtr->typePtr == &tclFsPathType) { FsPath *fsPathPtr = PATHOBJ(pathPtr); if (PATHFLAGS(pathPtr) != 0 && fsPathPtr->cwdPtr == cwdPtr) { return fsPathPtr->normPathPtr; } } +#endif /* * We know the cwd is a normalised object which does not end in a * directory delimiter, unless the cwd is the name of a volume, in which * case it will end in a delimiter! We handle this situation here. A @@ -1548,11 +1583,13 @@ fsPathPtr->nativePathPtr = nativeRep; fsPathPtr->fsRecPtr = NULL; fsPathPtr->filesystemEpoch = tsdPtr->filesystemEpoch; SETPATHOBJ(pathPtr, fsPathPtr); +#if 0 PATHFLAGS(pathPtr) = 0; +#endif pathPtr->typePtr = &tclFsPathType; return TCL_OK; } @@ -1627,11 +1664,13 @@ fsPathPtr->fsRecPtr = fsFromPtr; fsPathPtr->fsRecPtr->fileRefCount++; fsPathPtr->filesystemEpoch = tsdPtr->filesystemEpoch; SETPATHOBJ(pathPtr, fsPathPtr); +#if 0 PATHFLAGS(pathPtr) = 0; +#endif pathPtr->typePtr = &tclFsPathType; return pathPtr; } @@ -1665,10 +1704,11 @@ if (Tcl_FSConvertToPathType(interp, pathPtr) != TCL_OK) { return NULL; } srcFsPathPtr = PATHOBJ(pathPtr); if (srcFsPathPtr->translatedPathPtr == NULL) { +#if 0 if (PATHFLAGS(pathPtr) != 0) { /* * We lack a translated path result, but we have a directory * (cwdPtr) and a tail (normPathPtr), and if we join the * translated version of cwdPtr to normPathPtr, we'll get the @@ -1685,18 +1725,21 @@ &srcFsPathPtr->normPathPtr); srcFsPathPtr->translatedPathPtr = retObj; Tcl_IncrRefCount(retObj); Tcl_DecrRefCount(translatedCwdPtr); } else { +#endif /* * It is a pure absolute, normalized path object. This is * something like being a 'pure list'. The object's string, * translatedPath and normalizedPath are all identical. */ retObj = srcFsPathPtr->normPathPtr; +#if 0 } +#endif } else { /* * It is an ordinary path object. */ @@ -1777,10 +1820,11 @@ if (Tcl_FSConvertToPathType(interp, pathPtr) != TCL_OK) { return NULL; } fsPathPtr = PATHOBJ(pathPtr); +#if 0 if (PATHFLAGS(pathPtr) != 0) { /* * This is a special path object which is the result of something like * 'file join' */ @@ -1888,10 +1932,11 @@ fsPathPtr->nativePathPtr = clientData; } PATHFLAGS(pathPtr) = 0; } +#endif /* * Ensure cwd hasn't changed. */ @@ -2550,11 +2595,13 @@ * Free old representation before installing our new one. */ TclFreeIntRep(pathPtr); SETPATHOBJ(pathPtr, fsPathPtr); +#if 0 PATHFLAGS(pathPtr) = 0; +#endif pathPtr->typePtr = &tclFsPathType; #if defined(__CYGWIN__) && defined(__WIN32__) if (copied) { Tcl_DecrRefCount(transPtr); } @@ -2640,11 +2687,13 @@ copyFsPathPtr->cwdPtr = srcFsPathPtr->cwdPtr; if (copyFsPathPtr->cwdPtr != NULL) { Tcl_IncrRefCount(copyFsPathPtr->cwdPtr); } +#if 0 copyFsPathPtr->flags = srcFsPathPtr->flags; +#endif if (srcFsPathPtr->fsRecPtr != NULL && srcFsPathPtr->nativePathPtr != NULL) { Tcl_FSDupInternalRepProc *dupProc = srcFsPathPtr->fsRecPtr->fsPtr->dupInternalRepProc; @@ -2689,11 +2738,15 @@ { FsPath *fsPathPtr = PATHOBJ(pathPtr); int cwdLen; Tcl_Obj *copy; - if (PATHFLAGS(pathPtr) == 0 || fsPathPtr->cwdPtr == NULL) { + if ( +#if 0 +PATHFLAGS(pathPtr) == 0 || +#endif + fsPathPtr->cwdPtr == NULL) { Tcl_Panic("Called UpdateStringOfFsPath with invalid object"); } copy = AppendPath(fsPathPtr->cwdPtr, fsPathPtr->normPathPtr);