diff options
author | dgp <dgp@users.sourceforge.net> | 2009-08-20 22:09:45 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2009-08-20 22:09:45 (GMT) |
commit | e645a06ed98f083f07698164c56a986e56094fb3 (patch) | |
tree | e29d2a2494a182f9ee84af7b8ea69e05ada9161d /generic/tclFileName.c | |
parent | 98d5d18c168e0eb4ac463f011898476550f81592 (diff) | |
download | tcl-e645a06ed98f083f07698164c56a986e56094fb3.zip tcl-e645a06ed98f083f07698164c56a986e56094fb3.tar.gz tcl-e645a06ed98f083f07698164c56a986e56094fb3.tar.bz2 |
* generic/tclFileName.c: Correct result from [glob */test] when *
matches something like ~foo. [Bug 2837800]
Diffstat (limited to 'generic/tclFileName.c')
-rw-r--r-- | generic/tclFileName.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/generic/tclFileName.c b/generic/tclFileName.c index c621aff..ad71008 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.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: tclFileName.c,v 1.96 2009/01/22 06:42:33 nijtmans Exp $ + * RCS: @(#) $Id: tclFileName.c,v 1.97 2009/08/20 22:09:45 dgp Exp $ */ #include "tclInt.h" @@ -2361,14 +2361,42 @@ DoGlob( pattern, &dirOnly); *p = save; if (result == TCL_OK) { - int subdirc, i; + int subdirc, i, repair = -1; Tcl_Obj **subdirv; result = Tcl_ListObjGetElements(interp, subdirsPtr, &subdirc, &subdirv); for (i=0; result==TCL_OK && i<subdirc; i++) { + Tcl_Obj *copy = NULL; + + if (Tcl_GetString(subdirv[i])[0] == '~') { + Tcl_ListObjLength(NULL, matchesObj, &repair); + copy = subdirv[i]; + subdirv[i] = Tcl_NewStringObj("./", 2); + Tcl_AppendObjToObj(subdirv[i], copy); + Tcl_IncrRefCount(subdirv[i]); + } result = DoGlob(interp, matchesObj, separators, subdirv[i], 1, p+1, types); + if (copy) { + int end; + + Tcl_DecrRefCount(subdirv[i]); + subdirv[i] = copy; + Tcl_ListObjLength(NULL, matchesObj, &end); + while (repair < end) { + const char *bytes; + int numBytes; + Tcl_Obj *fixme, *newObj; + Tcl_ListObjIndex(NULL, matchesObj, repair, &fixme); + bytes = Tcl_GetStringFromObj(fixme, &numBytes); + newObj = Tcl_NewStringObj(bytes+2, numBytes-2); + Tcl_ListObjReplace(NULL, matchesObj, repair, 1, + 1, &newObj); + repair++; + } + repair = -1; + } } } TclDecrRefCount(subdirsPtr); |