summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2001-05-03 22:38:20 (GMT)
committerdgp <dgp@users.sourceforge.net>2001-05-03 22:38:20 (GMT)
commit30b6ae94051b57f5a17ab9ca7a7c3ffd6615680e (patch)
tree3556e64731aaee88def2382ca03907296de5e342
parentbe1d3ffdb010f8ac70bfb807fca3631897628951 (diff)
downloadtcl-30b6ae94051b57f5a17ab9ca7a7c3ffd6615680e.zip
tcl-30b6ae94051b57f5a17ab9ca7a7c3ffd6615680e.tar.gz
tcl-30b6ae94051b57f5a17ab9ca7a7c3ffd6615680e.tar.bz2
Fix for Bug 420186
-rw-r--r--ChangeLog10
-rw-r--r--doc/library.n5
-rw-r--r--library/init.tcl9
-rw-r--r--tests/autoMkindex.tcl9
-rw-r--r--tests/autoMkindex.test6
5 files changed, 30 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 2fb859f..d19c164 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2001-05-03 Don Porter <dgp@users.sourceforge.net>
+
+ * doc/library.n:
+ * library/init.tcl:
+ * tests/autoMkindex.test: Modified [auto_import] to apply
+ pattern matching in the [namespace import] style. [Bug 420186]
+ ***POTENTIAL INCOMPATIBILITY*** for any callers of [auto_import]
+ from outside Tcl that expect the pattern matching to be like that
+ of [string match].
+
2001-05-03 Miguel Sofer <msofer@users.sourceforge.net>
* generic/tclParse.c:
diff --git a/doc/library.n b/doc/library.n
index 72e659e..7687de1 100644
--- a/doc/library.n
+++ b/doc/library.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: library.n,v 1.14 2000/09/07 14:27:49 poenitz Exp $
+'\" RCS: @(#) $Id: library.n,v 1.15 2001/05/03 22:38:20 dgp Exp $
.so man.macros
.TH library n "8.0" Tcl "Tcl Built-In Commands"
.BS
@@ -81,7 +81,8 @@ the imported commands specified by \fIpattern\fR reside in an
autoloaded library. If so, the commands are loaded so that they will
be available to the interpreter for creating the import links. If the
commands do not reside in an autoloaded library, \fBauto_import\fR
-does nothing.
+does nothing. The pattern matching is performed according to the
+matching rules of \fBnamespace importer\fR.
.TP
\fBauto_load \fIcmd\fR
This command attempts to load the definition for a Tcl command named
diff --git a/library/init.tcl b/library/init.tcl
index 6dcf926..c739c29 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.46 2001/04/07 02:10:17 msofer Exp $
+# RCS: @(#) $Id: init.tcl,v 1.47 2001/05/03 22:38:20 dgp Exp $
#
# Copyright (c) 1991-1993 The Regents of the University of California.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
@@ -501,9 +501,10 @@ proc auto_import {pattern} {
auto_load_index
foreach pattern $patternList {
- foreach name [array names auto_index] {
- if {[string match $pattern $name] && \
- [string equal "" [info commands $name]]} {
+ foreach name [array names auto_index $pattern] {
+ if {[string equal "" [info commands $name]]
+ && [string equal [namespace qualifiers $pattern] \
+ [namespace qualifiers $name]]} {
uplevel #0 $auto_index($name)
}
}
diff --git a/tests/autoMkindex.tcl b/tests/autoMkindex.tcl
index 2756358..8e9e74d 100644
--- a/tests/autoMkindex.tcl
+++ b/tests/autoMkindex.tcl
@@ -71,3 +71,12 @@ namespace eval ::buried {
{my proc} mycmd5 args {return "mycmd"}
}
{::buried::my proc} mycmd6 args {return "another"}
+
+# A correctly functioning [auto_import] won't choke when a child
+# namespace [namespace import]s from its parent.
+#
+namespace eval ::parent::child {
+ namespace import ::parent::*
+}
+proc ::parent::child::test {} {}
+
diff --git a/tests/autoMkindex.test b/tests/autoMkindex.test
index 4be6bee..77c4d80 100644
--- a/tests/autoMkindex.test
+++ b/tests/autoMkindex.test
@@ -9,7 +9,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: autoMkindex.test,v 1.11 2000/04/10 17:18:57 ericm Exp $
+# RCS: @(#) $Id: autoMkindex.test,v 1.12 2001/05/03 22:38:20 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -70,7 +70,7 @@ test autoMkindex-1.3 {examine tclIndex} {
}
namespace delete tcl_autoMkindex_tmp
set ::result
-} "{::buried::explicit $element} {::buried::inside $element} {{::buried::my proc} $element} {::buried::mycmd1 $element} {::buried::mycmd4 $element} {::buried::myproc $element} {::buried::pub_one $element} {::buried::pub_two $element} {::buried::relative $element} {::buried::under::neath $element} {::buried::within $element} {indented $element} {normal $element} {top $element}"
+} "{::buried::explicit $element} {::buried::inside $element} {{::buried::my proc} $element} {::buried::mycmd1 $element} {::buried::mycmd4 $element} {::buried::myproc $element} {::buried::pub_one $element} {::buried::pub_two $element} {::buried::relative $element} {::buried::under::neath $element} {::buried::within $element} {::parent::child::test $element} {indented $element} {normal $element} {top $element}"
test autoMkindex-2.1 {commands on the autoload path can be imported} {
@@ -138,7 +138,7 @@ test autoMkindex-3.2 {auto_mkindex_parser::command} {
AutoMkindexTestReset
set ::result
-} "{::buried::explicit $element} {::buried::inside $element} {{::buried::my proc} $element} {::buried::mycmd1 $element} {::buried::mycmd2 $element} {::buried::mycmd4 $element} {::buried::myproc $element} {::buried::pub_one $element} {::buried::pub_two $element} {::buried::relative $element} {::buried::under::neath $element} {::buried::within $element} {indented $element} {mycmd3 $element} {normal $element} {top $element}"
+} "{::buried::explicit $element} {::buried::inside $element} {{::buried::my proc} $element} {::buried::mycmd1 $element} {::buried::mycmd2 $element} {::buried::mycmd4 $element} {::buried::myproc $element} {::buried::pub_one $element} {::buried::pub_two $element} {::buried::relative $element} {::buried::under::neath $element} {::buried::within $element} {::parent::child::test $element} {indented $element} {mycmd3 $element} {normal $element} {top $element}"
test autoMkindex-3.3 {auto_mkindex_parser::command} {knownBug} {