diff options
author | dgp <dgp@users.sourceforge.net> | 2013-01-30 19:00:27 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2013-01-30 19:00:27 (GMT) |
commit | ddaf86432d2523d3242c670af64654571f36a0d5 (patch) | |
tree | 43a466d8834829d1bb81dc12d20bdc9a442fb6d9 /library | |
parent | f26510438d420ec20e8840063ca9c3cc8989663e (diff) | |
parent | 3ac002a666fce71f19f025288d9e18c0819bb91a (diff) | |
download | tcl-ddaf86432d2523d3242c670af64654571f36a0d5.zip tcl-ddaf86432d2523d3242c670af64654571f36a0d5.tar.gz tcl-ddaf86432d2523d3242c670af64654571f36a0d5.tar.bz2 |
For [package] etc., select modernizations from Patrick Fradin.
Diffstat (limited to 'library')
-rw-r--r-- | library/package.tcl | 26 | ||||
-rw-r--r-- | library/tm.tcl | 10 |
2 files changed, 11 insertions, 25 deletions
diff --git a/library/package.tcl b/library/package.tcl index c30431c..52daa0e 100644 --- a/library/package.tcl +++ b/library/package.tcl @@ -395,9 +395,7 @@ proc pkg_mkIndex {args} { foreach pkg [lsort [array names files]] { set cmd {} - foreach {name version} $pkg { - break - } + lassign $pkg name version lappend cmd ::tcl::Pkg::Create -name $name -version $version foreach spec [lsort -index 0 $files($pkg)] { foreach {file type procs} $spec { @@ -544,8 +542,7 @@ proc tclPkgUnknown {name args} { # Don't add directories we've already seen, or ones already on the # $use_path. foreach dir [lrange $auto_path $index end] { - if {![info exists tclSeenPath($dir)] - && ([lsearch -exact $use_path $dir] == -1) } { + if {![info exists tclSeenPath($dir)] && ($dir ni $use_path)} { lappend use_path $dir } } @@ -628,8 +625,7 @@ proc tcl::MacOSXPkgUnknown {original name args} { # Don't add directories we've already seen, or ones already on the # $use_path. foreach dir [lrange $auto_path $index end] { - if {![info exists tclSeenPath($dir)] - && ([lsearch -exact $use_path $dir] == -1) } { + if {![info exists tclSeenPath($dir)] && ($dir ni $use_path)} { lappend use_path $dir } } @@ -681,10 +677,7 @@ proc ::tcl::Pkg::Create {args} { } # Initialize parameters - set opts(-name) {} - set opts(-version) {} - set opts(-source) {} - set opts(-load) {} + array set opts {-name {} -version {} -source {} -load {}} # process parameters for {set i 0} {$i < $len} {incr i} { @@ -732,14 +725,9 @@ proc ::tcl::Pkg::Create {args} { # Handle -load and -source specs foreach key {load source} { foreach filespec $opts(-$key) { - foreach {filename proclist} {{} {}} { - break - } - foreach {filename proclist} $filespec { - break - } - - if {![llength $proclist]} { + lassign $filespec filename proclist + + if { [llength $proclist] == 0 } { set cmd "\[list $key \[file join \$dir [list $filename]\]\]" lappend cmdList $cmd } else { diff --git a/library/tm.tcl b/library/tm.tcl index ce8a013..d2af4f5 100644 --- a/library/tm.tcl +++ b/library/tm.tcl @@ -54,7 +54,7 @@ namespace eval ::tcl::tm { # Export the public API namespace export path - namespace ensemble create -command path -subcommand {add remove list} + namespace ensemble create -command path -subcommands {add remove list} } # ::tcl::tm::path implementations -- @@ -260,10 +260,8 @@ proc ::tcl::tm::UnknownHandler {original name args} { # Otherwise we still have to fallback to the regular # package search to complete the processing. - if { - ($pkgname eq $name) && - [package vsatisfies $pkgversion {*}$args] - } then { + if {($pkgname eq $name) + && [package vsatisfies $pkgversion {*}$args]} { set satisfied 1 # We do not abort the loop, and keep adding provide @@ -347,7 +345,7 @@ proc ::tcl::tm::Defaults {} { # Calls 'path add' to paths to the list of module search paths. proc ::tcl::tm::roots {paths} { - foreach {major minor} [split [info tclversion] .] break + lassign [split [package present Tcl] .] major minor foreach pa $paths { set p [file join $pa tcl$major] for {set n $minor} {$n >= 0} {incr n -1} { |