diff options
| author | donal.k.fellows@manchester.ac.uk <dkf> | 2013-09-27 10:29:43 (GMT) |
|---|---|---|
| committer | donal.k.fellows@manchester.ac.uk <dkf> | 2013-09-27 10:29:43 (GMT) |
| commit | d1177b3a4067d200eb743d453db5e2ebc9507c81 (patch) | |
| tree | 16ec0b14f5357ad7601ebefaf5c1e71465d39eba /generic/tclVar.c | |
| parent | c6a63350f148cc16b4f3a5cd07ef339441f73e68 (diff) | |
| download | tcl-d1177b3a4067d200eb743d453db5e2ebc9507c81.zip tcl-d1177b3a4067d200eb743d453db5e2ebc9507c81.tar.gz tcl-d1177b3a4067d200eb743d453db5e2ebc9507c81.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.c | 47 |
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 |
