summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--generic/tclNamesp.c20
-rw-r--r--tests/namespace.test28
3 files changed, 40 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 31bdb1d..c4bf470 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-08-25 Donal K. Fellows <donal.k.fellows@man.ac.uk>
+
+ * generic/tclNamesp.c (NsEnsembleImplementationCmd): Use the
+ ensemble command token to get the name of the ensemble for passing
+ to the -unknown handler instead of relying on objv[0], which may
+ contain useless info in the presence of [namespace import].
+ Problem found by Don Porter when investigating [Bug 1016167].
+
2004-08-24 Don Porter <dgp@users.sourceforge.net>
* generic/tclProc.c: The routine TclProcInterpProc was a specific
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index e38f2da..d1da5ae 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -21,7 +21,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclNamesp.c,v 1.44 2004/08/03 21:46:55 dkf Exp $
+ * RCS: @(#) $Id: tclNamesp.c,v 1.45 2004/08/25 21:28:26 dkf Exp $
*/
#include "tclInt.h"
@@ -4933,22 +4933,12 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
if (ensemblePtr->unknownHandler != NULL && reparseCount++ < 1) {
int paramc, i;
- Tcl_Obj **paramv, *unknownCmd;
- char *ensName = TclGetString(objv[0]);
+ Tcl_Obj **paramv, *unknownCmd, *ensObj;
unknownCmd = Tcl_DuplicateObj(ensemblePtr->unknownHandler);
- if (ensName[0] == ':') {
- Tcl_ListObjAppendElement(NULL, unknownCmd, objv[0]);
- } else {
- Tcl_Obj *qualEnsembleObj =
- Tcl_NewStringObj(Tcl_GetCurrentNamespace(interp)->fullName,-1);
- if (Tcl_GetCurrentNamespace(interp)->parentPtr) {
- Tcl_AppendStringsToObj(qualEnsembleObj, "::", ensName, NULL);
- } else {
- Tcl_AppendStringsToObj(qualEnsembleObj, ensName, NULL);
- }
- Tcl_ListObjAppendElement(NULL, unknownCmd, qualEnsembleObj);
- }
+ TclNewObj(ensObj);
+ Tcl_GetCommandFullName(interp, ensemblePtr->token, ensObj);
+ Tcl_ListObjAppendElement(NULL, unknownCmd, ensObj);
for (i=1 ; i<objc ; i++) {
Tcl_ListObjAppendElement(NULL, unknownCmd, objv[i]);
}
diff --git a/tests/namespace.test b/tests/namespace.test
index e22eb13..987741e 100644
--- a/tests/namespace.test
+++ b/tests/namespace.test
@@ -11,7 +11,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: namespace.test,v 1.28 2004/05/25 19:45:17 msofer Exp $
+# RCS: @(#) $Id: namespace.test,v 1.29 2004/08/25 21:28:27 dkf Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -1649,6 +1649,32 @@ test namespace-47.6 {ensemble: unknown handler} {
while parsing result of ensemble unknown subcommand handler
invoked from within
"foo bar"}}
+test namespace-47.7 {ensemble: unknown handler and namespace import} {
+ namespace eval foo {
+ namespace export bar
+ namespace ensemble create -command bar -unknown ::foo::u -subcomm x
+ proc u {ens args} {
+ global result
+ lappend result $ens $args
+ namespace ensemble config $ens -subcommand {x y}
+ }
+ proc x args {
+ global result
+ lappend result XXX $args
+ }
+ proc y args {
+ global result
+ lappend result YYY $args
+ }
+ }
+ namespace import foo::bar
+ set result {}
+ lappend result [catch {namespace ensemble config bar} msg] $msg
+ bar x 123
+ bar y 456
+ namespace delete foo
+ set result
+} {1 {bar is not an ensemble command} XXX 123 ::bar {y 456} YYY 456}
# cleanup
catch {rename cmd1 {}}