summaryrefslogtreecommitdiffstats
path: root/library/init.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'library/init.tcl')
-rw-r--r--library/init.tcl69
1 files changed, 33 insertions, 36 deletions
diff --git a/library/init.tcl b/library/init.tcl
index 7287398..e188329 100644
--- a/library/init.tcl
+++ b/library/init.tcl
@@ -3,7 +3,7 @@
# Default system startup file for Tcl-based applications. Defines
# "unknown" procedure and auto-load facilities.
#
-# RCS: @(#) $Id: init.tcl,v 1.32 1999/08/09 16:30:50 hobbs Exp $
+# RCS: @(#) $Id: init.tcl,v 1.33 1999/08/19 02:59:40 hobbs Exp $
#
# Copyright (c) 1991-1993 The Regents of the University of California.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
@@ -72,7 +72,7 @@ if {[info exists __dir]} {
# Windows specific end of initialization
-if {(![interp issafe]) && ($tcl_platform(platform) == "windows")} {
+if {(![interp issafe]) && [string equal $tcl_platform(platform) "windows"]} {
namespace eval tcl {
proc envTraceProc {lo n1 n2 op} {
set x $::env($n2)
@@ -82,7 +82,7 @@ if {(![interp issafe]) && ($tcl_platform(platform) == "windows")} {
}
foreach p [array names env] {
set u [string toupper $p]
- if {$u != $p} {
+ if {[string compare $u $p]} {
switch -- $u {
COMSPEC -
PATH {
@@ -102,7 +102,7 @@ if {(![interp issafe]) && ($tcl_platform(platform) == "windows")} {
unset u
}
if {![info exists env(COMSPEC)]} {
- if {$tcl_platform(os) == {Windows NT}} {
+ if {[string equal $tcl_platform(os) "Windows NT"]} {
set env(COMSPEC) cmd.exe
} else {
set env(COMSPEC) command.com
@@ -116,7 +116,7 @@ package unknown tclPkgUnknown
# Conditionalize for presence of exec.
-if {[info commands exec] == ""} {
+if {[llength [info commands exec]] == 0} {
# Some machines, such as the Macintosh, do not have exec. Also, on all
# platforms, safe interpreters do not have exec.
@@ -129,7 +129,7 @@ set errorInfo ""
# Define a log command (which can be overwitten to log errors
# differently, specially when stderr is not available)
-if {[info commands tclLog] == ""} {
+if {[llength [info commands tclLog]] == 0} {
proc tclLog {string} {
catch {puts stderr $string}
}
@@ -219,7 +219,7 @@ proc unknown args {
}
}
- if {([info level] == 1) && ([info script] == "") \
+ if {([info level] == 1) && [string equal [info script] ""] \
&& [info exists tcl_interactive] && $tcl_interactive} {
if {![info exists auto_noexec]} {
set new [auto_execok $name]
@@ -227,7 +227,7 @@ proc unknown args {
set errorCode $savedErrorCode
set errorInfo $savedErrorInfo
set redir ""
- if {[info commands console] == ""} {
+ if {[string equal [info commands console] ""]} {
set redir ">&@stdout <@stdin"
}
return [uplevel exec $redir $new [lrange $args 1 end]]
@@ -235,7 +235,7 @@ proc unknown args {
}
set errorCode $savedErrorCode
set errorInfo $savedErrorInfo
- if {$name == "!!"} {
+ if {[string equal $name "!!"]} {
set newcmd [history event]
} elseif {[regexp {^!(.+)$} $name dummy event]} {
set newcmd [history event $event]
@@ -250,7 +250,7 @@ proc unknown args {
}
set ret [catch {set cmds [info commands $name*]} msg]
- if {[string compare $name "::"] == 0} {
+ if {[string equal $name "::"]} {
set name ""
}
if {$ret != 0} {
@@ -260,8 +260,8 @@ proc unknown args {
if {[llength $cmds] == 1} {
return [uplevel [lreplace $args 0 0 $cmds]]
}
- if {[llength $cmds] != 0} {
- if {$name == ""} {
+ if {[llength $cmds]} {
+ if {[string equal $name ""]} {
return -code error "empty command name \"\""
} else {
return -code error \
@@ -311,7 +311,7 @@ proc auto_load {cmd {namespace {}}} {
foreach name $nameList {
if {[info exists auto_index($name)]} {
uplevel #0 $auto_index($name)
- if {[info commands $name] != ""} {
+ if {[string compare [info commands $name] ""]} {
return 1
}
}
@@ -331,10 +331,9 @@ proc auto_load {cmd {namespace {}}} {
proc auto_load_index {} {
global auto_index auto_oldpath auto_path errorInfo errorCode
- if {[info exists auto_oldpath]} {
- if {$auto_oldpath == $auto_path} {
- return 0
- }
+ if {[info exists auto_oldpath] && \
+ [string equal $auto_oldpath $auto_path]} {
+ return 0
}
set auto_oldpath $auto_path
@@ -352,25 +351,24 @@ proc auto_load_index {} {
} else {
set error [catch {
set id [gets $f]
- if {$id == "# Tcl autoload index file, version 2.0"} {
+ if {[string equal $id \
+ "# Tcl autoload index file, version 2.0"]} {
eval [read $f]
- } elseif {$id == \
- "# Tcl autoload index file: each line identifies a Tcl"} {
+ } elseif {[string equal $id "# Tcl autoload index file: each line identifies a Tcl"]} {
while {[gets $f line] >= 0} {
- if {([string index $line 0] == "#")
+ if {[string equal [string index $line 0] "#"] \
|| ([llength $line] != 2)} {
continue
}
set name [lindex $line 0]
set auto_index($name) \
- "source [file join $dir [lindex $line 1]]"
+ "source [file join $dir [lindex $line 1]]"
}
} else {
- error \
- "[file join $dir tclIndex] isn't a proper Tcl index file"
+ error "[file join $dir tclIndex] isn't a proper Tcl index file"
}
} msg]
- if {$f != ""} {
+ if {[string compare $f ""]} {
close $f
}
if {$error} {
@@ -423,21 +421,19 @@ proc auto_qualify {cmd namespace} {
# (if the current namespace is not the global one)
if {$n == 0} {
- if {[string compare $namespace ::] == 0} {
+ if {[string equal $namespace ::]} {
# ( nocolons , :: ) -> nocolons
return [list $cmd]
} else {
# ( nocolons , ::sub ) -> ::sub::nocolons nocolons
return [list ${namespace}::$cmd $cmd]
}
+ } elseif {[string equal $namespace ::]} {
+ # ( foo::bar , :: ) -> ::foo::bar
+ return [list ::$cmd]
} else {
- if {[string compare $namespace ::] == 0} {
- # ( foo::bar , :: ) -> ::foo::bar
- return [list ::$cmd]
- } else {
- # ( foo::bar , ::sub ) -> ::sub::foo::bar ::foo::bar
- return [list ${namespace}::$cmd ::$cmd]
- }
+ # ( foo::bar , ::sub ) -> ::sub::foo::bar ::foo::bar
+ return [list ${namespace}::$cmd ::$cmd]
}
}
@@ -462,7 +458,8 @@ proc auto_import {pattern} {
foreach pattern $patternList {
foreach name [array names auto_index] {
- if {[string match $pattern $name] && "" == [info commands $name]} {
+ if {[string match $pattern $name] && \
+ [string equal "" [info commands $name]]} {
uplevel #0 $auto_index($name)
}
}
@@ -516,7 +513,7 @@ proc auto_execok name {
set windir $env(WINDIR)
}
if {[info exists windir]} {
- if {$tcl_platform(os) == "Windows NT"} {
+ if {[string equal $tcl_platform(os) "Windows NT"]} {
append path "$windir/system32;"
}
append path "$windir/system;$windir;"
@@ -559,7 +556,7 @@ proc auto_execok name {
return $auto_execs($name)
}
foreach dir [split $env(PATH) :] {
- if {$dir == ""} {
+ if {[string equal $dir ""]} {
set dir .
}
set file [file join $dir $name]