Skip to content
Tcl Source Code View Ticket
Login

View Ticket

[glob -path /priv *] doesn't find /private

Closed / Fixed910525ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 23 years ago
Descriptionplain2004-03-05 15:38:24
This is observed with Tcl8.4.4 under Mac OSX 10.2.3:

The statement [glob -path /priv *] fails to find the
directory /private.  Instead an error is raised:
"no files matched glob pattern "*"".
vincentdarleyplain2004-03-06 02:07:47
Logged In: YES 
user_id=32170

I notice that this also fails on Windows:

% glob -path C:/Win *
no files matched glob pattern "*"

It seems like the handling of 'toplevel' paths is buggy...

Thanks for the report.
vincentdarleyplain2004-03-08 01:52:37
Logged In: YES 
user_id=32170

Please test this patch:

diff -u -r1.47 tclFileName.c
--- tclFileName.c       5 Feb 2004 20:25:32 -0000       1.47
+++ tclFileName.c       7 Mar 2004 18:42:44 -0000
@@ -1745,6 +1745,13 @@
                /* Have to split off the end */
                Tcl_DStringAppend(&pref, last,
first+pathlength-last);
                pathOrDir = Tcl_NewStringObj(first,
last-first-1);
+               /*
+                * We must ensure there's at least one path
separator
+                * in the prefix, even if it's just "/" or
"C:/".
+                */
+               if (strpbrk(Tcl_GetString(pathOrDir), "\\/")
== NULL) {
+                   Tcl_AppendToObj(pathOrDir, last-1, 1);
+               }
            }
            /* Need to quote 'prefix' */
            Tcl_DStringInit(&prefix);

Should work on Windows and Unix, I think (but only tested on
the former).
vincentdarley Closed ticket [910525ffff]. [History diff]2004-03-09 20:07:29
vincentdarleyplain2004-03-09 20:07:30
Logged In: YES 
user_id=32170

Fixed in cvs HEAD and 8.4 branch (so will be in 8.4.7 if
there is ever such a release).
Log in (anonymous is fine) to add a comment.