Artifacts Associated With Ticket 623448ffffffffffffffffffffffffffffffffff
Ticket change [e282918831] (rid 87643) by svogel on 2002-10-15 09:02:40:
- assignee initialized to: "dkf"
- cmimetype initialized to: "text/plain"
- 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. - foundin initialized to: "obsolete: 8.4.0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "svogel"
- subsystem initialized to: "18. Commands M-Z"
- title initialized to: "string map not correctly mapping"
- type initialized to: "Bug"
Ticket change [9899ac22bf] (rid 110636) by dkf on 2002-10-15 17:21:51:
- closedate changed to: "2002-10-15T10:21:51"
- closer changed to: "dkf"
- 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.
- login: "dkf"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- status changed to: "Closed"
- username: "dkf"
Ticket change [c36ad07b3c] (rid 111656) by svogel on 2002-10-15 18:02:33:
- closedate changed to: "2002-10-15T11:02:33"
- closer changed to: "svogel"
- 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
- login: "svogel"
- mimetype: "text/plain"
- username: "svogel"