diff options
author | andreask <andreask> | 2013-01-22 19:30:43 (GMT) |
---|---|---|
committer | andreask <andreask> | 2013-01-22 19:30:43 (GMT) |
commit | 48c9fcb7281cc6aa076113db874c7ae0e105795d (patch) | |
tree | 7187940ff056462bfa41705a2ce04d0ed07d424e /tests/filebox.test | |
parent | 41f5d19540b0b3f053da352e1569c9a4ed019dd5 (diff) | |
download | tk-48c9fcb7281cc6aa076113db874c7ae0e105795d.zip tk-48c9fcb7281cc6aa076113db874c7ae0e105795d.tar.gz tk-48c9fcb7281cc6aa076113db874c7ae0e105795d.tar.bz2 |
Contribution by Patrick Fradin <patrick.fradin@planar.com>contrib_patrick_fradin_code_cleanup
Quoting his mail:
<pre>
==========================================================
Hi Jeff,
I spent some of my time to contribute to the TclTk community ! I'm in
late for Christmas gift but like we said in French : "Mieux vaut tard
que jamais". ;-)
I've use TclDevKit 5.3.0 tclchecker to analyse TclTk code in Tcl and
Tk library directories (library, tools and tests) to correct a lot of
warnings and few errors. (encapsulate some expr, use 'chan xxx'
instead of fconfigure, fileevent...)
I've made some improvements too :
Examples :
- Use 'lassign' instead of many 'lindex' of 'foreach/break' loop.
- Use 'in' or 'ni' operators instead of 'lsearch -exact' or to
factorise some eq/ne && / || tests.
- Use 'eq' or 'ne' to tests strings instead of '==' or '!='.
- Use 'unset -nocomplain' to avoid 'catch {unset...}'.
- Remove some useless catch around 'destroy' calls.
- Use expand {*} instead of 'eval'. Don't touch a lot of code because
I don't know all structs and lists. I think it could be a greater
improvement to reduce 'eval' calls.
Due to previous experience, I dot not change any indentation ! ;-)
==========================================================
</pre>
Diffstat (limited to 'tests/filebox.test')
-rw-r--r-- | tests/filebox.test | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/tests/filebox.test b/tests/filebox.test index 7b9fa2c..eb5380b 100644 --- a/tests/filebox.test +++ b/tests/filebox.test @@ -54,12 +54,12 @@ proc PressButton {btn} { proc EnterFileByKey {parent fileName fileDir} { global tk_strictMotif - if {$parent == "."} { + if {$parent eq "."} { set w .__tk_filedialog } else { set w $parent.__tk_filedialog } - upvar ::tk::dialog::file::__tk_filedialog data + upvar 1 ::tk::dialog::file::__tk_filedialog data if {$tk_strictMotif} { $data(sEnt) delete 0 end @@ -75,19 +75,19 @@ proc EnterFileByKey {parent fileName fileDir} { proc SendButtonPress {parent btn type} { global tk_strictMotif - if {$parent == "."} { + if {$parent eq "."} { set w .__tk_filedialog } else { set w $parent.__tk_filedialog } - upvar ::tk::dialog::file::__tk_filedialog data + upvar 1 ::tk::dialog::file::__tk_filedialog data set button $data($btn\Btn) - if ![winfo ismapped $button] { + if {![winfo ismapped $button]} { update } - if {$type == "mouse"} { + if {$type eq "mouse"} { PressButton $button } else { event generate $w <Enter> @@ -104,7 +104,7 @@ proc SendButtonPress {parent btn type} { # #---------------------------------------------------------------------- -if {$tcl_platform(platform) == "unix"} { +if {$tcl_platform(platform) eq "unix"} { set modes "0 1" } else { set modes 1 @@ -146,7 +146,7 @@ foreach mode $modes { # set addedExtensions {} - if {$tcl_platform(platform) == "unix"} { + if {$tcl_platform(platform) eq "unix"} { set tk_strictMotif $mode # Extension adding is only done when using the non-motif file # box with an extension-less filename @@ -185,8 +185,8 @@ foreach mode $modes { } -returnCodes error -result {bad file type "Foo", should be "typeName {extension ?extensions ...?} ?{macType ?macTypes ...?}?"} set isNative [expr { - [info commands ::tk::MotifFDialog] eq "" && - [info commands ::tk::dialog::file::] eq "" + ([info commands ::tk::MotifFDialog] eq "") && + ([info commands ::tk::dialog::file::] eq "") }] set parent . @@ -270,8 +270,7 @@ foreach mode $modes { foreach {x res} [list 1 "-unset-" 2 "Text files"] { set t [expr {$x + [llength [array names filters]]}] test filebox-3.$t-$mode "tk_getOpenFile command" nonUnixUserInteraction { - catch {unset tv} - catch {unset typeName} + unset -nocomplain tv typeName ToPressButton $parent ok if {[info exists tv]} { } else { @@ -319,8 +318,8 @@ foreach mode $modes { } -returnCodes error -result {bad file type "Foo", should be "typeName {extension ?extensions ...?} ?{macType ?macTypes ...?}?"} set isNative [expr { - [info commands ::tk::MotifFDialog] eq "" && - [info commands ::tk::dialog::file::] eq "" + ([info commands ::tk::MotifFDialog] eq "") && + ([info commands ::tk::dialog::file::] eq "") }] set parent . |