summaryrefslogtreecommitdiffstats
path: root/generic/tclVar.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2013-09-27 10:29:43 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2013-09-27 10:29:43 (GMT)
commita5a2f896bb91053061b5a83f09cb0778c3b53e3b (patch)
tree16ec0b14f5357ad7601ebefaf5c1e71465d39eba /generic/tclVar.c
parent790f8f7114d0cc7b44cbaddc66e36c877c9c55b6 (diff)
downloadtcl-a5a2f896bb91053061b5a83f09cb0778c3b53e3b.zip
tcl-a5a2f896bb91053061b5a83f09cb0778c3b53e3b.tar.gz
tcl-a5a2f896bb91053061b5a83f09cb0778c3b53e3b.tar.bz2
[219226]: Rewrote how ::env is synchronized to the environment so it no longer
smashes the array or its elements flat, This affects traces on env, links to env, and iterations over env: it makes them work as naïvely expected.
Diffstat (limited to 'generic/tclVar.c')
-rw-r--r--generic/tclVar.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/generic/tclVar.c b/generic/tclVar.c
index af1a563..4694cd8 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -3850,6 +3850,53 @@ ArrayNamesCmd(
/*
*----------------------------------------------------------------------
*
+ * TclFindArrayPtrElements --
+ *
+ * Fill out a hash table (which *must* use Tcl_Obj* keys) with an entry
+ * for each existing element of the given array. The provided hash table
+ * is assumed to be initially empty.
+ *
+ * Result:
+ * none
+ *
+ * Side effects:
+ * The keys of the array gain an extra reference. The supplied hash table
+ * has elements added to it.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TclFindArrayPtrElements(
+ Var *arrayPtr,
+ Tcl_HashTable *tablePtr)
+{
+ Var *varPtr;
+ Tcl_HashSearch search;
+
+ if ((arrayPtr == NULL) || !TclIsVarArray(arrayPtr)
+ || TclIsVarUndefined(arrayPtr)) {
+ return;
+ }
+
+ for (varPtr=VarHashFirstVar(arrayPtr->value.tablePtr, &search);
+ varPtr!=NULL ; varPtr=VarHashNextVar(&search)) {
+ Tcl_HashEntry *hPtr;
+ Tcl_Obj *nameObj;
+ int dummy;
+
+ if (TclIsVarUndefined(varPtr)) {
+ continue;
+ }
+ nameObj = VarHashGetKey(varPtr);
+ hPtr = Tcl_CreateHashEntry(tablePtr, (char *) nameObj, &dummy);
+ Tcl_SetHashValue(hPtr, nameObj);
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* ArraySetCmd --
*
* This object-based function is invoked to process the "array set" Tcl