summaryrefslogtreecommitdiffstats
path: root/generic/tclAssembly.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2018-03-07 18:39:44 (GMT)
committerdgp <dgp@users.sourceforge.net>2018-03-07 18:39:44 (GMT)
commit2c44354d13f15b788a4213ab50441eed6ad54f75 (patch)
treeb78a9c9ff6edf0a01ad9f4f76cb337031205c7c8 /generic/tclAssembly.c
parent612199cbe93e3fb4c39cd92afd245616115ad442 (diff)
downloadtcl-2c44354d13f15b788a4213ab50441eed6ad54f75.zip
tcl-2c44354d13f15b788a4213ab50441eed6ad54f75.tar.gz
tcl-2c44354d13f15b788a4213ab50441eed6ad54f75.tar.bz2
Establish 4 symbols for categories of parsed index values:
TCL_INDEX_START = 0 The start index. TCL_INDEX_END = -2 The "end" index. TCL_INDEX_BEFORE = -1 All indices less than start. TCL_INDEX_AFTER = INT_MAX All indices greater than "end". Then use these symbols among callers of TclGetIndexFromToken() so that index value parsing can directly implement the callers sense of when out of range indices ought to be treated the same as start or end positions.
Diffstat (limited to 'generic/tclAssembly.c')
-rw-r--r--generic/tclAssembly.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c
index 02c64bd..a3fac8f 100644
--- a/generic/tclAssembly.c
+++ b/generic/tclAssembly.c
@@ -2258,8 +2258,13 @@ GetListIndexOperand(
Tcl_DecrRefCount(value);
/* Convert to an integer, advance to the next token and return. */
- status = TclGetIndexFromToken(tokenPtr, result, TCL_INDEX_OUT_OF_RANGE,
- TCL_INDEX_OUT_OF_RANGE);
+ /*
+ * 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 = TclGetIndexFromToken(tokenPtr, result, TCL_INDEX_BEFORE,
+ TCL_INDEX_BEFORE);
*tokenPtrPtr = TokenAfter(tokenPtr);
if (status == TCL_ERROR && interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%.*s\"",