Tcl Source Code

Artifact [68eaa7cdb4]
Login

Artifact 68eaa7cdb4a4092d0b44339bdb6ea44a8ed44f52:

Attachment "1379287-amend.patch" to ticket [1379287fff] added by dgp 2006-03-04 03:10:11.
Index: generic/tclPathObj.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclPathObj.c,v
retrieving revision 1.50
diff -u -r1.50 tclPathObj.c
--- generic/tclPathObj.c	3 Mar 2006 04:32:11 -0000	1.50
+++ generic/tclPathObj.c	3 Mar 2006 19:52:45 -0000
@@ -162,8 +162,9 @@
     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;
     Tcl_Obj *retVal = NULL;
-    dirSep = TclGetString(pathPtr);
+    oldDirSep = dirSep = TclGetString(pathPtr);
 
     if (tclPlatform == TCL_PLATFORM_WINDOWS) {
 	if (dirSep[0] != 0 && dirSep[1] == ':' &&
@@ -191,6 +192,7 @@
      * since we will have to expand the link to be able to back up one level.
      */
 
+    rootOffset = dirSep - oldDirSep;
     while (*dirSep != 0) {
 	oldDirSep = dirSep;
 	if (!first) {
@@ -318,9 +320,9 @@
 		    if (curLen == 0) {
 			/* Attempt to .. beyond root becomes root: "/" */
 			if (dirSep[3] != 0) {
-			    Tcl_SetObjLength(retVal, 0);
+			    Tcl_SetObjLength(retVal, rootOffset);
 			} else {
-			    Tcl_SetObjLength(retVal, 1);
+			    Tcl_SetObjLength(retVal, rootOffset+1);
 			}
 		    }
 		}