Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: ef29f025bb2316b562feea2156e252dc16e6994d
Ticket: f2f70aa60c0844cd9ebcaabb630e5ea64325db90
regsub -all misses matches in Tcl 8.6
User & Date: gustafn2 on 2016-10-14 07:37:36
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    "regsub -all" returns different results in tcl 8.5 and tcl 8.6 The example below was condensed out of a complex example in openacs, where one function uses special characters as "markers" in regsub. When \x001 and \x002 are used as markers, not all of these markers can be changed back with tcl 8.6, where it succeeds with tcl 8.5. When \u0001 and \u0002 are used instead, the behavior is correct in all cases. It seems as if the change was introduced in early Tcl 8.6, since the problem is contained already in tcl 8.6.0.
    
    ===================================================
    set txt {
        <img src="http://openacs.org/place1.png">
        <img src="http://openacs.org/place2.png">
    }
    
    # broken in 8.6.0 .. 8.6.6, ok in 8.5.19
    set changed [regsub -all {(http://[^\(\)\"<>\s]+)} $txt "\x001\\1\x002" txt1]
    set changed_back [regsub -all {\x001([^\x002]*)\x002} $txt1 {\1} txt2]
    puts stderr "$tcl_patchLevel: changed $changed changed_back $changed_back"
    
    # ok in 8.6.0 .. 8.6.6, 8.5.19
    set changed [regsub -all {(http://[^\(\)\"<>\s]+)} $txt "\u0001\\1\u0002" txt1]
    set changed_back [regsub -all {\u0001([^\u0002]*)\u0002} $txt1 {\1} txt2]
    puts stderr "$tcl_patchLevel: changed $changed changed_back $changed_back"
    
    # 1st case broken:
    #     8.6.6: changed 2 changed_back 1
    #     8.6.6: changed 2 changed_back 2
    #
    # OK: 
    #     8.5.19: changed 2 changed_back 2
    #     8.5.19: changed 2 changed_back 2
    
  5. foundin changed to: "8.6.0 - 8.6.6"
  6. is_private changed to: "0"
  7. login: "gustafn2"
  8. priority changed to: "5 Medium"
  9. resolution changed to: "None"
  10. severity changed to: "Severe"
  11. status changed to: "Open"
  12. submitter changed to: "gustafn2"
  13. subsystem changed to: "43. Regexp"
  14. title changed to: "regsub -all misses matches in Tcl 8.6"
  15. type changed to: "Bug"