summaryrefslogtreecommitdiffstats
path: root/generic/tclAssembly.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2018-03-09 22:18:30 (GMT)
committerdgp <dgp@users.sourceforge.net>2018-03-09 22:18:30 (GMT)
commit87fd09e44a51e90ebb71a1f46a5300859c62e99a (patch)
tree0cdf856871de94cc8600b76014a998f815070896 /generic/tclAssembly.c
parentf337281f750a928dcc07884286cc1f4cceeab809 (diff)
parentcd4e0ec5deffef9dbc4331768ca660fef4590501 (diff)
downloadtcl-87fd09e44a51e90ebb71a1f46a5300859c62e99a.zip
tcl-87fd09e44a51e90ebb71a1f46a5300859c62e99a.tar.gz
tcl-87fd09e44a51e90ebb71a1f46a5300859c62e99a.tar.bz2
[db36fa5122] Upgrade the index value parsing and encoding machinery.
Refactor many systems to make consistent use of it. Repairs many indexing errors in corner cases.
Diffstat (limited to 'generic/tclAssembly.c')
-rw-r--r--generic/tclAssembly.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c
index 120fd9a..b6bebb6 100644
--- a/generic/tclAssembly.c
+++ b/generic/tclAssembly.c
@@ -2248,23 +2248,24 @@ GetListIndexOperand(
Tcl_Token* tokenPtr = *tokenPtrPtr;
/* INOUT: Pointer to the next token in the
* source code */
- Tcl_Obj* intObj; /* Integer from the source code */
- int status; /* Tcl status return */
-
- /*
- * Extract the next token as a string.
- */
+ Tcl_Obj *value;
+ int status;
- if (GetNextOperand(assemEnvPtr, tokenPtrPtr, &intObj) != TCL_OK) {
+ /* General operand validity check */
+ if (GetNextOperand(assemEnvPtr, tokenPtrPtr, &value) != TCL_OK) {
return TCL_ERROR;
}
-
+
+ /* Convert to an integer, advance to the next token and return. */
/*
- * Convert to an integer, advance to the next token and return.
+ * NOTE: Indexing a list with an index before it yields the
+ * same result as indexing after it, and might be more easily portable
+ * when list size limits grow.
*/
+ status = TclIndexEncode(interp, value,
+ TCL_INDEX_BEFORE,TCL_INDEX_BEFORE, result);
- status = TclGetIntForIndex(interp, intObj, -2, result);
- Tcl_DecrRefCount(intObj);
+ Tcl_DecrRefCount(value);
*tokenPtrPtr = TokenAfter(tokenPtr);
return status;
}