|
2014-09-09
| ||
| 19:55 | • Closed ticket [84af1192f5]: "regsub -all c.*" is errorneously compiled... artifact: 57f14f8663 user: dkf | |
| 19:49 | [84af1192f5]: [regsub] compiler no longer confused by quantification handling. check-in: 25f44e9a6d user: dkf tags: trunk | |
| 19:15 | • Ticket [84af1192f5] "regsub -all c.*" is errorneously compiled to &quo... artifact: 3603687644 user: dkf | |
|
2014-09-08
| ||
| 17:39 | • Ticket [84af1192f5]: 3 changes artifact: 4baf89a187 user: aku | |
| 14:30 | • Ticket [84af1192f5]: 3 changes artifact: 7c1effa3a8 user: dgp | |
| 13:46 | • Ticket [84af1192f5]: 3 changes artifact: 961d3dfd0d user: dgp | |
| 12:04 | • New ticket [84af1192f5]. artifact: 9855ffae96 user: oehhar | |
"regsub -all c.*" is errorneously compiled to "string map"
regsub result is different with tcl 8.5.6 and 8.6.2:
set a "123(qwe)" in tcl 8.6 # regsub -all "\\(.*" $a "" 123qwe) in tcl 8.5 # regsub -all "\\(.*" $a "" 123
Donal analyzed that this is due to the fact, that the regsub is compiled to string map: (Donals writing follows):
That's definitely a bug, and it is related to the -all option in [regsub] and how things are compiled to bytecode. The engine itself has no problem.
% regexp -inline "\\(.*" $a
(qwe)
% tcl::unsupported::disassemble script {regsub -all "\\(.*" $a ""}
ByteCode 0x0x10304a410, refCt 1, epoch 15, interp 0x0x100829a10
(epoch 15)
Source "regsub -all \"\\(.*\" $a \"\""
Cmds 1, src 25, inst 9, litObjs 3, aux 0, stkDepth 3, code/src 0.00
Commands 1:
1: pc 0-7, src 0-24
Command 1: "regsub -all \"\\(.*\" $a \"\""
(0) push1 0 # "("
(2) push1 1 # ""
(4) push1 2 # "a"
(6) loadStk
(7) strmap
(8) done
Conversion to a [string map]? I don't think that's possibly right! (The
problem is that the condition used for conversion here is right for
[string match] but not [string map]. Ugh.)
Have you filed a bug report yet? This one's serious. Also, removing the -all option will work fine in this case; it's never actually useful with a trailing “.*” in the pattern.
Original clt thread: https://groups.google.com/forum/#!topic/comp.lang.tcl/HUdJ2suZVPI
25f44e9a6d[84af1192f5]: [regsub] compiler no longer confused by quantification handling. check-in2014-09-09 19:49:08
Bug introduced to trunk in http://core.tcl.tk/tcl/info/8e20d1a93f
Bug originates in http://core.tcl.tk/tcl/info/d2d9a5c8de
Problem is in the analysis of the results of TclReToGlob(); something which produces a * in the pattern has to be rejected when we're going to a strmap-instruction-based implementation.
Minimal test is to look at result of:
regsub -all {\(.*} 123(qwe) ""
Which should be 3 characters long.
This is now fixed. The problem was that the .* at the end of the pattern was being interpreted as if it wasn't there, which is correct for non-capturing regexp but wrong for regsub (which is effectively always capturing).
There would have also been a problem with this more unusual pattern (it's the same cause as above, the identical bug and the identical fix):
regsub -all {.*\(} 123(qwe) ""