summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorbch <brad.harder@gmail.com>2020-12-06 18:39:21 (GMT)
committerbch <brad.harder@gmail.com>2020-12-06 18:39:21 (GMT)
commitc9c1696a2d8c2c3d094e54b96defd269c0687692 (patch)
treec7c98017b4ab7b39f9dfb815b5c490ba9827e921 /generic
parent53d6118a090b1b452072c01b26df2bd43ee8e49b (diff)
downloadtcl-c9c1696a2d8c2c3d094e54b96defd269c0687692.zip
tcl-c9c1696a2d8c2c3d094e54b96defd269c0687692.tar.gz
tcl-c9c1696a2d8c2c3d094e54b96defd269c0687692.tar.bz2
allow NULL for indexPtr to say "am not interested in index, just membership in set of possibilities" for Tcl_GetIndexFromObj()
Diffstat (limited to 'generic')
-rw-r--r--generic/tclIndexObj.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c
index 89582b7..c3092c9 100644
--- a/generic/tclIndexObj.c
+++ b/generic/tclIndexObj.c
@@ -166,11 +166,12 @@ GetIndexFromObjList(
* Results:
* If the value of objPtr is identical to or a unique abbreviation for
* one of the entries in tablePtr, then the return value is TCL_OK and
- * the index of the matching entry is stored at *indexPtr. If there isn't
- * a proper match, then TCL_ERROR is returned and an error message is
- * left in interp's result (unless interp is NULL). The msg argument is
- * used in the error message; for example, if msg has the value "option"
- * then the error message will say something like 'bad option "foo": must
+ * the index of the matching entry is stored at *indexPtr
+ * (unless indexPtr is NULL). If there isn't a proper match, then
+ * TCL_ERROR is returned and an error message is left in interp's
+ * result (unless interp is NULL). The msg argument is used in the
+ * error message; for example, if msg has the value "option" then
+ * the error message will say something like 'bad option "foo": must
* be ...'
*
* Side effects:
@@ -212,15 +213,17 @@ Tcl_GetIndexFromObjStruct(
*/
if (!(flags & TCL_INDEX_TEMP_TABLE)) {
- irPtr = TclFetchIntRep(objPtr, &indexType);
- if (irPtr) {
- indexRep = (IndexRep *)irPtr->twoPtrValue.ptr1;
- if (indexRep->tablePtr==tablePtr && indexRep->offset==offset) {
- *indexPtr = indexRep->index;
- return TCL_OK;
+ irPtr = TclFetchIntRep (objPtr, &indexType);
+ if (irPtr) {
+ indexRep = (IndexRep *) irPtr->twoPtrValue.ptr1;
+ if (indexRep->tablePtr == tablePtr && indexRep->offset == offset) {
+ if (indexPtr != NULL) {
+ *indexPtr = indexRep->index;
+ }
+ return TCL_OK;
+ }
}
}
- }
/*
* Lookup the value of the object in the table. Accept unique
@@ -291,7 +294,9 @@ Tcl_GetIndexFromObjStruct(
indexRep->index = index;
}
- *indexPtr = index;
+ if(indexPtr != NULL) {
+ *indexPtr = index;
+ }
return TCL_OK;
error: