From 0ca2509a6a916f079e64160010f7490742df2256 Mon Sep 17 00:00:00 2001 From: Miguel Sofer Date: Thu, 12 Oct 2006 16:24:11 +0000 Subject: * generic/tclInterp.c (ApplyObjCmd): * tests/interp.test (interp-14.5-10): made [interp alias] use the ensemble rewrite machinery to produce better error messages [Bug 1576006] --- ChangeLog | 7 +++++ generic/tclInterp.c | 31 ++++++++++++++++--- tests/interp.test | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 121 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index e1f8e2e..12eedfe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-10-12 Miguel Sofer + + * generic/tclInterp.c (ApplyObjCmd): + * tests/interp.test (interp-14.5-10): made [interp alias] use the + ensemble rewrite machinery to produce better error messages + [Bug 1576006] + 2006-10-12 David Gravereaux * win/nmakehlp.c: Replaced all wnsprintf() calls with snprintf(). diff --git a/generic/tclInterp.c b/generic/tclInterp.c index b0d03ad..6379528 100644 --- a/generic/tclInterp.c +++ b/generic/tclInterp.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclInterp.c,v 1.62 2005/12/12 23:00:08 dkf Exp $ + * RCS: @(#) $Id: tclInterp.c,v 1.63 2006/10/12 16:24:13 msofer Exp $ */ #include "tclInt.h" @@ -1691,13 +1691,13 @@ AliasObjCmd( Tcl_Obj *CONST objv[]) /* Argument vector. */ { #define ALIAS_CMDV_PREALLOC 10 - Tcl_Interp *targetInterp; - Alias *aliasPtr; + Alias *aliasPtr = (Alias *) clientData; + Tcl_Interp *targetInterp = aliasPtr->targetInterp; int result, prefc, cmdc, i; Tcl_Obj **prefv, **cmdv; Tcl_Obj *cmdArr[ALIAS_CMDV_PREALLOC]; - aliasPtr = (Alias *) clientData; - targetInterp = aliasPtr->targetInterp; + Interp *tPtr = (Interp *) targetInterp; + int isRootEnsemble = (tPtr->ensembleRewrite.sourceObjs == NULL); /* * Append the arguments to the command prefix and invoke the command in @@ -1724,6 +1724,20 @@ AliasObjCmd( for (i=0; iensembleRewrite.sourceObjs = objv; + tPtr->ensembleRewrite.numRemovedObjs = 1; + tPtr->ensembleRewrite.numInsertedObjs = prefc; + } else { + tPtr->ensembleRewrite.numInsertedObjs += prefc - 1; + } + if (targetInterp != interp) { Tcl_Preserve((ClientData) targetInterp); result = Tcl_EvalObjv(targetInterp, cmdc, cmdv, TCL_EVAL_INVOKE); @@ -1732,6 +1746,13 @@ AliasObjCmd( } else { result = Tcl_EvalObjv(targetInterp, cmdc, cmdv, TCL_EVAL_INVOKE); } + + if (isRootEnsemble) { + tPtr->ensembleRewrite.sourceObjs = NULL; + tPtr->ensembleRewrite.numRemovedObjs = 0; + tPtr->ensembleRewrite.numInsertedObjs = 0; + } + for (i=0; i