From fce0abd807701f8f0b1cbc8f820d3254efdd7f32 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 13 Aug 2008 18:14:43 +0000 Subject: * generic/tclFileName.c: Fix for errors handling -types {} * tests/fileName.test: option to [glob]. [Bug 1750300] Thanks to Matthias Kraft and George Peter Staplin. --- ChangeLog | 6 ++++++ generic/tclFileName.c | 6 +++++- tests/fileName.test | 39 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6db6c9b..4afbdb0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-08-13 Don Porter + + * 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-12 Jeff Hobbs * generic/tclOOInfo.c (InfoObjectDefnCmd, InfoObjectMixinsCmd): diff --git a/generic/tclFileName.c b/generic/tclFileName.c index ce2ee53..999a685 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.89 2008/07/21 21:25:21 nijtmans Exp $ + * RCS: @(#) $Id: tclFileName.c,v 1.90 2008/08/13 18:14:44 dgp Exp $ */ #include "tclInt.h" @@ -1412,6 +1412,9 @@ Tcl_GlobObjCmd( */ Tcl_ListObjLength(interp, typePtr, &length); + if (length <= 0) { + goto skipTypes; + } globTypes = (Tcl_GlobTypeData *) TclStackAlloc(interp, sizeof(Tcl_GlobTypeData)); globTypes->type = 0; @@ -1529,6 +1532,7 @@ Tcl_GlobObjCmd( } } + skipTypes: /* * Now we perform the actual glob below. This may involve joining together * the pattern arguments, dealing with particular file types etc. We use a diff --git a/tests/fileName.test b/tests/fileName.test index 27cb661..f0788f4 100644 --- a/tests/fileName.test +++ b/tests/fileName.test @@ -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: fileName.test,v 1.54 2008/07/21 21:25:22 nijtmans Exp $ +# RCS: @(#) $Id: fileName.test,v 1.55 2008/08/13 18:14:44 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -1455,6 +1455,43 @@ test fileName-19.1 {ensure that [Bug 1325099] stays fixed} { list [file exists ~//.nonexistant_file] [file exists ~///.nonexistant_file] } {0 0} +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] -- cgit v0.12