Ticket UUID: | 943995 | |||
Title: | glob inconsistency with VFS | |||
Type: | Bug | Version: | obsolete: 8.4.9 | |
Submitter: | dgp | Created on: | 2004-04-28 20:50:38 | |
Subsystem: | 37. File System | Assigned To: | dgp | |
Priority: | 7 High | Severity: | ||
Status: | Closed | Last Modified: | 2006-05-28 09:21:07 | |
Resolution: | Fixed | Closed By: | sf-robot | |
Closed on: | 2006-05-28 02:21:07 | |||
Description: |
Using a package that provides a virtual filesystem: % file volumes trofs:// / % file isdirectory trofs://1/modules 1 % glob -directory trofs://1/modules * trofs://1/modules/base64-2.3.tm trofs://1/modules/cmdline-1.2.2.tm trofs://1/modules/msgcat-1.4.1.tm trofs://1/modules/struct-2.0.tm trofs://1/modules/http-2.4.4.tm trofs://1/modules/log-1.1.tm trofs://1/modules/htmlparse-1.0.tm trofs://1/modules/textutil-0.6.tm % glob trofs://1/modules/* no files matched glob pattern "trofs://1/modules/*" Something amiss in [glob] ? | |||
User Comments: |
sf-robot added on 2006-05-28 09:21:06:
Logged In: YES user_id=1312539 This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker). dgp added on 2006-05-14 06:21:51: Logged In: YES user_id=80530 committed for 8.4.14 please test dgp added on 2006-05-12 04:06:27: File Added - 177634: 943995.patch dgp added on 2006-05-12 04:06:26: Logged In: YES user_id=80530 Here's a patch against Tcl 8.4.13 that needs testing on Windows before acceptance. dgp added on 2006-05-12 03:05:55: Logged In: YES user_id=80530 Aha! Looking this over again, and the problem I have with 8.4.* is in TclDoGlob(). That routine is designed to be recursive, and passes two arguments, headPtr and tail down the recursive stack, each time holding a different partition of the pathname pattern we're globbing for. The problem is that as the stack of calls shifts more of the path from tail to head, it tries to do some normalization along the way. Turning //// runs into / and that sort of thing. Trouble with that is, when we have a virtual filesystem system in place, normalization isn't something you can do reliably as a local operations, it requires cooperation of all the Tcl_Filesystem drivers to be sure that the changes don't move a path out of one Tcl_Filesystem and into another one. In the reported example, the pattern trofs://1/modules/* gets transformed to trofs:/1/modules/* and this takes it out of the trofs filesystem and into the native filesystem, where the glob comes up empty. The fix is to revise TclDoGlob so that as it shifts things from tail to head, the only revisions it can make are those dictated by the special chars of glob patterns. Working on that patch now. dgp added on 2006-03-10 12:22:23: Logged In: YES user_id=80530 sure would like this to be backported for 8.4.13. I'll at least take a look. vincentdarley added on 2004-12-17 01:38:10: Logged In: YES user_id=32170 The problem is that the 8.5 and 8.4 codebases have diverged sufficiently that each requires its own fix. Unfortunately my time precludes doing both at the moment if that is complicated. I try to do both if the fix is similar, but sometimes it isn't. There are now a number of filesystem fixes in 8.5 which are not in 8.4, and probably never will be, unless someone decides simply to replace 8.4's filesystem with 8.5's. dgp added on 2004-12-16 05:27:57: Logged In: YES user_id=80530 Ack! This fix never made it back into 8.4 ?! vincentdarley added on 2004-05-07 20:09:15: Logged In: YES user_id=32170 Fixed in cvs head. dgp added on 2004-05-07 05:39:57: Logged In: YES user_id=80530 Yes, that appears to correct the problem, thanks. vincentdarley added on 2004-05-07 02:18:06: File Added - 86315: vfsGlobVol.patch vincentdarley added on 2004-05-07 02:18:05: Logged In: YES user_id=32170 Attached a patch to fix this bug. Please test. (It includes new tests in Tcl test suite, but I obviously can't test your 'trofs'). vincentdarley added on 2004-04-30 19:18:31: Logged In: YES user_id=32170 That doesn't help. Here are some new tests for fileSystem.test (one passes, two fail), which illustrate the problem. test filesystem-7.3.1 {glob in simplefs} \ {testsimplefilesystem} { set dir [pwd] cd [tcltest::temporaryDirectory] file mkdir simpledir close [open [file join simpledir simplefile] w] testsimplefilesystem 1 set res [glob -nocomplain simplefs:/simpledir/*] eval lappend res [glob -nocomplain simplefs:/simpledir] testsimplefilesystem 0 file delete -force simpledir cd $dir set res } {simplefs:/simpledir/simplefile simplefs:/simpledir} test filesystem-7.3.2 {glob in simplefs} \ {testsimplefilesystem} { set dir [pwd] cd [tcltest::temporaryDirectory] file mkdir simpledir close [open [file join simpledir simplefile] w] testsimplefilesystem 1 set res [glob -nocomplain simplefs:/s*] testsimplefilesystem 0 file delete -force simpledir cd $dir if {[llength $res] > 0} { set res "ok" } else { set res "no files found with 'glob -nocomplain simplefs:/s*'" } } {ok} test filesystem-7.3.3 {glob in simplefs} \ {testsimplefilesystem} { set dir [pwd] cd [tcltest::temporaryDirectory] file mkdir simpledir close [open [file join simpledir simplefile] w] testsimplefilesystem 1 set res [glob -nocomplain simplefs:/*] testsimplefilesystem 0 file delete -force simpledir cd $dir if {[llength $res] > 0} { set res "ok" } else { set res "no files found with 'glob -nocomplain simplefs:/s*'" } } {ok} I'll be unable to look at this further for the next week, at least. vincentdarley added on 2004-04-30 05:13:03: Logged In: YES user_id=32170 I'm not sure that'll help. I think the code I pointed to needs to be fixed to ensure the volume name is shifted from the pattern to the path, since otherwise I think the code (DoGlob) that is called will do the wrong thing. dgp added on 2004-04-30 02:22:03: Logged In: YES user_id=80530 Ah. Does that mean if I choose a volume prefix that doesn't include // I can avoid the problem? vincentdarley added on 2004-04-30 01:59:51: Logged In: YES user_id=32170 Looks like a bug in glob, indeed. Most likely following this comment in tclFileName.c: /* * Handling empty path prefixes with glob patterns like 'C:' or * 'c:////////' is a pain on Windows if we leave it too late, since * these aren't really patterns at all! We therefore check the head * of the pattern now for such cases, if we don't have an unquoted * prefix yet. * * Similarly on Unix with '/' at the head of the pattern -- it * just indicates the root volume, so we treat it as such. */ Probably the code after that should check whether the pattern's head matches any of 'file volumes'? |