Skip to content
Tcl Source Code History Of Ticket b73f1296966202b2
Login

History Of Ticket b73f1296966202b2

Artifacts Associated With Ticket b73f1296966202b2

  1. Ticket change [764283071c] (rid 257570) by serhiy.storchaka on 2026-10-11 08:18:34:

    1. cmimetype initialized to: "text/x-fossil-wiki"
    2. comment initialized to:
      <tt>regexp -all</tt> does not try to match at the end of the string, so an RE that can match the empty string there misses its last match. <tt>regsub -all</tt> does try there, so the two disagree:
      <verbatim>
      regexp -all {a*} ab                  ;# 2, but regsub -all {a*} ab <&> gives <a><><> (3 matches)
      regexp -all -inline -indices -line {$} "a\n"   ;# {1 0}, but the empty line at the end also matches: {1 0} {2 1}
      </verbatim>
      PostgreSQL, Python, Perl, Java, Ruby and JavaScript all report the match at the end (3 matches for the first example). Tests regexp-23.5, 23.7 and 23.9, added for [2826551fff], expect it too, but are marked knownBug.
      
      The cause is the end of the <tt>-all</tt> loop in <tt>Tcl_RegexpObjCmd()</tt>: it stops when the next offset reaches the end of the string (<tt>offset >= stringLength</tt>), while <tt>Tcl_RegsubObjCmd()</tt> loops while <tt>offset <= wlen</tt>. Fixing it changes the number of matches that <tt>regexp -all</tt> reports for such REs, and several existing tests (regexp-18.8 to 18.10, 23.2, 23.3, 26.10 to 26.13) that expect the current results.
      
    3. foundin initialized to: "8.6.18, 9.0.5, 9.1.0"
    4. login: "serhiy.storchaka"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. severity initialized to: "Minor"
    8. status initialized to: "Open"
    9. submitter initialized to: "serhiy.storchaka"
    10. subsystem initialized to: "43. Regexp"
    11. title initialized to:
      regexp -all misses an empty match at the end of the string
      
    12. type initialized to: "Bug"
  2. Ticket change [4a617ea2dc] (rid 257575) by serhiy.storchaka on 2026-10-11 08:21:44:

    1. icomment:
      Proposed fix in branch [/timeline?r=regexp-all-end-of-string|regexp-all-end-of-string]: the <tt>-all</tt> loop also tries at the end of the string, as <tt>regsub -all</tt> does. The knownBug marks are removed from regexp-23.5, 23.7 and 23.9, and the tests that expected the old results are updated. Together with the fix for [471101ffff] (branch regexp-all-search-start), zero-width REs like <tt>\y</tt>, <tt>\m</tt> or <tt>$</tt> then give the same matches with <tt>-all</tt> as in other RE engines.
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
  3. Ticket change [d30d5562ff] (rid 257896) by jan.nijtmans on 2026-10-13 12:17:27:

    1. assignee changed to: "jan.nijtmans"
    2. closedate changed to: "2461327.0121187964"
    3. closer changed to: "jan.nijtmans"
    4. comment changed to:
      <tt>regexp -all</tt> does not try to match at the end of the string, so an RE that can match the empty string there misses its last match. <tt>regsub -all</tt> does try there, so the two disagree:
      <verbatim>
      regexp -all {a*} ab                  ;# 2, but regsub -all {a*} ab <&> gives <a><><> (3 matches)
      regexp -all -inline -indices -line {$} "a\n"   ;# {1 0}, but the empty line at the end also matches: {1 0} {2 1}
      </verbatim>
      PostgreSQL, Python, Perl, Java, Ruby and JavaScript all report the match at the end (3 matches for the first example). Tests regexp-23.5, 23.7 and 23.9, added for [2826551fff], expect it too, but are marked knownBug.
      
      The cause is the end of the <tt>-all</tt> loop in <tt>Tcl_RegexpObjCmd()</tt>: it stops when the next offset reaches the end of the string (<tt>offset >= stringLength</tt>), while <tt>Tcl_RegsubObjCmd()</tt> loops while <tt>offset <= wlen</tt>. Fixing it changes the number of matches that <tt>regexp -all</tt> reports for such REs, and several existing tests (regexp-18.8 to 18.10, 23.2, 23.3, 26.10 to 26.13) that expect the current results.
      
    5. icomment:
      Fixed in [63d4837de7|trunk], core-9-0-branch and core-8-6-branch
      
      Many thanks!
      
    6. login: "jan.nijtmans"
    7. mimetype: "text/x-fossil-wiki"
    8. resolution changed to: "Fixed"
    9. status changed to: "Closed"