summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2018-04-19 17:46:37 (GMT)
committerdgp <dgp@users.sourceforge.net>2018-04-19 17:46:37 (GMT)
commit5c2ea0542f62da981d08766756c2e421db40955c (patch)
treed29de3b601a09abceab0c9317a21be62ed21b9f5
parent346eec18923b94fd1c361528afd629c79262631a (diff)
downloadtcl-5c2ea0542f62da981d08766756c2e421db40955c.zip
tcl-5c2ea0542f62da981d08766756c2e421db40955c.tar.gz
tcl-5c2ea0542f62da981d08766756c2e421db40955c.tar.bz2
Adapt [array for] to use the refactored routines.
-rw-r--r--generic/tclVar.c42
1 files changed, 5 insertions, 37 deletions
diff --git a/generic/tclVar.c b/generic/tclVar.c
index 7a71990..51eec61 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -3043,12 +3043,10 @@ ArrayForNRCmd(
int objc,
Tcl_Obj *const *objv)
{
- Interp *iPtr = (Interp *) interp;
Tcl_Obj *varListObj, *arrayNameObj, *scriptObj;
ArraySearch *searchPtr = NULL;
Var *varPtr;
- Var *arrayPtr;
- int numVars;
+ int isArray, numVars;
/*
* array for {k v} a body
@@ -3064,7 +3062,6 @@ ArrayForNRCmd(
* Parse arguments.
*/
-
if (Tcl_ListObjLength(interp, objv[1], &numVars) != TCL_OK) {
return TCL_ERROR;
}
@@ -3078,41 +3075,12 @@ ArrayForNRCmd(
arrayNameObj = objv[2];
- /*
- * Locate the array variable.
- */
-
- varPtr = TclObjLookupVarEx(interp, arrayNameObj, NULL, /*flags*/ 0,
- /*msg*/ 0, /*createPart1*/ 0, /*createPart2*/ 0, &arrayPtr);
-
- /*
- * Special array trace used to keep the env array in sync for array names,
- * array get, etc.
- */
-
- if (varPtr && (varPtr->flags & VAR_TRACED_ARRAY)
- && (TclIsVarArray(varPtr) || TclIsVarUndefined(varPtr))) {
- if (TclObjCallVarTraces(iPtr, arrayPtr, varPtr, arrayNameObj, NULL,
- (TCL_LEAVE_ERR_MSG|TCL_NAMESPACE_ONLY|TCL_GLOBAL_ONLY|
- TCL_TRACE_ARRAY), /* leaveErrMsg */ 1, -1) == TCL_ERROR) {
- return TCL_ERROR;
- }
+ if (TCL_ERROR == LocateArray(interp, arrayNameObj, &varPtr, &isArray)) {
+ return TCL_ERROR;
}
- /*
- * Verify that it is indeed an array variable. This test comes after the
- * traces; the variable may actually become an array as an effect of said
- * traces.
- */
-
- if ((varPtr == NULL) || !TclIsVarArray(varPtr)
- || TclIsVarUndefined(varPtr)) {
- const char *varName = Tcl_GetString(arrayNameObj);
-
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "\"%s\" isn't an array", varName));
- Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ARRAY", varName, NULL);
- return TCL_ERROR;
+ if (!isArray) {
+ return NotArrayError(interp, arrayNameObj);
}
/*