summaryrefslogtreecommitdiffstats
path: root/generic/tclInt.h
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2018-03-09 19:23:42 (GMT)
committerdgp <dgp@users.sourceforge.net>2018-03-09 19:23:42 (GMT)
commit6798b2404f883074422c40ca7d196ad174a2d1ef (patch)
tree6bc5d750f07996cf65383a86276793777cbf5ecc /generic/tclInt.h
parent5fd318bc35bbaa27e006360af375ca2c078b763a (diff)
downloadtcl-6798b2404f883074422c40ca7d196ad174a2d1ef.zip
tcl-6798b2404f883074422c40ca7d196ad174a2d1ef.tar.gz
tcl-6798b2404f883074422c40ca7d196ad174a2d1ef.tar.bz2
Refactor the index value encode/decode machinery for broader use.
Make use of it to fix index value flaws in [lsearch].
Diffstat (limited to 'generic/tclInt.h')
-rw-r--r--generic/tclInt.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 1b1b078..3821e42 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -4013,6 +4013,21 @@ MODULE_SCOPE unsigned TclHashObjKey(Tcl_HashTable *tablePtr, void *keyPtr);
MODULE_SCOPE int TclFullFinalizationRequested(void);
/*
+ * Utility routines for encoding index values as integers. Used by both
+ * some of the command compilers and by [lsort] and [lsearch].
+ */
+
+MODULE_SCOPE int TclIndexEncode(Tcl_Interp *interp, Tcl_Obj *objPtr,
+ int before, int after, int *indexPtr);
+MODULE_SCOPE int TclIndexDecode(int encoded, int endValue);
+
+/* Constants used in index value encoding routines. */
+#define TCL_INDEX_END (-2)
+#define TCL_INDEX_BEFORE (-1)
+#define TCL_INDEX_START (0)
+#define TCL_INDEX_AFTER (INT_MAX)
+
+/*
*----------------------------------------------------------------
* Macros used by the Tcl core to create and release Tcl objects.
* TclNewObj(objPtr) creates a new object denoting an empty string.