summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstanton <stanton>1999-02-03 02:58:40 (GMT)
committerstanton <stanton>1999-02-03 02:58:40 (GMT)
commit18cb0870c48ff94988c65661ecc3b38cbcdda304 (patch)
tree21ad86d7992bf55482e4cee778b38ceb6c5abca1
parent17481a9360ea758b106cce6d9ec42c575a877eb5 (diff)
downloadtcl-18cb0870c48ff94988c65661ecc3b38cbcdda304.zip
tcl-18cb0870c48ff94988c65661ecc3b38cbcdda304.tar.gz
tcl-18cb0870c48ff94988c65661ecc3b38cbcdda304.tar.bz2
* tests/interp.test:
* generic/tclInterp.c (DeleteAlias): Changed to use Tcl_DeleteCommandFromToken so we handle renames properly. This avoids senseless panic. [Bug: 736]
-rw-r--r--generic/tclInterp.c26
-rw-r--r--tests/interp.test12
2 files changed, 8 insertions, 30 deletions
diff --git a/generic/tclInterp.c b/generic/tclInterp.c
index 16f12c7..bdf4f72 100644
--- a/generic/tclInterp.c
+++ b/generic/tclInterp.c
@@ -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: tclInterp.c,v 1.3 1998/09/14 18:40:00 stanton Exp $
+ * RCS: @(#) $Id: tclInterp.c,v 1.4 1999/02/03 02:58:40 stanton Exp $
*/
#include <stdio.h>
@@ -2005,8 +2005,6 @@ DeleteAlias(interp, slaveInterp, aliasName)
Slave *slavePtr; /* Slave record for slave interpreter. */
Alias *aliasPtr; /* Points at alias structure to delete. */
Tcl_HashEntry *hPtr; /* Search variable. */
- char *tmpPtr, *namePtr; /* Local pointers to name of command to
- * be deleted. */
slavePtr = (Slave *) Tcl_GetAssocData(slaveInterp, "tclSlaveRecord",
NULL);
@@ -2031,33 +2029,13 @@ DeleteAlias(interp, slaveInterp, aliasName)
aliasPtr = (Alias *) Tcl_GetHashValue(hPtr);
/*
- * Get a copy of the real name of the command -- it might have
- * been renamed, and we want to delete the renamed command, not
- * the current command (if any) by the name of the original alias.
- * We need the local copy because the name may get smashed when the
- * command to delete is exposed, if it was hidden.
- */
-
- tmpPtr = Tcl_GetCommandName(slaveInterp, aliasPtr->slaveCmd);
- namePtr = (char *) ckalloc((unsigned) strlen(tmpPtr) + 1);
- strcpy(namePtr, tmpPtr);
-
- /*
* NOTE: The deleteProc for this command will delete the
* alias from the hash table. The deleteProc will also
* delete the target information from the master interpreter
* target table.
*/
- if (Tcl_DeleteCommand(slaveInterp, namePtr) != 0) {
- if (Tcl_ExposeCommand(slaveInterp, namePtr, namePtr) != TCL_OK) {
- panic("DeleteAlias: did not find alias to be deleted");
- }
- if (Tcl_DeleteCommand(slaveInterp, namePtr) != 0) {
- panic("DeleteAlias: did not find alias to be deleted");
- }
- }
- ckfree(namePtr);
+ (void) Tcl_DeleteCommandFromToken(slaveInterp, aliasPtr->slaveCmd);
return TCL_OK;
}
diff --git a/tests/interp.test b/tests/interp.test
index 8b77842..da0c433 100644
--- a/tests/interp.test
+++ b/tests/interp.test
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: interp.test,v 1.5 1998/11/02 23:04:14 stanton Exp $
+# RCS: @(#) $Id: interp.test,v 1.6 1999/02/03 02:58:41 stanton Exp $
if {[string compare test [info procs test]] == 1} then {source defs}
@@ -2258,11 +2258,11 @@ test interp-29.2 {recursion limit inheritance} {
}
# This test dumps core in Tcl 8.0.3!
-#test interp-30.1 {deletion of aliases inside namespaces} {
-# set i [interp create]
-# $i alias ns::cmd list
-# $i alias ns::cmd {}
-#} {}
+test interp-30.1 {deletion of aliases inside namespaces} {
+ set i [interp create]
+ $i alias ns::cmd list
+ $i alias ns::cmd {}
+} {}
foreach i [interp slaves] {
interp delete $i