diff options
Diffstat (limited to 'generic/tclProc.c')
-rw-r--r-- | generic/tclProc.c | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/generic/tclProc.c b/generic/tclProc.c index a9134f2..0313b29 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -898,29 +898,52 @@ TclNRUplevelObjCmd( Interp *iPtr = (Interp *) interp; CmdFrame *invoker = NULL; int word = 0; + int havelevel = 0; int result; CallFrame *savedVarFramePtr, *framePtr; Tcl_Obj *objPtr; if (objc < 2) { + /* to do + * simplify things by interpreting the argument as a command when there + * is only one argument. This requires a TIP since currently a single + * argument is interpreted as a level indicator if possible. + */ uplevelSyntax: Tcl_WrongNumArgs(interp, 1, objv, "?level? command ?arg ...?"); return TCL_ERROR; + } else if (objc == 2) { + int status ,llength; + status = Tcl_ListObjLength(interp, objv[1], &llength); + if (status == TCL_OK && llength > 1) { + /* the first argument can't interpreted as a level. Avoid + * generating a string representation of the script. */ + result = TclGetFrame(interp, "1", &framePtr); + if (result == -1) { + return TCL_ERROR; + } + havelevel = 1; + objc -= 1; + objv += 1; + } } - /* - * Find the level to use for executing the command. - */ + if (!havelevel) { + /* + * Find the level to use for executing the command. + */ - result = TclObjGetFrame(interp, objv[1], &framePtr); - if (result == -1) { - return TCL_ERROR; - } - objc -= result + 1; - if (objc == 0) { - goto uplevelSyntax; + result = TclObjGetFrame(interp, objv[1], &framePtr); + if (result == -1) { + return TCL_ERROR; + } + objc -= result + 1; + if (objc == 0) { + goto uplevelSyntax; + } + objv += result + 1; } - objv += result + 1; + /* * Modify the interpreter state to execute in the given frame. |