diff --git a/generic/tcl.h b/generic/tcl.h index 7ef41802877..f8a34c0043b 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -123,6 +123,7 @@ extern "C" { */ #include +#include /* *---------------------------------------------------------------------------- @@ -136,7 +137,7 @@ extern "C" { */ #include -#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 +#ifndef TCL_NO_DEPRECATED # define TCL_VARARGS(type, name) (type name, ...) # define TCL_VARARGS_DEF(type, name) (type name, ...) # define TCL_VARARGS_START(type, name, list) (va_start(list, name), name) @@ -256,7 +257,7 @@ extern "C" { * New code should use prototypes. */ -#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 +#ifndef TCL_NO_DEPRECATED # undef _ANSI_ARGS_ # define _ANSI_ARGS_(x) x @@ -299,7 +300,7 @@ extern "C" { * VOID. This block is skipped under Cygwin and Mingw. */ -#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 +#ifndef TCL_NO_DEPRECATED #if defined(_WIN32) && !defined(HAVE_WINNT_IGNORE_VOID) #ifndef VOID #define VOID void @@ -317,7 +318,7 @@ typedef long LONG; #ifndef __VXWORKS__ # define VOID void #endif -#endif /* !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 */ +#endif /* !TCL_NO_DEPRECATED */ /* * Miscellaneous declarations. @@ -414,7 +415,6 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt; #define Tcl_WideAsDouble(val) ((double)((Tcl_WideInt)(val))) #define Tcl_DoubleAsWide(val) ((Tcl_WideInt)((double)(val))) - #if TCL_MAJOR_VERSION < 9 typedef int Tcl_Size; # define TCL_SIZE_MAX INT_MAX @@ -476,7 +476,7 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt; */ typedef struct Tcl_Interp -#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 +#ifndef TCL_NO_DEPRECATED { /* TIP #330: Strongly discourage extensions from using the string * result. */ @@ -584,19 +584,28 @@ typedef void (Tcl_ThreadCreateProc) (void *clientData); */ typedef struct Tcl_RegExpIndices { - long start; /* Character offset of first character in +#if TCL_MAJOR_VERSION > 8 + Tcl_Size start; /* Character offset of first character in * match. */ - long end; /* Character offset of first character after + Tcl_Size end; /* Character offset of first character after * the match. */ +#else + long start; + long end; +#endif } Tcl_RegExpIndices; typedef struct Tcl_RegExpInfo { - int nsubs; /* Number of subexpressions in the compiled + Tcl_Size nsubs; /* Number of subexpressions in the compiled * expression. */ Tcl_RegExpIndices *matches; /* Array of nsubs match offset pairs. */ - long extendStart; /* The offset at which a subsequent match +#if TCL_MAJOR_VERSION > 8 + Tcl_Size extendStart; /* The offset at which a subsequent match * might begin. */ +#else + long extendStart; long reserved; /* Reserved for later use. */ +#endif } Tcl_RegExpInfo; /* @@ -634,7 +643,7 @@ typedef struct stat *Tcl_OldStat_; #define TCL_BREAK 3 #define TCL_CONTINUE 4 -#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 +#ifndef TCL_NO_DEPRECATED #define TCL_RESULT_SIZE 200 #endif @@ -652,7 +661,7 @@ typedef struct stat *Tcl_OldStat_; * Argument descriptors for math function callbacks in expressions: */ -#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 +#ifndef TCL_NO_DEPRECATED typedef enum { TCL_INT, TCL_DOUBLE, TCL_EITHER, TCL_WIDE_INT } Tcl_ValueType; @@ -696,7 +705,7 @@ typedef int (Tcl_CmdObjTraceProc) (void *clientData, Tcl_Interp *interp, int level, const char *command, Tcl_Command commandInfo, int objc, struct Tcl_Obj *const *objv); typedef int (Tcl_CmdObjTraceProc2) (void *clientData, Tcl_Interp *interp, - size_t level, const char *command, Tcl_Command commandInfo, size_t objc, + ptrdiff_t level, const char *command, Tcl_Command commandInfo, ptrdiff_t objc, struct Tcl_Obj *const *objv); typedef void (Tcl_CmdObjTraceDeleteProc) (void *clientData); typedef void (Tcl_DupInternalRepProc) (struct Tcl_Obj *srcPtr, @@ -723,7 +732,7 @@ typedef void (Tcl_NamespaceDeleteProc) (void *clientData); typedef int (Tcl_ObjCmdProc) (void *clientData, Tcl_Interp *interp, int objc, struct Tcl_Obj *const *objv); typedef int (Tcl_ObjCmdProc2) (void *clientData, Tcl_Interp *interp, - size_t objc, struct Tcl_Obj *const *objv); + ptrdiff_t objc, struct Tcl_Obj *const *objv); typedef int (Tcl_LibraryInitProc) (Tcl_Interp *interp); typedef int (Tcl_LibraryUnloadProc) (Tcl_Interp *interp, int flags); typedef void (Tcl_PanicProc) (const char *format, ...); @@ -972,9 +981,9 @@ typedef struct Tcl_DString { #define Tcl_DStringLength(dsPtr) ((dsPtr)->length) #define Tcl_DStringValue(dsPtr) ((dsPtr)->string) -#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 +#ifndef TCL_NO_DEPRECATED # define Tcl_DStringTrunc Tcl_DStringSetLength -#endif /* !TCL_NO_DEPRECATED */ +#endif /* * Definitions for the maximum number of digits of precision that may be @@ -1096,7 +1105,7 @@ typedef struct Tcl_DString { #define TCL_TRACE_UNSETS 0x40 #define TCL_TRACE_DESTROYED 0x80 -#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 +#ifndef TCL_NO_DEPRECATED #define TCL_INTERP_DESTROYED 0x100 #endif @@ -1134,9 +1143,9 @@ typedef struct Tcl_DString { * give the flag) */ -#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 +#ifndef TCL_NO_DEPRECATED # define TCL_PARSE_PART1 0x400 -#endif /* !TCL_NO_DEPRECATED */ +#endif /* * Types for linked variables: @@ -1294,10 +1303,15 @@ struct Tcl_HashTable { * table. */ Tcl_Size rebuildSize; /* Enlarge table when numEntries gets to be * this large. */ +#if TCL_MAJOR_VERSION > 8 + size_t mask; /* Mask value used in hashing function. */ +#endif int downShift; /* Shift count used in hashing function. * Designed to use high-order bits of * randomized keys. */ - int mask; /* Mask value used in hashing function. */ +#if TCL_MAJOR_VERSION < 9 + int mask; /* Mask value used in hashing function. */ +#endif int keyType; /* Type of keys used in this table. It's * either TCL_CUSTOM_KEYS, TCL_STRING_KEYS, * TCL_ONE_WORD_KEYS, or an integer giving the @@ -1463,7 +1477,11 @@ typedef void (Tcl_ScaleTimeProc) (Tcl_Time *timebuf, void *clientData); * interface. */ -#define TCL_CLOSE2PROC ((Tcl_DriverCloseProc *) 1) +#if TCL_MAJOR_VERSION > 8 +# define TCL_CLOSE2PROC NULL +#else +# define TCL_CLOSE2PROC ((Tcl_DriverCloseProc *)(void *)(size_t)1) +#endif /* * Channel version tag. This was introduced in 8.3.2/8.4. @@ -2038,6 +2056,12 @@ typedef struct Tcl_Parse { * *tokenPtr. */ int errorType; /* One of the parsing error types defined * above. */ +#if TCL_MAJOR_VERSION > 8 + int incomplete; /* This field is set to 1 by Tcl_ParseCommand + * if the command appears to be incomplete. + * This information is used by + * Tcl_CommandComplete. */ +#endif /* * The fields below are intended only for the private use of the parser. @@ -2056,10 +2080,9 @@ typedef struct Tcl_Parse { * beginning of region where the error * occurred (e.g. the open brace if the close * brace is missing). */ - int incomplete; /* This field is set to 1 by Tcl_ParseCommand - * if the command appears to be incomplete. - * This information is used by - * Tcl_CommandComplete. */ +#if TCL_MAJOR_VERSION < 9 + int incomplete; +#endif Tcl_Token staticTokens[NUM_STATIC_TOKENS]; /* Initial space for tokens for command. This * space should be large enough to accommodate @@ -2410,7 +2433,11 @@ typedef int (Tcl_NRPostProc) (void *data[], Tcl_Interp *interp, * stubs tables. */ -#define TCL_STUB_MAGIC ((int) 0xFCA3BACF) +#if TCL_MAJOR_VERSION > 8 +# define TCL_STUB_MAGIC ((int) 0xFCA3BACB + (int) sizeof(void *)) +#else +# define TCL_STUB_MAGIC ((int) 0xFCA3BACF) +#endif /* * The following function is required to be defined in all stubs aware @@ -2632,7 +2659,7 @@ EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv); * Deprecated Tcl functions: */ -#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 +#ifndef TCL_NO_DEPRECATED /* * These function have been renamed. The old names are deprecated, but we * define these macros for backwards compatibility. diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 70d2160e154..4159cc467ec 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -9195,7 +9195,7 @@ Tcl_NRCallObjProc2( ptrdiff_t objc, Tcl_Obj *const objv[]) { - if (objc > INT_MAX) { + if ((size_t)objc > INT_MAX) { Tcl_WrongNumArgs(interp, 1, objv, "?args?"); return TCL_ERROR; } diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 204830be80c..710ed0bf0c9 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -557,7 +557,7 @@ TclGetByteArrayFromObj( if (numBytesPtr != NULL) { /* Make sure we return a value between 0 and UINT_MAX-1, or (size_t)-1 */ - *numBytesPtr = ((size_t)(unsigned int)(baPtr->used + 1)) - 1; + *numBytesPtr = ((ptrdiff_t)(unsigned int)(baPtr->used + 1)) - 1; } return baPtr->bytes; } diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 7d82250e827..9c3ca0d2550 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -4217,7 +4217,7 @@ extern const TclStubs *tclStubsPtr; # define Tcl_SetPanicProc(arg) ((void)((Tcl_SetPanicProc)(arg))) # endif # define Tcl_MainEx Tcl_MainExW - EXTERN void Tcl_MainExW(int argc, wchar_t **argv, + EXTERN void Tcl_MainExW(Tcl_Size argc, wchar_t **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp); #elif !defined(TCL_NO_DEPRECATED) # define Tcl_FindExecutable(arg) ((void)((Tcl_FindExecutable)(arg))) diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index db98d54129c..774485ddd25 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -602,7 +602,7 @@ TclInitEncodingSubsystem(void) type.nullSize = 1; type.clientData = INT2PTR(ENCODING_UTF); Tcl_CreateEncoding(&type); - type.clientData = INT2PTR(0); + type.clientData = NULL; type.encodingName = "cesu-8"; Tcl_CreateEncoding(&type); @@ -614,7 +614,7 @@ TclInitEncodingSubsystem(void) type.clientData = INT2PTR(TCL_ENCODING_LE); Tcl_CreateEncoding(&type); type.encodingName = "ucs-2be"; - type.clientData = INT2PTR(0); + type.clientData = NULL; Tcl_CreateEncoding(&type); type.encodingName = "ucs-2"; type.clientData = INT2PTR(leFlags); @@ -628,7 +628,7 @@ TclInitEncodingSubsystem(void) type.clientData = INT2PTR(TCL_ENCODING_LE); Tcl_CreateEncoding(&type); type.encodingName = "utf-32be"; - type.clientData = INT2PTR(0); + type.clientData = NULL; Tcl_CreateEncoding(&type); type.encodingName = "utf-32"; type.clientData = INT2PTR(leFlags); @@ -639,13 +639,13 @@ TclInitEncodingSubsystem(void) type.freeProc = NULL; type.nullSize = 2; type.encodingName = "utf-16le"; - type.clientData = INT2PTR(TCL_ENCODING_LE|ENCODING_UTF); + type.clientData = INT2PTR(TCL_ENCODING_LE); Tcl_CreateEncoding(&type); type.encodingName = "utf-16be"; - type.clientData = INT2PTR(ENCODING_UTF); + type.clientData = NULL; Tcl_CreateEncoding(&type); type.encodingName = "utf-16"; - type.clientData = INT2PTR(leFlags|ENCODING_UTF); + type.clientData = INT2PTR(leFlags); Tcl_CreateEncoding(&type); #ifndef TCL_NO_DEPRECATED diff --git a/generic/tclOO.h b/generic/tclOO.h index 6f1849160a6..775bd32f44a 100644 --- a/generic/tclOO.h +++ b/generic/tclOO.h @@ -63,7 +63,7 @@ typedef struct Tcl_ObjectContext_ *Tcl_ObjectContext; typedef int (Tcl_MethodCallProc)(void *clientData, Tcl_Interp *interp, Tcl_ObjectContext objectContext, int objc, Tcl_Obj *const *objv); typedef int (Tcl_MethodCallProc2)(void *clientData, Tcl_Interp *interp, - Tcl_ObjectContext objectContext, size_t objc, Tcl_Obj *const *objv); + Tcl_ObjectContext objectContext, ptrdiff_t objc, Tcl_Obj *const *objv); typedef void (Tcl_MethodDeleteProc)(void *clientData); typedef int (Tcl_CloneProc)(Tcl_Interp *interp, void *oldClientData, void **newClientData); diff --git a/generic/tclObj.c b/generic/tclObj.c index aeaa0cd6dd9..93e3a08929c 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -1751,11 +1751,7 @@ TclGetStringFromObj( } } if (lengthPtr != NULL) { -#if TCL_MAJOR_VERSION > 8 - *lengthPtr = objPtr->length; -#else - *lengthPtr = ((size_t)(unsigned)(objPtr->length + 1)) - 1; -#endif + *lengthPtr = ((ptrdiff_t)(unsigned)(objPtr->length + 1)) - 1; } return objPtr->bytes; } @@ -4081,7 +4077,7 @@ Tcl_GetNumber( numBytes = 0; } if (numBytes < 0) { - numBytes = strlen(bytes); + numBytes = (ptrdiff_t)strlen(bytes); } if (numBytes > INT_MAX) { if (interp) { diff --git a/generic/tclProc.c b/generic/tclProc.c index d02cac24125..3abf3c39519 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -1690,7 +1690,7 @@ NRInterpProc2( * interpreted. */ Tcl_Interp *interp,/* Interpreter in which procedure was * invoked. */ - size_t objc, /* Count of number of arguments to this + ptrdiff_t objc, /* Count of number of arguments to this * procedure. */ Tcl_Obj *const objv[]) /* Argument value objects. */ { @@ -1709,7 +1709,7 @@ ObjInterpProc2( * interpreted. */ Tcl_Interp *interp,/* Interpreter in which procedure was * invoked. */ - size_t objc, /* Count of number of arguments to this + ptrdiff_t objc, /* Count of number of arguments to this * procedure. */ Tcl_Obj *const objv[]) /* Argument value objects. */ { diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 3a51f7eeada..104375e81e8 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -97,7 +97,7 @@ static void uniCodePanic(void) { } # define Tcl_GetUnicode (unsigned short *(*)(Tcl_Obj *))(void *)uniCodePanic # define Tcl_GetUnicodeFromObj (unsigned short *(*)(Tcl_Obj *, int *))(void *)uniCodePanic -# define TclGetUnicodeFromObj (unsigned short *(*)(Tcl_Obj *, size_t *))(void *)uniCodePanic +# define TclGetUnicodeFromObj (unsigned short *(*)(Tcl_Obj *, ptrdiff_t *))(void *)uniCodePanic # define Tcl_NewUnicodeObj (Tcl_Obj *(*)(const unsigned short *, int))(void *)uniCodePanic # define Tcl_SetUnicodeObj (void(*)(Tcl_Obj *, const unsigned short *, int))(void *)uniCodePanic # define Tcl_AppendUnicodeToObj (void(*)(Tcl_Obj *, const unsigned short *, int))(void *)uniCodePanic diff --git a/tests/ioCmd.test b/tests/ioCmd.test index 2a1f6165e3e..e132b9ac6a3 100644 --- a/tests/ioCmd.test +++ b/tests/ioCmd.test @@ -1072,7 +1072,7 @@ test iocmd-23.1 {chan read, regular data return} -match glob -body { rename foo {} set res } -result {{read rc* 4096} {read rc* 4096} snarfsnarf} -test iocmd-23.2 {chan read, bad data return, to much} -match glob -body { +test iocmd-23.2 {chan read, bad data return, too much} -match glob -body { set res {} proc foo {args} { oninit; onfinal; track @@ -2383,7 +2383,7 @@ test iocmd.tf-23.1 {chan read, regular data return} -match glob -body { rename foo {} set res } -constraints {testchannel thread} -result {{read rc* 4096} {read rc* 4096} snarfsnarf} -test iocmd.tf-23.2 {chan read, bad data return, to much} -match glob -body { +test iocmd.tf-23.2 {chan read, bad data return, too much} -match glob -body { set res {} proc foo {args} { oninit; onfinal; track diff --git a/tools/regexpTestLib.tcl b/tools/regexpTestLib.tcl index 454a4e88524..71dc9093077 100644 --- a/tools/regexpTestLib.tcl +++ b/tools/regexpTestLib.tcl @@ -42,7 +42,7 @@ proc readInputFile {} { # # strings with embedded @'s are truncated -# unpreceeded @'s are replaced by {} +# unpreceded @'s are replaced by {} # proc removeAts {ls} { set len [llength $ls] diff --git a/unix/dltest/pkgt.c b/unix/dltest/pkgt.c index e8047db98be..0c4b3d7089f 100644 --- a/unix/dltest/pkgt.c +++ b/unix/dltest/pkgt.c @@ -16,10 +16,10 @@ static int TraceProc2 ( void *clientData, Tcl_Interp *interp, - size_t level, + ptrdiff_t level, const char *command, Tcl_Command commandInfo, - size_t objc, + ptrdiff_t objc, struct Tcl_Obj *const *objv) { (void)clientData; @@ -55,12 +55,12 @@ static int Pkgt_EqObjCmd2( void *dummy, /* Not used. */ Tcl_Interp *interp, /* Current interpreter. */ - size_t objc, /* Number of arguments. */ + ptrdiff_t objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { Tcl_WideInt result; const char *str1, *str2; - size_t len1, len2; + ptrdiff_t len1, len2; (void)dummy; if (objc != 3) { @@ -71,7 +71,7 @@ Pkgt_EqObjCmd2( str1 = Tcl_GetStringFromObj(objv[1], &len1); str2 = Tcl_GetStringFromObj(objv[2], &len2); if (len1 == len2) { - result = (Tcl_UtfNcmp(str1, str2, len1) == 0); + result = (Tcl_UtfNcmp(str1, str2, (size_t)len1) == 0); } else { result = 0; } diff --git a/win/tclAppInit.c b/win/tclAppInit.c index 27eb1641d11..a3914f131d5 100644 --- a/win/tclAppInit.c +++ b/win/tclAppInit.c @@ -141,7 +141,7 @@ _tmain( TclZipfs_AppHook(&argc, &argv); #endif - Tcl_Main((size_t)argc, argv, TCL_LOCAL_APPINIT); + Tcl_Main(argc, argv, TCL_LOCAL_APPINIT); return 0; /* Needed only to prevent compiler warning. */ }