diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | generic/tclNamesp.c | 17 | ||||
-rw-r--r-- | tests/error.test | 8 | ||||
-rw-r--r-- | tests/result.test | 4 |
4 files changed, 19 insertions, 16 deletions
@@ -1,3 +1,9 @@ +2010-06-03 Alexandre Ferrieux <ferrieux@users.sourceforge.net> + + * generic/tclNamesp.c: Safer (and faster) computation of [uplevel] + * tests/error.test: offsets in TIP 348. Toplevel offsets no longer + * tests/result.test: overestimated. + 2010-06-02 Jan Nijtmans <nijtmans@users.sf.net> * generic/tclOO.h BUILD_tcloo is never defined (leftover) 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)); } } diff --git a/tests/error.test b/tests/error.test index 515d064..e30fd50 100644 --- a/tests/error.test +++ b/tests/error.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: error.test,v 1.32 2010/05/31 22:58:56 ferrieux Exp $ +# RCS: @(#) $Id: error.test,v 1.33 2010/06/02 23:36:26 ferrieux Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -174,13 +174,13 @@ test error-4.6 {errorstack via info } -body { proc g x {error G:$x} catch {f 12} info errorstack -} -match glob -result {CALL {g 1212} CALL {f 12} UP 3} +} -match glob -result {CALL {g 1212} CALL {f 12} UP 1} test error-4.7 {errorstack via options dict } -body { proc f x {g $x$x} proc g x {error G:$x} catch {f 12} m d dict get $d -errorstack -} -match glob -result {CALL {g 1212} CALL {f 12} UP 3} +} -match glob -result {CALL {g 1212} CALL {f 12} UP 1} # Errors in error command itself @@ -244,7 +244,7 @@ test error-6.10 {catch must reset errorstack} -body { catch {f 13} set e2 [info errorstack] list $e1 $e2 -} -match glob -result {{CALL {g 1212} CALL {f 12} UP 3} {CALL {g 1313} CALL {f 13} UP 3}} +} -match glob -result {{CALL {g 1212} CALL {f 12} UP 1} {CALL {g 1313} CALL {f 13} UP 1}} test error-7.1 {Bug 1397843} -body { variable cmds diff --git a/tests/result.test b/tests/result.test index a610343..8bde7ef 100644 --- a/tests/result.test +++ b/tests/result.test @@ -138,11 +138,11 @@ test result-6.3 {Bug 2383005} { test result-6.4 {non-list -errorstack} { catch {return -code error -errorstack {{}a} eek} m o list $m [dict get $o -errorcode] [dict get $o -errorstack] -} {{bad -errorstack value: expected a list but got "{}a"} {TCL RESULT NONLIST_ERRORSTACK} {UP 3}} +} {{bad -errorstack value: expected a list but got "{}a"} {TCL RESULT NONLIST_ERRORSTACK} {UP 1}} test result-6.5 {odd-sized-list -errorstack} { catch {return -code error -errorstack a eek} m o list $m [dict get $o -errorcode] [dict get $o -errorstack] -} {{forbidden odd-sized list for -errorstack: "a"} {TCL RESULT ODDSIZEDLIST_ERRORSTACK} {UP 3}} +} {{forbidden odd-sized list for -errorstack: "a"} {TCL RESULT ODDSIZEDLIST_ERRORSTACK} {UP 1}} # cleanup cleanupTests return |