From d33fc57550e1921bfadb8fe4b90d7e55bf23e6f5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 25 Oct 2022 12:23:26 +0000 Subject: Some more int -> Tcl_Size conversions, making the diff with the Tcl 9.0 header-files smaller --- generic/tclArithSeries.h | 4 ++-- generic/tclCompile.h | 17 ++++++++--------- generic/tclDecls.h | 28 ++++++++++++++-------------- generic/tclInt.h | 6 +++--- generic/tclStringRep.h | 19 ++++++++++++------- win/tclWinPort.h | 3 +++ 6 files changed, 42 insertions(+), 35 deletions(-) diff --git a/generic/tclArithSeries.h b/generic/tclArithSeries.h index 3ace052..af4777c 100644 --- a/generic/tclArithSeries.h +++ b/generic/tclArithSeries.h @@ -41,11 +41,11 @@ MODULE_SCOPE int TclArithSeriesObjIndex(Tcl_Obj *arithSeriesPtr, Tcl_WideInt index, Tcl_Obj **elementObj); MODULE_SCOPE Tcl_WideInt TclArithSeriesObjLength(Tcl_Obj *arithSeriesPtr); MODULE_SCOPE Tcl_Obj * TclArithSeriesObjRange(Tcl_Interp *interp, - Tcl_Obj *arithSeriesPtr, int fromIdx, int toIdx); + Tcl_Obj *arithSeriesPtr, Tcl_Size fromIdx, Tcl_Size toIdx); MODULE_SCOPE Tcl_Obj * TclArithSeriesObjReverse(Tcl_Interp *interp, Tcl_Obj *arithSeriesPtr); MODULE_SCOPE int TclArithSeriesGetElements(Tcl_Interp *interp, - Tcl_Obj *objPtr, int *objcPtr, Tcl_Obj ***objvPtr); + Tcl_Obj *objPtr, Tcl_Size *objcPtr, Tcl_Obj ***objvPtr); MODULE_SCOPE Tcl_Obj * TclNewArithSeriesInt(Tcl_WideInt start, Tcl_WideInt end, Tcl_WideInt step, Tcl_WideInt len); diff --git a/generic/tclCompile.h b/generic/tclCompile.h index 2843ef5..b21ed7d 100644 --- a/generic/tclCompile.h +++ b/generic/tclCompile.h @@ -1212,7 +1212,6 @@ MODULE_SCOPE Tcl_Obj *TclNewInstNameObj(unsigned char inst); MODULE_SCOPE int TclPushProcCallFrame(void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], int isLambda); - /* *---------------------------------------------------------------- @@ -1260,10 +1259,10 @@ MODULE_SCOPE int TclPushProcCallFrame(void *clientData, #define TclCheckStackDepth(depth, envPtr) \ do { \ - int _dd = (depth); \ - if (_dd != (envPtr)->currStackDepth) { \ - Tcl_Panic("bad stack depth computations: is %i, should be %i", \ - (envPtr)->currStackDepth, _dd); \ + size_t _dd = (depth); \ + if (_dd != (size_t)(envPtr)->currStackDepth) { \ + Tcl_Panic("bad stack depth computations: is %" TCL_Z_MODIFIER "u, should be %" TCL_Z_MODIFIER "u", \ + (size_t)(envPtr)->currStackDepth, _dd); \ } \ } while (0) @@ -1580,9 +1579,9 @@ MODULE_SCOPE int TclPushProcCallFrame(void *clientData, * of LOOP ranges is an interesting datum for debugging purposes, and that is * what we compute now. * - * static int ExceptionRangeStarts(CompileEnv *envPtr, int index); - * static void ExceptionRangeEnds(CompileEnv *envPtr, int index); - * static void ExceptionRangeTarget(CompileEnv *envPtr, int index, LABEL); + * static int ExceptionRangeStarts(CompileEnv *envPtr, Tcl_Size index); + * static void ExceptionRangeEnds(CompileEnv *envPtr, Tcl_Size index); + * static void ExceptionRangeTarget(CompileEnv *envPtr, Tcl_Size index, LABEL); */ #define ExceptionRangeStarts(envPtr, index) \ @@ -1641,7 +1640,7 @@ MODULE_SCOPE int TclPushProcCallFrame(void *clientData, #define DefineLineInformation \ ExtCmdLoc *mapPtr = envPtr->extCmdMapPtr; \ - int eclIndex = mapPtr->nuloc - 1 + Tcl_Size eclIndex = mapPtr->nuloc - 1 #define SetLineInformation(word) \ envPtr->line = mapPtr->loc[eclIndex].line[(word)]; \ diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 0736b73..d1af7be 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -4351,9 +4351,9 @@ extern const TclStubs *tclStubsPtr; #undef Tcl_GetString #undef Tcl_GetUnicode #define Tcl_GetString(objPtr) \ - Tcl_GetStringFromObj(objPtr, (int *)NULL) + Tcl_GetStringFromObj(objPtr, (Tcl_Size *)NULL) #define Tcl_GetUnicode(objPtr) \ - Tcl_GetUnicodeFromObj(objPtr, (int *)NULL) + Tcl_GetUnicodeFromObj(objPtr, (Tcl_Size *)NULL) #undef Tcl_GetBytesFromObj #undef Tcl_GetIndexFromObjStruct #undef Tcl_GetBooleanFromObj @@ -4441,17 +4441,17 @@ extern const TclStubs *tclStubsPtr; #endif #if defined(USE_TCL_STUBS) # define Tcl_WCharToUtfDString (sizeof(wchar_t) != sizeof(short) \ - ? (char *(*)(const wchar_t *, int, Tcl_DString *))tclStubsPtr->tcl_UniCharToUtfDString \ - : (char *(*)(const wchar_t *, int, Tcl_DString *))Tcl_Char16ToUtfDString) + ? (char *(*)(const wchar_t *, Tcl_Size, Tcl_DString *))tclStubsPtr->tcl_UniCharToUtfDString \ + : (char *(*)(const wchar_t *, Tcl_Size, Tcl_DString *))Tcl_Char16ToUtfDString) # define Tcl_UtfToWCharDString (sizeof(wchar_t) != sizeof(short) \ - ? (wchar_t *(*)(const char *, int, Tcl_DString *))tclStubsPtr->tcl_UtfToUniCharDString \ - : (wchar_t *(*)(const char *, int, Tcl_DString *))Tcl_UtfToChar16DString) + ? (wchar_t *(*)(const char *, Tcl_Size, Tcl_DString *))tclStubsPtr->tcl_UtfToUniCharDString \ + : (wchar_t *(*)(const char *, Tcl_Size, Tcl_DString *))Tcl_UtfToChar16DString) # define Tcl_UtfToWChar (sizeof(wchar_t) != sizeof(short) \ ? (int (*)(const char *, wchar_t *))tclStubsPtr->tcl_UtfToUniChar \ : (int (*)(const char *, wchar_t *))Tcl_UtfToChar16) # define Tcl_WCharLen (sizeof(wchar_t) != sizeof(short) \ - ? (int (*)(wchar_t *))tclStubsPtr->tcl_UniCharLen \ - : (int (*)(wchar_t *))Tcl_Char16Len) + ? (Tcl_Size (*)(wchar_t *))tclStubsPtr->tcl_UniCharLen \ + : (Tcl_Size (*)(wchar_t *))Tcl_Char16Len) #ifdef TCL_NO_DEPRECATED # undef Tcl_ListObjGetElements # define Tcl_ListObjGetElements(interp, listPtr, objcPtr, objvPtr) (sizeof(*(objcPtr)) == sizeof(int) \ @@ -4484,17 +4484,17 @@ extern const TclStubs *tclStubsPtr; #endif /* TCL_NO_DEPRECATED */ #else # define Tcl_WCharToUtfDString (sizeof(wchar_t) != sizeof(short) \ - ? (char *(*)(const wchar_t *, int, Tcl_DString *))Tcl_UniCharToUtfDString \ - : (char *(*)(const wchar_t *, int, Tcl_DString *))Tcl_Char16ToUtfDString) + ? (char *(*)(const wchar_t *, Tcl_Size, Tcl_DString *))Tcl_UniCharToUtfDString \ + : (char *(*)(const wchar_t *, Tcl_Size, Tcl_DString *))Tcl_Char16ToUtfDString) # define Tcl_UtfToWCharDString (sizeof(wchar_t) != sizeof(short) \ - ? (wchar_t *(*)(const char *, int, Tcl_DString *))Tcl_UtfToUniCharDString \ - : (wchar_t *(*)(const char *, int, Tcl_DString *))Tcl_UtfToChar16DString) + ? (wchar_t *(*)(const char *, Tcl_Size, Tcl_DString *))Tcl_UtfToUniCharDString \ + : (wchar_t *(*)(const char *, Tcl_Size, Tcl_DString *))Tcl_UtfToChar16DString) # define Tcl_UtfToWChar (sizeof(wchar_t) != sizeof(short) \ ? (int (*)(const char *, wchar_t *))Tcl_UtfToUniChar \ : (int (*)(const char *, wchar_t *))Tcl_UtfToChar16) # define Tcl_WCharLen (sizeof(wchar_t) != sizeof(short) \ - ? (int (*)(wchar_t *))Tcl_UniCharLen \ - : (int (*)(wchar_t *))Tcl_Char16Len) + ? (Tcl_Size (*)(wchar_t *))Tcl_UniCharLen \ + : (Tcl_Size (*)(wchar_t *))Tcl_Char16Len) #ifdef TCL_NO_DEPRECATED # define Tcl_ListObjGetElements(interp, listPtr, objcPtr, objvPtr) (sizeof(*(objcPtr)) == sizeof(int) \ ? (Tcl_ListObjGetElements)((interp), (listPtr), (int *)(void *)(objcPtr), (objvPtr)) \ diff --git a/generic/tclInt.h b/generic/tclInt.h index 40cf10c..6af0991 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4190,8 +4190,8 @@ MODULE_SCOPE int TclIndexEncode(Tcl_Interp *interp, Tcl_Obj *objPtr, MODULE_SCOPE int TclIndexDecode(int encoded, int endValue); /* Constants used in index value encoding routines. */ -#define TCL_INDEX_END (-2) -#define TCL_INDEX_START (0) +#define TCL_INDEX_END ((Tcl_Size)-2) +#define TCL_INDEX_START ((Tcl_Size)0) /* *---------------------------------------------------------------------- @@ -4697,7 +4697,7 @@ MODULE_SCOPE const TclFileAttrProcs tclpFileAttrProcs[]; * of counting along a string of all one-byte characters. The ANSI C * "prototype" for this macro is: * - * MODULE_SCOPE void TclNumUtfChars(int numChars, const char *bytes, + * MODULE_SCOPE void TclNumUtfCharsM(int numChars, const char *bytes, * int numBytes); *---------------------------------------------------------------- */ diff --git a/generic/tclStringRep.h b/generic/tclStringRep.h index faa2c2c..bce9092 100644 --- a/generic/tclStringRep.h +++ b/generic/tclStringRep.h @@ -31,6 +31,10 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ + +#ifndef _TCLSTRINGREP +#define _TCLSTRINGREP + /* * The following structure is the internal rep for a String object. It keeps @@ -42,15 +46,15 @@ */ typedef struct { - int numChars; /* The number of chars in the string. -1 means - * this value has not been calculated. >= 0 - * means that there is a valid Unicode rep, or - * that the number of UTF bytes == the number - * of chars. */ - int allocated; /* The amount of space actually allocated for + Tcl_Size numChars; /* The number of chars in the string. + * TCL_INDEX_NONE means this value has not been + * calculated. Any other means that there is a valid + * Unicode rep, or that the number of UTF bytes == + * the number of chars. */ + Tcl_Size allocated; /* The amount of space actually allocated for * the UTF string (minus 1 byte for the * termination char). */ - int maxChars; /* Max number of chars that can fit in the + Tcl_Size maxChars; /* Max number of chars that can fit in the * space allocated for the unicode array. */ int hasUnicode; /* Boolean determining whether the string has * a Unicode representation. */ @@ -84,6 +88,7 @@ typedef struct { ((objPtr)->internalRep.twoPtrValue.ptr2 = NULL), \ ((objPtr)->internalRep.twoPtrValue.ptr1 = (void *) (stringPtr)) +#endif /* _TCLSTRINGREP */ /* * Local Variables: * mode: c diff --git a/win/tclWinPort.h b/win/tclWinPort.h index b61e481..d7d60a4 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -461,6 +461,9 @@ typedef DWORD_PTR * PDWORD_PTR; # pragma warning(disable:4090) /* see: https://developercommunity.visualstudio.com/t/c-compiler-incorrect-propagation-of-const-qualifie/390711 */ # pragma warning(disable:4146) # pragma warning(disable:4244) +#if !defined(_WIN64) +# pragma warning(disable:4305) +#endif # pragma warning(disable:4267) # pragma warning(disable:4996) #endif -- cgit v0.12