From: SourceForge.net <no...@so...> - 2008-11-21 13:38:00
|
Bugs item #489537, was opened at 2001-12-05 20:56 Message generated for change (Comment added) made by nobody You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=489537&group_id=10894 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: 10. Objects Group: obsolete: 8.4a4 Status: Closed Resolution: Fixed Priority: 4 Private: No Submitted By: Don Porter (dgp) Assigned to: Don Porter (dgp) Summary: string rep of list: should quote '#' Initial Comment: Kudos to Joe English for catching this one, and Donal Fellows for analyzing the right solution. list(n) says: list ?arg arg ...? Braces and backslashes get added as necessary,... so that eval may be used to execute the resulting list, with arg1 comprising the command's name and the other args comprising its arguments. However, in an interacive tclsh: % proc # {} {puts !} % set cmd [list #] # % eval $cmd % A patch is attached that offers one fix with changes to Tcl_{Scan|Convert}CountedElement. It is overkill in that it quotes leading '#' in all list elements when it is only needed for the first list element, but in those routines, the ordinal of the element is not known. Perhaps an additional flag value could be added if more sophistication is wanted, limiting the quoting to the first element. Two part.test tests were updated, and tests based on the demo above was added to util.test. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2008-11-21 13:37 Message: ABRpEh <a href="http://xjkatwakcfxh.com/">xjkatwakcfxh</a>, [url=http://uizzvswmnaoe.com/]uizzvswmnaoe[/url], [link=http://sjqazgpgiczg.com/]sjqazgpgiczg[/link], http://gfhwkumabgbn.com/ ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-09-04 16:43 Message: Logged In: YES user_id=80530 TIP 148 Accepted. Patch committed to HEAD (8.5a0). ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-08-09 22:44 Message: Logged In: YES user_id=80530 The attached file 489537-fix.patch is the prototype implementation of TIP 148. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-08-08 19:57 Message: Logged In: YES user_id=80530 Updated fix patch that implements draft TIP. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-07-24 16:01 Message: Logged In: YES user_id=80530 ...and here's the test patch, that I am committing to HEAD. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-07-24 15:59 Message: Logged In: YES user_id=80530 updated to address those comments. Now in the form of two patches, one that adds tests to the test suite that demo the bug. And a second that contains the fix. Here's the fix patch... ---------------------------------------------------------------------- Comment By: Donal K. Fellows (dkf) Date: 2003-07-24 14:12 Message: Logged In: YES user_id=79902 I'd feel happier if the addition of TCL_DONT_QUOTE_HASH didn't rearrange the positions of the internal Tcl_ConvertElement flags. No reason why that value has to occupy a contiguous bit with TCL_DONT_USE_BRACES... Apart from that, there ought to be an extra dict test like this (or maybe with the result the other way round): test dict-2.8 {dict create command - #-quoting in string rep} { dict create # #comment ## ##comment } {{#} #comment ## ##comment} Minor issues aside, looks excellent to me. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-07-24 00:35 Message: Logged In: YES user_id=80530 Here's a completely new patch (replaces previous 489537.patch) that I think is better than all. 1) Does not change the public API (no TIP needed!) 2) Does not disturb the Tk test suite. 3) By default, chooses safe quoting. 4) Leaves open door for a TIP exposing to extensions the power to ask for less quoting of hashes when it is known safe. 5) Corrects several more callers of Tcl_Convert*Element() 6) Adds many more tests for bugs when those callers are not patched. Please review. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-07-22 21:24 Message: Logged In: YES user_id=80530 New patch 489537.patch is same as liststring2.patch except it adds two more tests to util.test that force string rep generation to illustrate the shimmering problem. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-07-22 17:00 Message: Logged In: YES user_id=80530 Because [eval] has pure-list optimizations, this bug now appears as a shimmering inconsistency. Consider this demo script # FILE: demo.tcl set cmdName [lindex $argv 0] proc $cmdName {} {puts Success!} set command [list $cmdName] puts "Eval \[$command]" ;# comment this out eval $command Correct behavior is for the script to write Success! to stdout. As written above, this fails for an argument that begins with the # character. However, if you comment out the indicated [puts], then we avoid string-rep generation, and the script works correctly for all arguments. Seems we should be able to correct a shimmering inconsistency without a TIP. Anyone relying on the buggy behavior should have been caught by the pure-list optimizations in eval by now. ---------------------------------------------------------------------- Comment By: Jeffrey Hobbs (hobbs) Date: 2003-03-05 17:40 Message: Logged In: YES user_id=72656 I think it requires a TIP. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-03-05 06:41 Message: Logged In: YES user_id=80530 opinion on making this fix in 8.5a0 ? ---------------------------------------------------------------------- Comment By: Jeffrey Hobbs (hobbs) Date: 2002-02-28 19:52 Message: Logged In: YES user_id=72656 I would like to make sure that this is logically worked over before commiting. It may be that the tests that would break don't exist, as it seems like a subtle change that might have ramifications. ---------------------------------------------------------------------- Comment By: miguel sofer (msofer) Date: 2002-02-28 19:42 Message: Logged In: YES user_id=148712 Adding a comment to the patch (thanks don!) ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2002-02-28 19:28 Message: Logged In: YES user_id=80530 The new patch works and passes both Tcl and Tk test suites. Haven't gone looking for ways to break it yet. ---------------------------------------------------------------------- Comment By: miguel sofer (msofer) Date: 2002-02-28 17:50 Message: Logged In: YES user_id=148712 A second patch: this will only quote '#' if it is the first element of the list: A new flag TCL_QUOTE_HASH is added to the interface of Tcl_Convert(Counted)Element. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2001-12-07 17:05 Message: Logged In: YES user_id=80530 If the current patch is accepted, many tests in the Tk test suite will fail. The first example is test button-7.2. It expects the result to be: .b1 #543210 {} {} but after the patch the result will actually be: .b1 {#543210} {} {} Possible remedies: 1) Just update all the relevant tests to expect the new string rep. (Create expected value with [list]) 2) Make a more sohpisticated patch that will only quote leading '#' in the first element of a list. 3) Make these tests compare their results as lists, rather than as strings, adding a new type of comparison to tcltest if necessary. ---------------------------------------------------------------------- Comment By: Donal K. Fellows (dkf) Date: 2001-12-06 10:00 Message: Logged In: YES user_id=79902 This is a *vevry* long-standing bug, since it was there in Tcl 7.4 (which is the oldest version I've got hanging about here) and it definitely should be resolved the way described as the alternative is to put a special case into the list(n) manpage. Which would be deeply blecherous. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2001-12-05 22:21 Message: Logged In: YES user_id=80530 With the patch: % list #foo a b c {#foo} a b c Does that answer the question? No error thrown, but yes the string rep changes. That's the point. Each list has multiple valid string reps. The guarantees of list(n) are met by the string rep after the patch, but not before. ---------------------------------------------------------------------- Comment By: Jeffrey Hobbs (hobbs) Date: 2001-12-05 22:07 Message: Logged In: YES user_id=72656 The patch changes semantics to the following: [list #foo a b c] == {\#foo a b c} by placing the \ in front of the #. This means that #foo will now be seen as a command, but when it is not (in most cases # will be for comments), then you will throw an error, no? ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2001-12-05 21:13 Message: Logged In: YES user_id=80530 Example? ---------------------------------------------------------------------- Comment By: Jeffrey Hobbs (hobbs) Date: 2001-12-05 21:10 Message: Logged In: YES user_id=72656 This is not correct for most cases, where the # is really meant to be a quote and has no command associated with it. This is only valid for the rare cases where the initial #- starting element has a command of the same name. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=489537&group_id=10894 |