summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2007-01-09 11:32:33 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2007-01-09 11:32:33 (GMT)
commit0461303eb629c1a59984468e671be1d59c424aae (patch)
treeeb7fe3acc99f488944e13733ec25289415624f84 /generic
parent1d642537ecda9cbd3044fd5f70d81b697abd6d87 (diff)
downloadtcl-0461303eb629c1a59984468e671be1d59c424aae.zip
tcl-0461303eb629c1a59984468e671be1d59c424aae.tar.gz
tcl-0461303eb629c1a59984468e671be1d59c424aae.tar.bz2
Fix [lindex] argument ordering. [bug 1631364]
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCompCmds.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 464f7d2..f5c553a 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompCmds.c,v 1.97 2006/12/07 23:35:29 dgp Exp $
+ * RCS: @(#) $Id: tclCompCmds.c,v 1.98 2007/01/09 11:32:33 dkf Exp $
*/
#include "tclInt.h"
@@ -2327,7 +2327,7 @@ TclCompileLindexCmd(
* created by Tcl_ParseCommand. */
CompileEnv *envPtr) /* Holds resulting instructions. */
{
- Tcl_Token *varTokenPtr;
+ Tcl_Token *idxTokenPtr, *valTokenPtr;
int i, numWords = parsePtr->numWords;
DefineLineInformation; /* TIP #280 */
@@ -2339,13 +2339,17 @@ TclCompileLindexCmd(
return TCL_ERROR;
}
- varTokenPtr = TokenAfter(parsePtr->tokenPtr);
+ valTokenPtr = TokenAfter(parsePtr->tokenPtr);
+ if (numWords != 3) {
+ goto emitComplexLindex;
+ }
- if ((numWords == 3) && (varTokenPtr->type == TCL_TOKEN_SIMPLE_WORD)) {
+ idxTokenPtr = TokenAfter(valTokenPtr);
+ if (idxTokenPtr->type == TCL_TOKEN_SIMPLE_WORD) {
Tcl_Obj *tmpObj;
int idx, result;
- tmpObj = Tcl_NewStringObj(varTokenPtr[1].start, varTokenPtr[1].size);
+ tmpObj = Tcl_NewStringObj(idxTokenPtr[1].start, idxTokenPtr[1].size);
result = Tcl_GetIntFromObj(NULL, tmpObj, &idx);
TclDecrRefCount(tmpObj);
@@ -2358,8 +2362,7 @@ TclCompileLindexCmd(
* by an "immediate lindex" which is the most efficient variety.
*/
- varTokenPtr = TokenAfter(varTokenPtr);
- CompileWord(envPtr, varTokenPtr, interp, 1);
+ CompileWord(envPtr, valTokenPtr, interp, 1);
TclEmitInstInt4(INST_LIST_INDEX_IMM, idx, envPtr);
return TCL_OK;
}
@@ -2374,9 +2377,10 @@ TclCompileLindexCmd(
* Push the operands onto the stack.
*/
+ emitComplexLindex:
for (i=1 ; i<numWords ; i++) {
- CompileWord(envPtr, varTokenPtr, interp, i);
- varTokenPtr = TokenAfter(varTokenPtr);
+ CompileWord(envPtr, valTokenPtr, interp, i);
+ valTokenPtr = TokenAfter(valTokenPtr);
}
/*