diff options
author | dgp <dgp@users.sourceforge.net> | 2013-01-31 05:17:33 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2013-01-31 05:17:33 (GMT) |
commit | 15624be5c60333dd6c9ca7a0b651fda1d92e7b7c (patch) | |
tree | d6af24523cb86d4a3b20a3e66c16644dadc319b2 /library | |
parent | 6d8a36d84d2843681302604a082e2f787c3c3674 (diff) | |
parent | f50bf4d17a2021e535f47e5253e24bd3dc1269b5 (diff) | |
download | tcl-contrib_patrick_fradin_code_cleanup.zip tcl-contrib_patrick_fradin_code_cleanup.tar.gz tcl-contrib_patrick_fradin_code_cleanup.tar.bz2 |
merge trunkcontrib_patrick_fradin_code_cleanup
Diffstat (limited to 'library')
-rw-r--r-- | library/auto.tcl | 44 | ||||
-rw-r--r-- | library/http/http.tcl | 70 | ||||
-rw-r--r-- | library/http/pkgIndex.tcl | 2 | ||||
-rw-r--r-- | library/init.tcl | 104 | ||||
-rw-r--r-- | library/msgcat/msgcat.tcl | 10 | ||||
-rw-r--r-- | library/package.tcl | 26 | ||||
-rw-r--r-- | library/platform/pkgIndex.tcl | 2 | ||||
-rw-r--r-- | library/platform/platform.tcl | 4 | ||||
-rw-r--r-- | library/tcltest/tcltest.tcl | 259 | ||||
-rw-r--r-- | library/tm.tcl | 16 | ||||
-rw-r--r-- | library/word.tcl | 12 |
11 files changed, 247 insertions, 302 deletions
diff --git a/library/auto.tcl b/library/auto.tcl index 49a2c61..e86257e 100644 --- a/library/auto.tcl +++ b/library/auto.tcl @@ -27,7 +27,7 @@ proc auto_reset {} { if {$fqcn eq ""} { continue } - rename $fqcn "" + rename $fqcn {} } } unset -nocomplain auto_execs auto_index ::tcl::auto_oldpath @@ -54,16 +54,14 @@ proc auto_reset {} { proc tcl_findLibrary {basename version patch initScript enVarName varName} { upvar #0 $varName the_library - global auto_path - global env - global tcl_platform + global auto_path env tcl_platform - set dirs [list] - set errors "" + set dirs {} + set errors {} # The C application may have hardwired a path, which we honor - if {[info exists the_library] && ($the_library ne "")} { + if {[info exists the_library] && $the_library ne ""} { lappend dirs $the_library } else { # Do the canonical search @@ -88,10 +86,8 @@ proc tcl_findLibrary {basename version patch initScript enVarName varName} { # auto_path that is not relative to the core library or binary paths. foreach d $auto_path { lappend dirs [file join $d $basename$version] - if { - ($tcl_platform(platform) eq "unix") - && ($tcl_platform(os) eq "Darwin") - } { + if {$tcl_platform(platform) eq "unix" + && $tcl_platform(os) eq "Darwin"} { # 4. On MacOSX, check the Resources/Scripts subdir too lappend dirs [file join $d $basename$version Resources Scripts] } @@ -138,7 +134,7 @@ proc tcl_findLibrary {basename version patch initScript enVarName varName} { if {[info exists seen($norm)]} { continue } - set seen($norm) "" + set seen($norm) {} lappend uniqdirs $i } set dirs $uniqdirs @@ -223,17 +219,17 @@ proc auto_mkindex {dir args} { auto_mkindex_parser::cleanup set fid [open "tclIndex" w] - chan puts -nonewline $fid $index - chan close $fid + puts -nonewline $fid $index + close $fid cd $oldDir } # Original version of auto_mkindex that just searches the source code for # "proc" at the beginning of the line. -proc auto_mkindex_old {a_dir args} { +proc auto_mkindex_old {dir args} { set oldDir [pwd] - cd $a_dir + cd $dir set dir [pwd] append index "# Tcl autoload index file, version 2.0\n" append index "# This file is generated by the \"auto_mkindex\" command\n" @@ -249,17 +245,17 @@ proc auto_mkindex_old {a_dir args} { set f "" set error [catch { set f [open $file] - while {[chan gets $f line] >= 0} { + while {[gets $f line] >= 0} { if {[regexp {^proc[ ]+([^ ]*)} $line match procName]} { set procName [lindex [auto_qualify $procName "::"] 0] append index "set [list auto_index($procName)]" append index " \[list source \[file join \$dir [list $file]\]\]\n" } } - chan close $f + close $f } msg opts] if {$error} { - catch {chan close $f} + catch {close $f} cd $oldDir return -options $opts $msg } @@ -267,12 +263,12 @@ proc auto_mkindex_old {a_dir args} { set f "" set error [catch { set f [open tclIndex w] - chan puts -nonewline $f $index - chan close $f + puts -nonewline $f $index + close $f cd $oldDir } msg opts] if {$error} { - catch {chan close $f} + catch {close $f} cd $oldDir error $msg $info $code return -options $opts $msg @@ -497,10 +493,10 @@ proc auto_mkindex_parser::commandInit {name arglist body} { proc auto_mkindex_parser::fullname {name} { variable contextStack - if {![string match "::*" $name]} { + if {![string match ::* $name]} { foreach ns $contextStack { set name "${ns}::$name" - if {[string match "::*" $name]} { + if {[string match ::* $name]} { break } } diff --git a/library/http/http.tcl b/library/http/http.tcl index 00140d7..9441acc 100644 --- a/library/http/http.tcl +++ b/library/http/http.tcl @@ -11,7 +11,7 @@ package require Tcl 8.6 # Keep this in sync with pkgIndex.tcl and with the install directories in # Makefiles -package provide http 2.8.5 +package provide http 2.8.6 namespace eval http { # Allow resourcing to not clobber existing data @@ -535,11 +535,10 @@ proc http::geturl {url args} { # If a timeout is specified we set up the after event and arrange for an # asynchronous socket connection. - set sockopts [list] + set sockopts [list -async] if {$state(-timeout) > 0} { set state(after) [after $state(-timeout) \ [list http::reset $token timeout]] - lappend sockopts -async } # If we are using the proxy, we must pass in the full URL that includes @@ -595,10 +594,15 @@ proc http::geturl {url args} { set socketmap($state(socketinfo)) $sock } - # Wait for the connection to complete. + if {![info exists phost]} { + set phost "" + } + fileevent $sock writable [list http::Connect $token $proto $phost $srvurl] - if {$state(-timeout) > 0} { - chan event $sock writable [list http::Connect $token] + # Wait for the connection to complete. + if {![info exists state(-command)]} { + # geturl does EVERYTHING asynchronously, so if the user + # calls it synchronously, we just do a wait here. http::wait $token if {![info exists state]} { @@ -614,13 +618,29 @@ proc http::geturl {url args} { set err [lindex $state(error) 0] cleanup $token return -code error $err - } elseif {$state(status) ne "connect"} { - # Likely to be connection timeout - return $token } - set state(status) "" } + return $token +} + + +proc http::Connected { token proto phost srvurl} { + variable http + variable urlTypes + + variable $token + upvar 0 $token state + + # Set back the variables needed here + set sock $state(sock) + set isQueryChannel [info exists state(-querychannel)] + set isQuery [info exists state(-query)] + set host [lindex [split $state(socketinfo) :] 0] + set port [lindex [split $state(socketinfo) :] 1] + + set defport [lindex $urlTypes($proto) 0] + # Send data in cr-lf format, but accept any line terminators chan configure $sock -translation {auto crlf} -buffersize $state(-blocksize) @@ -751,35 +771,17 @@ proc http::geturl {url args} { chan event $sock readable [list http::Event $sock $token] } - if {![info exists state(-command)]} { - # geturl does EVERYTHING asynchronously, so if the user calls it - # synchronously, we just do a wait here. - - wait $token - if {$state(status) eq "error"} { - # Something went wrong, so throw the exception, and the - # enclosing catch will do cleanup. - return -code error [lindex $state(error) 0] - } - } } err]} { # The socket probably was never connected, or the connection dropped # later. - # Clean up after events and such, but DON'T call the command callback - # (if available) because we're going to throw an exception from here - # instead. - # if state(status) is error, it means someone's already called Finish # to do the above-described clean up. if {$state(status) ne "error"} { - Finish $token $err 1 + Finish $token $err } - cleanup $token - return -code error $err } - return $token } # Data access functions: @@ -863,7 +865,7 @@ proc http::cleanup {token} { # Sets the status of the connection, which unblocks # the waiting geturl call -proc http::Connect {token} { +proc http::Connect {token proto phost srvurl} { variable [set token] upvar 0 $token state set err "due to unexpected EOF" @@ -871,10 +873,10 @@ proc http::Connect {token} { [chan eof $state(sock)] || ([set err [chan configure $state(sock) -error]] ne "") } { - Finish $token "connect failed $err" 1 + Finish $token "connect failed $err" } else { - set state(status) connect chan event $state(sock) writable {} + ::http::Connected $token $proto $phost $srvurl } return } @@ -979,7 +981,7 @@ proc http::Event {sock token} { } elseif {$n == 0} { # We have now read all headers # We ignore HTTP/1.1 100 Continue returns. RFC2616 sec 8.2.3 - if {($state(http) == "") || ([lindex $state(http) 1] == 100)} { + if {($state(http) == "") || ([regexp {^\S+\s(\d+)} $state(http) {} x] && $x == 100)} { return } @@ -1379,7 +1381,7 @@ proc http::mapReply {string} { } set converted [string map $formMap $string] if {[string match "*\[\u0100-\uffff\]*" $converted]} { - regexp {[\u0100-\uffff]} $converted badChar + regexp "\[\u0100-\uffff\]" $converted badChar # Return this error message for maximum compatability... :^/ return -code error \ "can't read \"formMap($badChar)\": no such element in array" diff --git a/library/http/pkgIndex.tcl b/library/http/pkgIndex.tcl index 303d3bd..a8641e1 100644 --- a/library/http/pkgIndex.tcl +++ b/library/http/pkgIndex.tcl @@ -1,2 +1,2 @@ if {![package vsatisfies [package provide Tcl] 8.6]} {return} -package ifneeded http 2.8.5 [list tclPkgSetup $dir http 2.8.5 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister ::http::mapReply}}}] +package ifneeded http 2.8.6 [list tclPkgSetup $dir http 2.8.6 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister ::http::mapReply}}}] diff --git a/library/init.tcl b/library/init.tcl index 7526002..bedc06e 100644 --- a/library/init.tcl +++ b/library/init.tcl @@ -12,7 +12,8 @@ # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -if {[info commands package] eq ""} { +# This test intentionally written in pre-7.5 Tcl +if {[info commands package] == ""} { error "version mismatch: library\nscripts expect Tcl version 7.5b1 or later but the loaded version is\nonly [info patchlevel]" } package require -exact Tcl 8.6.0 @@ -84,7 +85,7 @@ namespace eval tcl { foreach arg $args { # This will handle forcing the numeric value without # ruining the internal type of a numeric object - if {[catch {expr { double ($arg) }} err]} { + if {[catch {expr {double($arg)}} err]} { return -code error $err } if {$arg < $val} {set val $arg} @@ -100,7 +101,7 @@ namespace eval tcl { foreach arg $args { # This will handle forcing the numeric value without # ruining the internal type of a numeric object - if {[catch {expr { double ($arg) }} err]} { + if {[catch {expr {double($arg)}} err]} { return -code error $err } if {$arg > $val} {set val $arg} @@ -137,7 +138,6 @@ if {(![interp issafe]) && ($tcl_platform(platform) eq "windows")} { trace add variable env($u) write \ [namespace code [list EnvTraceProc $p]] } - default {} } } } @@ -155,13 +155,14 @@ if {(![interp issafe]) && ($tcl_platform(platform) eq "windows")} { # Setup the unknown package handler + if {[interp issafe]} { package unknown {::tcl::tm::UnknownHandler ::tclPkgUnknown} } else { # Set up search for Tcl Modules (TIP #189). # and setup platform specific unknown package handlers - if {($::tcl_platform(os) eq "Darwin") && - ($::tcl_platform(platform) eq "unix")} { + if {$tcl_platform(os) eq "Darwin" + && $tcl_platform(platform) eq "unix"} { package unknown {::tcl::tm::UnknownHandler \ {::tcl::MacOSXPkgUnknown ::tclPkgUnknown}} } else { @@ -172,7 +173,7 @@ if {[interp issafe]} { namespace eval ::tcl::clock [list variable TclLibDir $::tcl_library] - proc clock {args} { + proc clock args { namespace eval ::tcl::clock [list namespace ensemble create -command \ [uplevel 1 [list namespace origin [lindex [info level 0] 0]]] \ -subcommands { @@ -182,7 +183,7 @@ if {[interp issafe]} { # Auto-loading stubs for 'clock.tcl' foreach cmd {add format scan} { - proc ::tcl::clock::$cmd {args} { + proc ::tcl::clock::$cmd args { variable TclLibDir source -encoding utf-8 [file join $TclLibDir clock.tcl] return [uplevel 1 [info level 0]] @@ -232,11 +233,10 @@ if {[namespace which -command tclLog] eq ""} { # args - A list whose elements are the words of the original # command, including the command name. -proc unknown {args} { +proc unknown args { variable ::tcl::UnknownPending global auto_noexec auto_noload env tcl_interactive errorInfo errorCode - if {[info exists errorInfo]} { set savedErrorInfo $errorInfo } @@ -267,9 +267,9 @@ proc unknown {args} { } if {$msg} { if {[info exists savedErrorCode]} { - set errorCode $savedErrorCode + set ::errorCode $savedErrorCode } else { - unset -nocomplain errorCode + unset -nocomplain ::errorCode } if {[info exists savedErrorInfo]} { set errorInfo $savedErrorInfo @@ -283,8 +283,8 @@ proc unknown {args} { # Note the dependence on how Tcl_AddErrorInfo, etc. # construct the stack trace. # - set errorInfo [dict get $opts -errorinfo] - set errorCode [dict get $opts -errorcode] + set errInfo [dict get $opts -errorinfo] + set errCode [dict get $opts -errorcode] set cinfo $args if {[string bytelength $cinfo] > 150} { set cinfo [string range $cinfo 0 150] @@ -301,7 +301,7 @@ proc unknown {args} { # and trim the extra contribution from the matching case # set expect "$msg\n while executing\n\"$cinfo" - if {$errorInfo eq $expect} { + if {$errInfo eq $expect} { # # The stack has only the eval from the expanded command # Do not generate any stack trace here. @@ -316,18 +316,18 @@ proc unknown {args} { # set expect "\n invoked from within\n\"$cinfo" set exlen [string length $expect] - set eilen [string length $errorInfo] + set eilen [string length $errInfo] set i [expr {$eilen - $exlen - 1}] - set einfo [string range $errorInfo 0 $i] + set einfo [string range $errInfo 0 $i] # - # For now verify that $errorInfo consists of what we are about + # For now verify that $errInfo consists of what we are about # to return plus what we expected to trim off. # - if {$errorInfo ne "$einfo$expect"} { + if {$errInfo ne "$einfo$expect"} { error "Tcl bug: unexpected stack trace in \"unknown\"" {} \ - [list CORE UNKNOWN BADTRACE $einfo $expect $errorInfo] + [list CORE UNKNOWN BADTRACE $einfo $expect $errInfo] } - return -code error -errorcode $errorCode \ + return -code error -errorcode $errCode \ -errorinfo $einfo $msg } else { dict incr opts -level @@ -336,8 +336,8 @@ proc unknown {args} { } } - if {([info level] == 1) && ([info script] eq "") && - [info exists tcl_interactive] && $tcl_interactive} { + if {([info level] == 1) && ([info script] eq "") + && [info exists tcl_interactive] && $tcl_interactive} { if {![info exists auto_noexec]} { set new [auto_execok $name] if {$new ne ""} { @@ -354,9 +354,9 @@ proc unknown {args} { } if {$name eq "!!"} { set newcmd [history event] - } elseif {[regexp {^!(.+)$} $name ___ event]} { + } elseif {[regexp {^!(.+)$} $name -> event]} { set newcmd [history event $event] - } elseif {[regexp {^\^([^^]*)\^([^^]*)\^?$} $name ___ old new]} { + } elseif {[regexp {^\^([^^]*)\^([^^]*)\^?$} $name -> old new]} { set newcmd [history event -1] catch {regsub -all -- $old $newcmd $new newcmd} } @@ -538,7 +538,7 @@ proc auto_qualify {cmd namespace} { # count separators and clean them up # (making sure that foo:::::bar will be treated as foo::bar) - set n [regsub -all "::+" $cmd :: cmd] + set n [regsub -all {::+} $cmd :: cmd] # Ignore namespace if the name starts with :: # Handle special case of only leading :: @@ -547,7 +547,7 @@ proc auto_qualify {cmd namespace} { # with the following form : # (inputCmd, inputNameSpace) -> output - if {[string match "::*" $cmd]} { + if {[string match ::* $cmd]} { if {$n > 1} { # (::foo::bar , *) -> ::foo::bar return [list $cmd] @@ -631,7 +631,7 @@ if {$tcl_platform(platform) eq "windows"} { # may be in the Path or PATH environment variables, and path # components are separated with semicolons, not colons as under Unix. # -proc auto_execok {name} { +proc auto_execok name { global auto_execs env tcl_platform if {[info exists auto_execs($name)]} { @@ -649,7 +649,7 @@ proc auto_execok {name} { # Add an initial ; to have the {} extension check first. set execExtensions [split ";$env(PATHEXT)" ";"] } else { - set execExtensions [list "" .com .exe .bat .cmd] + set execExtensions [list {} .com .exe .bat .cmd] } if {[string tolower $name] in $shellBuiltins} { @@ -666,7 +666,7 @@ proc auto_execok {name} { if {[llength [file split $name]] != 1} { foreach ext $execExtensions { set file ${name}${ext} - if {[file exists $file] && (![file isdirectory $file])} { + if {[file exists $file] && ![file isdirectory $file]} { return [set auto_execs($name) [list $file]] } } @@ -692,14 +692,14 @@ proc auto_execok {name} { foreach ext $execExtensions { unset -nocomplain checked - foreach dir [split $path ";"] { + foreach dir [split $path {;}] { # Skip already checked directories if {[info exists checked($dir)] || ($dir eq "")} { continue } - set checked($dir) "" + set checked($dir) {} set file [file join $dir ${name}${ext}] - if {[file exists $file] && (![file isdirectory $file])} { + if {[file exists $file] && ![file isdirectory $file]} { return [set auto_execs($name) [list $file]] } } @@ -710,7 +710,7 @@ proc auto_execok {name} { } else { # Unix version. # -proc auto_execok {name} { +proc auto_execok name { global auto_execs env if {[info exists auto_execs($name)]} { @@ -718,7 +718,7 @@ proc auto_execok {name} { } set auto_execs($name) "" if {[llength [file split $name]] != 1} { - if {[file executable $name] && (![file isdirectory $name])} { + if {[file executable $name] && ![file isdirectory $name]} { set auto_execs($name) [list $name] } return $auto_execs($name) @@ -728,7 +728,7 @@ proc auto_execok {name} { set dir . } set file [file join $dir $name] - if {[file executable $file] && (![file isdirectory $file])} { + if {[file executable $file] && ![file isdirectory $file]} { set auto_execs($name) [list $file] return $auto_execs($name) } @@ -789,7 +789,7 @@ proc tcl::CopyDirectory {action src dest} { lappend existing {*}[glob -nocomplain -directory $dest \ -type hidden * .*] foreach s $existing { - if {[file tail $s] ni ". .."} { + if {[file tail $s] ni {. ..}} { return -code error "error $action \"$src\" to\ \"$dest\": file already exists" } @@ -817,37 +817,9 @@ proc tcl::CopyDirectory {action src dest} { [glob -nocomplain -directory $src -types hidden *]] foreach s [lsort -unique $filelist] { - if {[file tail $s] ni ". .."} { + if {[file tail $s] ni {. ..}} { file copy -force -- $s [file join $dest [file tail $s]] } } return } - -# TIP 131 -if {0} { -proc tcl::rmmadwiw {} { - set magic { - 42 83 fe f6 ff f8 f1 e5 c6 f9 eb fd ff fb f1 e5 cc f5 ec f5 e3 fd fe - ff f5 fa f3 e1 c7 f9 f2 fd ff f9 fe f9 ed f4 fa f6 e6 f9 f2 e6 fd f9 - ff f9 f6 e6 fa fd ff fc fb fc f9 f1 ed - } - foreach mystic [lassign $magic tragic] { - set comic [expr (0x$mystic ^ 0x$tragic) - 255 + 0x$tragic] - append logic [format %x $comic] - set tragic $mystic - } - binary format H* $logic -} - -proc tcl::mathfunc::rmmadwiw {} { - set age [expr {9 * 6}] - set mind "" - while {$age} { - lappend mind [expr {$age % 13}] - set age [expr {$age / 13}] - } - set matter [lreverse $mind] - return [join $matter ""] -} -} diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl index 5ebb642..112507a 100644 --- a/library/msgcat/msgcat.tcl +++ b/library/msgcat/msgcat.tcl @@ -238,7 +238,7 @@ proc msgcat::mclocale {args} { could be path to unsafe code." } set Locale [string tolower $newLocale] - set Loclist [list] + set Loclist {} set word "" foreach part [split $Locale _] { set word [string trim "${word}_${part}" _] @@ -246,7 +246,7 @@ proc msgcat::mclocale {args} { set Loclist [linsert $Loclist 0 $word] } } - lappend Loclist "" + lappend Loclist {} set Locale [lindex $Loclist 0] } return $Locale @@ -465,7 +465,7 @@ proc msgcat::mcmax {args} { foreach string $args { set translated [uplevel 1 [list [namespace origin mc] $string]] set len [string length $translated] - if {$len > $max} { + if {$len>$max} { set max $len } } @@ -488,7 +488,7 @@ proc msgcat::ConvertLocale {value} { # $ # Match all the way to the end # } $value -> language _ territory _ codeset _ modifier if {![regexp {^([^_.@]+)(_([^.@]*))?([.]([^@]*))?(@(.*))?$} $value \ - ___ language _ territory _ codeset _ modifier]} { + -> language _ territory _ codeset _ modifier]} { return -code error "invalid locale '$value': empty language part" } set ret $language @@ -520,7 +520,7 @@ proc msgcat::Init {} { # # On Darwin, fallback to current CFLocale identifier if available. # - if {[info exists ::tcl::mac::locale] && ($::tcl::mac::locale ne "")} { + if {[info exists ::tcl::mac::locale] && $::tcl::mac::locale ne ""} { if {![catch { mclocale [ConvertLocale $::tcl::mac::locale] }]} { diff --git a/library/package.tcl b/library/package.tcl index 296553c..52daa0e 100644 --- a/library/package.tcl +++ b/library/package.tcl @@ -125,7 +125,6 @@ proc pkg_mkIndex {args} { } } - set fileList [list] set dir [lindex $args $idx] set patternList [lrange $args [expr {$idx + 1}] end] if {![llength $patternList]} { @@ -395,13 +394,13 @@ proc pkg_mkIndex {args} { append index "# full path name of this file's directory.\n" foreach pkg [lsort [array names files]] { - set cmd [list] + set cmd {} 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 { if {$direct} { - set procs "" + set procs {} } lappend cmd "-$type" [list $file $procs] } @@ -410,8 +409,8 @@ proc pkg_mkIndex {args} { } set f [open [file join $dir pkgIndex.tcl] w] - chan puts $f $index - chan close $f + puts $f $index + close $f } # tclPkgSetup -- @@ -543,7 +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)]) && ($dir ni $use_path)} { + if {![info exists tclSeenPath($dir)] && ($dir ni $use_path)} { lappend use_path $dir } } @@ -626,7 +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)]) && ($dir ni $use_path)} { + if {![info exists tclSeenPath($dir)] && ($dir ni $use_path)} { lappend use_path $dir } } @@ -678,7 +677,7 @@ proc ::tcl::Pkg::Create {args} { } # Initialize parameters - array set opts {-name "" -version "" -source "" -load ""} + array set opts {-name {} -version {} -source {} -load {}} # process parameters for {set i 0} {$i < $len} {incr i} { @@ -720,16 +719,15 @@ proc ::tcl::Pkg::Create {args} { # OK, now everything is good. Generate the package ifneeded statment. set cmdline "package ifneeded $opts(-name) $opts(-version) " - set cmdList [list] - set lazyFileList [list] + set cmdList {} + set lazyFileList {} # Handle -load and -source specs foreach key {load source} { foreach filespec $opts(-$key) { - lassign "" filename proclist lassign $filespec filename proclist - - if {![llength $proclist]} { + + if { [llength $proclist] == 0 } { set cmd "\[list $key \[file join \$dir [list $filename]\]\]" lappend cmdList $cmd } else { @@ -746,4 +744,4 @@ proc ::tcl::Pkg::Create {args} { return $cmdline } -interp alias "" ::pkg::create "" ::tcl::Pkg::Create +interp alias {} ::pkg::create {} ::tcl::Pkg::Create diff --git a/library/platform/pkgIndex.tcl b/library/platform/pkgIndex.tcl index 220a67b..b882e4f 100644 --- a/library/platform/pkgIndex.tcl +++ b/library/platform/pkgIndex.tcl @@ -1,3 +1,3 @@ -package ifneeded platform 1.0.10 [list source [file join $dir platform.tcl]] +package ifneeded platform 1.0.11 [list source [file join $dir platform.tcl]] package ifneeded platform::shell 1.1.4 [list source [file join $dir shell.tcl]] diff --git a/library/platform/platform.tcl b/library/platform/platform.tcl index 71b9b7e..d9b1aee 100644 --- a/library/platform/platform.tcl +++ b/library/platform/platform.tcl @@ -259,7 +259,7 @@ proc ::platform::LibcVersion {base _->_ vv} { if {![catch { set vdata [lindex [split [exec -- $libc] \n] 0] }]} { - regexp {([0-9]+(\.[0-9]+)*)} $vdata ___ v + regexp {version ([0-9]+(\.[0-9]+)*), by} $vdata -> v lassign [split $v "."] major minor set v glibc${major}.${minor} return 1 @@ -372,7 +372,7 @@ proc ::platform::patterns {id} { # ### ### ### ######### ######### ######### ## Ready -package provide platform 1.0.10 +package provide platform 1.0.11 # ### ### ### ######### ######### ######### ## Demo application diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl index 532ccd6..d6e6487 100644 --- a/library/tcltest/tcltest.tcl +++ b/library/tcltest/tcltest.tcl @@ -156,15 +156,15 @@ namespace eval tcltest { # rather than go through command interfaces. # proc ArrayDefault {varName value} { - variable [set varName] - if {[array exists [set varName]]} { + variable $varName + if {[array exists $varName]} { return } - if {[info exists [set varName]]} { + if {[info exists $varName]} { # Pre-initialized value is a scalar: destroy it! - unset -- [set varName] + unset $varName } - array set [set varName] $value + array set $varName $value } # save the original environment so that it can be restored later @@ -177,7 +177,7 @@ namespace eval tcltest { # createdNewFiles will store test files as indices and the list of # files (that should not have been) left behind by the test files # as values. - ArrayDefault createdNewFiles "" + ArrayDefault createdNewFiles {} # initialize skippedBecause array to keep track of constraints that # kept tests from running; a constraint name of "userSpecifiedSkip" @@ -186,12 +186,12 @@ namespace eval tcltest { # the test didn't match the argument given to the -match flag; both # of these constraints are counted only if tcltest::debug is set to # true. - ArrayDefault skippedBecause "" + ArrayDefault skippedBecause {} # initialize the testConstraints array to keep track of valid # predefined constraints (see the explanation for the # InitConstraints proc for more details). - ArrayDefault testConstraints "" + ArrayDefault testConstraints {} ##### Initialize internal variables of tcltest, but only if the caller # has not already pre-initialized them. This is done to support @@ -199,18 +199,18 @@ namespace eval tcltest { # rather than go through command interfaces. # proc Default {varName value {verify AcceptAll}} { - variable [set varName] - if {![info exists [set varName]]} { - variable [set varName] [$verify $value] + variable $varName + if {![info exists $varName]} { + variable $varName [$verify $value] } else { - variable [set varName] [$verify [set [set varName]]] + variable $varName [$verify [set $varName]] } } # Save any arguments that we might want to pass through to other # programs. This is used by the -args flag. # FINDUSER - Default parameters "" + Default parameters {} # Count the number of files tested (0 if runAllTests wasn't called). # runAllTests will set testSingleFile to false, so stats will @@ -221,7 +221,7 @@ namespace eval tcltest { Default numTestFiles 0 AcceptInteger Default testSingleFile true AcceptBoolean Default currentFailure false AcceptBoolean - Default failFiles "" AcceptList + Default failFiles {} AcceptList # Tests should remove all files they create. The test suite will # check the current working dir for files created by the tests. @@ -231,8 +231,8 @@ namespace eval tcltest { # # Note that $filesExisted lists only those files that exist in # the original [temporaryDirectory]. - Default filesMade "" AcceptList - Default filesExisted "" AcceptList + Default filesMade {} AcceptList + Default filesExisted {} AcceptList proc FillFilesExisted {} { variable filesExisted @@ -242,20 +242,20 @@ namespace eval tcltest { } # After successful filling, turn this into a no-op. - proc FillFilesExisted {args} {} + proc FillFilesExisted args {} } # Kept only for compatibility - Default constraintsSpecified "" AcceptList - trace add variable constraintsSpecified read \ - {set ::tcltest::constraintsSpecified [array names ::tcltest::testConstraints] ;# } + Default constraintsSpecified {} AcceptList + trace add variable constraintsSpecified read [namespace code { + set constraintsSpecified [array names testConstraints] ;#}] # tests that use threads need to know which is the main thread Default mainThread 1 variable mainThread - if {[info commands thread::id] ne ""} { + if {[info commands thread::id] ne {}} { set mainThread [thread::id] - } elseif {[info commands testthread] ne ""} { + } elseif {[info commands testthread] ne {}} { set mainThread [testthread id] } @@ -264,7 +264,7 @@ namespace eval tcltest { # change to that directory. variable workingDirectory trace add variable workingDirectory write \ - [namespace code {cd $workingDirectory ;#}] + [namespace code {cd $workingDirectory ;#}] Default workingDirectory [pwd] AcceptAbsolutePath proc workingDirectory { {dir ""} } { @@ -290,15 +290,15 @@ namespace eval tcltest { } # stdout and stderr buffers for use when we want to store them - Default outData "" - Default errData "" + Default outData {} + Default errData {} # keep track of test level for nested test commands variable testLevel 0 # the variables and procs that existed when saveState was called are # stored in a variable of the same name - Default saveState "" + Default saveState {} # Internationalization support -- used in [SetIso8859_1_Locale] and # [RestoreLocale]. Those commands are used in cmdIL.test. @@ -334,12 +334,10 @@ namespace eval tcltest { "windows" { set isoLocale French } - default {} } } - variable ChannelsWeOpened - array set ChannelsWeOpened {} + variable ChannelsWeOpened; array set ChannelsWeOpened {} # output goes to stdout by default Default outputChannel stdout proc outputChannel { {filename ""} } { @@ -466,16 +464,13 @@ namespace eval tcltest { ##### Set up the configurable options # # The configurable options of the package - variable Option - array set Option "" + variable Option; array set Option {} # Usage strings for those options - variable Usage - array set Usage "" + variable Usage; array set Usage {} # Verification commands for those options - variable Verify - array set Verify "" + variable Verify; array set Verify {} # Initialize the default values of the configurable options that are # historically associated with an exported variable. If that variable @@ -498,14 +493,14 @@ namespace eval tcltest { set Option($option) $msg } if {[string length $varName]} { - variable [set varName] - if {[info exists [set varName]]} { - if {[catch {$verify [set [set varName]]} msg]} { + variable $varName + if {[info exists $varName]} { + if {[catch {$verify [set $varName]} msg]} { return -code error $msg } else { set Option($option) $msg } - unset -- [set varName] + unset $varName } namespace eval [namespace current] \ [list upvar 0 Option($option) $varName] @@ -553,20 +548,21 @@ namespace eval tcltest { proc EstablishAutoConfigureTraces {} { variable OptionControlledVariables foreach varName [concat $OptionControlledVariables Option] { - variable [set varName] - trace add variable [set varName] read [namespace code {ProcessCmdLineArgs ;#}] + variable $varName + trace add variable $varName read [namespace code { + ProcessCmdLineArgs ;#}] } } proc RemoveAutoConfigureTraces {} { variable OptionControlledVariables foreach varName [concat $OptionControlledVariables Option] { - variable [set varName] - foreach pair [trace info variable [set varName]] { + variable $varName + foreach pair [trace info variable $varName] { lassign $pair op cmd - if {("read" eq $op) && - [string match "*ProcessCmdLineArgs*" $cmd]} { - trace remove variable [set varName] $op $cmd + if {($op eq "read") && + [string match *ProcessCmdLineArgs* $cmd]} { + trace remove variable $varName $op $cmd } } } @@ -574,7 +570,7 @@ namespace eval tcltest { proc RemoveAutoConfigureTraces {} {} } - proc Configure {args} { + proc Configure args { variable Option variable Verify set n [llength $args] @@ -605,7 +601,7 @@ namespace eval tcltest { return -code error "missing value for option $option" } } - proc configure {args} { + proc configure args { if {[llength $args] > 1} { RemoveAutoConfigureTraces } @@ -619,7 +615,7 @@ namespace eval tcltest { if {![regexp {^(pass|body|skip|start|error|line)$} $level]} { # translate single characters abbreviations to expanded list set level [string map {p pass b body s skip t start e error l line} \ - [split $level ""]] + [split $level {}]] } } set valid [list] @@ -694,7 +690,7 @@ namespace eval tcltest { Internal debug level } AcceptInteger debug - proc SetSelectedConstraints {args} { + proc SetSelectedConstraints args { variable Option foreach c $Option(-constraints) { testConstraint $c 1 @@ -704,10 +700,10 @@ namespace eval tcltest { Do not skip the listed constraints listed in -constraints. } AcceptList trace add variable Option(-constraints) write \ - [namespace code {SetSelectedConstraints ;#}] + [namespace code {SetSelectedConstraints ;#}] # Don't run only the "-constraint" specified tests by default - proc ClearUnselectedConstraints {args} { + proc ClearUnselectedConstraints args { variable Option variable testConstraints if {!$Option(-limitconstraints)} {return} @@ -768,13 +764,13 @@ namespace eval tcltest { [namespace code {normalizePath Option(-testdir) ;#}] proc AcceptLoadFile { file } { - if {"" eq $file} {return $file} + if {$file eq {}} {return $file} set file [file join [temporaryDirectory] $file] return [AcceptReadable $file] } proc ReadLoadScript {args} { variable Option - if {"" eq $Option(-loadfile)} {return} + if {$Option(-loadfile) eq {}} {return} set tmp [open $Option(-loadfile) r] loadScript [read $tmp] close $tmp @@ -785,7 +781,8 @@ namespace eval tcltest { trace add variable Option(-loadfile) write [namespace code ReadLoadScript] proc AcceptOutFile { file } { - if {$file in "stderr stdout"} {return $file} + if {[string equal stderr $file]} {return $file} + if {[string equal stdout $file]} {return $file} return [file join [temporaryDirectory] $file] } @@ -808,7 +805,7 @@ namespace eval tcltest { interp eval $slave [package ifneeded tcltest $Version] interp eval $slave "tcltest::configure {*}{$args}" interp alias $slave ::tcltest::ReportToMaster \ - "" ::tcltest::ReportedFromSlave + {} ::tcltest::ReportedFromSlave } proc ReportedFromSlave {total passed skipped failed because newfiles} { variable numTests @@ -881,7 +878,7 @@ proc tcltest::DebugPArray {level arrayvar} { variable debug if {$debug >= $level} { - catch {upvar 1 $arrayvar [set arrayvar]} + catch {upvar 1 $arrayvar $arrayvar} parray $arrayvar } return @@ -965,8 +962,7 @@ proc tcltest::testConstraint {constraint {value ""}} { if {[catch {expr {$value && $value}} msg]} { return -code error $msg } - if {[limitConstraints] && - ($constraint ni $Option(-constraints))} { + if {[limitConstraints] && ($constraint ni $Option(-constraints))} { set value 0 } set testConstraints($constraint) $value @@ -990,11 +986,7 @@ proc tcltest::interpreter { {interp ""} } { if {[llength [info level 0]] == 1} { return $tcltest } - if {"" eq $interp} { - set tcltest "" - } else { - set tcltest $interp - } + set tcltest $interp } ##################################################################### @@ -1059,7 +1051,7 @@ proc tcltest::PrintError {errorMsg} { [expr {80 - $InitialMsgLen}]]] puts [errorChannel] [string range $errorMsg 0 $beginningIndex] - while {"end" ne $beginningIndex} { + while {$beginningIndex ne "end"} { puts -nonewline [errorChannel] \ [string repeat " " $InitialMsgLen] if {($endingIndex - $beginningIndex) @@ -1112,7 +1104,7 @@ proc tcltest::PrintError {errorMsg} { proc tcltest::SafeFetch {n1 n2 op} { variable testConstraints DebugPuts 3 "entering SafeFetch $n1 $n2 $op" - if {"" eq $n2} {return} + if {$n2 eq {}} {return} if {![info exists testConstraints($n2)]} { if {[catch {testConstraint $n2 [eval [ConstraintInitializer $n2]]}]} { testConstraint $n2 0 @@ -1182,13 +1174,13 @@ proc tcltest::DefineConstraintInitializers {} { # constraints. ConstraintInitializer unixOnly \ - {string equal $::tcl_platform(platform) "unix"} + {string equal $::tcl_platform(platform) unix} ConstraintInitializer macOnly \ - {string equal $::tcl_platform(platform) "macintosh"} + {string equal $::tcl_platform(platform) macintosh} ConstraintInitializer pcOnly \ - {string equal $::tcl_platform(platform) "windows"} + {string equal $::tcl_platform(platform) windows} ConstraintInitializer winOnly \ - {string equal $::tcl_platform(platform) "windows"} + {string equal $::tcl_platform(platform) windows} ConstraintInitializer unix {testConstraint unixOnly} ConstraintInitializer mac {testConstraint macOnly} @@ -1257,9 +1249,8 @@ proc tcltest::DefineConstraintInitializers {} { # are running as root on Unix. ConstraintInitializer root {expr \ - {("unix" eq $::tcl_platform(platform)) && - (("root" eq $::tcl_platform(user)) || - ("" eq $::tcl_platform(user)))}} + {($::tcl_platform(platform) eq "unix") && + ($::tcl_platform(user) in {root {}})}} ConstraintInitializer notRoot {expr {![testConstraint root]}} # Set nonBlockFiles constraint: 1 means this platform supports @@ -1268,7 +1259,7 @@ proc tcltest::DefineConstraintInitializers {} { ConstraintInitializer nonBlockFiles { set code [expr {[catch {set f [open defs r]}] || [catch {chan configure $f -blocking off}]}] - catch {chan close $f} + catch {close $f} set code } @@ -1293,10 +1284,10 @@ proc tcltest::DefineConstraintInitializers {} { ConstraintInitializer unixExecs { set code 1 - if {"macintosh" eq $::tcl_platform(platform)} { + if {$::tcl_platform(platform) eq "macintosh"} { set code 0 } - if {"windows" eq $::tcl_platform(platform)} { + if {$::tcl_platform(platform) eq "windows"} { if {[catch { set file _tcl_test_remove_me.txt makeFile {hello} $file @@ -1400,7 +1391,7 @@ proc tcltest::Usage { {option ""} } { append msg \n$line($opt) append msg [string repeat " " [expr {$max - $length($opt)}]] set u [string trim $usage($opt)] - catch {append u " (default: \[[Configure $opt]\])"} + catch {append u " (default: \[[Configure $opt]])"} regsub -all {\s*\n\s*} $u " " u while {[string length $u] > $rest} { set break [string wordstart $u $rest] @@ -1414,7 +1405,7 @@ proc tcltest::Usage { {option ""} } { append msg $u } return $msg\n - } elseif {"-help" eq $option} { + } elseif {$option eq "-help"} { return [list -help "" "Display this usage information."] } else { set type [lindex [info args $Verify($option)] 0] @@ -1441,15 +1432,15 @@ proc tcltest::Usage { {option ""} } { proc tcltest::ProcessFlags {flagArray} { # Process -help first if {"-help" in $flagArray} { - PrintUsageInfo + PrintUsageInfo exit 1 } - if {![llength $flagArray]} { - RemoveAutoConfigureTraces + if {[llength $flagArray] == 0} { + RemoveAutoConfigureTraces } else { set args $flagArray - while {([llength $args] > 1) && [catch {configure {*}$args} msg]} { + while {[llength $args] > 1 && [catch {configure {*}$args} msg]} { # Something went wrong parsing $args for tcltest options # Check whether the problem is "unknown option" @@ -1572,7 +1563,7 @@ namespace eval tcltest::Replace { proc tcltest::Replace::puts {args} { variable [namespace parent]::outData variable [namespace parent]::errData - switch -- [llength $args] { + switch [llength $args] { 1 { # Only the string to be printed is specified append outData [lindex $args 0]\n @@ -1581,7 +1572,7 @@ proc tcltest::Replace::puts {args} { } 2 { # Either -nonewline or channelId has been specified - if {"-nonewline" eq [lindex $args 0]} { + if {[lindex $args 0] eq "-nonewline"} { append outData [lindex $args end] return # return [Puts -nonewline [lindex $args end]] @@ -1591,23 +1582,20 @@ proc tcltest::Replace::puts {args} { } } 3 { - if {"-nonewline" eq [lindex $args 0]} { + if {[lindex $args 0] eq "-nonewline"} { # Both -nonewline and channelId are specified, unless # it's an error. -nonewline is supposed to be argv[0]. set channel [lindex $args 1] set newline "" } } - default {} } if {[info exists channel]} { - if {($channel eq [[namespace parent]::outputChannel]) || - ($channel eq "stdout")} { + if {$channel in [list [[namespace parent]::outputChannel] stdout]} { append outData [lindex $args end]$newline return - } elseif {($channel eq [[namespace parent]::errorChannel]) || - ($channel eq "stderr")} { + } elseif {$channel in [list [[namespace parent]::errorChannel] stderr]} { append errData [lindex $args end]$newline return } @@ -1641,8 +1629,8 @@ proc tcltest::Eval {script {ignoreOutput 1}} { variable errData DebugPuts 3 "[lindex [info level 0] 0] called" if {!$ignoreOutput} { - set outData "" - set errData "" + set outData {} + set errData {} rename ::puts [namespace current]::Replace::Puts namespace eval :: [list namespace import [namespace origin Replace::puts]] namespace import Replace::puts @@ -1750,11 +1738,11 @@ proc tcltest::SubstArguments {argList} { # separated strings as it throws away the whitespace which maybe # important so we have to do it all by hand. - set result "" + set result {} set token "" while {[string length $argList]} { - # Look for the next word containing a quote: \" \{ \} + # Look for the next word containing a quote: " { } if {[regexp -indices {[^ \t\n]*[\"\{\}]+[^ \t\n]*} \ $argList all]} { # Get the text leading up to this word, but not including @@ -1772,11 +1760,11 @@ proc tcltest::SubstArguments {argList} { } else { # Take everything up to the end of the argList. set text $argList - set word "" - set argList [list] + set word {} + set argList {} } - if {$token ne ""} { + if {$token ne {}} { # If we saw a word with quote before, then there is a # multi-word token starting with that word. In this case, # add the text and the current word to this token. @@ -1791,11 +1779,11 @@ proc tcltest::SubstArguments {argList} { set token $word } - if { ([catch {llength $token} length] == 0) && ($length == 1)} { + if { [catch {llength $token} length] == 0 && $length == 1} { # The token is a valid list so add it to the result. # lappend result [string trim $token] append result \{$token\} - set token "" + set token {} } } @@ -1883,7 +1871,7 @@ proc tcltest::test {name description args} { # Pre-define everything to null except output and errorOutput. We # determine whether or not to trap output based on whether or not # these variables (output & errorOutput) are defined. - lassign "" constraints setup cleanup body result returnCodes match + lassign {} constraints setup cleanup body result returnCodes match # Set the default match mode set match exact @@ -1895,8 +1883,7 @@ proc tcltest::test {name description args} { # The old test format can't have a 3rd argument (constraints or # script) that starts with '-'. - if {[string match -* [lindex $args 0]] || - ([llength $args] <= 1)} { + if {[string match -* [lindex $args 0]] || ([llength $args] <= 1)} { if {[llength $args] == 1} { set list [SubstArguments [lindex $args 0]] foreach {element value} $list { @@ -2037,7 +2024,7 @@ proc tcltest::test {name description args} { [file join [workingDirectory] core] \ [file join [temporaryDirectory] core-$name] } msg - if {$msg ne ""} { + if {$msg ne {}} { append coreMsg "\nError:\ Problem renaming core file: $msg" } @@ -2047,7 +2034,7 @@ proc tcltest::test {name description args} { # check if the return code matched the expected return code set codeFailure 0 - if {(!$setupFailure) && ($returnCode ni $returnCodes)} { + if {!$setupFailure && ($returnCode ni $returnCodes)} { set codeFailure 1 } @@ -2055,7 +2042,7 @@ proc tcltest::test {name description args} { # them. If the comparison fails, then so did the test. set outputFailure 0 variable outData - if {[info exists output] && (!$codeFailure)} { + if {[info exists output] && !$codeFailure} { if {[set outputCompare [catch { CompareStrings $outData $output $match } outputMatch]] == 0} { @@ -2067,7 +2054,7 @@ proc tcltest::test {name description args} { set errorFailure 0 variable errData - if {[info exists errorOutput] && (!$codeFailure)} { + if {[info exists errorOutput] && !$codeFailure} { if {[set errorCompare [catch { CompareStrings $errData $errorOutput $match } errorMatch]] == 0} { @@ -2116,8 +2103,8 @@ proc tcltest::test {name description args} { } puts [outputChannel] "\n" if {[IsVerbose line]} { - if {(![catch {set testFrame [info frame -1]}]) && - ([dict get $testFrame type] eq "source")} { + if {![catch {set testFrame [info frame -1]}] && + [dict get $testFrame type] eq "source"} { set testFile [dict get $testFrame file] set testLine [dict get $testFrame line] } else { @@ -2171,7 +2158,7 @@ proc tcltest::test {name description args} { puts [outputChannel] "---- Return code should have been\ one of: $returnCodes" if {[IsVerbose error]} { - if {[info exists errorInfo(body)] && ([lsearch $returnCodes 1] < 0)} { + if {[info exists errorInfo(body)] && (1 ni $returnCodes)} { puts [outputChannel] "---- errorInfo: $errorInfo(body)" puts [outputChannel] "---- errorCode: $errorCode(body)" } @@ -2252,7 +2239,7 @@ proc tcltest::Skipped {name constraints} { } return 1 } - if {"" eq $constraints} { + if {$constraints eq {}} { # If we're limited to the listed constraints and there aren't # any listed, then we shouldn't run the test. if {[limitConstraints]} { @@ -2269,7 +2256,7 @@ proc tcltest::Skipped {name constraints} { set doTest 0 if {[string match {*[$\[]*} $constraints] != 0} { # full expression, e.g. {$foo > [info tclversion]} - catch {set doTest [uplevel \#0 [list expr $constraints]]} + catch {set doTest [uplevel #0 [list expr $constraints]]} } elseif {[regexp {[^.:_a-zA-Z0-9 \n\r\t]+} $constraints] != 0} { # something like {a || b} should be turned into # $testConstraints(a) || $testConstraints(b). @@ -2384,7 +2371,7 @@ proc tcltest::cleanupTests {{calledFromAllFile 0}} { set testFileName [file tail [info script]] # Hook to handle reporting to a parent interpreter - if {[llength [info commands "[namespace current]::ReportToMaster"]]} { + if {[llength [info commands [namespace current]::ReportToMaster]]} { ReportToMaster $numTests(Total) $numTests(Passed) $numTests(Skipped) \ $numTests(Failed) [array get skippedBecause] \ [array get createdNewFiles] @@ -2406,12 +2393,12 @@ proc tcltest::cleanupTests {{calledFromAllFile 0}} { catch {file delete -force -- $file} } } - set currentFiles [list] + set currentFiles {} foreach file [glob -nocomplain \ -directory [temporaryDirectory] *] { lappend currentFiles [file tail $file] } - set newFiles [list] + set newFiles {} foreach file $currentFiles { if {$file ni $filesExisted} { lappend newFiles $file @@ -2444,7 +2431,7 @@ proc tcltest::cleanupTests {{calledFromAllFile 0}} { if {[llength $failFiles] > 0} { puts [outputChannel] \ "Files with failing tests: $failFiles" - set failFiles [list] + set failFiles {} } } @@ -2487,7 +2474,7 @@ proc tcltest::cleanupTests {{calledFromAllFile 0}} { # loop is running, which is the real issue. # Actually, this doesn't belong here at all. A package # really has no business [exit]-ing an application. - if {(![catch {package present Tk}]) && (![testConstraint interactive])} { + if {![catch {package present Tk}] && ![testConstraint interactive]} { exit } } else { @@ -2560,7 +2547,7 @@ proc tcltest::cleanupTests {{calledFromAllFile 0}} { [file join [workingDirectory] core] \ [file join [temporaryDirectory] core-$testFileName] } msg - if {$msg ne ""} { + if {$msg ne {}} { PrintError "Problem renaming file: $msg" } } else { @@ -2605,9 +2592,7 @@ proc tcltest::cleanupTests {{calledFromAllFile 0}} { # None # a lower case version is needed for compatibility with tcltest 1.0 -proc tcltest::getMatchingFiles {args} { - GetMatchingFiles {*}$args -} +proc tcltest::getMatchingFiles args {GetMatchingFiles {*}$args} proc tcltest::GetMatchingFiles { args } { if {[llength $args]} { @@ -2739,8 +2724,8 @@ proc tcltest::runAllTests { {shell ""} } { [temporaryDirectory]" # [file system] first available in Tcl 8.4 - if {(![catch {file system [testsDirectory]} result]) && - ("native" ne [lindex $result 0])} { + if {![catch {file system [testsDirectory]} result] + && ([lindex $result 0] ne "native")} { # If we aren't running in the native filesystem, then we must # run the tests in a single process (via 'source'), because # trying to run then via a pipe will fail since the files don't @@ -2800,7 +2785,7 @@ proc tcltest::runAllTests { {shell ""} } { incr numTestFiles set pipeFd [open $cmd "r"] while {[gets $pipeFd line] >= 0} { - if {[regexp -- [join { + if {[regexp [join { {^([^:]+):\t} {Total\t([0-9]+)\t} {Passed\t([0-9]+)\t} @@ -2809,12 +2794,12 @@ proc tcltest::runAllTests { {shell ""} } { } ""] $line null testFile \ Total Passed Skipped Failed]} { foreach index {Total Passed Skipped Failed} { - incr numTests($index) [set [set index]] + incr numTests($index) [set $index] } if {$Failed > 0} { lappend failFiles $testFile } - } elseif {[regexp -- [join { + } elseif {[regexp [join { {^Number of tests skipped } {for each constraint:} {|^\t(\d+)\t(.+)$} @@ -2883,11 +2868,6 @@ proc tcltest::runAllTests { {shell ""} } { # none. proc tcltest::loadTestedCommands {} { - variable l - if {"" eq [loadScript]} { - return - } - return [uplevel 1 [loadScript]] } @@ -2930,8 +2910,7 @@ proc tcltest::saveState {} { proc tcltest::restoreState {} { variable saveState foreach p [uplevel 1 {::info procs}] { - if {($p ni [lindex $saveState 0]) && - ("[namespace current]::$p" ne \ + if {($p ni [lindex $saveState 0]) && ("[namespace current]::$p" ne [uplevel 1 [list ::namespace origin $p]])} { DebugPuts 2 "[lindex [info level 0] 0]: Removing proc $p" @@ -3212,9 +3191,9 @@ proc tcltest::OpenFiles {} { proc tcltest::LeakFiles {old} { if {[catch {testchannel open} new]} { - return "" + return {} } - set leak [list] + set leak {} foreach p $new { if {$p ni $old} { lappend leak $p @@ -3287,7 +3266,7 @@ proc tcltest::RestoreLocale {} { # proc tcltest::threadReap {} { - if {[info commands testthread] ne ""} { + if {[info commands testthread] ne {}} { # testthread built into tcltest @@ -3307,7 +3286,7 @@ proc tcltest::threadReap {} { } testthread errorproc ThreadError return [llength [testthread names]] - } elseif {[info commands thread::id] ne ""} { + } elseif {[info commands thread::id] ne {}} { # Thread extension @@ -3346,7 +3325,7 @@ namespace eval tcltest { # for compatibility support. The modern way to add a custom # test constraint is to just call the [testConstraint] command # straight away, without all this "hook" nonsense. - if {[namespace current] eq \ + if {[namespace current] eq [namespace qualifiers [namespace which initConstraintsHook]]} { InitConstraints } else { @@ -3391,11 +3370,11 @@ namespace eval tcltest { } foreach hook { PrintUsageInfoHook processCmdLineArgsHook processCmdLineArgsAddFlagsHook } { - if {[namespace current] eq [namespace qualifiers \ - [namespace which $hook]]} { + if {[namespace current] eq + [namespace qualifiers [namespace which $hook]]} { set required true } else { - proc $hook {args} {} + proc $hook args {} } } return $required diff --git a/library/tm.tcl b/library/tm.tcl index f821abb..d2af4f5 100644 --- a/library/tm.tcl +++ b/library/tm.tcl @@ -45,7 +45,7 @@ namespace eval ::tcl::tm { # Default paths. None yet. - variable paths [list] + variable paths {} # The regex pattern a file name has to match to make it a Tcl Module. @@ -203,11 +203,11 @@ proc ::tcl::tm::UnknownHandler {original name args} { set satisfied 0 foreach path $paths { - if {(![interp issafe]) && (![file exists $path])} { + if {![interp issafe] && ![file exists $path]} { continue } set currentsearchpath [file join $path $pkgroot] - if {(![interp issafe]) && (![file exists $currentsearchpath])} { + if {![interp issafe] && ![file exists $currentsearchpath]} { continue } set strip [llength [file split $path]] @@ -225,7 +225,7 @@ proc ::tcl::tm::UnknownHandler {original name args} { foreach file [glob -nocomplain -directory $currentsearchpath *.tm] { set pkgfilename [join [lrange [file split $file] $strip end] ::] - if {![regexp -- $pkgpattern $pkgfilename ___ pkgname pkgversion]} { + if {![regexp -- $pkgpattern $pkgfilename --> pkgname pkgversion]} { # Ignore everything not matching our pattern for # package names. continue @@ -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] - } { + 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} { - lassign [split [info tclversion] "."] major minor + 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} { diff --git a/library/word.tcl b/library/word.tcl index 14bcf2d..b8f34a5 100644 --- a/library/word.tcl +++ b/library/word.tcl @@ -31,7 +31,7 @@ namespace eval ::tcl { variable WordBreakRE array set WordBreakRE {} - proc UpdateWordBreakREs {args} { + proc UpdateWordBreakREs args { # Ignores the arguments global tcl_wordchars tcl_nonwordchars variable WordBreakRE @@ -66,7 +66,7 @@ namespace eval ::tcl { proc tcl_wordBreakAfter {str start} { variable ::tcl::WordBreakRE - set result [list -1 -1] + set result {-1 -1} regexp -indices -start $start -- $WordBreakRE(after) $str result return [lindex $result 1] } @@ -84,7 +84,7 @@ proc tcl_wordBreakAfter {str start} { proc tcl_wordBreakBefore {str start} { variable ::tcl::WordBreakRE - set result [list -1 -1] + set result {-1 -1} regexp -indices -- $WordBreakRE(before) [string range $str 0 $start] result return [lindex $result 1] } @@ -103,7 +103,7 @@ proc tcl_wordBreakBefore {str start} { proc tcl_endOfWord {str start} { variable ::tcl::WordBreakRE - set result [list -1 -1] + set result {-1 -1} regexp -indices -start $start -- $WordBreakRE(end) $str result return [lindex $result 1] } @@ -121,7 +121,7 @@ proc tcl_endOfWord {str start} { proc tcl_startOfNextWord {str start} { variable ::tcl::WordBreakRE - set result [list -1 -1] + set result {-1 -1} regexp -indices -start $start -- $WordBreakRE(next) $str result return [lindex $result 1] } @@ -137,7 +137,7 @@ proc tcl_startOfNextWord {str start} { proc tcl_startOfPreviousWord {str start} { variable ::tcl::WordBreakRE - set word [list -1 -1] + set word {-1 -1} regexp -indices -- $WordBreakRE(previous) [string range $str 0 $start-1] \ result word return [lindex $word 0] |