summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tclNamesp.c19
-rw-r--r--generic/tclVar.c22
2 files changed, 23 insertions, 18 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;
+ }
}
}
}
diff --git a/generic/tclVar.c b/generic/tclVar.c
index 9097fd1..e84ce8f 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclVar.c,v 1.81 2004/05/22 16:21:17 msofer Exp $
+ * RCS: @(#) $Id: tclVar.c,v 1.82 2004/05/23 22:53:20 msofer Exp $
*/
#include "tclInt.h"
@@ -758,30 +758,18 @@ TclLookupSimpleVar(interp, varName, flags, create, errMsgPtr, indexPtr)
}
}
- /*
- * FIXME: [Bug 736729]
- *
- * 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. It should instead create a
- * variable in the namespace.
- *
- * Fix in progress - that it is not here yet may indicate that the
- * picture above is incomplete or wrong.
- * - Miguel Sofer, 2004-05-22
- */
-
/*
* Don't pass TCL_LEAVE_ERR_MSG, we may yet create the variable,
* or otherwise generate our own error!
*/
+
var = Tcl_FindNamespaceVar(interp, varName, (Tcl_Namespace *) cxtNsPtr,
flags & ~TCL_LEAVE_ERR_MSG);
+
if (var != (Tcl_Var) NULL) {
varPtr = (Var *) var;
}
+
if (varPtr == NULL) {
if (create) { /* var wasn't found so create it */
TclGetNamespaceForQualName(interp, varName, cxtNsPtr,
@@ -799,7 +787,7 @@ TclLookupSimpleVar(interp, varName, flags, create, errMsgPtr, indexPtr)
Tcl_SetHashValue(hPtr, varPtr);
varPtr->hPtr = hPtr;
varPtr->nsPtr = varNsPtr;
- if ((lookGlobal) || (varNsPtr == NULL)) {
+ if (lookGlobal) {
/*
* The variable was created starting from the global
* namespace: a global reference is returned even if