summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2004-12-02 18:49:21 (GMT)
committervincentdarley <vincentdarley>2004-12-02 18:49:21 (GMT)
commite05bd52770456e6db2d99f2112bb78fae3619235 (patch)
tree81352b7f5a8f339ceca27e7930069261d4b1712e /generic
parentdaaaa7768cb634eed14f66460b8fdf6d85d719c1 (diff)
downloadtcl-e05bd52770456e6db2d99f2112bb78fae3619235.zip
tcl-e05bd52770456e6db2d99f2112bb78fae3619235.tar.gz
tcl-e05bd52770456e6db2d99f2112bb78fae3619235.tar.bz2
filesystem, glob, tilde fix
Diffstat (limited to 'generic')
-rw-r--r--generic/tclPathObj.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c
index 2ed8eed..54116a9 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.38 2004/11/22 12:53:06 vincentdarley Exp $
+ * RCS: @(#) $Id: tclPathObj.c,v 1.39 2004/12/02 18:49:21 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -1232,6 +1232,12 @@ TclNewFSPathObj(Tcl_Obj *dirPtr, CONST char *addStrRep, int len)
* inside the directory. Returns a Tcl_Obj representing filename
* of the path relative to the directory.
*
+ * In the case where the resulting path would start with a '~', we
+ * take special care to return an ordinary string. This means to
+ * use that path (and not have it interpreted as a user name),
+ * one must prepend './'. This may seem strange, but that is how
+ * 'glob' is currently defined.
+ *
* Results:
* NULL on error, otherwise a valid object, typically with
* refCount of zero, which it is assumed the caller will
@@ -1273,6 +1279,16 @@ TclFSMakePathRelative(interp, pathPtr, cwdPtr)
}
TclFreeIntRep(pathPtr);
}
+ /* Now pathPtr is a string object */
+
+ if (Tcl_GetString(pathPtr)[0] == '~') {
+ /*
+ * If the first character of the path is a tilde,
+ * we must just return the path as is, to agree
+ * with the defined behaviour of 'glob'.
+ */
+ return pathPtr;
+ }
fsPathPtr = (FsPath*)ckalloc((unsigned)sizeof(FsPath));