Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Simplify STRING_AT macro. Protect Tcl_GetIndexFromObjStruct from invalid "offset" values, like 0 or -1. Undocumented, because I don't want to promote people start using that. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | core-8-5-branch |
Files: | files | file ages | folders |
SHA1: |
8d90ad34d174691263098bd82e0879e3 |
User & Date: | jan.nijtmans 2013-01-24 08:05:42 |
Context
2013-01-24
| ||
19:09 | Silence come compiler warnings. check-in: 846d6d7575 user: dgp tags: core-8-5-branch | |
14:56 | merge core-8-5-branch Closed-Leaf check-in: ae2e423023 user: jan.nijtmans tags: bug-3601260 | |
08:22 | Simplify STRING_AT macro. Protect Tcl_GetIndexFromObjStruct from invalid "offset" values, like 0 or ... check-in: 4d66f17ddb user: jan.nijtmans tags: trunk | |
08:05 | Simplify STRING_AT macro. Protect Tcl_GetIndexFromObjStruct from invalid "offset" values, like 0 or ... check-in: 8d90ad34d1 user: jan.nijtmans tags: core-8-5-branch | |
2013-01-23
| ||
13:57 | Protect Tcl_GetIndexFromObjStruct from invalid "offset" values, like 0 or -1. Undocumented, because ... check-in: d72e9c88d9 user: jan.nijtmans tags: core-8-4-branch | |
09:03 | Fix [2911139]: connect asynchronously, but without unnecessary internal waits. check-in: 5562d8bc15 user: dkf tags: core-8-5-branch | |
Changes
Changes to generic/tclIndexObj.c.
︙ | ︙ | |||
49 50 51 52 53 54 55 | int index; /* Selected index into table. */ } IndexRep; /* * The following macros greatly simplify moving through a table... */ | | | | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | int index; /* Selected index into table. */ } IndexRep; /* * The following macros greatly simplify moving through a table... */ #define STRING_AT(table, offset) \ (*((const char *const *)(((char *)(table)) + (offset)))) #define NEXT_ENTRY(table, offset) \ (&(STRING_AT(table, offset))) #define EXPAND_OF(indexRep) \ STRING_AT((indexRep)->tablePtr, (indexRep)->offset*(indexRep)->index) /* *---------------------------------------------------------------------- * * Tcl_GetIndexFromObj -- * * This function looks up an object's value in a table of strings and |
︙ | ︙ | |||
134 135 136 137 138 139 140 | * Results: * If the value of objPtr is identical to or a unique abbreviation for * one of the entries in objPtr, 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 | | | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | * Results: * If the value of objPtr is identical to or a unique abbreviation for * one of the entries in objPtr, 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 be * ...' * * Side effects: * The result of the lookup is cached as the internal rep of objPtr, so * that repeated lookups can be done quickly. * *---------------------------------------------------------------------- |
︙ | ︙ | |||
166 167 168 169 170 171 172 173 174 175 176 177 178 179 | int index, idx, numAbbrev; char *key, *p1; const char *p2; const char *const *entryPtr; Tcl_Obj *resultPtr; IndexRep *indexRep; /* * See if there is a valid cached result from a previous lookup. */ if (objPtr->typePtr == &indexType) { indexRep = objPtr->internalRep.otherValuePtr; if (indexRep->tablePtr==tablePtr && indexRep->offset==offset) { | > > > > | 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | int index, idx, numAbbrev; char *key, *p1; const char *p2; const char *const *entryPtr; Tcl_Obj *resultPtr; IndexRep *indexRep; /* Protect against invalid values, like -1 or 0. */ if (offset < (int)sizeof(char *)) { offset = (int)sizeof(char *); } /* * See if there is a valid cached result from a previous lookup. */ if (objPtr->typePtr == &indexType) { indexRep = objPtr->internalRep.otherValuePtr; if (indexRep->tablePtr==tablePtr && indexRep->offset==offset) { |
︙ | ︙ |