summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclFileName.c6
-rw-r--r--tests/fileName.test42
3 files changed, 51 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 030f11c..9364fb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-08-13 Don Porter <dgp@users.sourceforge.net>
+
+ * generic/tclFileName.c: Fix for errors handling -types {}
+ * tests/fileName.test: option to [glob]. [Bug 1750300]
+ Thanks to Matthias Kraft and George Peter Staplin.
+
2008-08-11 Andreas Kupries <andreask@activestate.com>
* generic/tclProc.c (Tcl_ProcObjCmd): Fixed memory leak triggered
diff --git a/generic/tclFileName.c b/generic/tclFileName.c
index 12a50e5..15c04d8 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.15 2006/10/03 18:20:33 dgp Exp $
+ * RCS: @(#) $Id: tclFileName.c,v 1.40.2.16 2008/08/13 17:59:06 dgp Exp $
*/
#include "tclInt.h"
@@ -1774,6 +1774,9 @@ Tcl_GlobObjCmd(dummy, interp, objc, objv)
* on an incompatible platform.
*/
Tcl_ListObjLength(interp, typePtr, &length);
+ if (length <= 0) {
+ goto skipTypes;
+ }
globTypes = (Tcl_GlobTypeData*) ckalloc(sizeof(Tcl_GlobTypeData));
globTypes->type = 0;
globTypes->perm = 0;
@@ -1879,6 +1882,7 @@ Tcl_GlobObjCmd(dummy, interp, objc, objv)
}
}
+ skipTypes:
/*
* Now we perform the actual glob below. This may involve joining
* together the pattern arguments, dealing with particular file types
diff --git a/tests/fileName.test b/tests/fileName.test
index 7635e2d..4573fbe 100644
--- a/tests/fileName.test
+++ b/tests/fileName.test
@@ -10,10 +10,10 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: fileName.test,v 1.30.2.7 2005/06/21 19:07:58 kennykb Exp $
+# RCS: @(#) $Id: fileName.test,v 1.30.2.8 2008/08/13 17:59:08 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
- package require tcltest
+ package require tcltest 2
namespace import -force ::tcltest::*
}
@@ -2008,6 +2008,44 @@ test fileName-18.1 {windows - split ADS name correctly} {winOnly} {
list $x $y
} {{c:/ ./c:d} c:/c:d}
+test fileName-20.1 {Bug 1750300} -setup {
+ set d [makeDirectory foo]
+ makeFile {} TAGS $d
+} -body {
+ llength [glob -nocomplain -directory $d -- TAGS tags Tags]
+} -cleanup {
+ removeFile TAGS $d
+ removeDirectory foo
+} -result 1
+test fileName-20.2 {Bug 1750300} -setup {
+ set d [makeDirectory foo]
+ makeFile {} TAGS $d
+} -body {
+ llength [glob -nocomplain -directory $d -types {} -- TAGS tags Tags]
+} -cleanup {
+ removeFile TAGS $d
+ removeDirectory foo
+} -result 1
+test fileName-20.3 {Bug 1750300} -setup {
+ set d [makeDirectory foo]
+ makeFile {} TAGS $d
+} -body {
+ llength [glob -nocomplain -directory $d -types {} -- *U*]
+} -cleanup {
+ removeFile TAGS $d
+ removeDirectory foo
+} -result 0
+test fileName-20.4 {Bug 1750300} -setup {
+ set d [makeDirectory foo]
+ makeFile {} TAGS $d
+} -body {
+ llength [glob -nocomplain -directory $d -types {} -- URGENT Urgent]
+} -cleanup {
+ removeFile TAGS $d
+ removeDirectory foo
+} -result 0
+
+
# cleanup
catch {file delete -force C:/globTest}
cd [temporaryDirectory]