summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tclInterp.c86
1 files changed, 41 insertions, 45 deletions
diff --git a/generic/tclInterp.c b/generic/tclInterp.c
index d1e4a7f..0a1e346 100644
--- a/generic/tclInterp.c
+++ b/generic/tclInterp.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclInterp.c,v 1.56 2005/04/12 20:28:47 dgp Exp $
+ * RCS: @(#) $Id: tclInterp.c,v 1.57 2005/04/15 22:41:43 dgp Exp $
*/
#include "tclInt.h"
@@ -350,64 +350,60 @@ Tcl_Init(interp)
code = Tcl_Eval(interp,
"if {[info proc tclInit]==\"\"} {\n"
" proc tclInit {} {\n"
-" global tcl_libPath tcl_library\n"
-" global env tclDefaultLibrary\n"
-" variable ::tcl::LibPath\n"
+" global tcl_libPath tcl_library env tclDefaultLibrary\n"
" rename tclInit {}\n"
-" set errors {}\n"
-" set localPath {}\n"
-" set LibPath {}\n"
" if {[info exists tcl_library]} {\n"
-" lappend localPath $tcl_library\n"
+" set scripts {{set tcl_library}}\n"
" } else {\n"
-" if {[info exists env(TCL_LIBRARY)]\n"
-" && [string length $env(TCL_LIBRARY)]} {\n"
-" lappend localPath $env(TCL_LIBRARY)\n"
-" lappend LibPath $env(TCL_LIBRARY)\n"
-" if {[regexp ^tcl(.*)$ [file tail $env(TCL_LIBRARY)] -> tail]} {\n"
-" if {$tail ne [info tclversion]} {\n"
-" lappend localPath [file join [file dirname\\\n"
-" $env(TCL_LIBRARY)] tcl[info tclversion]]\n"
-" lappend LibPath [file join [file dirname\\\n"
-" $env(TCL_LIBRARY)] tcl[info tclversion]]\n"
-" }\n"
-" }\n"
+" set scripts {}\n"
+" if {[info exists env(TCL_LIBRARY)] && ($env(TCL_LIBRARY) ne {})} {\n"
+" lappend scripts {set env(TCL_LIBRARY)}\n"
+" lappend scripts {\n"
+"if {[regexp ^tcl(.*)$ [file tail $env(TCL_LIBRARY)] -> tail] == 0} continue\n"
+"if {$tail eq [info tclversion]} continue\n"
+"file join [file dirname $env(TCL_LIBRARY)] tcl[info tclversion]}\n"
" }\n"
-" if {[catch {\n"
-" lappend localPath $tclDefaultLibrary\n"
-" unset tclDefaultLibrary\n"
-" }]} {\n"
-" lappend localPath [::tcl::pkgconfig get scriptdir,runtime]\n"
+" if {[info exists tclDefaultLibrary]} {\n"
+" lappend scripts {set tclDefaultLibrary}\n"
+" } else {\n"
+" lappend scripts {::tcl::pkgconfig get scriptdir,runtime}\n"
" }\n"
-" set parentDir [file normalize [file dirname [file dirname\\\n"
-" [info nameofexecutable]]]]\n"
-" set grandParentDir [file dirname $parentDir]\n"
-" lappend LibPath [file join $parentDir lib tcl[info tclversion]]\n"
-" lappend LibPath [file join $grandParentDir lib tcl[info tclversion]]\n"
-" lappend LibPath [file join $parentDir library]\n"
-" lappend LibPath [file join $grandParentDir library]\n"
-" lappend LibPath [file join $grandParentDir\\\n"
-" tcl[info patchlevel] library]\n"
-" lappend LibPath [file join [file dirname $grandParentDir]\\\n"
-" tcl[info patchlevel] library]\n"
-" catch {\n"
-" set LibPath [concat $LibPath $tcl_libPath]\n"
+" lappend scripts {\n"
+"set parentDir [file dirname [file dirname [info nameofexecutable]]]\n"
+"set grandParentDir [file dirname $parentDir]\n"
+"file join $parentDir lib tcl[info tclversion]} \\\n"
+" {file join $grandParentDir lib tcl[info tclversion]} \\\n"
+" {file join $parentDir library} \\\n"
+" {file join $grandParentDir library} \\\n"
+" {file join $grandParentDir tcl[info patchlevel] library} \\\n"
+" {\n"
+"file join [file dirname $grandParentDir] tcl[info patchlevel] library}\n"
+" if {[info exists tcl_libPath]\n"
+" && [catch {llength $tcl_libPath} len] == 0} {\n"
+" for {set i 0} {$i < $len} {incr i} {\n"
+" lappend scripts [list lindex \\$tcl_libPath $i]\n"
+" }\n"
" }\n"
" }\n"
-" foreach i [concat $localPath $LibPath] {\n"
-" set tcl_library $i\n"
-" set tclfile [file join $i init.tcl]\n"
+" set dirs {}\n"
+" set errors {}\n"
+" foreach script $scripts {\n"
+" lappend dirs [eval $script]\n"
+" set tcl_library [lindex $dirs end]\n"
+" set tclfile [file join $tcl_library init.tcl]\n"
" if {[file exists $tclfile]} {\n"
-" if {![catch {uplevel #0 [list source $tclfile]} msg opts]} {\n"
-" return\n"
-" } else {\n"
+" if {[catch {uplevel #0 [list source $tclfile]} msg opts]} {\n"
" append errors \"$tclfile: $msg\n\"\n"
" append errors \"[dict get $opts -errorinfo]\n\"\n"
+" continue\n"
" }\n"
+" unset -nocomplain tclDefaultLibrary\n"
+" return\n"
" }\n"
" }\n"
+" unset -nocomplain tclDefaultLibrary\n"
" set msg \"Can't find a usable init.tcl in the following directories: \n\"\n"
-" append msg \" $localPath $LibPath\n\n\"\n"
+" append msg \" $dirs\n\n\"\n"
" append msg \"$errors\n\n\"\n"
" append msg \"This probably means that Tcl wasn't installed properly.\n\"\n"
" error $msg\n"