Skip to content
Tcl Source Code History Of Ticket 623448ffffffffffffffffffffffffffffffffff
Login

History Of Ticket 623448ffffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 623448ffffffffffffffffffffffffffffffffff

  1. Ticket change [e282918831] (rid 87643) by svogel on 2002-10-15 09:02:40:

    1. assignee initialized to: "dkf"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized 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 initialized to: "obsolete: 8.4.0"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "svogel"
    9. subsystem initialized to: "18. Commands M-Z"
    10. title initialized to: "string map not correctly mapping"
    11. type initialized to: "Bug"
  2. Ticket change [9899ac22bf] (rid 110636) by dkf on 2002-10-15 17:21:51:

    1. closedate changed to: "2002-10-15T10:21:51"
    2. closer changed to: "dkf"
    3. icomment:
      Logged In: YES 
      user_id=79902
      
      You seem to have misunderstood how [string map] works, and
      its key feature is that it never processes the same
      character twice.  This means that after the application of
      the second matching pattern (though you should understand
      that the order of patterns does not matter in your case) the
      third pattern cannot match because to do so, it would need
      to match against a mixture of input pattern and generated
      text.
      
      If you are processing XML, try using TclXSLT or TclDOM.
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. resolution changed to: "Invalid"
    7. status changed to: "Closed"
    8. username: "dkf"
  3. Ticket change [c36ad07b3c] (rid 111656) by svogel on 2002-10-15 18:02:33:

    1. closedate changed to: "2002-10-15T11:02:33"
    2. closer changed to: "svogel"
    3. icomment:
      Logged In: YES 
      user_id=250752
      
      O.k. I see. This is somehow difficult to understand. The doc 
      says: "string is only iterated over once, so earlier key 
      replacements will have no affect for later key matches"
      But it has then in some degree an effect on later key 
      matches. Maybe I just misunderstood that. Now it's clear to 
      me.
      The example in the docs is quite good.
      Thanks Donal
      
      
    4. login: "svogel"
    5. mimetype: "text/plain"
    6. username: "svogel"