diff options
author | dgp <dgp@users.sourceforge.net> | 2013-05-24 18:37:19 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2013-05-24 18:37:19 (GMT) |
commit | 44c1eaa96ca8158ccbb3acddb45eadfadfb9f07a (patch) | |
tree | bc9f6116a6d8c642d51f11b104c94e8fd996c30f | |
parent | 6075b0d3f07eeac6144d0a6f7af0803cf9705b96 (diff) | |
download | tcl-44c1eaa96ca8158ccbb3acddb45eadfadfb9f07a.zip tcl-44c1eaa96ca8158ccbb3acddb45eadfadfb9f07a.tar.gz tcl-44c1eaa96ca8158ccbb3acddb45eadfadfb9f07a.tar.bz2 |
3613854 - Fixup stack maintenance /code generation for [array set x $oddList].
Postscript - I see that this commit created a memory leak.
Will commit a fix within a few days.
-rw-r--r-- | generic/tclCompCmds.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c index 10faff7..5a5cd88 100644 --- a/generic/tclCompCmds.c +++ b/generic/tclCompCmds.c @@ -263,11 +263,6 @@ TclCompileArraySetCmd( } varTokenPtr = TokenAfter(parsePtr->tokenPtr); - PushVarNameWord(interp, varTokenPtr, envPtr, TCL_NO_ELEMENT, - &localIndex, &simpleVarName, &isScalar, 1); - if (!isScalar) { - return TCL_ERROR; - } dataTokenPtr = TokenAfter(varTokenPtr); literalObj = Tcl_NewObj(); isDataLiteral = TclWordKnownAtCompileTime(dataTokenPtr, literalObj); @@ -276,6 +271,23 @@ TclCompileArraySetCmd( isDataEven = (isDataValid && (len & 1) == 0); /* + * Special case: literal odd-length argument is always an error. + */ + + if (isDataValid && !isDataEven) { + PushStringLiteral(envPtr, "list must have an even number of elements"); + PushStringLiteral(envPtr, "-errorCode {TCL ARGUMENT FORMAT}"); + TclEmitInstInt4(INST_RETURN_IMM, 1, envPtr); + TclEmitInt4( 0, envPtr); + goto done; + } + + PushVarNameWord(interp, varTokenPtr, envPtr, TCL_NO_ELEMENT, + &localIndex, &simpleVarName, &isScalar, 1); + if (!isScalar) { + return TCL_ERROR; + } + /* * Special case: literal empty value argument is just an "ensure array" * operation. */ @@ -300,21 +312,6 @@ TclCompileArraySetCmd( } /* - * Special case: literal odd-length argument is always an error. - */ - - if (isDataValid && !isDataEven) { - savedStackDepth = envPtr->currStackDepth; - PushStringLiteral(envPtr, "list must have an even number of elements"); - PushStringLiteral(envPtr, "-errorCode {TCL ARGUMENT FORMAT}"); - TclEmitInstInt4(INST_RETURN_IMM, 1, envPtr); - TclEmitInt4( 0, envPtr); - envPtr->currStackDepth = savedStackDepth; - PushStringLiteral(envPtr, ""); - goto done; - } - - /* * Prepare for the internal foreach. */ |