Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: e282918831ce7dc32a82404bc0be9a2fb345bf1f
Ticket: 623448ffffffffffffffffffffffffffffffffff
string map not correctly mapping
User & Date: svogel on 2002-10-15 09:02:40
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    The following code-snippet shows the misbehaviour:
    Some empty p and an "answer"-block should be added 
    to this xml:
    
    set data 
    {<cnt><quest><p>q1</p></quest><ans><p>a1</p></an
    s></cnt>}
    
    # simply with map in "question" and "answer" empty "p" 
    are added
    # and a new "answer"-block should be inserted
    set result [string map {
    </p></quest> </p><p></p></quest> 
    </p></ans> </p><p></p></ans>
    </ans></cnt> 
    </ans><ans><p></p></ans></cnt>
    } $data]
    
    # result is:
    # 
    <cnt><quest><p>q1</p><p></p></quest><ans><p>a1<
    /p><p></p></ans></cnt>
    # the empty "p" tags are inserted, but the last map-
    pattern is not.
    
    # When doing the same in two steps as here:
    set result [string map {
    </p></quest> </p><p></p></quest> 
    </p></ans> </p><p></p></ans>
    } $data]
    set result [string map {
    </ans></cnt> 
    </ans><ans><p></p></ans></cnt>
    } $result]
    # now everything is fine, result is:
    <cnt><quest><p>q1</p><p></p></quest><ans><p>a1<
    /p><p></p></ans><ans><p></p></ans></cnt>
    
    This is observed also in Tcl 8.2. As I see in tclCmdMZ.c 
    in function Tcl_StringObjCmd the pointers of the 
    matches are precomputed, may that be the problem? I 
    don't really understand the rest of the code enough to 
    provide a patch.
    
  4. foundin changed to: "obsolete: 8.4.0"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "svogel"
  9. subsystem changed to: "18. Commands M-Z"
  10. title changed to: "string map not correctly mapping"
  11. type changed to: "Bug"