Tcl Source Code

Artifact [86e6e65848]
Login

Artifact 86e6e65848b749d8ad6f477196e5e0f5708c57c3:

Attachment "1999716.patch" to ticket [1999176fff] added by dgp 2008-06-25 03:00:00.
Index: generic/tclPathObj.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclPathObj.c,v
retrieving revision 1.69
diff -u -r1.69 tclPathObj.c
--- generic/tclPathObj.c	23 Jun 2008 15:34:15 -0000	1.69
+++ generic/tclPathObj.c	24 Jun 2008 19:27:53 -0000
@@ -1768,6 +1768,16 @@
 
 	if (pathType == TCL_PATH_RELATIVE) {
 	    Tcl_Obj *origDir = fsPathPtr->cwdPtr;
+
+	    /*
+	     * NOTE: here we are (dangerously?) assuming that origDir points
+	     * to a Tcl_Obj with Tcl_ObjType == &tclFsPathType .  The
+	     *     pathType = Tcl_FSGetPathType(fsPathPtr->cwdPtr);
+	     * above that set the pathType value should have established
+	     * that, but it's far less clear on what basis we know there's
+	     * been no shimmering since then.
+	     */
+
 	    FsPath *origDirFsPathPtr = PATHOBJ(origDir);
 
 	    fsPathPtr->cwdPtr = origDirFsPathPtr->cwdPtr;
@@ -1881,7 +1891,20 @@
 	 * might loop back through here.
 	 */
 
-	if (path[0] != '\0') {
+	if (path[0] == '\0') {
+	    /*
+	     * Special handling for the empty string value.  This one is
+	     * very weird with [file normalize {}] => {}.  (The reasoning
+	     * supporting this is unknown to DGP, but he fears changing it.)
+	     * Attempt here to keep the expectations of other parts of
+	     * Tcl_Filesystem code about state of the FsPath fields satisfied.
+	     *
+	     * In particular, capture the cwd value and save so it can be
+	     * stored in the cwdPtr field below.
+	     */
+	    useThisCwd = Tcl_FSGetCwd(interp);
+
+	} else {
 	    /*
 	     * We don't ask for the type of 'pathPtr' here, because that is
 	     * not correct for our purposes when we have a path like '~'. Tcl