diff options
author | dgp <dgp@users.sourceforge.net> | 2020-09-19 16:35:01 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2020-09-19 16:35:01 (GMT) |
commit | 8c327a0577a8db466b7e326aa45973b440c6108f (patch) | |
tree | b549f14132cbde4925119fb089a370d49b177f14 /generic | |
parent | 1d9b09692dbf8ea343c44f4cca02676ad091cb41 (diff) | |
parent | ac45c8d85147e6927979c08d95567504148b74cd (diff) | |
download | tcl-8c327a0577a8db466b7e326aa45973b440c6108f.zip tcl-8c327a0577a8db466b7e326aa45973b440c6108f.tar.gz tcl-8c327a0577a8db466b7e326aa45973b440c6108f.tar.bz2 |
merge 8.6
Diffstat (limited to 'generic')
-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. |