summaryrefslogtreecommitdiffstats
path: root/generic/tclPathObj.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2006-03-04 02:33:36 (GMT)
committerdgp <dgp@users.sourceforge.net>2006-03-04 02:33:36 (GMT)
commit6f94a562a5b889245a18db93b134aaaa62e5b651 (patch)
tree31b7f597697b236a1a05da0030cc17bc4dbce084 /generic/tclPathObj.c
parent582550ff6d9cb4106e887545d6fa3805303de2c1 (diff)
downloadtcl-6f94a562a5b889245a18db93b134aaaa62e5b651.zip
tcl-6f94a562a5b889245a18db93b134aaaa62e5b651.tar.gz
tcl-6f94a562a5b889245a18db93b134aaaa62e5b651.tar.bz2
another stab at fixing 1379287
Diffstat (limited to 'generic/tclPathObj.c')
-rw-r--r--generic/tclPathObj.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c
index be530f5..a40d448 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.51 2006/03/03 20:10:09 dgp Exp $
+ * RCS: @(#) $Id: tclPathObj.c,v 1.52 2006/03/04 02:33:36 dgp Exp $
*/
#include "tclInt.h"
@@ -158,13 +158,14 @@ TclFSNormalizeAbsolutePath(
* of normalization. */
{
ClientData clientData = NULL;
- CONST char *dirSep, *oldDirSep;
+ CONST char *dirSep, *oldDirSep, *pathString;
int first = 1; /* Set to zero once we've passed the first
* directory separator - we can't use '..' to
* remove the volume in a path. */
- int rootOffset;
+ int rootOffset = -1;
+ int unc = 0;
Tcl_Obj *retVal = NULL;
- oldDirSep = dirSep = TclGetString(pathPtr);
+ pathString = dirSep = TclGetString(pathPtr);
if (tclPlatform == TCL_PLATFORM_WINDOWS) {
if (dirSep[0] != 0 && dirSep[1] == ':' &&
@@ -177,6 +178,7 @@ TclFSNormalizeAbsolutePath(
* since the first two segments are actually inseparable.
*/
+ unc = 1;
dirSep += 2;
dirSep += FindSplitPos(dirSep, '/');
if (*dirSep != 0) {
@@ -192,13 +194,18 @@ TclFSNormalizeAbsolutePath(
* since we will have to expand the link to be able to back up one level.
*/
- rootOffset = dirSep - oldDirSep;
while (*dirSep != 0) {
+ if ((rootOffset == -1) && IsSeparatorOrNull(dirSep[0])) {
+ rootOffset = dirSep - pathString;
+ }
oldDirSep = dirSep;
if (!first) {
dirSep++;
}
dirSep += FindSplitPos(dirSep, '/');
+ if (rootOffset == -1) {
+ rootOffset = dirSep - pathString;
+ }
if (dirSep[0] == 0 || dirSep[1] == 0) {
if (retVal != NULL) {
Tcl_AppendToObj(retVal, oldDirSep, dirSep - oldDirSep);
@@ -319,7 +326,7 @@ TclFSNormalizeAbsolutePath(
}
if (curLen == 0) {
/* Attempt to .. beyond root becomes root: "/" */
- if (dirSep[3] != 0) {
+ if ((dirSep[3] != 0) || unc) {
Tcl_SetObjLength(retVal, rootOffset);
} else {
Tcl_SetObjLength(retVal, rootOffset+1);