10
10
* See the file "license.terms" for information on usage and redistribution of
11
11
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
13
* RCS: @(#) $Id: tclPathObj.c,v 1.66.2.4 2008/06/29 19:08:36 dgp Exp $
13
* RCS: @(#) $Id: tclPathObj.c,v 1.66.2.5 2008/12/04 17:45:02 dgp Exp $
16
16
#include "tclInt.h"
1271
1274
pathPtr->bytes = NULL;
1272
1275
pathPtr->length = 0;
1278
* Look for path components made up of only "."
1279
* This is overly conservative analysis to keep simple. It may
1280
* mark some things as needing more aggressive normalization
1281
* that don't actually need it. No harm done.
1283
for (p = addStrRep; len > 0; p++, len--) {
1285
case 0: /* So far only "." since last dirsep or start */
1294
PATHFLAGS(pathPtr) |= TCLPATH_NEEDNORM;
1302
case 1: /* Scanning for next dirsep */
1312
if (len == 0 && count) {
1313
PATHFLAGS(pathPtr) |= TCLPATH_NEEDNORM;
1274
1316
return pathPtr;
1757
1799
Tcl_AppendObjToObj(copy, fsPathPtr->normPathPtr);
1760
* Normalize the combined string, but only starting after the end of
1761
* the previously normalized 'dir'. This should be much faster! We use
1762
* 'cwdLen-1' so that we are already pointing at the dir-separator
1763
* that we know about. The normalization code will actually start off
1764
* directly after that separator.
1767
TclFSNormalizeToUniquePath(interp, copy, cwdLen-1,
1768
(fsPathPtr->nativePathPtr == NULL ? &clientData : NULL));
1771
* Now we need to construct the new path object
1801
/* Normalize the combined string. */
1803
if (PATHFLAGS(pathPtr) & TCLPATH_NEEDNORM) {
1805
* If the "tail" part has components (like /../) that cause
1806
* the combined path to need more complete normalizing,
1807
* call on the more powerful routine to accomplish that so
1808
* we avoid [Bug 2385549] ...
1811
Tcl_Obj *newCopy = TclFSNormalizeAbsolutePath(interp, copy, NULL);
1812
Tcl_DecrRefCount(copy);
1816
* ... but in most cases where we join a trouble free tail
1817
* to a normalized head, we can more efficiently normalize the
1818
* combined path by passing over only the unnormalized tail
1819
* portion. When this is sufficient, prior developers claim
1820
* this should be much faster. We use 'cwdLen-1' so that we are
1821
* already pointing at the dir-separator that we know about.
1822
* The normalization code will actually start off directly
1823
* after that separator.
1826
TclFSNormalizeToUniquePath(interp, copy, cwdLen-1,
1827
(fsPathPtr->nativePathPtr == NULL ? &clientData : NULL));
1830
/* Now we need to construct the new path object. */
1774
1832
if (pathType == TCL_PATH_RELATIVE) {
1775
1833
Tcl_Obj *origDir = fsPathPtr->cwdPtr;
1810
1868
TclDecrRefCount(dir);
1812
1870
if (clientData != NULL) {
1872
* This may be unnecessary. It appears that the
1873
* TclFSNormalizeToUniquePath call above should have already
1874
* set this up. Not changing out of fear of the unknown.
1813
1876
fsPathPtr->nativePathPtr = clientData;
1815
1878
PATHFLAGS(pathPtr) = 0;