diff options
author | ferrieux <ferrieux@users.sourceforge.net> | 2010-06-02 23:36:23 (GMT) |
---|---|---|
committer | ferrieux <ferrieux@users.sourceforge.net> | 2010-06-02 23:36:23 (GMT) |
commit | 5c5e3f51ea23ae06e71dd6b272376ed8a833aa84 (patch) | |
tree | e0ae05f51b24282b7f9a8240cff13435db359108 /generic | |
parent | 862cbfbc4c58e28e598535335bad2514e5bc835f (diff) | |
download | tcl-5c5e3f51ea23ae06e71dd6b272376ed8a833aa84.zip tcl-5c5e3f51ea23ae06e71dd6b272376ed8a833aa84.tar.gz tcl-5c5e3f51ea23ae06e71dd6b272376ed8a833aa84.tar.bz2 |
Safer (and faster) computation of [uplevel] offsets in TIP 348. Toplevel offsets no longer overestimated.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclNamesp.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index bf91bc7..7422125 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -22,7 +22,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.206 2010/05/31 22:58:56 ferrieux Exp $ + * RCS: @(#) $Id: tclNamesp.c,v 1.207 2010/06/02 23:36:23 ferrieux Exp $ */ #include "tclInt.h" @@ -4954,22 +4954,19 @@ Tcl_LogCommandInfo( Tcl_ListObjReplace(interp, iPtr->errorStack, 0, len, 0, NULL); } - if (iPtr->varFramePtr != iPtr->framePtr) { + if (!iPtr->framePtr->objc) { + /* special frame, nothing to report */ + } else if (iPtr->varFramePtr != iPtr->framePtr) { /* uplevel case, [lappend errorstack UP $relativelevel] */ - struct CallFrame *frame; - int n; - for (n=0, frame=iPtr->framePtr; - (frame && (frame != iPtr->varFramePtr)); - n++, frame=frame->callerPtr); Tcl_ListObjAppendElement(NULL, iPtr->errorStack, iPtr->upLiteral); - Tcl_ListObjAppendElement(NULL, iPtr->errorStack, Tcl_NewIntObj(n)); + Tcl_ListObjAppendElement(NULL, iPtr->errorStack, Tcl_NewIntObj(iPtr->framePtr->level - iPtr->varFramePtr->level)); } else if (iPtr->framePtr != iPtr->rootFramePtr) { /* normal case, [lappend errorstack CALL [info level 0]] */ Tcl_ListObjAppendElement(NULL, iPtr->errorStack, iPtr->callLiteral); Tcl_ListObjAppendElement(NULL, iPtr->errorStack, - Tcl_NewListObj(iPtr->varFramePtr->objc, - iPtr->varFramePtr->objv)); + Tcl_NewListObj(iPtr->framePtr->objc, + iPtr->framePtr->objv)); } } |