Skip to content
Tcl Source Code History Of Ticket 219233ffffffffff
Login

History Of Ticket 219233ffffffffff

Artifacts Associated With Ticket 219233ffffffffff

  1. Ticket change [ab4f2a0c49] (rid 101083) by nobody on 2000-10-26 05:03:56:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 4438 Bug
      Version: 8.3
      SubmitDate: '2000-03-21'
      LastModified: '2000-04-03'
      Severity: MED
      Status: Assigned
      Submitter: techsupp
      ChangedBy: hobbs
      OS: Windows 95
      OSVersion: OSR2
      FixedDate: '2000-10-25'
      ClosedDate: '2000-10-25'
      
      
      Name:
      Keith Lea
      
      ReproducibleScript:
      % string match {[a-z0-9_/-]} \\
      1
      % string match {[a-z0-9_/]} \\
      0
      
      
      
      It's accidently interp'ing the "/-]" as "/-]]", taking last
      ] as ] endrange and ] endblock. 
      -- 04/03/2000 hobbs
      This needs to be fixed in Tcl_String(Case)Match in tclUtil.c,
      but wait until 8.4 just in case someone was counting on the
      previous perverse behavior. 
      -- 04/03/2000 hobbs
      
    4. foundin initialized to: "obsolete: 8.3"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "81. Bundled Packages"
    10. title initialized to:
      string match doesn't work as documented when - is the last c
      
    11. type initialized to: "Bug"
  2. Ticket change [a12dfca596] (rid 109674) by dkf on 2000-11-24 18:35:30:

    1. icomment:
      Hmm.  The problem seems to be that the first pattern is actually malformed by the rules of [string match], but there is no way to indicate this.  I suppose the correct way of dealing with this is to decide that we were not really matching a range after all, but that's not very good at all.  Either that, or we state that a malformed pattern matches nothing at all.
      
      Hmm.  On successful matching of a range, should we really back up a character at the unexpected end of string , or should we fail at that point?
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  3. Ticket change [4b48081319] (rid 126676) by dkf on 2000-11-24 20:18:50:

    1. icomment:
      Improved detection of bug:
        % sstring match \[a-] ]
        1
        % string match \[a-]x ]x
        0
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. priority changed to: "6"
    5. username: "dkf"
  4. Ticket change [58b17dd6ea] (rid 117844) by dkf on 2001-02-07 23:02:37:

    1. subsystem changed to: "18. Commands M-Z"
  5. Ticket change [5377bc8f83] (rid 93763) by dkf on 2001-02-15 23:32:37:

    1. assignee changed to: "dkf"
    2. icomment:
      Apparently, the way [string match] handles syntactically invalid patterns is by failing to match anything at all.  It's not entirely clear to me that this is an optimal strategy...
      
      
    3. login: "dkf"
    4. mimetype: "text/plain"
    5. username: "dkf"
  6. Ticket change [2b71110c1e] (rid 118742) by dkf on 2001-02-23 17:24:41:

    1. icomment:
      See Patch #103932 https://sourceforge.net/patch/?func=detailpatch&patch_id=103932&group_id=10894
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  7. Ticket change [ba04fa04b4] (rid 129244) by dkf on 2001-03-17 03:57:56:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      This behaviour won't be changed before 9.0
      
      Any fixes that *are* done must be applied to code in both tclUtil.c and tclUtf.c
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. priority changed to: "3 Low"
    5. resolution changed to: "Later"
    6. username: "dkf"
  8. Ticket change [cd95aef196] (rid 95917) by lupylucke on 2003-11-23 15:20:03:

    1. icomment:
      Logged In: YES 
      user_id=915599
      
      I encountered a problem with `string match' too. I suppouse
      it is, finally, the same bug: it is possible to match a [ in
      a character set quoting int with \. Thits should work with ]
      too, but it doesn't!
      
      % string match {[\[]} {[}
      1
      % string match {[\]]} {]}
      0
      
      
      
      
    2. login: "lupylucke"
    3. mimetype: "text/plain"
    4. username: "lupylucke"
  9. Ticket change [8855f8c3d8] (rid 131851) by dkf on 2003-11-24 23:17:10:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      Backslashes aren't special inside the square-bracket term,
      so the first match doesn't match what you are expecting and
      the second match isn't looking for what you think it is:
      
      % set str \\
      \
      % string match {[\[]} $str
      1
      % set str {\]}
      \]
      % string match {[\]]} $str
      1
      
      The glob-matching engine used by [string match] isn't very
      smart...  :^(  Consider using regular expressions instead.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  10. Ticket change [09bea83268] (rid 113710) by dkf on 2004-10-04 20:59:13:

    1. title changed to: "string match oddity when - is the last char"
  11. Ticket change [9129f1297b] (rid 120580) by matzek on 2007-06-14 20:56:20:

    1. icomment:
      Logged In: YES 
      user_id=330806
      Originator: NO
      
      Hi!
      
      I add another example to the list:
      
      % string match {*[.-]*} "2.1-Beta"
      0
      % string match {*[-.]*} "2.1-Beta"
      1
      % string match {*[.-]*} "Beta-2.1"
      1
      % string match {*[-.]*} "Beta-2.1"
      1
      
      If this is not going to be fixed soon, I suggest to at least document this behavior. Could be enough to just add the hyphen to the list of characters that need to be escaped...
      
      kind regards
      -- Matthias Kraft
      
      
    2. login: "matzek"
    3. mimetype: "text/plain"
    4. username: "matzek"
  12. Ticket change [ac4fd569d8] (rid 101272) by matzek on 2007-06-14 21:00:55:

    1. icomment:
      Logged In: YES 
      user_id=330806
      Originator: NO
      
      I forgot to mention that the example below is taken from a recent Tcl interpreter (8.4.14)...
      
      
      
    2. login: "matzek"
    3. mimetype: "text/plain"
    4. username: "matzek"
  13. Ticket change [f1b062ad37] (rid 109398) by dkf on 2007-06-14 21:50:12:

    1. icomment:
      Logged In: YES 
      user_id=79902
      Originator: NO
      
      Comments below indicate "wait until 9.0", this being a strategy that was mainly from Jeff.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  14. Ticket change [c455066ad5] (rid 111830) by gneumann on 2010-11-18 16:52:04:

    1. icomment:
      i was hit by apparently the same problem.
      
      % string match {[-.]} -
      1
      % string match {[.-]} -
      0 
      # even worse
      % string match {[.-]} A
      1 
      
      This is certainly unexpected behavior and should be at least documented.
      
      
    2. login: "gneumann"
    3. mimetype: "text/plain"
    4. username: "gneumann"
  15. Ticket change [4ae03ebd5e] (rid 162869) by dgp on 2018-05-07 16:19:56:

    1. closer changed to: "nobody"
    2. comment changed to:
      OriginalBugID: 4438 Bug
      Version: 8.3
      SubmitDate: '2000-03-21'
      LastModified: '2000-04-03'
      Severity: MED
      Status: Assigned
      Submitter: techsupp
      ChangedBy: hobbs
      OS: Windows 95
      OSVersion: OSR2
      FixedDate: '2000-10-25'
      ClosedDate: '2000-10-25'
      
      
      Name:
      Keith Lea
      
      ReproducibleScript:
      % string match {[a-z0-9_/-]} \\
      1
      % string match {[a-z0-9_/]} \\
      0
      
      
      
      It's accidently interp'ing the "/-]" as "/-]]", taking last
      ] as ] endrange and ] endblock. 
      -- 04/03/2000 hobbs
      This needs to be fixed in Tcl_String(Case)Match in tclUtil.c,
      but wait until 8.4 just in case someone was counting on the
      previous perverse behavior. 
      -- 04/03/2000 hobbs
      
    3. icomment:
      
      
      "Wait until 9.0" is no longer a blockage.
      
      This should be fixed at least on the trunk, if not
      on earlier branches too.
      
    4. login: "dgp"
    5. mimetype: "text/plain"
    6. priority changed to: "7 High"
    7. resolution changed to: "Remind"
    8. severity changed to: "Minor"
  16. Ticket change [f0e1b306aa] (rid 162870) by dgp on 2018-05-07 16:21:29:

    1. icomment:
      
      If someone wants to pursue a "refactor first, then fix" strategy,
      I can accept that.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  17. Ticket change [044389336d] (rid 162871) by sebres on 2018-05-07 22:03:22:

    1. icomment:
      If the behavior like below is acceptable for you, I can do a back-porting from my own branches (I assume it's relative easy):
      
        % string match {[.-B} A
        invalid match pattern: brackets [] not balanced
      
      Otherwise, I would like to know how exactly it must be then "fixed" (after the possible refactoring)...
      
      E.g. another variant of the "fix" can be:
      
        % string match {[.-B} A
        0
        % string match {[.-B} \[.-A
        0
        % string match {[.-B} \[.-B
        1
      
      Quasi by unbalanced brackets the pattern {[.-B} will be equivalent to the {\[.-B}
      
      Anyway, current implementation is definitely wrong:
        % string match {[.-B} A
        1
      should result either to an error or to 0.
      
    2. login: "sebres"
    3. mimetype: "text/plain"
  18. Ticket change [3230c841bf] (rid 259304) by serhiy.storchaka on 2026-10-19 17:43:27:

    1. foundin changed to: "8.6.18, 9.0.5, 9.1.0"
    2. icomment:
      Still present in 8.6, 9.0 and 9.1. Proposed fix for 9.1 in branch [/timeline?r=glob-bracket-posix|glob-bracket-posix], on top of [/timeline?r=glob-match-linear|glob-match-linear] (the matcher change for [a4a7f2abd3]): in all four matchers, a <tt>-</tt> right before the closing bracket is a literal, as in POSIX and Python's fnmatch. So <tt><nowiki>{[.-]}</nowiki></tt> matches only "." and "-", and <tt><nowiki>{*[.-]*}</nowiki></tt> matches "2.1-Beta". Test string-11.57; util-5.40, 5.41, 5.43 and 5.44 tested the old behaviour and are changed. Unbalanced brackets (<tt><nowiki>{[.-B}</nowiki></tt>) are not changed.
      
    3. login: "serhiy.storchaka"
    4. mimetype: "text/x-fossil-wiki"
  19. Ticket change [1940dcb665] (rid 259307) by dgp on 2026-10-19 17:56:34:

    1. icomment:
      
      Alert that if this change is accepted it will require bold
      labels of
      
      POTENTIAL INCOMPATIBILITY
      
      in the release notes.
      
      I'm unsettled by changing the functioning of RE processing
      in order to "fix" a "bug", most especially one that has survived
      for 25 years and more.
      
      Would help to have more people examine the impact.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. priority changed to: "9 Immediate"
  20. Ticket change [edd9a13297] (rid 263169) by serhiy.storchaka on 2026-11-26 17:25:43:

    1. icomment:
      Agreed, it is an incompatibility, so it is proposed for 9.1 only. But the current behaviour is hardly useful: <tt><nowiki>{[.-]}</nowiki></tt> is the range "." to "]", which matches "/", digits and upper-case letters, but not "-", and <tt><nowiki>{[]a]}</nowiki></tt> never matches. POSIX, glibc fnmatch, Python fnmatch, bash, dash and SQLite GLOB all treat a "-" before "]" as literal and a "]" first in a set as a member. Should this go through a TIP?
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
  21. Ticket change [887898646d] (rid 263248) by jan.nijtmans on 2026-11-27 10:05:33:

    1. icomment:
      I would be OK putting this in 9.1, with a small 'potential incompatibility' in the release notes. It's too small for a TIP, and - actually - a bugfix
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"