diff options
author | ericm <ericm> | 2000-01-27 19:48:29 (GMT) |
---|---|---|
committer | ericm <ericm> | 2000-01-27 19:48:29 (GMT) |
commit | d8c3ee2177ba3302b1caf7fe451592c210d68212 (patch) | |
tree | 24c3203693a2642f3a3c42276897974f14712b60 | |
parent | b51a945c65f5f8555db941619e83775ad306b65b (diff) | |
download | tcl-d8c3ee2177ba3302b1caf7fe451592c210d68212.zip tcl-d8c3ee2177ba3302b1caf7fe451592c210d68212.tar.gz tcl-d8c3ee2177ba3302b1caf7fe451592c210d68212.tar.bz2 |
* tests/pkg/samename.tcl: test file for bug #1983
* tests/pkgMkIndex.test:
* library/package.tcl:
Fixed bug #1983, dealing with pkg_mkIndex incorrectly handling
situations with two procs by the same name but in different
namespaces (ie, foo::baz and bar::baz).
-rw-r--r-- | library/package.tcl | 50 | ||||
-rw-r--r-- | tests/pkg/samename.tcl | 25 | ||||
-rw-r--r-- | tests/pkgMkIndex.test | 10 |
3 files changed, 59 insertions, 26 deletions
diff --git a/library/package.tcl b/library/package.tcl index 6bf7ff1..f0f9f44 100644 --- a/library/package.tcl +++ b/library/package.tcl @@ -3,7 +3,7 @@ # utility procs formerly in init.tcl which can be loaded on demand # for package management. # -# RCS: @(#) $Id: package.tcl,v 1.7 2000/01/27 19:20:05 ericm Exp $ +# RCS: @(#) $Id: package.tcl,v 1.8 2000/01/27 19:48:29 ericm Exp $ # # Copyright (c) 1991-1993 The Regents of the University of California. # Copyright (c) 1994-1998 Sun Microsystems, Inc. @@ -285,31 +285,31 @@ proc pkg_mkIndex {args} { if {! [info exists ::tcl::namespaces($::tcl::x)]} { namespace import -force ${::tcl::x}::* } - } - - # Figure out what commands appeared - - foreach ::tcl::x [info commands] { - set ::tcl::newCmds($::tcl::x) 1 - } - foreach ::tcl::x $::tcl::origCmds { - catch {unset ::tcl::newCmds($::tcl::x)} - } - foreach ::tcl::x [array names ::tcl::newCmds] { - # reverse engineer which namespace a command comes from - - set ::tcl::abs [namespace origin $::tcl::x] - - # special case so that global names have no leading - # ::, this is required by the unknown command - - set ::tcl::abs [auto_qualify $::tcl::abs ::] - - if {[string compare $::tcl::x $::tcl::abs]} { - # Name changed during qualification - set ::tcl::newCmds($::tcl::abs) 1 - unset ::tcl::newCmds($::tcl::x) + # Figure out what commands appeared + + foreach ::tcl::x [info commands] { + set ::tcl::newCmds($::tcl::x) 1 + } + foreach ::tcl::x $::tcl::origCmds { + catch {unset ::tcl::newCmds($::tcl::x)} + } + foreach ::tcl::x [array names ::tcl::newCmds] { + # determine which namespace a command comes from + + set ::tcl::abs [namespace origin $::tcl::x] + + # special case so that global names have no leading + # ::, this is required by the unknown command + + set ::tcl::abs [auto_qualify $::tcl::abs ::] + + if {[string compare $::tcl::x $::tcl::abs]} { + # Name changed during qualification + + set ::tcl::newCmds($::tcl::abs) 1 + unset ::tcl::newCmds($::tcl::x) + } } } } diff --git a/tests/pkg/samename.tcl b/tests/pkg/samename.tcl new file mode 100644 index 0000000..8aa5080 --- /dev/null +++ b/tests/pkg/samename.tcl @@ -0,0 +1,25 @@ +package provide football 1.0 + +namespace eval ::pro:: { + # + # export only public functions. + # + namespace export {[a-z]*} +} +namespace eval ::college:: { + # + # export only public functions. + # + namespace export {[a-z]*} +} + +proc ::pro::team {} { + puts "go packers!" + return true +} + +proc ::college::team {} { + puts "go badgers!" + return true +} + diff --git a/tests/pkgMkIndex.test b/tests/pkgMkIndex.test index 17f3223..664505c 100644 --- a/tests/pkgMkIndex.test +++ b/tests/pkgMkIndex.test @@ -8,7 +8,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: pkgMkIndex.test,v 1.13 2000/01/27 19:20:05 ericm Exp $ +# RCS: @(#) $Id: pkgMkIndex.test,v 1.14 2000/01/27 19:48:30 ericm Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -348,6 +348,14 @@ test pkgMkIndex-11.1 {conflicting namespace imports} { pkgtest::runIndex -lazy $fullPkgPath import.tcl } {0 {{fubar:1.0 {tclPkgSetup {import.tcl source ::fubar::foo}}}}} +# Verify that the auto load list generated is correct even when there +# is a proc name conflict between two namespaces (ie, ::foo::baz and +# ::bar::baz) + +test pkgMkIndex-12.1 {same name procs in different namespace} { + pkgtest::runIndex -lazy $fullPkgPath samename.tcl +} {0 {{football:1.0 {tclPkgSetup {samename.tcl source {::college::team ::pro::team}}}}}} + # cleanup namespace delete pkgtest |