summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorpooryorick <com.digitalsmarties@pooryorick.com>2020-09-19 14:33:24 (GMT)
committerpooryorick <com.digitalsmarties@pooryorick.com>2020-09-19 14:33:24 (GMT)
commitac45c8d85147e6927979c08d95567504148b74cd (patch)
treea3ed13d7c9003e3a95c2e5f16645fdce24016d1a /generic
parente14285c3a1d7dd2d7407fda5a5c841ccb5cae488 (diff)
downloadtcl-ac45c8d85147e6927979c08d95567504148b74cd.zip
tcl-ac45c8d85147e6927979c08d95567504148b74cd.tar.gz
tcl-ac45c8d85147e6927979c08d95567504148b74cd.tar.bz2
Fix for [b9ecf3ce98], [uplevel] unnecessarily generates string representation.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclProc.c45
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.