home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.tcl
- Path: sparky!uunet!mdisea!kelsey
- From: kelsey@mdd.comm.mot.com (Joe Kelsey)
- Subject: Bug in extended Tcl: LoadPackageIndexes
- Message-ID: <1992Sep15.221703.18160@mdd.comm.mot.com>
- Summary: Loads *last* package in a path instead of *first* package in a path.
- Keywords: TCLPATH auto_path TCLSH LoadPackageIndexes demand_load
- Sender: news@mdd.comm.mot.com
- Organization: Motorola, Mobile Data Division - Seattle, WA
- Date: Tue, 15 Sep 1992 22:17:03 GMT
- Lines: 54
-
- Extended TCL searches through the TCLPATH looking for files named *.tlib.
- Whenever it finds one, it loads the package index. At the end of this
- process, it then looks for defined procs. If you use TCLPATH, expecting it to
- operate like PATH, with an earlier instance of a name superseding a later
- instance of a name, you can expect surprises! The problem occurs if you try
- to test a new package by placing it in a directory path in front of the
- standard path, for example,
-
- set TCLPATH {../local /usr/local/lib/tcl /usr/local/lib/tk}
-
- Then place test.tlib in ../local, with the ``official'' version in
- /usr/local/lib/tcl. The TCLSH:LoadPackageIndexes command uses the full
- pathname to determine if it already loaded a package instead of the last file
- name, thus resulting in the last package encountered becoming the loaded
- package! I think the problem occurred because the ``Ouster'' style indexing
- allows only one index per directory, while the extended package concept places
- an index per package library file.
-
- I fixed the problem by changing the TCLENV(LOADED:xxx) array element to
- mention just the package name rather than the full path name:
-
- *** extended/tcllib/TclInit.tcl.orig Sat Aug 22 09:26:56 1992
- --- extended/tcllib/TclInit.tcl Tue Sep 15 13:22:14 1992
- ***************
- *** 58,69 ****
- # Load library indexes along path.
- #
- proc TCLSH:LoadPackageIndexes {path} {
- ! global TCLPATH TCLENV
- foreach dir $path {
- foreach libFile [glob -nocomplain $dir/*.tlib] {
- ! if ![info exists TCLENV(LOADED:$libFile)] {
- loadlibindex $libFile
- ! set TCLENV(LOADED:$libFile) 1
- }
- }
- if {[file readable $dir/tclIndex] && ![info exists TCLENV(LOADED:$dir/tclIndex)]} {
- --- 58,70 ----
- # Load library indexes along path.
- #
- proc TCLSH:LoadPackageIndexes {path} {
- ! global TCLENV
- foreach dir $path {
- foreach libFile [glob -nocomplain $dir/*.tlib] {
- ! set libName [string range $libFile [expr [string last / $libFile]+1] end]
- ! if ![info exists TCLENV(LOADED:$libName)] {
- loadlibindex $libFile
- ! set TCLENV(LOADED:$libName) 1
- }
- }
- if {[file readable $dir/tclIndex] && ![info exists TCLENV(LOADED:$dir/tclIndex)]} {
-
- /Joe
-
-