summaryrefslogtreecommitdiffstats
path: root/generic/tclFileName.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2009-08-17 20:00:01 (GMT)
committerdgp <dgp@users.sourceforge.net>2009-08-17 20:00:01 (GMT)
commit5692abb8cd8eb0556295d7e65e607f57ed918e97 (patch)
tree75a9f10c8e04da4ef8236a9a4d2f81bfbbd5bca7 /generic/tclFileName.c
parentc78ca1c741ddf3ca2eef6b19088a52961f830eb4 (diff)
downloadtcl-5692abb8cd8eb0556295d7e65e607f57ed918e97.zip
tcl-5692abb8cd8eb0556295d7e65e607f57ed918e97.tar.gz
tcl-5692abb8cd8eb0556295d7e65e607f57ed918e97.tar.bz2
* generic/tclFileName.c: Correct result from [glob */test] when *
* tests/fileName.test: matches something like ~foo. [Bug 2837800]
Diffstat (limited to 'generic/tclFileName.c')
-rw-r--r--generic/tclFileName.c30
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;
+ }
}
}
}