summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2020-09-13 20:28:02 (GMT)
committerfvogel <fvogelnew1@free.fr>2020-09-13 20:28:02 (GMT)
commite89503a925f86a4914df078203ed227305110bbd (patch)
tree928ee197f4d824447f5069ed6820e351afc7aaaf /generic
parent779b664e54a9f926fbbd56866693099fe4ee2639 (diff)
parent2b83b2c9993319e242389505cc899ceacdea58c5 (diff)
downloadtcl-e89503a925f86a4914df078203ed227305110bbd.zip
tcl-e89503a925f86a4914df078203ed227305110bbd.tar.gz
tcl-e89503a925f86a4914df078203ed227305110bbd.tar.bz2
Merge implementation of TIP #585 (Promote the INDEX_TEMP_TABLE flag of Tcl_GetIndexFromObj*() to the public interface) after positive vote from the TCT.
Diffstat (limited to 'generic')
-rw-r--r--generic/tcl.h9
-rw-r--r--generic/tclFCmd.c4
-rw-r--r--generic/tclIndexObj.c8
-rw-r--r--generic/tclInt.h9
-rw-r--r--generic/tclTestObj.c2
5 files changed, 13 insertions, 19 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index 02ef01e..65169c0 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -973,11 +973,14 @@ typedef struct Tcl_DString {
#define TCL_DONT_QUOTE_HASH 8
/*
- * Flag that may be passed to Tcl_GetIndexFromObj to force it to disallow
- * abbreviated strings.
+ * Flags that may be passed to Tcl_GetIndexFromObj.
+ * TCL_EXACT disallows abbreviated strings.
+ * TCL_INDEX_TEMP_TABLE disallows caching of lookups. A possible use case is
+ * a table that will not live long enough to make it worthwhile.
*/
-#define TCL_EXACT 1
+#define TCL_EXACT 1
+#define TCL_INDEX_TEMP_TABLE 2
/*
*----------------------------------------------------------------------------
diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c
index 3babd43..d6a152a 100644
--- a/generic/tclFCmd.c
+++ b/generic/tclFCmd.c
@@ -1085,7 +1085,7 @@ TclFileAttrsCmd(
}
if (Tcl_GetIndexFromObj(interp, objv[0], attributeStrings,
- "option", INDEX_TEMP_TABLE, &index) != TCL_OK) {
+ "option", TCL_INDEX_TEMP_TABLE, &index) != TCL_OK) {
goto end;
}
if (Tcl_FSFileAttrsGet(interp, index, filePtr,
@@ -1110,7 +1110,7 @@ TclFileAttrsCmd(
for (i = 0; i < objc ; i += 2) {
if (Tcl_GetIndexFromObj(interp, objv[i], attributeStrings,
- "option", INDEX_TEMP_TABLE, &index) != TCL_OK) {
+ "option", TCL_INDEX_TEMP_TABLE, &index) != TCL_OK) {
goto end;
}
if (i + 1 == objc) {
diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c
index 4749e6e..a0a31da 100644
--- a/generic/tclIndexObj.c
+++ b/generic/tclIndexObj.c
@@ -114,7 +114,7 @@ Tcl_GetIndexFromObj(
int flags, /* 0 or TCL_EXACT */
int *indexPtr) /* Place to store resulting integer index. */
{
- if (!(flags & INDEX_TEMP_TABLE)) {
+ if (!(flags & TCL_INDEX_TEMP_TABLE)) {
/*
* See if there is a valid cached result from a previous lookup (doing the
@@ -216,7 +216,7 @@ GetIndexFromObjList(
tablePtr[objc] = NULL;
result = Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr,
- sizeof(char *), msg, flags | INDEX_TEMP_TABLE, indexPtr);
+ sizeof(char *), msg, flags | TCL_INDEX_TEMP_TABLE, indexPtr);
ckfree(tablePtr);
@@ -280,7 +280,7 @@ Tcl_GetIndexFromObjStruct(
* See if there is a valid cached result from a previous lookup.
*/
- if (!(flags & INDEX_TEMP_TABLE)) {
+ if (!(flags & TCL_INDEX_TEMP_TABLE)) {
irPtr = TclFetchIntRep(objPtr, &indexType);
if (irPtr) {
indexRep = (IndexRep *)irPtr->twoPtrValue.ptr1;
@@ -344,7 +344,7 @@ Tcl_GetIndexFromObjStruct(
* operation.
*/
- if (!(flags & INDEX_TEMP_TABLE)) {
+ if (!(flags & TCL_INDEX_TEMP_TABLE)) {
irPtr = TclFetchIntRep(objPtr, &indexType);
if (irPtr) {
indexRep = (IndexRep *)irPtr->twoPtrValue.ptr1;
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 1d380f9..a5e8122 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -2612,15 +2612,6 @@ typedef struct TclFileAttrProcs {
} TclFileAttrProcs;
/*
- * Private flag value which controls Tcl_GetIndexFromObj*() routines
- * to instruct them not to cache lookups because the table will not
- * live long enough to make it worthwhile. Must not clash with public
- * flag value TCL_EXACT.
- */
-
-#define INDEX_TEMP_TABLE 2
-
-/*
* Opaque handle used in pipeline routines to encapsulate platform-dependent
* state.
*/
diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c
index 99cb1f4..bd5d92e 100644
--- a/generic/tclTestObj.c
+++ b/generic/tclTestObj.c
@@ -627,7 +627,7 @@ TestindexobjCmd(
argv[objc-4] = NULL;
result = Tcl_GetIndexFromObj((setError? interp : NULL), objv[3],
- argv, "token", INDEX_TEMP_TABLE|(allowAbbrev? 0 : TCL_EXACT),
+ argv, "token", TCL_INDEX_TEMP_TABLE|(allowAbbrev? 0 : TCL_EXACT),
&index);
ckfree(argv);
if (result == TCL_OK) {