Tcl Source Code

Artifact [07acea043b]
Login

Artifact 07acea043b4a2779cf53f96a206310c8b7fdc7f0:

Attachment "tcl-file-normalize+dirname+tail-patch-20020618" to ticket [566669ffff] added by taguchiv6 2002-06-18 14:41:22.
diff -u unix/tclUnixFCmd.c~ unix/tclUnixFCmd.c
--- unix/tclUnixFCmd.c~	Tue Jun 11 02:41:52 2002
+++ unix/tclUnixFCmd.c	Tue Jun 18 15:54:21 2002
@@ -1697,6 +1697,10 @@
 	}
 	currentPathEndPosition++;
     }
+
+    if (nextCheckpoint == 0) {
+        nextCheckpoint = pathLen;
+    }
     /* 
      * We should really now convert this to a canonical path.  We do
      * that with 'realpath' if we have it available.  Otherwise we could
diff -u generic/tclFileName.c~ generic/tclFileName.c
--- generic/tclFileName.c~	Wed Jun  5 20:59:33 2002
+++ generic/tclFileName.c	Tue Jun 18 15:32:45 2002
@@ -2601,6 +2601,16 @@
     int splitElements;
     Tcl_Obj *splitPtr;
     Tcl_Obj *splitResultPtr = NULL;
+    CONST char *path;
+ 
+    /*
+     * if env(HOME) == "~", then file dirname "~" must return "~".
+     */
+    if ((strcmp((path = Tcl_GetString(pathPtr)), "~") == 0) && 
+	(strcmp((getenv("HOME")), "~") == 0)) {
+      Tcl_IncrRefCount(pathPtr);
+      return pathPtr;
+    }
 
     /* 
      * The behaviour we want here is slightly different to
diff -u generic/tclCmdAH.c.orig generic/tclCmdAH.c
--- generic/tclCmdAH.c.orig	Tue Jun 18 16:05:24 2002
+++ generic/tclCmdAH.c	Tue Jun 18 16:18:46 2002
@@ -1216,10 +1216,21 @@
     	case FILE_TAIL: {
 	    int splitElements;
 	    Tcl_Obj *splitPtr;
+	    CONST char *path = Tcl_GetString(objv[2]);
 
 	    if (objc != 3) {
 		goto only3Args;
 	    }
+
+	    /*
+             * if env(HOME) == "~" then "file tail ~" must return nil string.
+             */
+	    if ((strcmp(path, "~") == 0) && (strcmp(getenv("HOME"), "~") == 0)) {
+	      Tcl_Obj *tail = NULL;
+	      Tcl_SetObjResult(interp, tail);
+	      return TCL_OK;
+	    }
+	      
 	    /* 
 	     * The behaviour we want here is slightly different to
 	     * the standard Tcl_FSSplitPath in the handling of home
@@ -1228,7 +1239,7 @@
 	     * had just a single component.
 	     */	    
 	    splitPtr = Tcl_FSSplitPath(objv[2], &splitElements);
-	    if ((splitElements == 1) && (Tcl_GetString(objv[2])[0] == '~')) {
+	    if ((splitElements == 1) && (path[0] == '~')) {
 		Tcl_DecrRefCount(splitPtr);
 		splitPtr = Tcl_FSGetNormalizedPath(interp, objv[2]);
 		if (splitPtr == NULL) {