Unexpected [glob] result, when types list is empty
Closed / Fixed1750300fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 18 years ago
Descriptionplain2007-07-09 11:25:38
Hi *,
consider the following examples:
* there is a plain file TAGS in the current directory:
% glob -- TAGS tags Tags
TAGS
% glob -types {} -- TAGS tags Tags
TAGS tags Tags
* there is _no_ file "urgent" in the current directory:
% glob -types {} -- U*
no files matched glob pattern "*U*"
% glob -types {} -- URGENT Urgent
URGENT Urgent
Seems an empty types list together with queries without patterns just returns the queries...
% set tcl_patchLevel
8.4.14
Operating systems: Linux, AIX, HP-UX and Solaris
kind regards
-- Matthias Kraft
matzekplain2007-07-09 18:33:41
Logged In: YES user_id=330806 Originator: YES the second example: the query was *U* of cause. Got one line too less with CnP and then typed the missing line :-/ ... kind regards -- Matthias Kraft
dkf Ticket [1750300fff]: 1 change
[History diff]2007-07-24 01:06:43
georgepsplain2007-12-15 04:54:53
Logged In: YES
user_id=585068
Originator: NO
Cool bug:
% cd /
% glob -types {} -- TMP tmp
TMP tmp
% file exists TMP
0
% glob -- TMP tmp
tmp
Here's a patch that fixes it:
Index: tclFileName.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclFileName.c,v
retrieving revision 1.86
diff -u -r1.86 tclFileName.c
--- tclFileName.c 13 Dec 2007 15:23:17 -0000 1.86
+++ tclFileName.c 14 Dec 2007 21:46:51 -0000
@@ -1412,6 +1412,11 @@
*/
Tcl_ListObjLength(interp, typePtr, &length);
+
+ if (length <= 0) {
+ goto skipTypes;
+ }
+
globTypes = (Tcl_GlobTypeData*)
TclStackAlloc(interp,sizeof(Tcl_GlobTypeData));
globTypes->type = 0;
@@ -1529,6 +1534,7 @@
}
}
+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
matzekplain2008-07-01 23:00:42
Logged In: YES user_id=330806 Originator: YES This one still persists in 8.5.3 ... Maybe someone could fix it one way or another. Thanks -- Matthias Kraft
dgpplain2008-08-14 01:15:21
Logged In: YES user_id=80530 Originator: NO fix committed to all active branches.
dasplain2008-08-14 06:57:52
Logged In: YES
user_id=90580
Originator: NO
the tests added for this bug depend on the filesystem being case sensitive, which is not the case everywhere, e.g. not with HFS+ on Mac OS X, it does not seem necessary to test for the fix in this way
==== fileName-20.1 Bug 1750300 FAILED
==== Contents of test case:
llength [glob -nocomplain -directory $d -- TAGS tags Tags]
---- Result was:
3
---- Result should have been (exact matching):
1
==== fileName-20.1 FAILED
==== fileName-20.2 Bug 1750300 FAILED
==== Contents of test case:
llength [glob -nocomplain -directory $d -types {} -- TAGS tags Tags]
---- Result was:
3
---- Result should have been (exact matching):
1
==== fileName-20.2 FAILED
dgpplain2008-08-14 11:10:12
Logged In: YES user_id=80530 Originator: NO You're right; I simply copied the test cases out of the bug report being too lazy to invent my own. I'll get these tests fixed tomorrow.
dgpplain2008-08-14 20:10:40
Logged In: YES user_id=80530 Originator: NO more portable tests committed.
Log in (anonymous is fine) to add a comment.