Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: a93954d90a7da403584b8beb362cc5bf0acaf6cf273aaac3227ec4438f57938e
Ticket: a382a311e098c19ae3abe371602eb84d7a1e00e6
glob on case insentitive sytems not respecting character class case
User & Date: juliannoble2 on 2026-03-28 04:55:08
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-plain"
  4. comment changed to:
    related but I suspect different to https://core.tcl-lang.org/tcl/tktview/108904173c
    
    An example on windows c:/windows/system32 folder (which is one of the largest default directories on a windows system)
    
      %llength [glob {[a]*}]
      246
      %llength [glob {[A]*}]
      246
      %llength [glob {[aA]*}]
      246
    
    I have an alternative command fglob that I implemented using twapi that can produce correct results.
    
      %llength [fglob {[a]*}]
      118
      %llength [fglob {[A]*}]
      128
      %llength [fglob {[aA]*}]
      246
    
    I expect on a case-insensitve system that characters outside either character classes or braced-alternative globs should be case-insensitive, but character classes such as [a-z] [A-Z] should be respect the case of the file as stored on the system - which is clearly possible to do, and at least in the cases I tested - pretty performantly.
    
    As a side note - my wrapper is using tcl script and twapi but no other c code - and is understandably slower on many simple queries such as *, it can outperform the builtin glob on some of the more complex glob queries.
      
      %time {glob {[a]*}}
      9444 microseconds per iteration
    
      %time {fglob {[aA]*}}
      3164 microseconds per iteration
      %time {fglob {[a]*}}
      1820 microseconds per iteration
    
    This suggests that there may be justification for re-examining the mechanisms being used here - although I don't claim to know all the tradeoffs that could be required to preferably optimise for simple cases.
    
    I would expect my tcl/twapi alternative to be slower in all cases.
    
    The difference is large enough that I don't think it's related to any side issues such as option parsing or checking for vfs etc (which I also do anyway)
    My fglob also handles braced expressions (even nested) and generates fairly complex regexps to post-process the result from necessarily broader queries that the underlying windows system accepts (only * and ? globs).
    
    Whilst I haven't set up tests to verify my fglob supports all possible valid globs (e.g processing escaped glob characters in all levels of nesting) the time difference is still a bit suspicious to me, and the simple cases above should be faster regardless of glob processing which I wouldn't expect to dominate.
    
    My time tests are on a modern fast nvme ssd - so I can't suggest that my glob vs fglob timings above are indicative for spinning rust systems, although testing on a mapped network drive from a share on a remote system the fglob version was still significantly faster than glob for those basic character-class queries.
    
  5. is_private changed to: "0"
  6. login: "juliannoble2"
  7. priority changed to: "5 Medium"
  8. private_contact changed to: "957fdfcd8744611e3fe1f4896c7538b1d9bf47b2"
  9. resolution changed to: "None"
  10. severity changed to: "Important"
  11. status changed to: "Open"
  12. submitter changed to: "juliannoble2"
  13. subsystem changed to: "37. File System"
  14. title changed to:
    glob on case insentitive sytems not respecting character class case
    
  15. type changed to: "Bug"