Tcl Source Code

Artifact [5e3cd404d9]
Login

Artifact 5e3cd404d9ae59d27db09ddf390dba9cb4f0a7a8:

Attachment "import.patch" to ticket [420186ffff] added by dgp 2001-05-04 05:36:09.
Index: ChangeLog
===================================================================
RCS file: /cvsroot/tcl/tcl/ChangeLog,v
retrieving revision 1.430
diff -u -r1.430 ChangeLog
--- ChangeLog	2001/05/03 21:14:57	1.430
+++ ChangeLog	2001/05/03 22:33:14
@@ -1,3 +1,13 @@
+2001-05-03  Don Porter  <[email protected]>
+
+	* 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  <[email protected]>
 
 	* generic/tclParse.c: 
Index: doc/library.n
===================================================================
RCS file: /cvsroot/tcl/tcl/doc/library.n,v
retrieving revision 1.14
diff -u -r1.14 library.n
--- doc/library.n	2000/09/07 14:27:49	1.14
+++ doc/library.n	2001/05/03 22:33:14
@@ -81,7 +81,8 @@
 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
Index: library/init.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/library/init.tcl,v
retrieving revision 1.46
diff -u -r1.46 init.tcl
--- library/init.tcl	2001/04/07 02:10:17	1.46
+++ library/init.tcl	2001/05/03 22:33:14
@@ -501,9 +501,10 @@
     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)
             }
         }
Index: tests/autoMkindex.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/autoMkindex.tcl,v
retrieving revision 1.2
diff -u -r1.2 autoMkindex.tcl
--- tests/autoMkindex.tcl	1999/03/31 18:58:50	1.2
+++ tests/autoMkindex.tcl	2001/05/03 22:33:14
@@ -71,3 +71,12 @@
     {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 {} {}
+
Index: tests/autoMkindex.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/autoMkindex.test,v
retrieving revision 1.11
diff -u -r1.11 autoMkindex.test
--- tests/autoMkindex.test	2000/04/10 17:18:57	1.11
+++ tests/autoMkindex.test	2001/05/03 22:33:15
@@ -70,7 +70,7 @@
     }
     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 @@
 
     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} {