diff options
author | vincentdarley <vincentdarley@noemail.net> | 2004-12-02 18:49:20 (GMT) |
---|---|---|
committer | vincentdarley <vincentdarley@noemail.net> | 2004-12-02 18:49:20 (GMT) |
commit | 1b5147047c042aabe13f89b00336603838c76fcb (patch) | |
tree | 81352b7f5a8f339ceca27e7930069261d4b1712e /generic/tclPathObj.c | |
parent | bf3ff0b63fb651f2fda532a5c13f950128f3dd9d (diff) | |
download | tcl-1b5147047c042aabe13f89b00336603838c76fcb.zip tcl-1b5147047c042aabe13f89b00336603838c76fcb.tar.gz tcl-1b5147047c042aabe13f89b00336603838c76fcb.tar.bz2 |
filesystem, glob, tilde fix
FossilOrigin-Name: 979efdf14b1361a85ac842dbedad560da402b270
Diffstat (limited to 'generic/tclPathObj.c')
-rw-r--r-- | generic/tclPathObj.c | 18 |
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)); |