summaryrefslogtreecommitdiffstats
path: root/generic/tclProc.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2020-09-19 17:21:08 (GMT)
committerdgp <dgp@users.sourceforge.net>2020-09-19 17:21:08 (GMT)
commitbfbfb2e5d326f539217bb8d1c2c42a4e4dd8c1a0 (patch)
treef01c901c54b3222c960aa93aa369e7db1415b421 /generic/tclProc.c
parent57849b86a1aeba3bfaa8605ee966af4ad76eabbe (diff)
parent249c689f2da9755c337657844972757e5b2d757a (diff)
downloadtcl-bfbfb2e5d326f539217bb8d1c2c42a4e4dd8c1a0.zip
tcl-bfbfb2e5d326f539217bb8d1c2c42a4e4dd8c1a0.tar.gz
tcl-bfbfb2e5d326f539217bb8d1c2c42a4e4dd8c1a0.tar.bz2
merge 8.7
Diffstat (limited to 'generic/tclProc.c')
-rw-r--r--generic/tclProc.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/generic/tclProc.c b/generic/tclProc.c
index e8c4e6c..a7d3f48 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -905,29 +905,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.