diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-03-09 11:50:52 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-03-09 11:50:52 (GMT) |
commit | 9d439c2c31ed769cc362bf803770817848e0dbfc (patch) | |
tree | a34ee2cd386abb51c4ba12d43082cee00c570ca1 | |
parent | 8b215bbfe1c4d5cbb2cfa8ad7671cd2cf464e106 (diff) | |
parent | 4a817f1ea075eef7f3077a32208c70e02a8df6c5 (diff) | |
download | tcl-9d439c2c31ed769cc362bf803770817848e0dbfc.zip tcl-9d439c2c31ed769cc362bf803770817848e0dbfc.tar.gz tcl-9d439c2c31ed769cc362bf803770817848e0dbfc.tar.bz2 |
Merge 8.7
58 files changed, 338 insertions, 246 deletions
diff --git a/.github/workflows/onefiledist.yml b/.github/workflows/onefiledist.yml index b6b3614..8bd8ed2 100644 --- a/.github/workflows/onefiledist.yml +++ b/.github/workflows/onefiledist.yml @@ -100,7 +100,7 @@ jobs: path: 1dist/*.dmg win: name: Windows - runs-on: windows-latest + runs-on: windows-2019 defaults: run: shell: msys2 {0} diff --git a/.github/workflows/win-build.yml b/.github/workflows/win-build.yml index 5c787f5..a8019ee 100644 --- a/.github/workflows/win-build.yml +++ b/.github/workflows/win-build.yml @@ -4,7 +4,7 @@ env: ERROR_ON_FAILURES: 1 jobs: msvc: - runs-on: windows-latest + runs-on: windows-2022 defaults: run: shell: powershell @@ -43,7 +43,7 @@ jobs: throw "nmake exit code: $lastexitcode" } gcc: - runs-on: windows-latest + runs-on: windows-2022 defaults: run: shell: msys2 {0} diff --git a/compat/zlib/win64-arm/libz.dll.a b/compat/zlib/win64-arm/libz.dll.a Binary files differnew file mode 100644 index 0000000..b6cbde7 --- /dev/null +++ b/compat/zlib/win64-arm/libz.dll.a diff --git a/compat/zlib/win64-arm/zdll.lib b/compat/zlib/win64-arm/zdll.lib Binary files differindex a1b6c50..0fe0140 100755..100644 --- a/compat/zlib/win64-arm/zdll.lib +++ b/compat/zlib/win64-arm/zdll.lib diff --git a/compat/zlib/win64-arm/zlib1.dll b/compat/zlib/win64-arm/zlib1.dll Binary files differindex 2abef88..1f43308 100755 --- a/compat/zlib/win64-arm/zlib1.dll +++ b/compat/zlib/win64-arm/zlib1.dll diff --git a/compat/zlib/win64/libz.dll.a b/compat/zlib/win64/libz.dll.a Binary files differindex 93be06e..b0c8722 100644 --- a/compat/zlib/win64/libz.dll.a +++ b/compat/zlib/win64/libz.dll.a diff --git a/compat/zlib/win64/zlib1.dll b/compat/zlib/win64/zlib1.dll Binary files differindex 81195c3..e893cff 100755 --- a/compat/zlib/win64/zlib1.dll +++ b/compat/zlib/win64/zlib1.dll diff --git a/doc/GetIndex.3 b/doc/GetIndex.3 index a788848..1169c6c 100644 --- a/doc/GetIndex.3 +++ b/doc/GetIndex.3 @@ -54,10 +54,12 @@ Null-terminated string describing what is being looked up, such as .AP int flags in OR-ed combination of bits providing additional information for operation. The only bits that are currently defined are \fBTCL_EXACT\fR -and \fBTCL_INDEX_TEMP_TABLE\fR. -.AP int *indexPtr out -The index of the string in \fItablePtr\fR that matches the value of -\fIobjPtr\fR is returned here. +, \fBTCL_INDEX_TEMP_TABLE\fR, and \fBTCL_INDEX_NULL_OK\fR. +.AP enum|char|short|int|long *indexPtr out +If not (int *)NULL, the index of the string in \fItablePtr\fR that +matches the value of \fIobjPtr\fR is returned here. The variable can +be any integer type, signed or unsigned, char, short, long or +long long. It can also be an enum. .BE .SH DESCRIPTION .PP @@ -70,8 +72,8 @@ the strings in \fItablePtr\fR to find a match. A match occurs if \fItablePtr\fR, or if it is a non-empty unique abbreviation for exactly one of the strings in \fItablePtr\fR and the \fBTCL_EXACT\fR flag was not specified; in either case -the index of the matching entry is stored at \fI*indexPtr\fR -and \fBTCL_OK\fR is returned. +\fBTCL_OK\fR is returned. If \fIindexPtr\fR is not NULL the index +of the matching entry is stored at \fI*indexPtr\fR. .PP If there is no matching entry, \fBTCL_ERROR\fR is returned and an error message is left in \fIinterp\fR's @@ -91,7 +93,9 @@ operation. Note: \fBTcl_GetIndexFromObj\fR assumes that the entries in \fItablePtr\fR are static: they must not change between invocations. This caching mechanism can be disallowed by specifying the \fBTCL_INDEX_TEMP_TABLE\fR flag. -If the value of \fIobjPtr\fR is the empty string, +If the \fBTCL_INDEX_NULL_OK\fR flag was specified, objPtr is allowed +to be NULL or the empty string. The resulting index is -1. +Otherwise, if the value of \fIobjPtr\fR is the empty string, \fBTcl_GetIndexFromObj\fR will treat it as a non-matching value and return \fBTCL_ERROR\fR. .PP diff --git a/doc/Notifier.3 b/doc/Notifier.3 index ec9f910..efbe216 100644 --- a/doc/Notifier.3 +++ b/doc/Notifier.3 @@ -103,7 +103,7 @@ passed to \fBTcl_DoOneEvent\fR. .AP int mode in Indicates whether events should be serviced by \fBTcl_ServiceAll\fR. Must be one of \fBTCL_SERVICE_NONE\fR or \fBTCL_SERVICE_ALL\fR. -.AP Tcl_NotifierProcs* notifierProcPtr in +.AP const Tcl_NotifierProcs* notifierProcPtr in Structure of function pointers describing notifier procedures that are to replace the ones installed in the executable. See \fBREPLACING THE NOTIFIER\fR for details. @@ -8,7 +8,7 @@ .so man.macros .BS .SH NAME -Tcl_UniChar, Tcl_UniCharToUtf, Tcl_UtfToUniChar, Tcl_UtfToChar16, Tcl_UtfToWChar, Tcl_UniCharToUtfDString, Tcl_UtfToUniCharDString, Tcl_Char16ToUtfDString, Tcl_UtfToWCharDString, Tcl_UtfToChar16DString, Tcl_UniCharLen, Tcl_UniCharNcmp, Tcl_UniCharNcasecmp, Tcl_UniCharCaseMatch, Tcl_UtfNcmp, Tcl_UtfNcasecmp, Tcl_UtfCharComplete, Tcl_NumUtfChars, Tcl_UtfFindFirst, Tcl_UtfFindLast, Tcl_UtfNext, Tcl_UtfPrev, Tcl_UniCharAtIndex, Tcl_UtfAtIndex, Tcl_UtfBackslash \- routines for manipulating UTF-8 strings +Tcl_UniChar, Tcl_UniCharToUtf, Tcl_UtfToUniChar, Tcl_UtfToChar16, Tcl_UtfToWChar, Tcl_UniCharToUtfDString, Tcl_UtfToUniCharDString, Tcl_Char16ToUtfDString, Tcl_UtfToWCharDString, Tcl_UtfToChar16DString, Tcl_WCharLen, Tcl_Char16Len, Tcl_UniCharLen, Tcl_UniCharNcmp, Tcl_UniCharNcasecmp, Tcl_UniCharCaseMatch, Tcl_UtfNcmp, Tcl_UtfNcasecmp, Tcl_UtfCharComplete, Tcl_NumUtfChars, Tcl_UtfFindFirst, Tcl_UtfFindLast, Tcl_UtfNext, Tcl_UtfPrev, Tcl_UniCharAtIndex, Tcl_UtfAtIndex, Tcl_UtfBackslash \- routines for manipulating UTF-8 strings .SH SYNOPSIS .nf \fB#include <tcl.h>\fR @@ -46,6 +46,12 @@ wchar_t * \fBTcl_UtfToWCharDString\fR(\fIsrc, length, dsPtr\fR) .sp int +\fBTcl_Char16Len\fR(\fIuniStr\fR) +.sp +int +\fBTcl_WCharLen\fR(\fIuniStr\fR) +.sp +int \fBTcl_UniCharLen\fR(\fIuniStr\fR) .sp int @@ -198,6 +204,14 @@ representation of the UTF-8 string. Storage for the return value is appended to the end of the \fBTcl_DString\fR. The Unicode string is terminated with a Unicode null character. .PP +\fBTcl_Char16Len\fR corresponds to \fBstrlen\fR for UTF-16 +characters. It accepts a null-terminated Unicode string and returns +the number of Unicode characters (not bytes) in that string. +.PP +\fBTcl_WCharLen\fR corresponds to \fBstrlen\fR for wchar_t +characters. It accepts a null-terminated Unicode string and returns +the number of Unicode characters (not bytes) in that string. +.PP \fBTcl_UniCharLen\fR corresponds to \fBstrlen\fR for Unicode characters. It accepts a null-terminated Unicode string and returns the number of Unicode characters (not bytes) in that string. diff --git a/generic/tcl.decls b/generic/tcl.decls index ebdbac1..3647512 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -1092,7 +1092,7 @@ declare 303 { declare 304 { int Tcl_GetIndexFromObjStruct(Tcl_Interp *interp, Tcl_Obj *objPtr, const void *tablePtr, int offset, const char *msg, int flags, - int *indexPtr) + void *indexPtr) } declare 305 { void *Tcl_GetThreadData(Tcl_ThreadDataKey *keyPtr, int size) @@ -1244,8 +1244,8 @@ declare 350 { declare 351 { int Tcl_UniCharIsWordChar(int ch) } -declare 352 {deprecated {Use Tcl_GetCharLength}} { - int Tcl_UniCharLen(const Tcl_UniChar *uniStr) +declare 352 { + int Tcl_Char16Len(const unsigned short *uniStr) } declare 353 {deprecated {Use Tcl_UtfNcmp}} { int Tcl_UniCharNcmp(const Tcl_UniChar *ucs, const Tcl_UniChar *uct, @@ -1365,7 +1365,7 @@ declare 385 { Tcl_Obj *patternObj) } declare 386 { - void Tcl_SetNotifier(Tcl_NotifierProcs *notifierProcPtr) + void Tcl_SetNotifier(const Tcl_NotifierProcs *notifierProcPtr) } declare 387 { Tcl_Mutex *Tcl_GetAllocMutex(void) @@ -2469,6 +2469,11 @@ declare 667 { size_t *objcPtr, Tcl_Obj *const *objv, Tcl_Obj ***remObjv) } +# TIP #617 +declare 668 { + int Tcl_UniCharLen(const int *uniStr) +} + # ----- BASELINE -- FOR -- 8.7.0 ----- # ############################################################################## diff --git a/generic/tcl.h b/generic/tcl.h index 346b79c..b82cf0a 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -979,10 +979,13 @@ typedef struct Tcl_DString { * TCL_EXACT disallows abbreviated strings. * TCL_INDEX_TEMP_TABLE disallows caching of lookups. A possible use case is * a table that will not live long enough to make it worthwhile. + * TCL_INDEX_NULL_OK allows the empty string or NULL to return TCL_OK. + * The returned value will be -1; */ #define TCL_EXACT 1 #define TCL_INDEX_TEMP_TABLE 2 +#define TCL_INDEX_NULL_OK 4 /* *---------------------------------------------------------------------------- diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 714bd80..ae7a3dc 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -7841,7 +7841,7 @@ ExprSqrtFunc( if (code != TCL_OK) { return TCL_ERROR; } - if ((d >= 0.0) && TclIsInfinite(d) + if ((d >= 0.0) && isinf(d) && (Tcl_GetBignumFromObj(NULL, objv[1], &big) == TCL_OK)) { mp_int root; mp_err err; @@ -7906,12 +7906,12 @@ CheckDoubleResult( double dResult) { #ifndef ACCEPT_NAN - if (TclIsNaN(dResult)) { + if (isnan(dResult)) { TclExprFloatError(interp, dResult); return TCL_ERROR; } #endif - if ((errno == ERANGE) && ((dResult == 0.0) || TclIsInfinite(dResult))) { + if ((errno == ERANGE) && ((dResult == 0.0) || isinf(dResult))) { /* * When ERANGE signals under/overflow, just accept 0.0 or +/-Inf */ diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 5ac08e9..31e8272 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -824,7 +824,7 @@ UpdateStringOfByteArray( for (i = 0; i < length && size <= INT_MAX; i++) { if ((src[i] == 0) || (src[i] > 127)) { - size++; + size += 1U; } } if (size > INT_MAX) { @@ -2383,12 +2383,12 @@ ScanNumber( value = (long) (buffer[0] + (buffer[1] << 8) + (buffer[2] << 16) - + (((long)buffer[3]) << 24)); + + (((unsigned long)buffer[3]) << 24)); } else { value = (long) (buffer[3] + (buffer[2] << 8) + (buffer[1] << 16) - + (((long) buffer[0]) << 24)); + + (((unsigned long) buffer[0]) << 24)); } /* diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 249ea9e..6069161 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -945,7 +945,7 @@ EXTERN void Tcl_GetEncodingNames(Tcl_Interp *interp); EXTERN int Tcl_GetIndexFromObjStruct(Tcl_Interp *interp, Tcl_Obj *objPtr, const void *tablePtr, int offset, const char *msg, int flags, - int *indexPtr); + void *indexPtr); /* 305 */ EXTERN void * Tcl_GetThreadData(Tcl_ThreadDataKey *keyPtr, int size); @@ -1063,8 +1063,7 @@ EXTERN int Tcl_UniCharIsUpper(int ch); /* 351 */ EXTERN int Tcl_UniCharIsWordChar(int ch); /* 352 */ -TCL_DEPRECATED("Use Tcl_GetCharLength") -int Tcl_UniCharLen(const Tcl_UniChar *uniStr); +EXTERN int Tcl_Char16Len(const unsigned short *uniStr); /* 353 */ TCL_DEPRECATED("Use Tcl_UtfNcmp") int Tcl_UniCharNcmp(const Tcl_UniChar *ucs, @@ -1165,7 +1164,8 @@ void Tcl_AppendUnicodeToObj(Tcl_Obj *objPtr, EXTERN int Tcl_RegExpMatchObj(Tcl_Interp *interp, Tcl_Obj *textObj, Tcl_Obj *patternObj); /* 386 */ -EXTERN void Tcl_SetNotifier(Tcl_NotifierProcs *notifierProcPtr); +EXTERN void Tcl_SetNotifier( + const Tcl_NotifierProcs *notifierProcPtr); /* 387 */ EXTERN Tcl_Mutex * Tcl_GetAllocMutex(void); /* 388 */ @@ -1972,6 +1972,8 @@ EXTERN int TclParseArgsObjv_(Tcl_Interp *interp, const Tcl_ArgvInfo *argTable, size_t *objcPtr, Tcl_Obj *const *objv, Tcl_Obj ***remObjv); +/* 668 */ +EXTERN int Tcl_UniCharLen(const int *uniStr); typedef struct { const struct TclPlatStubs *tclPlatStubs; @@ -2311,7 +2313,7 @@ typedef struct TclStubs { Tcl_Encoding (*tcl_GetEncoding) (Tcl_Interp *interp, const char *name); /* 301 */ const char * (*tcl_GetEncodingName) (Tcl_Encoding encoding); /* 302 */ void (*tcl_GetEncodingNames) (Tcl_Interp *interp); /* 303 */ - int (*tcl_GetIndexFromObjStruct) (Tcl_Interp *interp, Tcl_Obj *objPtr, const void *tablePtr, int offset, const char *msg, int flags, int *indexPtr); /* 304 */ + int (*tcl_GetIndexFromObjStruct) (Tcl_Interp *interp, Tcl_Obj *objPtr, const void *tablePtr, int offset, const char *msg, int flags, void *indexPtr); /* 304 */ void * (*tcl_GetThreadData) (Tcl_ThreadDataKey *keyPtr, int size); /* 305 */ Tcl_Obj * (*tcl_GetVar2Ex) (Tcl_Interp *interp, const char *part1, const char *part2, int flags); /* 306 */ ClientData (*tcl_InitNotifier) (void); /* 307 */ @@ -2359,7 +2361,7 @@ typedef struct TclStubs { int (*tcl_UniCharIsSpace) (int ch); /* 349 */ int (*tcl_UniCharIsUpper) (int ch); /* 350 */ int (*tcl_UniCharIsWordChar) (int ch); /* 351 */ - TCL_DEPRECATED_API("Use Tcl_GetCharLength") int (*tcl_UniCharLen) (const Tcl_UniChar *uniStr); /* 352 */ + int (*tcl_Char16Len) (const unsigned short *uniStr); /* 352 */ TCL_DEPRECATED_API("Use Tcl_UtfNcmp") int (*tcl_UniCharNcmp) (const Tcl_UniChar *ucs, const Tcl_UniChar *uct, unsigned long numChars); /* 353 */ char * (*tcl_Char16ToUtfDString) (const unsigned short *uniStr, int uniLength, Tcl_DString *dsPtr); /* 354 */ unsigned short * (*tcl_UtfToChar16DString) (const char *src, int length, Tcl_DString *dsPtr); /* 355 */ @@ -2393,7 +2395,7 @@ typedef struct TclStubs { Tcl_Obj * (*tcl_GetRange) (Tcl_Obj *objPtr, int first, int last); /* 383 */ TCL_DEPRECATED_API("Use Tcl_AppendStringsToObj") void (*tcl_AppendUnicodeToObj) (Tcl_Obj *objPtr, const Tcl_UniChar *unicode, int length); /* 384 */ int (*tcl_RegExpMatchObj) (Tcl_Interp *interp, Tcl_Obj *textObj, Tcl_Obj *patternObj); /* 385 */ - void (*tcl_SetNotifier) (Tcl_NotifierProcs *notifierProcPtr); /* 386 */ + void (*tcl_SetNotifier) (const Tcl_NotifierProcs *notifierProcPtr); /* 386 */ Tcl_Mutex * (*tcl_GetAllocMutex) (void); /* 387 */ int (*tcl_GetChannelNames) (Tcl_Interp *interp); /* 388 */ int (*tcl_GetChannelNamesEx) (Tcl_Interp *interp, const char *pattern); /* 389 */ @@ -2675,6 +2677,7 @@ typedef struct TclStubs { void (*tclSplitPath_) (const char *path, size_t *argcPtr, const char ***argvPtr); /* 665 */ Tcl_Obj * (*tclFSSplitPath_) (Tcl_Obj *pathPtr, size_t *lenPtr); /* 666 */ int (*tclParseArgsObjv_) (Tcl_Interp *interp, const Tcl_ArgvInfo *argTable, size_t *objcPtr, Tcl_Obj *const *objv, Tcl_Obj ***remObjv); /* 667 */ + int (*tcl_UniCharLen) (const int *uniStr); /* 668 */ } TclStubs; extern const TclStubs *tclStubsPtr; @@ -3409,8 +3412,8 @@ extern const TclStubs *tclStubsPtr; (tclStubsPtr->tcl_UniCharIsUpper) /* 350 */ #define Tcl_UniCharIsWordChar \ (tclStubsPtr->tcl_UniCharIsWordChar) /* 351 */ -#define Tcl_UniCharLen \ - (tclStubsPtr->tcl_UniCharLen) /* 352 */ +#define Tcl_Char16Len \ + (tclStubsPtr->tcl_Char16Len) /* 352 */ #define Tcl_UniCharNcmp \ (tclStubsPtr->tcl_UniCharNcmp) /* 353 */ #define Tcl_Char16ToUtfDString \ @@ -4039,6 +4042,8 @@ extern const TclStubs *tclStubsPtr; (tclStubsPtr->tclFSSplitPath_) /* 666 */ #define TclParseArgsObjv_ \ (tclStubsPtr->tclParseArgsObjv_) /* 667 */ +#define Tcl_UniCharLen \ + (tclStubsPtr->tcl_UniCharLen) /* 668 */ #endif /* defined(USE_TCL_STUBS) */ @@ -4254,6 +4259,7 @@ extern const TclStubs *tclStubsPtr; #define Tcl_GetUnicode(objPtr) \ Tcl_GetUnicodeFromObj(objPtr, (int *)NULL) #undef Tcl_GetBytesFromObj +#undef Tcl_GetIndexFromObjStruct #ifdef TCL_NO_DEPRECATED #undef Tcl_GetStringFromObj #undef Tcl_GetUnicodeFromObj @@ -4262,6 +4268,8 @@ extern const TclStubs *tclStubsPtr; #if defined(USE_TCL_STUBS) #define Tcl_GetBytesFromObj(interp, objPtr, sizePtr) \ (sizeof(*sizePtr) <= sizeof(int) ? tclStubsPtr->tclGetBytesFromObj(interp, objPtr, (int *)sizePtr) : tclStubsPtr->tcl_GetBytesFromObj(interp, objPtr, (size_t *)sizePtr)) +#define Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, offset, msg, flags, indexPtr) \ + (tclStubsPtr->tcl_GetIndexFromObjStruct((interp), (objPtr), (tablePtr), (offset), (msg), (flags)|(int)(sizeof(*indexPtr)<<8), (indexPtr))) #ifdef TCL_NO_DEPRECATED #define Tcl_GetStringFromObj(objPtr, sizePtr) \ (sizeof(*sizePtr) <= sizeof(int) ? tclStubsPtr->tcl_GetStringFromObj(objPtr, (int *)sizePtr) : tclStubsPtr->tclGetStringFromObj(objPtr, (size_t *)sizePtr)) @@ -4273,6 +4281,8 @@ extern const TclStubs *tclStubsPtr; #else #define Tcl_GetBytesFromObj(interp, objPtr, sizePtr) \ (sizeof(*sizePtr) <= sizeof(int) ? (TclGetBytesFromObj)(interp, objPtr, (int *)sizePtr) : (Tcl_GetBytesFromObj)(interp, objPtr, (size_t *)sizePtr)) +#define Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, offset, msg, flags, indexPtr) \ + ((Tcl_GetIndexFromObjStruct)((interp), (objPtr), (tablePtr), (offset), (msg), (flags)|(int)(sizeof(*indexPtr)<<8), (indexPtr))) #ifdef TCL_NO_DEPRECATED #define Tcl_GetStringFromObj(objPtr, sizePtr) \ (sizeof(*sizePtr) <= sizeof(int) ? (Tcl_GetStringFromObj)(objPtr, (int *)sizePtr) : (TclGetStringFromObj)(objPtr, (size_t *)sizePtr)) @@ -4298,13 +4308,15 @@ extern const TclStubs *tclStubsPtr; #undef Tcl_StringMatch #define Tcl_StringMatch(str, pattern) Tcl_StringCaseMatch((str), (pattern), 0) -#if TCL_UTF_MAX <= 3 +#if TCL_UTF_MAX < 4 # undef Tcl_UniCharToUtfDString # define Tcl_UniCharToUtfDString Tcl_Char16ToUtfDString # undef Tcl_UtfToUniCharDString # define Tcl_UtfToUniCharDString Tcl_UtfToChar16DString # undef Tcl_UtfToUniChar # define Tcl_UtfToUniChar Tcl_UtfToChar16 +# undef Tcl_UniCharLen +# define Tcl_UniCharLen Tcl_Char16Len #endif #if defined(USE_TCL_STUBS) # define Tcl_WCharToUtfDString (sizeof(wchar_t) != sizeof(short) \ @@ -4316,6 +4328,9 @@ extern const TclStubs *tclStubsPtr; # 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) #ifdef TCL_NO_DEPRECATED # undef Tcl_ListObjGetElements # define Tcl_ListObjGetElements(interp, listPtr, objcPtr, objvPtr) (sizeof(*objcPtr) == sizeof(int) \ @@ -4356,6 +4371,9 @@ extern const TclStubs *tclStubsPtr; # 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) #endif /* @@ -4377,6 +4395,13 @@ extern const TclStubs *tclStubsPtr; #undef TclUtfCharComplete #undef TclUtfNext #undef TclUtfPrev +#undef TclListObjGetElements_ +#undef TclListObjLength_ +#undef TclDictObjSize_ +#undef TclSplitList_ +#undef TclSplitPath_ +#undef TclFSSplitPath_ +#undef TclParseArgsObjv_ #if defined(USE_TCL_STUBS) && (TCL_UTF_MAX < 4) && !defined(TCL_NO_DEPRECATED) # undef Tcl_UtfCharComplete # undef Tcl_UtfNext diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index fd83855..4630a02 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -2798,7 +2798,7 @@ UtfToUcs2Proc( { const char *srcStart, *srcEnd, *srcClose, *dstStart, *dstEnd; int result, numChars; -#if TCL_UTF_MAX <= 3 +#if TCL_UTF_MAX < 4 int len; #endif Tcl_UniChar ch = 0; @@ -2829,7 +2829,7 @@ UtfToUcs2Proc( result = TCL_CONVERT_NOSPACE; break; } -#if TCL_UTF_MAX <= 3 +#if TCL_UTF_MAX < 4 src += (len = TclUtfToUniChar(src, &ch)); if ((ch >= 0xD800) && (len < 3)) { src += TclUtfToUniChar(src, &ch); @@ -3242,7 +3242,7 @@ Iso88591FromUtfProc( */ if (ch > 0xFF -#if TCL_UTF_MAX <= 3 +#if TCL_UTF_MAX < 4 || ((ch >= 0xD800) && (len < 3)) #endif ) { @@ -3250,7 +3250,7 @@ Iso88591FromUtfProc( result = TCL_CONVERT_UNKNOWN; break; } -#if TCL_UTF_MAX <= 3 +#if TCL_UTF_MAX < 4 if ((ch >= 0xD800) && (len < 3)) { len = 4; } diff --git a/generic/tclExecute.c b/generic/tclExecute.c index bfb094a..0279218 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -514,7 +514,7 @@ VarHashCreateVar( *(ptrPtr) = (ClientData) \ (&((objPtr)->internalRep.wideValue)), TCL_OK) : \ TclHasInternalRep((objPtr), &tclDoubleType) \ - ? (((TclIsNaN((objPtr)->internalRep.doubleValue)) \ + ? (((isnan((objPtr)->internalRep.doubleValue)) \ ? (*(tPtr) = TCL_NUMBER_NAN) \ : (*(tPtr) = TCL_NUMBER_DOUBLE)), \ *(ptrPtr) = (ClientData) \ @@ -1857,7 +1857,7 @@ TclIncrObj( w1 = *((const Tcl_WideInt *)ptr1); w2 = *((const Tcl_WideInt *)ptr2); - sum = w1 + w2; + sum = (Tcl_WideInt)((Tcl_WideUInt)w1 + (Tcl_WideUInt)w2); /* * Check for overflow. @@ -3711,7 +3711,7 @@ TEBCresume( if (GetNumberFromObj(NULL, objPtr, &ptr, &type) == TCL_OK) { if (type == TCL_NUMBER_INT) { Tcl_WideInt augend = *((const Tcl_WideInt *)ptr); - Tcl_WideInt sum = augend + increment; + Tcl_WideInt sum = (Tcl_WideInt)((Tcl_WideUInt)augend + (Tcl_WideUInt)increment); /* * Overflow when (augend and sum have different sign) and @@ -5904,7 +5904,8 @@ TEBCresume( (wResult * w2 != w1)) { wResult -= 1; } - wResult = w1 - w2*wResult; + wResult = (Tcl_WideInt)((Tcl_WideUInt)w1 - + (Tcl_WideUInt)w2*(Tcl_WideUInt)wResult); goto wideResultOfArithmetic; } break; @@ -6111,7 +6112,7 @@ TEBCresume( switch (*pc) { case INST_ADD: - wResult = w1 + w2; + wResult = (Tcl_WideInt)((Tcl_WideUInt)w1 + (Tcl_WideUInt)w2); /* * Check for overflow. */ @@ -6122,7 +6123,7 @@ TEBCresume( goto wideResultOfArithmetic; case INST_SUB: - wResult = w1 - w2; + wResult = (Tcl_WideInt)((Tcl_WideUInt)w1 - (Tcl_WideUInt)w2); /* * Must check for overflow. The macro tests for overflows in * sums by looking at the sign bits. As we have a subtraction @@ -7529,20 +7530,20 @@ TEBCresume( #ifdef TCL_WIDE_CLICKS wval = TclpGetWideClicks(); #else - wval = (Tcl_WideInt) TclpGetClicks(); + wval = (Tcl_WideInt)TclpGetClicks(); #endif break; case 1: /* microseconds */ Tcl_GetTime(&now); - wval = (Tcl_WideInt) now.sec * 1000000 + now.usec; + wval = (Tcl_WideInt)now.sec * 1000000 + now.usec; break; case 2: /* milliseconds */ Tcl_GetTime(&now); - wval = (Tcl_WideInt) now.sec * 1000 + now.usec / 1000; + wval = (Tcl_WideInt)now.sec * 1000 + now.usec / 1000; break; case 3: /* seconds */ Tcl_GetTime(&now); - wval = (Tcl_WideInt) now.sec; + wval = (Tcl_WideInt)now.sec; break; default: Tcl_Panic("clockRead instruction with unknown clock#"); @@ -7802,7 +7803,7 @@ TEBCresume( fprintf(stdout, " ... found catch at %d, catchTop=%d, " "unwound to %ld, new pc %u\n", rangePtr->codeOffset, (int) (catchTop - initCatchTop - 1), - (long) *catchTop, (unsigned) rangePtr->catchOffset); + (long)*catchTop, (unsigned) rangePtr->catchOffset); } #endif pc = (codePtr->codeStart + rangePtr->catchOffset); @@ -8148,21 +8149,22 @@ ExecuteExtendedBinaryMathOp( * TODO: examine for logic simplification */ - if (((wQuotient < (Tcl_WideInt) 0) - || ((wQuotient == (Tcl_WideInt) 0) + if (((wQuotient < 0) + || ((wQuotient == 0) && ((w1 < 0 && w2 > 0) || (w1 > 0 && w2 < 0)))) && (wQuotient * w2 != w1)) { - wQuotient -= (Tcl_WideInt) 1; + wQuotient -= 1; } - wRemainder = w1 - w2*wQuotient; + wRemainder = (Tcl_WideInt)((Tcl_WideUInt)w1 - + (Tcl_WideUInt)w2*(Tcl_WideUInt)wQuotient); WIDE_RESULT(wRemainder); } Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2); /* TODO: internals intrusion */ - if ((w1 > ((Tcl_WideInt) 0)) ^ !mp_isneg(&big2)) { + if ((w1 > ((Tcl_WideInt)0)) ^ !mp_isneg(&big2)) { /* * Arguments are opposite sign; remainder is sum. */ @@ -8275,9 +8277,9 @@ ExecuteExtendedBinaryMathOp( && ((size_t)shift < CHAR_BIT*sizeof(Tcl_WideInt))) { w1 = *((const Tcl_WideInt *)ptr1); if (!((w1>0 ? w1 : ~w1) - & -(((Tcl_WideInt)1) + & -(((Tcl_WideUInt)1) << (CHAR_BIT*sizeof(Tcl_WideInt) - 1 - shift)))) { - WIDE_RESULT(w1 << shift); + WIDE_RESULT((Tcl_WideUInt)w1 << shift); } } } else { @@ -8432,7 +8434,7 @@ ExecuteExtendedBinaryMathOp( } negativeExponent = (w2 < 0); - oddExponent = (int) (w2 & (Tcl_WideInt)1); + oddExponent = (int)w2 & 1; } else { Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2); negativeExponent = mp_isneg(&big2); @@ -8522,8 +8524,8 @@ ExecuteExtendedBinaryMathOp( * Reduce small powers of 2 to shifts. */ - if ((Tcl_WideUInt) w2 < (Tcl_WideUInt) CHAR_BIT*sizeof(Tcl_WideInt) - 1) { - WIDE_RESULT(((Tcl_WideInt) 1) << (int)w2); + if ((Tcl_WideUInt)w2 < (Tcl_WideUInt)CHAR_BIT*sizeof(Tcl_WideInt) - 1) { + WIDE_RESULT(((Tcl_WideInt)1) << (int)w2); } goto overflowExpon; } @@ -8534,8 +8536,8 @@ ExecuteExtendedBinaryMathOp( * Reduce small powers of 2 to shifts. */ - if ((Tcl_WideUInt) w2 < CHAR_BIT * sizeof(Tcl_WideInt) - 1) { - WIDE_RESULT(signum * (((Tcl_WideInt) 1) << (int) w2)); + if ((Tcl_WideUInt)w2 < CHAR_BIT * sizeof(Tcl_WideInt) - 1) { + WIDE_RESULT(signum * (((Tcl_WideInt)1) << (int) w2)); } goto overflowExpon; } @@ -8653,7 +8655,7 @@ ExecuteExtendedBinaryMathOp( * Check now for IEEE floating-point error. */ - if (TclIsNaN(dResult)) { + if (isnan(dResult)) { TclExprFloatError(interp, dResult); return GENERAL_ARITHMETIC_ERROR; } @@ -8666,7 +8668,7 @@ ExecuteExtendedBinaryMathOp( switch (opcode) { case INST_ADD: - wResult = w1 + w2; + wResult = (Tcl_WideInt)((Tcl_WideUInt)w1 + (Tcl_WideUInt)w2); if ((type1 == TCL_NUMBER_INT) || (type2 == TCL_NUMBER_INT)) { /* @@ -8680,7 +8682,7 @@ ExecuteExtendedBinaryMathOp( break; case INST_SUB: - wResult = w1 - w2; + wResult = (Tcl_WideInt)((Tcl_WideUInt)w1 - (Tcl_WideUInt)w2); if ((type1 == TCL_NUMBER_INT) || (type2 == TCL_NUMBER_INT)) { /* @@ -8906,7 +8908,7 @@ TclCompareTwoNumbers( * doubles. */ - if (DBL_MANT_DIG > CHAR_BIT*sizeof(Tcl_WideInt) || w1 == (Tcl_WideInt) d1 + if (DBL_MANT_DIG > CHAR_BIT*sizeof(Tcl_WideInt) || w1 == (Tcl_WideInt)d1 || modf(d2, &tmp) != 0.0) { goto doubleCompare; } @@ -8929,7 +8931,7 @@ TclCompareTwoNumbers( if (d2 > (double)WIDE_MAX) { return MP_LT; } - w2 = (Tcl_WideInt) d2; + w2 = (Tcl_WideInt)d2; goto wideCompare; case TCL_NUMBER_BIG: Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2); @@ -8954,7 +8956,7 @@ TclCompareTwoNumbers( w2 = *((const Tcl_WideInt *)ptr2); d2 = (double) w2; if (DBL_MANT_DIG > CHAR_BIT*sizeof(Tcl_WideInt) - || w2 == (Tcl_WideInt) d2 || modf(d1, &tmp) != 0.0) { + || w2 == (Tcl_WideInt)d2 || modf(d1, &tmp) != 0.0) { goto doubleCompare; } if (d1 < (double)WIDE_MIN) { @@ -8963,10 +8965,10 @@ TclCompareTwoNumbers( if (d1 > (double)WIDE_MAX) { return MP_GT; } - w1 = (Tcl_WideInt) d1; + w1 = (Tcl_WideInt)d1; goto wideCompare; case TCL_NUMBER_BIG: - if (TclIsInfinite(d1)) { + if (isinf(d1)) { return (d1 > 0.0) ? MP_GT : MP_LT; } Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2); @@ -8999,7 +9001,7 @@ TclCompareTwoNumbers( return compare; case TCL_NUMBER_DOUBLE: d2 = *((const double *)ptr2); - if (TclIsInfinite(d2)) { + if (isinf(d2)) { compare = (d2 > 0.0) ? MP_LT : MP_GT; mp_clear(&big1); return compare; @@ -9602,11 +9604,11 @@ TclExprFloatError( { const char *s; - if ((errno == EDOM) || TclIsNaN(value)) { + if ((errno == EDOM) || isnan(value)) { s = "domain error: argument not in valid range"; Tcl_SetObjResult(interp, Tcl_NewStringObj(s, -1)); Tcl_SetErrorCode(interp, "ARITH", "DOMAIN", s, NULL); - } else if ((errno == ERANGE) || TclIsInfinite(value)) { + } else if ((errno == ERANGE) || isinf(value)) { if (value == 0.0) { s = "floating-point value too small to represent"; Tcl_SetObjResult(interp, Tcl_NewStringObj(s, -1)); diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c index 9f1058a..1f600c5 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.c @@ -235,11 +235,12 @@ GetIndexFromObjList( * Results: * If the value of objPtr is identical to or a unique abbreviation for * one of the entries in tablePtr, 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 + * the index of the matching entry is stored at *indexPtr + * (unless indexPtr is NULL). 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: @@ -249,6 +250,7 @@ GetIndexFromObjList( *---------------------------------------------------------------------- */ +#undef Tcl_GetIndexFromObjStruct int Tcl_GetIndexFromObjStruct( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ @@ -261,8 +263,8 @@ Tcl_GetIndexFromObjStruct( int offset, /* The number of bytes between entries */ const char *msg, /* Identifying word to use in error * messages. */ - int flags, /* 0, TCL_EXACT or TCL_INDEX_TEMP_TABLE */ - int *indexPtr) /* Place to store resulting integer index. */ + int flags, /* 0, TCL_EXACT, TCL_INDEX_TEMP_TABLE or TCL_INDEX_NULL_OK */ + void *indexPtr) /* Place to store resulting index. */ { int index, idx, numAbbrev; const char *key, *p1; @@ -287,8 +289,8 @@ Tcl_GetIndexFromObjStruct( if ((indexRep->tablePtr == tablePtr) && (indexRep->offset == offset) && (indexRep->index >= 0)) { - *indexPtr = indexRep->index; - return TCL_OK; + index = indexRep->index; + goto uncachedDone; } } } @@ -302,6 +304,9 @@ Tcl_GetIndexFromObjStruct( index = -1; numAbbrev = 0; + if (!*key && (flags & TCL_INDEX_NULL_OK)) { + goto uncachedDone; + } /* * Scan the table looking for one of: * - An exact match (always preferred) @@ -362,7 +367,25 @@ Tcl_GetIndexFromObjStruct( indexRep->index = index; } - *indexPtr = index; + uncachedDone: + if (indexPtr != NULL) { + if ((flags>>8) & (int)~sizeof(int)) { + if ((flags>>8) == sizeof(uint64_t)) { + *(uint64_t *)indexPtr = index; + return TCL_OK; + } else if ((flags>>8) == sizeof(uint32_t)) { + *(uint32_t *)indexPtr = index; + return TCL_OK; + } else if ((flags>>8) == sizeof(uint16_t)) { + *(uint16_t *)indexPtr = index; + return TCL_OK; + } else if ((flags>>8) == sizeof(uint8_t)) { + *(uint8_t *)indexPtr = index; + return TCL_OK; + } + } + *(int *)indexPtr = index; + } return TCL_OK; error: @@ -388,7 +411,7 @@ Tcl_GetIndexFromObjStruct( *entryPtr, NULL); entryPtr = NEXT_ENTRY(entryPtr, offset); while (*entryPtr != NULL) { - if (*NEXT_ENTRY(entryPtr, offset) == NULL) { + if ((*NEXT_ENTRY(entryPtr, offset) == NULL) && !(flags & TCL_INDEX_NULL_OK)) { Tcl_AppendStringsToObj(resultPtr, (count > 0 ? "," : ""), " or ", *entryPtr, NULL); } else if (**entryPtr) { @@ -397,6 +420,9 @@ Tcl_GetIndexFromObjStruct( } entryPtr = NEXT_ENTRY(entryPtr, offset); } + if ((flags & TCL_INDEX_NULL_OK)) { + Tcl_AppendStringsToObj(resultPtr, ", or \"\"", NULL); + } } Tcl_SetObjResult(interp, resultPtr); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", msg, key, NULL); diff --git a/generic/tclInt.h b/generic/tclInt.h index b82a473..2873ad3 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4510,7 +4510,7 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file, (objPtr)->bytes = &tclEmptyString; \ (objPtr)->length = 0; \ } else { \ - (objPtr)->bytes = (char *)ckalloc((len) + 1); \ + (objPtr)->bytes = (char *)ckalloc((unsigned int)(len) + 1U); \ memcpy((objPtr)->bytes, (bytePtr) ? (bytePtr) : &tclEmptyString, (len)); \ (objPtr)->bytes[len] = '\0'; \ (objPtr)->length = (len); \ @@ -4965,22 +4965,15 @@ MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_SafeInit; /* *---------------------------------------------------------------- * Macros used by the Tcl core to test for some special double values. - * The ANSI C "prototypes" for these macros are: + * (deprecated) The ANSI C "prototypes" for these macros are: * * MODULE_SCOPE int TclIsInfinite(double d); * MODULE_SCOPE int TclIsNaN(double d); */ -#ifdef _MSC_VER -# define TclIsInfinite(d) (!(_finite((d)))) -# define TclIsNaN(d) (_isnan((d))) -#else -# define TclIsInfinite(d) ((d) > DBL_MAX || (d) < -DBL_MAX) -# ifdef NO_ISNAN -# define TclIsNaN(d) ((d) != (d)) -# else -# define TclIsNaN(d) (isnan(d)) -# endif +#if !defined(TCL_NO_DEPRECATED) && !defined(BUILD_tcl) +# define TclIsInfinite(d) isinf(d) +# define TclIsNaN(d) isnan(d) #endif /* diff --git a/generic/tclLink.c b/generic/tclLink.c index 5baa092..39f5345 100644 --- a/generic/tclLink.c +++ b/generic/tclLink.c @@ -606,7 +606,7 @@ EqualDouble( { return (a == b) #ifdef ACCEPT_NAN - || (TclIsNaN(a) && TclIsNaN(b)) + || (isnan(a) && isnan(b)) #endif /* ACCEPT_NAN */ ; } @@ -615,9 +615,9 @@ static inline int IsSpecial( double a) { - return TclIsInfinite(a) + return isinf(a) #ifdef ACCEPT_NAN - || TclIsNaN(a) + || isnan(a) #endif /* ACCEPT_NAN */ ; } diff --git a/generic/tclNotify.c b/generic/tclNotify.c index 12b40b1..1140168 100644 --- a/generic/tclNotify.c +++ b/generic/tclNotify.c @@ -226,7 +226,7 @@ TclFinalizeNotifier(void) void Tcl_SetNotifier( - Tcl_NotifierProcs *notifierProcPtr) + const Tcl_NotifierProcs *notifierProcPtr) { tclNotifierHooks = *notifierProcPtr; diff --git a/generic/tclOODefineCmds.c b/generic/tclOODefineCmds.c index cadfee5..4af23c2 100644 --- a/generic/tclOODefineCmds.c +++ b/generic/tclOODefineCmds.c @@ -2002,7 +2002,7 @@ TclOODefineMethodObjCmd( } if (objc == 5) { if (Tcl_GetIndexFromObj(interp, objv[2], exportModes, "export flag", - 0, (int *) &exportMode) != TCL_OK) { + 0, &exportMode) != TCL_OK) { return TCL_ERROR; } switch (exportMode) { diff --git a/generic/tclObj.c b/generic/tclObj.c index 16a95cd..a06b8fd 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -2547,7 +2547,7 @@ Tcl_GetDoubleFromObj( { do { if (objPtr->typePtr == &tclDoubleType) { - if (TclIsNaN(objPtr->internalRep.doubleValue)) { + if (isnan(objPtr->internalRep.doubleValue)) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "floating point value is Not a Number", -1)); @@ -3054,7 +3054,7 @@ Tcl_GetLongFromObj( if (w >= (Tcl_WideInt)(LONG_MIN) && w <= (Tcl_WideInt)(ULONG_MAX)) { - *longPtr = (long) w; + *longPtr = (long)w; return TCL_OK; } goto tooLarge; @@ -3090,12 +3090,12 @@ Tcl_GetLongFromObj( } if (big.sign) { if (value <= 1 + (unsigned long)LONG_MAX) { - *longPtr = - (long) value; + *longPtr = (long)(-value); return TCL_OK; } } else { if (value <= (unsigned long)ULONG_MAX) { - *longPtr = (long) value; + *longPtr = (long)value; return TCL_OK; } } @@ -3329,12 +3329,12 @@ Tcl_GetWideIntFromObj( } if (big.sign) { if (value <= 1 + ~(Tcl_WideUInt)WIDE_MIN) { - *wideIntPtr = - (Tcl_WideInt) value; + *wideIntPtr = (Tcl_WideInt)(-value); return TCL_OK; } } else { if (value <= (Tcl_WideUInt)WIDE_MAX) { - *wideIntPtr = (Tcl_WideInt) value; + *wideIntPtr = (Tcl_WideInt)value; return TCL_OK; } } @@ -3800,7 +3800,7 @@ Tcl_SetBignumObj( goto tooLargeForWide; } if (bignumValue->sign) { - TclSetIntObj(objPtr, -(Tcl_WideInt)value); + TclSetIntObj(objPtr, (Tcl_WideInt)(-value)); } else { TclSetIntObj(objPtr, (Tcl_WideInt)value); } @@ -3880,7 +3880,7 @@ TclGetNumberFromObj( { do { if (objPtr->typePtr == &tclDoubleType) { - if (TclIsNaN(objPtr->internalRep.doubleValue)) { + if (isnan(objPtr->internalRep.doubleValue)) { *typePtr = TCL_NUMBER_NAN; } else { *typePtr = TCL_NUMBER_DOUBLE; diff --git a/generic/tclScan.c b/generic/tclScan.c index 134f60d..6bc914d 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -916,9 +916,10 @@ Tcl_ScanObjCmd( } if (flags & SCAN_LONGER) { if (Tcl_GetWideIntFromObj(NULL, objPtr, &wideValue) != TCL_OK) { - wideValue = WIDE_MAX; if (TclGetString(objPtr)[0] == '-') { wideValue = WIDE_MIN; + } else { + wideValue = WIDE_MAX; } } if ((flags & SCAN_UNSIGNED) && (wideValue < 0)) { diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index e87f714..a7986b0 100644 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -543,8 +543,7 @@ TclParseNumber( int under = 0; /* Flag trailing '_' as error if true once * number is accepted. */ -#define ALL_BITS UWIDE_MAX -#define MOST_BITS (ALL_BITS >> 1) +#define MOST_BITS (UWIDE_MAX >> 1) /* * Initialize bytes to start of the object's string rep if the caller @@ -915,7 +914,7 @@ TclParseNumber( acceptState = state; acceptPoint = p; acceptLen = len; - /* FALLTHRU */ + /* FALLTHRU */ case ZERO_B: zerob: if (c == '0') { @@ -1447,10 +1446,10 @@ TclParseNumber( objPtr->typePtr = &tclIntType; if (signum) { objPtr->internalRep.wideValue = - - (Tcl_WideInt) octalSignificandWide; + (Tcl_WideInt)(-octalSignificandWide); } else { objPtr->internalRep.wideValue = - (Tcl_WideInt) octalSignificandWide; + (Tcl_WideInt)octalSignificandWide; } } } @@ -1483,10 +1482,10 @@ TclParseNumber( objPtr->typePtr = &tclIntType; if (signum) { objPtr->internalRep.wideValue = - - (Tcl_WideInt) significandWide; + (Tcl_WideInt)(-significandWide); } else { objPtr->internalRep.wideValue = - (Tcl_WideInt) significandWide; + (Tcl_WideInt)significandWide; } } } @@ -2189,7 +2188,7 @@ RefineApproximation( */ if (roundToEven) { rteSignificand = frexp(approxResult, &rteExponent); - rteSigWide = (Tcl_WideInt) ldexp(rteSignificand, FP_PRECISION); + rteSigWide = (Tcl_WideInt)ldexp(rteSignificand, FP_PRECISION); if ((rteSigWide & 1) == 0) { mp_clear(&twoMd); mp_clear(&twoMv); @@ -3852,15 +3851,13 @@ ShouldBankerRoundUp( int r = mp_cmp_mag(twor, S); switch (r) { - case MP_LT: - return 0; case MP_EQ: return isodd; case MP_GT: return 1; + default: + return 0; } - Tcl_Panic("in ShouldBankerRoundUp, trichotomy fails!"); - return 0; } /* @@ -3898,15 +3895,13 @@ ShouldBankerRoundUpToNext( r = mp_cmp_mag(&temp, S); mp_clear(&temp); switch(r) { - case MP_LT: - return 0; case MP_EQ: return isodd; case MP_GT: return 1; + default: + return 0; } - Tcl_Panic("in ShouldBankerRoundUpToNext, trichotomy fails!"); - return 0; } /* @@ -4837,7 +4832,7 @@ Tcl_InitBignumFromDouble( * Infinite values can't convert to bignum. */ - if (TclIsInfinite(d)) { + if (isinf(d)) { if (interp != NULL) { const char *s = "integer value too large to represent"; @@ -4852,7 +4847,7 @@ Tcl_InitBignumFromDouble( err = mp_init(b); mp_zero(b); } else { - Tcl_WideInt w = (Tcl_WideInt) ldexp(fract, mantBits); + Tcl_WideInt w = (Tcl_WideInt)ldexp(fract, mantBits); int shift = expt - mantBits; err = mp_init_i64(b, w); diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index bee1e3e..7d4aef3 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -561,7 +561,7 @@ Tcl_GetUniChar( TclNumUtfChars(stringPtr->numChars, objPtr->bytes, objPtr->length); } if (stringPtr->numChars == objPtr->length) { - return (Tcl_UniChar) objPtr->bytes[index]; + return (unsigned char) objPtr->bytes[index]; } FillUnicodeRep(objPtr); stringPtr = GET_STRING(objPtr); @@ -571,7 +571,7 @@ Tcl_GetUniChar( return -1; } ch = stringPtr->unicode[index]; -#if TCL_UTF_MAX <= 3 +#if TCL_UTF_MAX < 4 /* See: bug [11ae2be95dac9417] */ if ((ch & 0xF800) == 0xD800) { if (ch & 0x400) { @@ -785,7 +785,7 @@ Tcl_GetRange( TclNewObj(newObjPtr); return newObjPtr; } -#if TCL_UTF_MAX <= 3 +#if TCL_UTF_MAX < 4 /* See: bug [11ae2be95dac9417] */ if ((first > 0) && ((stringPtr->unicode[first] & 0xFC00) == 0xDC00) && ((stringPtr->unicode[first-1] & 0xFC00) == 0xD800)) { @@ -914,9 +914,9 @@ Tcl_SetObjLength( * Need to enlarge the buffer. */ if (objPtr->bytes == &tclEmptyString) { - objPtr->bytes = (char *)ckalloc(length + 1); + objPtr->bytes = (char *)ckalloc((unsigned int)length + 1U); } else { - objPtr->bytes = (char *)ckrealloc(objPtr->bytes, length + 1); + objPtr->bytes = (char *)ckrealloc(objPtr->bytes, (unsigned int)length + 1U); } stringPtr->allocated = length; } @@ -1020,9 +1020,9 @@ Tcl_AttemptSetObjLength( char *newBytes; if (objPtr->bytes == &tclEmptyString) { - newBytes = (char *)attemptckalloc(length + 1); + newBytes = (char *)attemptckalloc((unsigned int)length + 1U); } else { - newBytes = (char *)attemptckrealloc(objPtr->bytes, length + 1); + newBytes = (char *)attemptckrealloc(objPtr->bytes, (unsigned int)length + 1U); } if (newBytes == NULL) { return 0; diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 5fd6da7..c533be6 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -1707,7 +1707,7 @@ const TclStubs tclStubs = { Tcl_UniCharIsSpace, /* 349 */ Tcl_UniCharIsUpper, /* 350 */ Tcl_UniCharIsWordChar, /* 351 */ - Tcl_UniCharLen, /* 352 */ + Tcl_Char16Len, /* 352 */ Tcl_UniCharNcmp, /* 353 */ Tcl_Char16ToUtfDString, /* 354 */ Tcl_UtfToChar16DString, /* 355 */ @@ -2023,6 +2023,7 @@ const TclStubs tclStubs = { TclSplitPath_, /* 665 */ TclFSSplitPath_, /* 666 */ TclParseArgsObjv_, /* 667 */ + Tcl_UniCharLen, /* 668 */ }; /* !END!: Do not edit above this line. */ diff --git a/generic/tclTest.c b/generic/tclTest.c index 84113fe..a5b9379 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -1653,7 +1653,7 @@ TestdoubledigitsObjCmd( if (status != TCL_OK) { doubleType = Tcl_GetObjType("double"); if (Tcl_FetchInternalRep(objv[1], doubleType) - && TclIsNaN(objv[1]->internalRep.doubleValue)) { + && isnan(objv[1]->internalRep.doubleValue)) { status = TCL_OK; memcpy(&d, &(objv[1]->internalRep.doubleValue), sizeof(double)); } @@ -6290,7 +6290,8 @@ TestGetIndexFromObjStructObjCmd( const char *const ary[] = { "a", "b", "c", "d", "ee", "ff", NULL, NULL }; - int idx,target, flags = 0; + int target, flags = 0; + signed char idx[8]; if (objc != 3 && objc != 4) { Tcl_WrongNumArgs(interp, 1, objv, "argument targetvalue ?flags?"); @@ -6302,13 +6303,17 @@ TestGetIndexFromObjStructObjCmd( if ((objc > 3) && (Tcl_GetIntFromObj(interp, objv[3], &flags) != TCL_OK)) { return TCL_ERROR; } + memset(idx, 85, sizeof(idx)); if (Tcl_GetIndexFromObjStruct(interp, (Tcl_GetString(objv[1])[0] ? objv[1] : NULL), ary, 2*sizeof(char *), - "dummy", flags, &idx) != TCL_OK) { + "dummy", flags, &idx[1]) != TCL_OK) { return TCL_ERROR; } - if (idx != target) { + if (idx[0] != 85 || idx[2] != 85) { + Tcl_AppendResult(interp, "Tcl_GetIndexFromObjStruct overwrites bytes near index variable", NULL); + return TCL_ERROR; + } else if (idx[1] != target) { char buffer[64]; - sprintf(buffer, "%d", idx); + sprintf(buffer, "%d", idx[1]); Tcl_AppendResult(interp, "index value comparison failed: got ", buffer, NULL); sprintf(buffer, "%d", target); diff --git a/generic/tclUtf.c b/generic/tclUtf.c index fcdf80a..169f240 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -1137,7 +1137,7 @@ Tcl_UniCharAtIndex( i = TclUtfToUniChar(src, &ch); src += i; } -#if TCL_UTF_MAX <= 3 +#if TCL_UTF_MAX < 4 if ((ch >= 0xD800) && (i < 3)) { /* Index points at character following high Surrogate */ return -1; @@ -1153,7 +1153,7 @@ Tcl_UniCharAtIndex( * Tcl_UtfAtIndex -- * * Returns a pointer to the specified character (not byte) position in - * the UTF-8 string. If TCL_UTF_MAX <= 3, characters > U+FFFF count as + * the UTF-8 string. If TCL_UTF_MAX < 4, characters > U+FFFF count as * 2 positions, but then the pointer should never be placed between * the two positions. * @@ -1178,7 +1178,7 @@ Tcl_UtfAtIndex( len = TclUtfToUniChar(src, &ch); src += len; } -#if TCL_UTF_MAX <= 3 +#if TCL_UTF_MAX < 4 if ((ch >= 0xD800) && (len < 3)) { /* Index points at character following high Surrogate */ src += TclUtfToUniChar(src, &ch); @@ -1500,7 +1500,7 @@ Tcl_UtfNcmp( cs += TclUtfToUniChar(cs, &ch1); ct += TclUtfToUniChar(ct, &ch2); if (ch1 != ch2) { -#if TCL_UTF_MAX <= 3 +#if TCL_UTF_MAX < 4 /* Surrogates always report higher than non-surrogates */ if (((ch1 & 0xFC00) == 0xD800)) { if ((ch2 & 0xFC00) != 0xD800) { @@ -1551,7 +1551,7 @@ Tcl_UtfNcasecmp( cs += TclUtfToUniChar(cs, &ch1); ct += TclUtfToUniChar(ct, &ch2); if (ch1 != ch2) { -#if TCL_UTF_MAX <= 3 +#if TCL_UTF_MAX < 4 /* Surrogates always report higher than non-surrogates */ if (((ch1 & 0xFC00) == 0xD800)) { if ((ch2 & 0xFC00) != 0xD800) { @@ -1600,7 +1600,7 @@ TclUtfCmp( cs += TclUtfToUniChar(cs, &ch1); ct += TclUtfToUniChar(ct, &ch2); if (ch1 != ch2) { -#if TCL_UTF_MAX <= 3 +#if TCL_UTF_MAX < 4 /* Surrogates always report higher than non-surrogates */ if (((ch1 & 0xFC00) == 0xD800)) { if ((ch2 & 0xFC00) != 0xD800) { @@ -1646,7 +1646,7 @@ TclUtfCasecmp( cs += TclUtfToUniChar(cs, &ch1); ct += TclUtfToUniChar(ct, &ch2); if (ch1 != ch2) { -#if TCL_UTF_MAX <= 3 +#if TCL_UTF_MAX < 4 /* Surrogates always report higher than non-surrogates */ if (((ch1 & 0xFC00) == 0xD800)) { if ((ch2 & 0xFC00) != 0xD800) { @@ -1773,6 +1773,36 @@ Tcl_UniCharToTitle( /* *---------------------------------------------------------------------- * + * Tcl_Char16Len -- + * + * Find the length of a UniChar string. The str input must be null + * terminated. + * + * Results: + * Returns the length of str in UniChars (not bytes). + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +Tcl_Char16Len( + const unsigned short *uniStr) /* Unicode string to find length of. */ +{ + int len = 0; + + while (*uniStr != '\0') { + len++; + uniStr++; + } + return len; +} + +/* + *---------------------------------------------------------------------- + * * Tcl_UniCharLen -- * * Find the length of a UniChar string. The str input must be null @@ -1787,9 +1817,10 @@ Tcl_UniCharToTitle( *---------------------------------------------------------------------- */ +#undef Tcl_UniCharLen int Tcl_UniCharLen( - const Tcl_UniChar *uniStr) /* Unicode string to find length of. */ + const int *uniStr) /* Unicode string to find length of. */ { int len = 0; @@ -2642,7 +2673,7 @@ TclUniCharMatch( *--------------------------------------------------------------------------- */ -#if TCL_UTF_MAX <= 3 +#if TCL_UTF_MAX < 4 int TclUtfToUCS4( const char *src, /* The UTF-8 string. */ diff --git a/generic/tclUtil.c b/generic/tclUtil.c index a96c752..66d1009 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -3231,7 +3231,7 @@ Tcl_PrintDouble( * Handle NaN. */ - if (TclIsNaN(value)) { + if (isnan(value)) { TclFormatNaN(value, dst); return; } @@ -3240,7 +3240,7 @@ Tcl_PrintDouble( * Handle infinities. */ - if (TclIsInfinite(value)) { + if (isinf(value)) { /* * Remember to copy the terminating NUL too. */ diff --git a/libtommath/tommath.def b/libtommath/tommath.def index 229fae4..879767f 100644 --- a/libtommath/tommath.def +++ b/libtommath/tommath.def @@ -143,3 +143,14 @@ EXPORTS mp_unpack mp_xor mp_zero + s_mp_mul_digs + s_mp_sub + s_mp_add + s_mp_toom_mul + s_mp_mul_digs_fast + s_mp_karatsuba_mul + s_mp_sqr_fast + s_mp_reverse + s_mp_karatsuba_sqr + s_mp_toom_sqr + s_mp_sqr diff --git a/libtommath/tommath.h b/libtommath/tommath.h index 5834a89..1094641 100644 --- a/libtommath/tommath.h +++ b/libtommath/tommath.h @@ -38,7 +38,7 @@ extern "C" { #endif /* detect 64-bit mode if possible */ -#if defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64) || \ +#if defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64) || defined(_M_ARM64) || \ defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__) || \ defined(__s390x__) || defined(__arch64__) || defined(__aarch64__) || \ defined(__sparcv9) || defined(__sparc_v9__) || defined(__sparc64__) || \ diff --git a/libtommath/win64-arm/libtommath.dll b/libtommath/win64-arm/libtommath.dll Binary files differnew file mode 100755 index 0000000..37bccf7 --- /dev/null +++ b/libtommath/win64-arm/libtommath.dll diff --git a/libtommath/win64-arm/libtommath.dll.a b/libtommath/win64-arm/libtommath.dll.a Binary files differnew file mode 100644 index 0000000..0108f90 --- /dev/null +++ b/libtommath/win64-arm/libtommath.dll.a diff --git a/libtommath/win64-arm/tommath.lib b/libtommath/win64-arm/tommath.lib Binary files differindex 6797592..f14fbe7 100755..100644 --- a/libtommath/win64-arm/tommath.lib +++ b/libtommath/win64-arm/tommath.lib diff --git a/libtommath/win64/libtommath.dll b/libtommath/win64/libtommath.dll Binary files differindex 2225faf..ace8fce 100755 --- a/libtommath/win64/libtommath.dll +++ b/libtommath/win64/libtommath.dll diff --git a/libtommath/win64/libtommath.dll.a b/libtommath/win64/libtommath.dll.a Binary files differindex 40adaf7..81be3c8 100644 --- a/libtommath/win64/libtommath.dll.a +++ b/libtommath/win64/libtommath.dll.a diff --git a/libtommath/win64/tommath.lib b/libtommath/win64/tommath.lib Binary files differindex 434fa7c..434fa7c 100755..100644 --- a/libtommath/win64/tommath.lib +++ b/libtommath/win64/tommath.lib diff --git a/tests/indexObj.test b/tests/indexObj.test index 9fd31b4..c327274 100644 --- a/tests/indexObj.test +++ b/tests/indexObj.test @@ -140,6 +140,10 @@ test indexObj-6.6 {Tcl_GetIndexFromObjStruct with NULL input} -constraints testi set x "" testgetindexfromobjstruct $x 0 } -returnCodes error -result {ambiguous dummy "": must be a, c, or ee} +test indexObj-6.7 {Tcl_GetIndexFromObjStruct} testindexobj { + set x "" + testgetindexfromobjstruct $x -1 4 +} "wrong # args: should be \"testgetindexfromobjstruct {} -1 4\"" test indexObj-7.1 {Tcl_ParseArgsObjv} testparseargs { testparseargs diff --git a/tests/string.test b/tests/string.test index 7da50e9..203d0c6 100644 --- a/tests/string.test +++ b/tests/string.test @@ -510,6 +510,9 @@ test string-5.20.$noComp {string index, bytearray object out of bounds} -body { test string-5.21.$noComp {string index, surrogates, bug [11ae2be95dac9417]} -constraints utf16 -body { run {list [string index a\U100000b 1] [string index a\U100000b 2] [string index a\U100000b 3]} } -result [list \U100000 {} b] +test string-5.22.$noComp {string index} -constraints testbytestring -body { + run {list [scan [string index [testbytestring \xFF] 0] %c var] $var} +} -result {1 255} test string-6.1.$noComp {string is, not enough args} { diff --git a/tools/tcltk-man2html.tcl b/tools/tcltk-man2html.tcl index 020aad9..75ed97e 100755 --- a/tools/tcltk-man2html.tcl +++ b/tools/tcltk-man2html.tcl @@ -682,7 +682,7 @@ array set exclude_refs_map { ttk_scale.n {variable} ttk_scrollbar.n {set} ttk_spinbox.n {format} - ttk_treeview.n {text open} + ttk_treeview.n {text open focus selection} ttk_widget.n {image text variable} TclZlib.3 {binary flush filename text} } diff --git a/unix/Makefile.in b/unix/Makefile.in index a3e822c..ffea44c 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -2322,7 +2322,8 @@ dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tclConfig.h.in $(UNIX_DIR)/tcl.pc.in gen $(TOP_DIR)/win/tcl.m4 $(TOP_DIR)/win/aclocal.m4 \ $(TOP_DIR)/win/tclsh.exe.manifest.in $(TOP_DIR)/win/tclUuid.h.in \ $(TOP_DIR)/win/gitmanifest.in $(TOP_DIR)/win/svnmanifest.in \ - $(DISTDIR)/win + $(TOP_DIR)/win/x86_64-w64-mingw32-nmakehlp.exe $(DISTDIR)/win + chmod 775 $(DISTDIR)/win/x86_64-w64-mingw32-nmakehlp.exe cp -p $(TOP_DIR)/win/*.[ch] $(TOP_DIR)/win/*.ico $(TOP_DIR)/win/*.rc \ $(DISTDIR)/win cp -p $(TOP_DIR)/win/*.bat $(DISTDIR)/win diff --git a/unix/configure b/unix/configure index 4a6ee81..5d18196 100755 --- a/unix/configure +++ b/unix/configure @@ -6761,11 +6761,11 @@ printf "%s\n" "#define _OE_SOCKETS 1" >>confdefs.h if test "$SHARED_BUILD" = 1 then : - SHLIB_LD='ld -shared -expect_unresolved "*"' + SHLIB_LD='${CC} -shared' else $as_nop - SHLIB_LD='ld -non_shared -expect_unresolved "*"' + SHLIB_LD='${CC} -non_shared' fi SHLIB_SUFFIX=".so" @@ -10341,47 +10341,6 @@ fi #-------------------------------------------------------------------- -# Check for support of isnan() function or macro -#-------------------------------------------------------------------- - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking isnan" >&5 -printf %s "checking isnan... " >&6; } -if test ${tcl_cv_isnan+y} -then : - printf %s "(cached) " >&6 -else $as_nop - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <math.h> -int -main (void) -{ - -isnan(0.0); /* Generates an error if isnan is missing */ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - tcl_cv_isnan=yes -else $as_nop - tcl_cv_isnan=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_isnan" >&5 -printf "%s\n" "$tcl_cv_isnan" >&6; } -if test $tcl_cv_isnan = no; then - -printf "%s\n" "#define NO_ISNAN 1" >>confdefs.h - -fi - -#-------------------------------------------------------------------- # Darwin specific API checks and defines #-------------------------------------------------------------------- diff --git a/unix/configure.ac b/unix/configure.ac index 335c5a2..7acb5ce 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -562,18 +562,6 @@ SC_ENABLE_LANGINFO AC_CHECK_FUNCS(cfmakeraw chflags mkstemps) #-------------------------------------------------------------------- -# Check for support of isnan() function or macro -#-------------------------------------------------------------------- - -AC_CACHE_CHECK([isnan], tcl_cv_isnan, [ - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]], [[ -isnan(0.0); /* Generates an error if isnan is missing */ -]])],[tcl_cv_isnan=yes],[tcl_cv_isnan=no])]) -if test $tcl_cv_isnan = no; then - AC_DEFINE(NO_ISNAN, 1, [Do we have a usable 'isnan'?]) -fi - -#-------------------------------------------------------------------- # Darwin specific API checks and defines #-------------------------------------------------------------------- diff --git a/unix/tcl.m4 b/unix/tcl.m4 index a5a4884..dfbb9be 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1515,9 +1515,9 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ # Digital OSF/1 SHLIB_CFLAGS="" AS_IF([test "$SHARED_BUILD" = 1], [ - SHLIB_LD='ld -shared -expect_unresolved "*"' + SHLIB_LD='${CC} -shared' ], [ - SHLIB_LD='ld -non_shared -expect_unresolved "*"' + SHLIB_LD='${CC} -non_shared' ]) SHLIB_SUFFIX=".so" DL_OBJS="tclLoadDl.o" diff --git a/unix/tclConfig.h.in b/unix/tclConfig.h.in index 5c24d40..1acc55d 100644 --- a/unix/tclConfig.h.in +++ b/unix/tclConfig.h.in @@ -349,9 +349,6 @@ /* Do we have getwd() */ #undef NO_GETWD -/* Do we have a usable 'isnan'? */ -#undef NO_ISNAN - /* Do we have memmove()? */ #undef NO_MEMMOVE diff --git a/unix/tclUnixTime.c b/unix/tclUnixTime.c index e0c7ac8..6ca641d 100644 --- a/unix/tclUnixTime.c +++ b/unix/tclUnixTime.c @@ -155,7 +155,7 @@ TclpGetClicks(void) Tcl_Time time; GetTime(&time); - now = time.sec*1000000 + time.usec; + now = ((unsigned long)(time.sec)*1000000UL) + (unsigned long)(time.usec); } else { /* * A semi-NativeGetTime, specialized to clicks. @@ -168,7 +168,7 @@ TclpGetClicks(void) Tcl_Time time; GetTime(&time); - now = time.sec*1000000 + time.usec; + now = ((unsigned long)(time.sec)*1000000UL) + (unsigned long)(time.usec); #endif /* NO_GETTOD */ return now; diff --git a/unix/tclXtNotify.c b/unix/tclXtNotify.c index 3d90135..45bda3e 100644 --- a/unix/tclXtNotify.c +++ b/unix/tclXtNotify.c @@ -181,7 +181,13 @@ TclSetAppContext( void InitNotifier(void) { - Tcl_NotifierProcs np; + static const Tcl_NotifierProcs np = + SetTimer, + WaitForEvent, + CreateFileHandler, + DeleteFileHandler, + NULL, NULL, NULL, NULL + }; /* * Only reinitialize if we are not in exit handling. The notifier can get @@ -193,14 +199,6 @@ InitNotifier(void) return; } - np.createFileHandlerProc = CreateFileHandler; - np.deleteFileHandlerProc = DeleteFileHandler; - np.setTimerProc = SetTimer; - np.waitForEventProc = WaitForEvent; - np.initNotifierProc = Tcl_InitNotifier; - np.finalizeNotifierProc = Tcl_FinalizeNotifier; - np.alertNotifierProc = Tcl_AlertNotifier; - np.serviceModeHookProc = Tcl_ServiceModeHook; Tcl_SetNotifier(&np); /* @@ -209,7 +207,6 @@ InitNotifier(void) */ initialized = 1; - memset(&np, 0, sizeof(np)); Tcl_CreateExitHandler(NotifierExitHandler, NULL); } @@ -20,7 +20,7 @@ In order to compile Tcl for Windows, you need the following: and - Visual C++ 6 or newer + Visual Studio 2015 or newer or @@ -42,6 +42,11 @@ In order to compile Tcl for Windows, you need the following: Msys + MinGW-w64 [https://www.mingw-w64.org/] (win32 or win64) + or + + LLVM MinGW [https://github.com/mstorsjo/llvm-mingw/] + (win32 or win64, IX86, AMD64 or ARM64) + In practice, this release is built with Visual C++ 6.0 and the TEA Makefile. @@ -62,8 +67,9 @@ configure/build process works just like the UNIX one, so you will want to refer to ../unix/README for available configure options. If you want 64-bit executables (x86_64), you need to configure using -the --enable-64bit option. Make sure that the x86_64-w64-mingw32 -compiler is present. For Cygwin this compiler can be found in the +the --enable-64bit (or --enable-64bit=arm64) option. Make sure that +the x86_64-w64-mingw32 (or aarch64-w64-mingw32) compiler is present. +For Cygwin the x86_64 compiler can be found in the "mingw64-x86_64-gcc-core" package, which can be installed through the normal Cygwin install process. If you only want 32-bit executables, the "mingw64-i686-gcc-core" package is what you need. For Linux, Darwin @@ -74,11 +80,13 @@ Use the Makefile "install" target to install Tcl. It will install it according to the prefix options you provided in the correct directory structure. -Note that in order to run tclsh87.exe, you must ensure that tcl87.dll is -on your path, in the system directory, or in the directory containing -tclsh87.exe. +Note that in order to run tclsh87.exe, you must ensure that tcl87.dll, +libtommath.dll and zlib1.dll are on your path, in the system +directory, or in the directory containing tclsh87.exe. -Note: Tcl no longer provides support for Win32s. +Note: Tcl no longer provides support for systems earlier than Windows 7. +You will also need the Windows Universal C runtime (UCRT): + [https://support.microsoft.com/en-us/topic/update-for-universal-c-runtime-in-windows-c0514201-7fe6-95a3-b0a5-287930f3560c] 3. Test suite ------------- diff --git a/win/configure b/win/configure index 310189a..56342c0 100755 --- a/win/configure +++ b/win/configure @@ -4107,7 +4107,7 @@ printf "%s\n" "$ac_cv_cross" >&6; } RC="x86_64-w64-mingw32-windres" ;; arm64|aarch64) - CC="aarch64-w64-mingw32-${CC}" + CC="aarch64-w64-mingw32-clang" LD="aarch64-w64-mingw32-ld" AR="aarch64-w64-mingw32-ar" RANLIB="aarch64-w64-mingw32-ranlib" @@ -4203,7 +4203,7 @@ printf "%s\n" "$ac_cv_win32" >&6; } if test "$ac_cv_win32" != "yes"; then as_fn_error $? "${CC} cannot produce win32 executables." "$LINENO" 5 fi - if test "$MACHINE" != "ARM64"; then + if test "$do64bit" != "arm64"; then extra_cflags="$extra_cflags -DHAVE_CPUID=1" fi @@ -4958,15 +4958,17 @@ then : ZLIB_LIBS=\${ZLIB_DIR_NATIVE}/win64-arm/libz.dll.a + TOMMATH_LIBS=\${TOMMATH_DIR_NATIVE}/win64-arm/libtommath.dll.a + else $as_nop ZLIB_LIBS=\${ZLIB_DIR_NATIVE}/win64-arm/zdll.lib + TOMMATH_LIBS=\${TOMMATH_DIR_NATIVE}/win64-arm/tommath.lib -fi - TOMMATH_LIBS=\${TOMMATH_DIR_NATIVE}/win64/libtommath.dll.a +fi else $as_nop @@ -4975,15 +4977,17 @@ then : ZLIB_LIBS=\${ZLIB_DIR_NATIVE}/win64/libz.dll.a + TOMMATH_LIBS=\${TOMMATH_DIR_NATIVE}/win64/libtommath.dll.a + else $as_nop ZLIB_LIBS=\${ZLIB_DIR_NATIVE}/win64/zdll.lib + TOMMATH_LIBS=\${TOMMATH_DIR_NATIVE}/win64/tommath.lib -fi - TOMMATH_LIBS=\${TOMMATH_DIR_NATIVE}/win64/tommath.lib +fi fi diff --git a/win/configure.ac b/win/configure.ac index 87b6780..01f70b4 100644 --- a/win/configure.ac +++ b/win/configure.ac @@ -144,17 +144,19 @@ AS_IF([test "$tcl_ok" = "yes"], [ AS_IF([test "$do64bit" = "arm64"], [ AS_IF([test "$GCC" == "yes"],[ AC_SUBST(ZLIB_LIBS,[\${ZLIB_DIR_NATIVE}/win64-arm/libz.dll.a]) + AC_SUBST(TOMMATH_LIBS,[\${TOMMATH_DIR_NATIVE}/win64-arm/libtommath.dll.a]) ], [ AC_SUBST(ZLIB_LIBS,[\${ZLIB_DIR_NATIVE}/win64-arm/zdll.lib]) + AC_SUBST(TOMMATH_LIBS,[\${TOMMATH_DIR_NATIVE}/win64-arm/tommath.lib]) ]) - AC_SUBST(TOMMATH_LIBS,[\${TOMMATH_DIR_NATIVE}/win64/libtommath.dll.a]) ], [ AS_IF([test "$GCC" == "yes"],[ AC_SUBST(ZLIB_LIBS,[\${ZLIB_DIR_NATIVE}/win64/libz.dll.a]) + AC_SUBST(TOMMATH_LIBS,[\${TOMMATH_DIR_NATIVE}/win64/libtommath.dll.a]) ], [ AC_SUBST(ZLIB_LIBS,[\${ZLIB_DIR_NATIVE}/win64/zdll.lib]) + AC_SUBST(TOMMATH_LIBS,[\${TOMMATH_DIR_NATIVE}/win64/tommath.lib]) ]) - AC_SUBST(TOMMATH_LIBS,[\${TOMMATH_DIR_NATIVE}/win64/tommath.lib]) ]) ], [ AC_SUBST(ZLIB_LIBS,[\${ZLIB_DIR_NATIVE}/win32/zdll.lib]) diff --git a/win/makefile.vc b/win/makefile.vc index 68c2aa7..6b2a682 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -603,7 +603,7 @@ $(TCLSCRIPTZIP): $(TCLDDELIB) $(TCLREGLIB) !endif
@echo file delete -force {$@} > "$(OUT_DIR)\zipper.tcl"
@echo zipfs mkzip {$@} {$(LIBTCLVFS)} {$(LIBTCLVFS)} >> "$(OUT_DIR)\zipper.tcl"
- @cd "$(OUT_DIR)" && $(TCLSH) zipper.tcl
+ @cd "$(OUT_DIR)" && $(TCLSH_NATIVE) zipper.tcl
pkgs:
@@ -1006,6 +1006,7 @@ install-libraries: tclConfig tcl-nmake install-msgs install-tzdata @$(CPY) "$(WIN_DIR)\rules.vc" "$(LIB_INSTALL_DIR)\nmake\"
@$(CPY) "$(WIN_DIR)\targets.vc" "$(LIB_INSTALL_DIR)\nmake\"
@$(CPY) "$(WIN_DIR)\nmakehlp.c" "$(LIB_INSTALL_DIR)\nmake\"
+ @$(CPY) "$(WIN_DIR)\x86_64-w64-mingw32-nmakehlp.exe" "$(LIB_INSTALL_DIR)\nmake\"
@$(CPY) "$(OUT_DIR)\tcl.nmake" "$(LIB_INSTALL_DIR)\nmake\"
!if !$(TCL_EMBED_SCRIPTS)
@echo Installing package cookiejar $(PKG_COOKIEJAR_VER)
diff --git a/win/rules-ext.vc b/win/rules-ext.vc index 6da5689..6d31a03 100644 --- a/win/rules-ext.vc +++ b/win/rules-ext.vc @@ -31,8 +31,13 @@ macro to the name of the project makefile. # We extract version numbers using the nmakehlp program. For now use
# the local copy of nmakehlp. Once we locate Tcl, we will use that
# one if it is newer.
+!if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)"
!if [$(CC) -nologo -DNDEBUG "nmakehlp.c" -link -subsystem:console > nul]
!endif
+!else
+!if [copy x86_64-w64-mingw32-nmakehlp.exe nmakehlp.exe >NUL]
+!endif
+!endif
# First locate the Tcl directory that we are working with.
!if "$(TCLDIR)" != ""
diff --git a/win/rules.vc b/win/rules.vc index 2f01de0..372d70a 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -550,8 +550,13 @@ NMAKEHLPC = $(_TCLDIR)\win\nmakehlp.c # We always build nmakehlp even if it exists since we do not know
# what source it was built from.
+!if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)"
!if [$(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console > nul]
!endif
+!else
+!if [copy $(NMAKEHLPC:nmakehlp.c=x86_64-w64-mingw32-nmakehlp.exe) nmakehlp.exe >NUL]
+!endif
+!endif
################################################################
# 5. Test for compiler features
@@ -1379,7 +1384,7 @@ OPTDEFINES = $(OPTDEFINES) /DUSE_THREAD_ALLOC=1 OPTDEFINES = $(OPTDEFINES) /DSTATIC_BUILD
!elseif $(TCL_VERSION) > 86
OPTDEFINES = $(OPTDEFINES) /DTCL_WITH_EXTERNAL_TOMMATH
-!if "$(MACHINE)" == "AMD64"
+!if "$(MACHINE)" == "AMD64" || "$(MACHINE)" == "ARM64"
OPTDEFINES = $(OPTDEFINES) /DMP_64BIT
!endif
!endif
@@ -1407,7 +1412,7 @@ OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_OPTIMIZED !if $(PROFILE)
OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_PROFILED
!endif
-!if "$(MACHINE)" == "AMD64"
+!if "$(MACHINE)" == "AMD64" || "$(MACHINE)" == "ARM64"
OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_DO64BIT
!endif
!if $(VCVERSION) < 1300
@@ -1469,7 +1474,7 @@ cdebug = $(cdebug) -Zi # cwarn includes default warning levels.
cwarn = $(WARNINGS)
-!if "$(MACHINE)" == "AMD64"
+!if "$(MACHINE)" == "AMD64" || "$(MACHINE)" == "ARM64"
# Disable pointer<->int warnings related to cast between different sizes
# There are a gadzillion of these due to use of ClientData and
# clutter up compiler
@@ -527,7 +527,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ RC="x86_64-w64-mingw32-windres" ;; arm64|aarch64) - CC="aarch64-w64-mingw32-${CC}" + CC="aarch64-w64-mingw32-clang" LD="aarch64-w64-mingw32-ld" AR="aarch64-w64-mingw32-ar" RANLIB="aarch64-w64-mingw32-ranlib" @@ -593,7 +593,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ if test "$ac_cv_win32" != "yes"; then AC_MSG_ERROR([${CC} cannot produce win32 executables.]) fi - if test "$MACHINE" != "ARM64"; then + if test "$do64bit" != "arm64"; then extra_cflags="$extra_cflags -DHAVE_CPUID=1" fi diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index d846db0..0e86611 100644 --- a/win/tclWin32Dll.c +++ b/win/tclWin32Dll.c @@ -683,6 +683,8 @@ TclWinCPUID( # endif #else + (void)index; + (void)regsPtr; /* * Don't know how to do assembly code for this compiler and/or * architecture. diff --git a/win/tclWinTime.c b/win/tclWinTime.c index 45338dd..a7e8474 100644 --- a/win/tclWinTime.c +++ b/win/tclWinTime.c @@ -249,7 +249,7 @@ TclpGetClicks(void) Tcl_Time now; /* Current Tcl time */ GetTime(&now); - return (unsigned long) (now.sec * 1000000) + now.usec; + return ((unsigned long)(now.sec)*1000000UL) + (unsigned long)(now.usec); } } diff --git a/win/x86_64-w64-mingw32-nmakehlp.exe b/win/x86_64-w64-mingw32-nmakehlp.exe Binary files differnew file mode 100755 index 0000000..f821add --- /dev/null +++ b/win/x86_64-w64-mingw32-nmakehlp.exe |