Artifacts Associated With Ticket f2f70aa60c0844cd9ebcaabb630e5ea64325db90
Ticket change [ef29f025bb] (rid 149249) by gustafn2 on 2016-10-14 07:37:36:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized 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 - foundin initialized to: "8.6.0 - 8.6.6"
- is_private initialized to: "0"
- login: "gustafn2"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- severity initialized to: "Severe"
- status initialized to: "Open"
- submitter initialized to: "gustafn2"
- subsystem initialized to: "43. Regexp"
- title initialized to: "regsub -all misses matches in Tcl 8.6"
- type initialized to: "Bug"
Ticket change [247284fd10] (rid 149252) by dkf on 2016-10-14 09:00:23:
- assignee changed to: "jan.nijtmans"
- closedate changed to: "2457675.87527312"
- closer changed to: "dkf"
- icomment:
This was the change to the <tt>\x<i>XX</i></tt> escape in Tcl itself. It was always documented to be followed by exactly two hex digits, but was in practice followed <i>incorrectly</i> by an arbitrary number of hex digits of which all but the last two were thrown away. This meant (for example) that <tt>\x44AZ</tt> expanded to <tt>JZ</tt> and not to <tt>DAZ</tt>. This was horribly wrong, and was fixed in 8.6 to conform to the specification. See <a href="//tip.tcl.tk/388.html">TIP #388</a> for the details. The workaround is to use the <tt>\u<i>XXXX</i></tt> form as that was always (correctly) consuming exactly 4 hex digits.
- login: "dkf"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Rejected"
- status changed to: "Closed"
- subsystem changed to: "45. Parsing and Eval"
- username: "dkf"
Ticket change [44aece65b2] (rid 149254) by gustafn2 on 2016-10-14 11:25:59:
- closedate changed to: "2457675.97638328"
- closer changed to: "gustafn2"
- icomment:
many thanks for the quick reply. i can confirm that the 2-hex-digit variant is correct: set changed [regsub -all {(http://[^\(\)\"<>\s]+)} $txt "\x01\\1\x02" txt1] set changed_back [regsub -all {\x01([^\x02]*)\x02} $txt1 {\1} txt2] puts stderr "$tcl_patchLevel: changed $changed changed_back $changed_back" its my fault, i have not spotted the 3-hex-digit at the first place, the change is documented in http://wiki.tcl.tk/21276. i am still not sure, why the regsub works sometimes and sometimes no (in the original case 7x ok, 1x not ok)... but i am not sure if i want to know this. - login: "gustafn2"
- mimetype: "text/plain"