summaryrefslogtreecommitdiffstats
path: root/generic/tclProc.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclProc.c')
-rw-r--r--generic/tclProc.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/generic/tclProc.c b/generic/tclProc.c
index 1ed48ac..85d6531 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -808,7 +808,7 @@ TclObjGetFrame(
} else {
result = -1;
}
- } else if (TclGetWideBitsFromObj(interp, objPtr, &w) == TCL_OK) {
+ } else if (TclGetWideBitsFromObj(NULL, objPtr, &w) == TCL_OK) {
/*
* If this were an integer, we'd have succeeded already.
* Docs say we have to treat this as a 'bad level' error.
@@ -817,10 +817,16 @@ TclObjGetFrame(
}
}
- if (result == 0) {
- level = curLevel - 1;
- }
if (result != -1) {
+ /* if relative current level */
+ if (result == 0) {
+ if (!curLevel) {
+ /* we are in top-level, so simply generate bad level */
+ name = "1";
+ goto badLevel;
+ }
+ level = curLevel - 1;
+ }
if (level >= 0) {
CallFrame *framePtr;
for (framePtr = iPtr->varFramePtr; framePtr != NULL;
@@ -832,9 +838,9 @@ TclObjGetFrame(
}
}
}
-
+badLevel:
if (name == NULL) {
- name = TclGetString(objPtr);
+ name = objPtr ? TclGetString(objPtr) : "1" ;
}
Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad level \"%s\"", name));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "LEVEL", name, NULL);
@@ -1847,9 +1853,7 @@ InterpProcNR2(
Tcl_SetErrorCode(interp, "TCL", "RESULT", "UNEXPECTED", NULL);
result = TCL_ERROR;
- /*
- * Fall through to the TCL_ERROR handling code.
- */
+ /* FALLTHRU */
case TCL_ERROR:
/*