summaryrefslogtreecommitdiffstats
path: root/generic/tclNamesp.c
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2004-05-23 22:53:18 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2004-05-23 22:53:18 (GMT)
commitf606211e0c51995aea56b201d27556a45c10109c (patch)
treeced351781e4a4d76a53b7dd645aabb4c988d1e6d /generic/tclNamesp.c
parent0463c49be94c19a4a433c4657f8e565e80e1b0b3 (diff)
downloadtcl-f606211e0c51995aea56b201d27556a45c10109c.zip
tcl-f606211e0c51995aea56b201d27556a45c10109c.tar.gz
tcl-f606211e0c51995aea56b201d27556a45c10109c.tar.bz2
* generic/tclNamesp.c (Tcl_FindNamespaceVar): [Bug 959052] fixed,
insuring that no "zombie" variables are found. * generic/tclVar.c (TclLookupSimpleVar): comments re [Bug 736729] (predecessor of [Bug 959052]) removed. * tests/namespace.test: added tests 17.10-12
Diffstat (limited to 'generic/tclNamesp.c')
-rw-r--r--generic/tclNamesp.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index ded1f96..c369ccf 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.37 2004/03/24 21:54:32 dkf Exp $
+ * RCS: @(#) $Id: tclNamesp.c,v 1.38 2004/05/23 22:53:20 msofer Exp $
*/
#include "tclInt.h"
@@ -2324,6 +2324,23 @@ Tcl_FindNamespaceVar(interp, name, contextNsPtr, flags)
simpleName);
if (entryPtr != NULL) {
varPtr = (Var *) Tcl_GetHashValue(entryPtr);
+
+ /* Fix for [Bug 959052].
+ * When a varName is looked from a namespace different from the
+ * global one, there is no corresponding variable in the namespace and
+ * there is a "zombie" variable in the global namespace (ie, the
+ * varName is in the hash table, but the variable is unset), this code
+ * returns a reference to the zombie. Except when the zombie was
+ * created by a [variable] call, it should instead create a
+ * variable in the namespace.
+ * In particular, zombies created by [trace], [upvar], [global] or
+ * a reference in a tclNsVarNameType obj should never be found.
+ */
+ if (TclIsVarUndefined(varPtr)
+ && !(varPtr->flags & VAR_NAMESPACE_VAR)
+ && !(flags & (TCL_GLOBAL_ONLY|TCL_NAMESPACE_ONLY))) {
+ varPtr = NULL;
+ }
}
}
}