Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 9855ffae96552a5c5729626bc256e45ef0af2c83
Ticket: 84af1192f514f190a1d14f31394ced8b6816e633
"regsub -all c.*" is errorneously compiled to "string map"
User & Date: oehhar on 2014-09-08 12:04:27
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    Эдуард Зозуля reported on clt :
    
    regsub result is different with tcl 8.5.6 and 8.6.2:
    <verbatim>
    set a "123(qwe)"
    
    in tcl 8.6
    # regsub -all "\\(.*" $a ""
    123qwe)
    
    in tcl 8.5
    # regsub -all "\\(.*" $a ""
    123
    </verbatim>
    
    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.
    <verbatim>
       % 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
    </verbatim>
    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]
    
  5. foundin changed to: "8.6.2"
  6. is_private changed to: "0"
  7. login: "oehhar"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "0f366eb3e9e2fcab52b8ebacd197db9047186a5f"
  10. resolution changed to: "None"
  11. severity changed to: "Critical"
  12. status changed to: "Open"
  13. submitter changed to: "oehhar"
  14. subsystem changed to: "43. Regexp"
  15. title changed to:
    "regsub -all c.*" is errorneously compiled to "string map"
    
  16. type changed to: "Bug"