From: <Fi...@us...> - 2009-09-16 06:05:48
|
Revision: 228 http://tcldrop.svn.sourceforge.net/tcldrop/?rev=228&view=rev Author: FireEgl Date: 2009-09-16 06:05:36 +0000 (Wed, 16 Sep 2009) Log Message: ----------- Commented out/removed code that changes ::tcl_precision. The default for ::tcl_precision is probably best. Modified Paths: -------------- tcldrop/lib/pubsafetcl.tcl tcldrop/modules/tcldrop/core-1.tm Modified: tcldrop/lib/pubsafetcl.tcl =================================================================== --- tcldrop/lib/pubsafetcl.tcl 2009-09-16 05:24:09 UTC (rev 227) +++ tcldrop/lib/pubsafetcl.tcl 2009-09-16 06:05:36 UTC (rev 228) @@ -24,14 +24,7 @@ variable script [info script] package provide pubsafetcl $version variable rcsid {$Id$} - # This works around a bug in Tcl v8.5+ that gives the wrong results. We decrease ::tcl_precision until we get the right results... - # Set the test expr to a variable rather than hard-coding it, this avoids it being byte-compiled (so that changes to ::tcl_precision won't be ignored in our test code): - if {![expr [set expr {1.1 + 2.2 eq 3.3}]]} { - # First set it as high as is allowed by Tcl: - while {![catch { incr tcl_precision }]} {} - # Now back down until it gives the right results: - while {![expr $expr]} { incr tcl_precision -1 } - } + proc Reset {{interp {safetcl}} args} { return "Reset [create $interp]." } # This proc initializes/resets the safe interpreter, and basically does stuff to make it even safer or more complete: Modified: tcldrop/modules/tcldrop/core-1.tm =================================================================== --- tcldrop/modules/tcldrop/core-1.tm 2009-09-16 05:24:09 UTC (rev 227) +++ tcldrop/modules/tcldrop/core-1.tm 2009-09-16 06:05:36 UTC (rev 228) @@ -1809,17 +1809,20 @@ # Import the core Tcldrop commands into the global namespace: proc ::tcldrop::core::start {} { - global restart tcldrop env tcl_interactive tcl_precision + global restart tcldrop env tcl_interactive # Note: If ::restart exists, it means we're already in the middle of a restart (probably just re-source'ing this file.) if {![info exists restart]} { - # This works around a bug in Tcl v8.5+ that gives the wrong results. We decrease ::tcl_precision until we get the right results... - # Set the test expr to a variable rather than hard-coding it, this avoids it being byte-compiled (so that changes to ::tcl_precision won't be ignored in our test code): - if {![expr [set expr {1.1 + 2.2 eq 3.3}]]} { - # First set it as high as is allowed by Tcl: - while {![catch { incr tcl_precision }]} {} - # Now back down until it gives the right results: - while {![expr $expr]} { incr tcl_precision -1 } - } + ## This works around a bug in Tcl v8.5+ that gives the wrong results. We decrease ::tcl_precision until we get the right results... + ## Set the test expr to a variable rather than hard-coding it, this avoids it being byte-compiled (so that changes to ::tcl_precision won't be ignored in our test code): + # Commented out, because the default ::tcl_precision default of 0 is probably best.. http://www.tcl.tk/cgi-bin/tct/tip/132.html http://wiki.tcl.tk/879 + # The "proper" way I guess is to use the format command whenever the result of an expr is being displayed + # to a user..something like [string trimright [format %f [expr {1.1 + 2.2}]] 0] should be used. + #if {![expr [set expr {1.1 + 2.2 eq 3.3}]]} { + # # First set it as high as is allowed by Tcl: + # while {![catch { incr tcl_precision }]} {} + # # Now back down until it gives the right results: + # while {![expr $expr]} { incr tcl_precision -1 } + #} # Import the Tcldrop core commands to the ::tcldrop namespace: namespace eval ::tcldrop { namespace import -force {::tcldrop::core::*} } namespace eval :: { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |