diff options
author | dgp <dgp@noemail.net> | 2009-08-17 20:00:01 (GMT) |
---|---|---|
committer | dgp <dgp@noemail.net> | 2009-08-17 20:00:01 (GMT) |
commit | 777fabb0d7576c50002ae8236dbc324c3b7e6e91 (patch) | |
tree | 75a9f10c8e04da4ef8236a9a4d2f81bfbbd5bca7 /generic/tclFileName.c | |
parent | 82a7b7a4a40bc922f6bb2b806672f0bfb6450943 (diff) | |
download | tcl-777fabb0d7576c50002ae8236dbc324c3b7e6e91.zip tcl-777fabb0d7576c50002ae8236dbc324c3b7e6e91.tar.gz tcl-777fabb0d7576c50002ae8236dbc324c3b7e6e91.tar.bz2 |
* generic/tclFileName.c: Correct result from [glob */test] when *
* tests/fileName.test: matches something like ~foo. [Bug 2837800]
FossilOrigin-Name: 5433dba4a65943dd96b3a6585baa6bbb753a772c
Diffstat (limited to 'generic/tclFileName.c')
-rw-r--r-- | generic/tclFileName.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/generic/tclFileName.c b/generic/tclFileName.c index c14893f..7d63018 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.40.2.17 2008/12/03 06:36:05 dgp Exp $ + * RCS: @(#) $Id: tclFileName.c,v 1.40.2.18 2009/08/17 20:00:01 dgp Exp $ */ #include "tclInt.h" @@ -2560,15 +2560,21 @@ TclDoGlob(interp, separators, headPtr, tail, types) head, tail, &dirOnly); *p = save; if (ret == TCL_OK) { - int resLength; + int resLength, repair = -1; ret = Tcl_ListObjLength(interp, resultPtr, &resLength); if (ret == TCL_OK) { int i; for (i =0; i< resLength; i++) { Tcl_Obj *elt; Tcl_DString ds; - Tcl_ListObjIndex(interp, resultPtr, i, &elt); + Tcl_ListObjIndex(NULL, resultPtr, i, &elt); Tcl_DStringInit(&ds); + if (Tcl_GetString(elt)[0] == '~') { + Tcl_Obj *paths = Tcl_GetObjResult(interp); + + Tcl_ListObjLength(NULL, paths, &repair); + Tcl_DStringAppend(&ds, "./", 2); + } Tcl_DStringAppend(&ds, Tcl_GetString(elt), -1); if(tclPlatform == TCL_PLATFORM_MAC) { Tcl_DStringAppend(&ds, ":",1); @@ -2580,6 +2586,24 @@ TclDoGlob(interp, separators, headPtr, tail, types) if (ret != TCL_OK) { break; } + if (repair >= 0) { + Tcl_Obj *paths = Tcl_GetObjResult(interp); + int end; + + Tcl_ListObjLength(NULL, paths, &end); + while (repair < end) { + const char *bytes; + int numBytes; + Tcl_Obj *fixme, *newObj; + Tcl_ListObjIndex(NULL, paths, repair, &fixme); + bytes = Tcl_GetStringFromObj(fixme, &numBytes); + newObj = Tcl_NewStringObj(bytes+2, numBytes-2); + Tcl_ListObjReplace(NULL, paths, repair, 1, + 1, &newObj); + repair++; + } + repair = -1; + } } } } |