diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-03-04 13:34:26 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-03-04 13:34:26 (GMT) |
| commit | f7829afaab261c9156598b36a008a4cac1eb3b86 (patch) | |
| tree | c00b70af48012a41888195a8c2a64953e15262ee | |
| parent | 423d8bf1e34f5281814b35f98870ad998d807b3e (diff) | |
| parent | 65cf4531a3d2d7d40b37d1cc4cda45bf80678b27 (diff) | |
| download | tcl-f7829afaab261c9156598b36a008a4cac1eb3b86.zip tcl-f7829afaab261c9156598b36a008a4cac1eb3b86.tar.gz tcl-f7829afaab261c9156598b36a008a4cac1eb3b86.tar.bz2 | |
Merge 8.7
| -rw-r--r-- | library/init.tcl | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/library/init.tcl b/library/init.tcl index 96d410c..95081ec 100644 --- a/library/init.tcl +++ b/library/init.tcl @@ -15,10 +15,6 @@ # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# 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 9.0b1 # Compute the auto path to use in this interpreter. @@ -60,6 +56,7 @@ if {![info exists auto_path]} { set auto_path "" } } + namespace eval tcl { if {![interp issafe]} { variable Dir @@ -363,16 +360,20 @@ proc unknown args { proc auto_load {cmd {namespace {}}} { global auto_index auto_path + # qualify names: if {$namespace eq ""} { set namespace [uplevel 1 [list ::namespace current]] } set nameList [auto_qualify $cmd $namespace] # workaround non canonical auto_index entries that might be around # from older auto_mkindex versions - lappend nameList $cmd - foreach name $nameList { + if {$cmd ni $nameList} {lappend nameList $cmd} + + # try to load (and create sub-cmd handler "_sub_load_cmd" for further usage): + foreach name $nameList [set _sub_load_cmd { + # via auto_index: if {[info exists auto_index($name)]} { - namespace eval :: $auto_index($name) + namespace inscope :: $auto_index($name) # There's a couple of ways to look for a command of a given # name. One is to use # info commands $name @@ -384,22 +385,19 @@ proc auto_load {cmd {namespace {}}} { return 1 } } - } + }] + + # load auto_index if possible: if {![info exists auto_path]} { return 0 } - if {![auto_load_index]} { return 0 } - foreach name $nameList { - if {[info exists auto_index($name)]} { - namespace eval :: $auto_index($name) - if {[namespace which -command $name] ne ""} { - return 1 - } - } - } + + # try again (something new could be loaded): + foreach name $nameList $_sub_load_cmd + return 0 } @@ -566,7 +564,7 @@ proc auto_import {pattern} { foreach name [array names auto_index $pattern] { if {([namespace which -command $name] eq "") && ([namespace qualifiers $pattern] eq [namespace qualifiers $name])} { - namespace eval :: $auto_index($name) + namespace inscope :: $auto_index($name) } } } @@ -629,7 +627,7 @@ proc auto_execok name { return "" } - set path "[file dirname [info nameof]];.;" + set path "[file dirname [info nameofexecutable]];.;" if {[info exists env(SystemRoot)]} { set windir $env(SystemRoot) } elseif {[info exists env(WINDIR)]} { |
