From e4971bdffcb5ad9da61fec42904e83511c80108d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 27 Jul 2023 12:57:27 +0000 Subject: Proposed fix for [e58d7e19e9]: Upwards compatibility of TclObjTypeHasProc() --- generic/tcl.h | 4 ++-- generic/tclInt.h | 14 ++++---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/generic/tcl.h b/generic/tcl.h index cae8fb6..0dfa8a8 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -677,9 +677,9 @@ typedef struct Tcl_ObjType { #if TCL_MAJOR_VERSION > 8 # define TCL_OBJTYPE_V0 0, \ 0,0,0,0,0,0,0 /* Pre-Tcl 9 */ -# define TCL_OBJTYPE_V1(a) 1, \ +# define TCL_OBJTYPE_V1(a) offsetof(Tcl_ObjType, indexProc), \ a,0,0,0,0,0,0 /* Tcl 9 Version 1 */ -# define TCL_OBJTYPE_V2(a,b,c,d,e,f,g) 2, \ +# define TCL_OBJTYPE_V2(a,b,c,d,e,f,g) offsetof(Tcl_ObjType, reservedProc), \ a,b,c,d,e,f,g /* Tcl 9 - AbstractLists */ #else # define TCL_OBJTYPE_V0 /* just empty */ diff --git a/generic/tclInt.h b/generic/tclInt.h index 9c7ad17..599fb2d 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -1084,16 +1084,10 @@ typedef struct ActiveInterpTrace { #define TCL_TRACE_LEAVE_EXEC 2 #if TCL_MAJOR_VERSION > 8 -/* - * Versions 0, 1, and 2 are currently supported concurrently for now - */ -#define TclObjTypeHasProc(objPtr, proc) \ - (((objPtr)->typePtr \ - && ( (objPtr)->typePtr->version == 1 \ - || (objPtr)->typePtr->version == 2)) \ - ? ((objPtr)->typePtr)->proc \ - : NULL) - +#define TclObjTypeHasProc(objPtr, proc) (((objPtr)->typePtr \ + && ((offsetof(Tcl_ObjType, proc) < offsetof(Tcl_ObjType, version)) \ + || (offsetof(Tcl_ObjType, proc) < (objPtr)->typePtr->version))) ? \ + ((objPtr)->typePtr)->proc : NULL) MODULE_SCOPE Tcl_Size TclLengthOne(Tcl_Obj *); -- cgit v0.12