diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-06-16 23:00:36 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-06-16 23:00:36 (GMT) |
commit | b787fb229d2e4874fdad8cb9c6bf792ae35f8f24 (patch) | |
tree | 5e3f3a8c7b6548c9a29bf4c578b5f752b1151ab6 /generic/tkObj.c | |
parent | d25c25608f9dffe7405b552f4c70510379f6a586 (diff) | |
download | tk-b787fb229d2e4874fdad8cb9c6bf792ae35f8f24.zip tk-b787fb229d2e4874fdad8cb9c6bf792ae35f8f24.tar.gz tk-b787fb229d2e4874fdad8cb9c6bf792ae35f8f24.tar.bz2 |
Implementation complete, appears to function as expected
Diffstat (limited to 'generic/tkObj.c')
-rw-r--r-- | generic/tkObj.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/generic/tkObj.c b/generic/tkObj.c index 3138d0a..4abdde5 100644 --- a/generic/tkObj.c +++ b/generic/tkObj.c @@ -50,6 +50,9 @@ typedef struct PixelRep { typedef struct { const Tcl_ObjType *doubleTypePtr; const Tcl_ObjType *intTypePtr; +#if TCL_MAJOR_VERSION < 9 + const Tcl_ObjType *endTypePtr; +#endif } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; @@ -183,6 +186,13 @@ GetTypeCache(void) /* Smart initialization of doubleTypePtr/intTypePtr without * hash-table lookup or creating complete Tcl_Obj's */ Tcl_Obj obj; +#if TCL_MAJOR_VERSION < 9 + obj.bytes = (char *)"end"; + obj.length = 3; + obj.typePtr = NULL; + Tcl_GetIntForIndex(NULL, &obj, TCL_INDEX_NONE, 0, (TkSizeT *)&obj.internalRep.doubleValue); + tsdPtr->endTypePtr = obj.typePtr; +#endif obj.bytes = (char *)"0.0"; obj.length = 3; obj.typePtr = NULL; @@ -222,7 +232,7 @@ TkGetIntForIndex( int lastOK, TkSizeT *indexPtr) { -#ifdef TK_NO_DEPRECATED +#if defined(TK_NO_DEPRECATED) || TCL_MAJOR_VERSION < 9 ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); #endif @@ -240,7 +250,9 @@ TkGetIntForIndex( } #endif #if TCL_MAJOR_VERSION < 9 - if ((*indexPtr < -1) || (end < TCL_INDEX_END)) { + if ((indexObj->typePtr == tsdPtr->endTypePtr) + && (indexObj->internalRep.wideValue == ((Tcl_WideInt)(((Tcl_WideUInt)-1) >> 1))-1)) { + /* 'end+2' and higher are illegal in Tk. */ return TCL_ERROR; } #endif |