From c9c1696a2d8c2c3d094e54b96defd269c0687692 Mon Sep 17 00:00:00 2001 From: bch Date: Sun, 6 Dec 2020 18:39:21 +0000 Subject: allow NULL for indexPtr to say "am not interested in index, just membership in set of possibilities" for Tcl_GetIndexFromObj() --- doc/GetIndex.3 | 8 ++++---- generic/tclIndexObj.c | 31 ++++++++++++++++++------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/doc/GetIndex.3 b/doc/GetIndex.3 index 8591c56..111ae62 100644 --- a/doc/GetIndex.3 +++ b/doc/GetIndex.3 @@ -56,8 +56,8 @@ 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. +If not NULL, the index of the string in \fItablePtr\fR that matches +the value of \fIobjPtr\fR is returned here. .BE .SH DESCRIPTION .PP @@ -70,8 +70,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 \fI*indexPtr\fR is not NULL the index +of the matching entry is stored there. .PP If there is no matching entry, \fBTCL_ERROR\fR is returned and an error message is left in \fIinterp\fR's diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c index 89582b7..c3092c9 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.c @@ -166,11 +166,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: @@ -212,15 +213,17 @@ Tcl_GetIndexFromObjStruct( */ if (!(flags & TCL_INDEX_TEMP_TABLE)) { - irPtr = TclFetchIntRep(objPtr, &indexType); - if (irPtr) { - indexRep = (IndexRep *)irPtr->twoPtrValue.ptr1; - if (indexRep->tablePtr==tablePtr && indexRep->offset==offset) { - *indexPtr = indexRep->index; - return TCL_OK; + irPtr = TclFetchIntRep (objPtr, &indexType); + if (irPtr) { + indexRep = (IndexRep *) irPtr->twoPtrValue.ptr1; + if (indexRep->tablePtr == tablePtr && indexRep->offset == offset) { + if (indexPtr != NULL) { + *indexPtr = indexRep->index; + } + return TCL_OK; + } } } - } /* * Lookup the value of the object in the table. Accept unique @@ -291,7 +294,9 @@ Tcl_GetIndexFromObjStruct( indexRep->index = index; } - *indexPtr = index; + if(indexPtr != NULL) { + *indexPtr = index; + } return TCL_OK; error: -- cgit v0.12 From 902547c2b25bc92a576879d666aaf79c6e635aab Mon Sep 17 00:00:00 2001 From: bch Date: Sun, 6 Dec 2020 20:57:32 +0000 Subject: comment grammar --- generic/tcl.decls | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tcl.decls b/generic/tcl.decls index dc57324..eacfb28 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -24,8 +24,8 @@ hooks {tclPlat tclInt tclIntPlat} scspec EXTERN # Declare each of the functions in the public Tcl interface. Note that -# the an index should never be reused for a different function in order -# to preserve backwards compatibility. +# in order to preserve backwards compatibility an index should +# never be reused for a different function declare 0 { int Tcl_PkgProvideEx(Tcl_Interp *interp, const char *name, -- cgit v0.12 From 933584b14430d2c9df09702eb344ff261bd40776 Mon Sep 17 00:00:00 2001 From: bch Date: Sun, 6 Dec 2020 20:58:21 +0000 Subject: Period. --- generic/tcl.decls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tcl.decls b/generic/tcl.decls index eacfb28..4362c4c 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -25,7 +25,7 @@ scspec EXTERN # Declare each of the functions in the public Tcl interface. Note that # in order to preserve backwards compatibility an index should -# never be reused for a different function +# never be reused for a different function. declare 0 { int Tcl_PkgProvideEx(Tcl_Interp *interp, const char *name, -- cgit v0.12 From 5d92b3dc112a0525e4c00cba1b4b9e9b5c29425d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 9 Dec 2021 14:46:41 +0000 Subject: TIP #613: New INDEX_NULL_OK flag for Tcl_GetIndexFromObj*() --- doc/GetIndex.3 | 6 ++++-- generic/tcl.h | 3 +++ generic/tclIndexObj.c | 20 +++++++++++++++----- generic/tclTest.c | 17 ++++++++++------- tests/indexObj.test | 4 ++++ 5 files changed, 36 insertions(+), 14 deletions(-) diff --git a/doc/GetIndex.3 b/doc/GetIndex.3 index a788848..1af1663 100644 --- a/doc/GetIndex.3 +++ b/doc/GetIndex.3 @@ -54,7 +54,7 @@ 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. +, \fBTCL_INDEX_TEMP_TABLE\fR, and \fBTCL_INDEX_NULL_OK\fR. .AP int *indexPtr out The index of the string in \fItablePtr\fR that matches the value of \fIobjPtr\fR is returned here. @@ -91,7 +91,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/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/tclIndexObj.c b/generic/tclIndexObj.c index c2812ea..e9c453a 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.c @@ -261,7 +261,7 @@ Tcl_GetIndexFromObjStruct( int offset, /* The number of bytes between entries */ const char *msg, /* Identifying word to use in error * messages. */ - int flags, /* 0 or TCL_EXACT */ + int flags, /* 0, TCL_EXACT, TCL_INDEX_TEMP_TABLE or TCL_INDEX_NULL_OK */ int *indexPtr) /* Place to store resulting integer index. */ { int index, idx, numAbbrev; @@ -280,7 +280,10 @@ Tcl_GetIndexFromObjStruct( * See if there is a valid cached result from a previous lookup. */ - if (!(flags & TCL_INDEX_TEMP_TABLE)) { + if (!objPtr && (flags & TCL_INDEX_NULL_OK)) { + *indexPtr = -1; + return TCL_OK; + } else if (objPtr && !(flags & TCL_INDEX_TEMP_TABLE)) { irPtr = TclFetchInternalRep(objPtr, &indexType); if (irPtr) { indexRep = (IndexRep *)irPtr->twoPtrValue.ptr1; @@ -296,10 +299,14 @@ Tcl_GetIndexFromObjStruct( * abbreviations unless TCL_EXACT is set in flags. */ - key = TclGetString(objPtr); + key = objPtr ? TclGetString(objPtr) : ""; index = -1; numAbbrev = 0; + if (!*key && (flags & TCL_INDEX_NULL_OK)) { + *indexPtr = -1; + return TCL_OK; + } /* * Scan the table looking for one of: * - An exact match (always preferred) @@ -344,7 +351,7 @@ Tcl_GetIndexFromObjStruct( * operation. */ - if (!(flags & TCL_INDEX_TEMP_TABLE)) { + if (objPtr && !(flags & TCL_INDEX_TEMP_TABLE)) { irPtr = TclFetchInternalRep(objPtr, &indexType); if (irPtr) { indexRep = (IndexRep *)irPtr->twoPtrValue.ptr1; @@ -386,7 +393,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) { @@ -395,6 +402,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/tclTest.c b/generic/tclTest.c index 46a1459..e18283d 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -6285,17 +6285,20 @@ TestGetIndexFromObjStructObjCmd( const char *const ary[] = { "a", "b", "c", "d", "e", "f", NULL, NULL }; - int idx,target; + int idx,target, flags = 0; - if (objc != 3) { - Tcl_WrongNumArgs(interp, 1, objv, "argument targetvalue"); + if (objc != 3 && objc != 4) { + Tcl_WrongNumArgs(interp, 1, objv, "argument targetvalue ?flags?"); return TCL_ERROR; } - if (Tcl_GetIndexFromObjStruct(interp, objv[1], ary, 2*sizeof(char *), - "dummy", 0, &idx) != TCL_OK) { + if (Tcl_GetIntFromObj(interp, objv[2], &target) != TCL_OK) { return TCL_ERROR; } - if (Tcl_GetIntFromObj(interp, objv[2], &target) != TCL_OK) { + if ((objc > 3) && (Tcl_GetIntFromObj(interp, objv[3], &flags) != TCL_OK)) { + return TCL_ERROR; + } + if (Tcl_GetIndexFromObjStruct(interp, (Tcl_GetString(objv[1])[0] ? objv[1] : NULL), ary, 2*sizeof(char *), + "dummy", flags, &idx) != TCL_OK) { return TCL_ERROR; } if (idx != target) { @@ -6307,7 +6310,7 @@ TestGetIndexFromObjStructObjCmd( Tcl_AppendResult(interp, " when ", buffer, " expected", NULL); return TCL_ERROR; } - Tcl_WrongNumArgs(interp, 3, objv, NULL); + Tcl_WrongNumArgs(interp, objc, objv, NULL); return TCL_OK; } diff --git a/tests/indexObj.test b/tests/indexObj.test index bd6a2c2..c615e15 100644 --- a/tests/indexObj.test +++ b/tests/indexObj.test @@ -131,6 +131,10 @@ test indexObj-6.4 {Tcl_GetIndexFromObjStruct} testindexobj { testgetindexfromobjstruct $x 1 testgetindexfromobjstruct $x 1 } "wrong # args: should be \"testgetindexfromobjstruct c 1\"" +test indexObj-6.5 {Tcl_GetIndexFromObjStruct} testindexobj { + set x "" + testgetindexfromobjstruct $x -1 4 +} "wrong # args: should be \"testgetindexfromobjstruct {} -1 4\"" test indexObj-7.1 {Tcl_ParseArgsObjv} testparseargs { testparseargs -- cgit v0.12 From 48cff4f47c0343d658ad32b1763b8461e9c71114 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 20 Dec 2021 14:10:05 +0000 Subject: formatting --- generic/tclTest.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/generic/tclTest.c b/generic/tclTest.c index 1c9e605..7b97a65 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -6286,7 +6286,7 @@ TestGetIndexFromObjStructObjCmd( "a", "b", "c", "d", "ee", "ff", NULL, NULL }; int target, flags = 0; - signed char idx[8]; + signed char idx[8]; if (objc != 3 && objc != 4) { Tcl_WrongNumArgs(interp, 1, objv, "argument targetvalue ?flags?"); @@ -6300,15 +6300,15 @@ TestGetIndexFromObjStructObjCmd( } memset(idx, 85, sizeof(idx)); if (Tcl_GetIndexFromObjStruct(interp, (Tcl_GetString(objv[1])[0] ? objv[1] : NULL), ary, 2*sizeof(char *), - "dummy", flags, &idx[0]) != TCL_OK) { + "dummy", flags, &idx[1]) != TCL_OK) { return TCL_ERROR; } - if (idx[1] != 85) { - Tcl_AppendResult(interp, "Tcl_GetIndexFromObjStruct overwrites size", NULL); + if (idx[0] != 85 || idx[2] != 85) { + Tcl_AppendResult(interp, "Tcl_GetIndexFromObjStruct overwrites bytes near index variable", NULL); return TCL_ERROR; - } else if (idx[0] != target) { + } else if (idx[1] != target) { char buffer[64]; - sprintf(buffer, "%d", idx[0]); + sprintf(buffer, "%d", idx[1]); Tcl_AppendResult(interp, "index value comparison failed: got ", buffer, NULL); sprintf(buffer, "%d", target); -- cgit v0.12 From 1f35ddfe6233a4a056ba3c4e67a4a7563f6d681f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 10 Feb 2022 14:16:00 +0000 Subject: Use Tcl_NewWideIntObj() for values that might be bigger than 32-bit --- generic/tclIORChan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index 2e25182..3e2bcbe 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -2111,7 +2111,7 @@ ReflectTruncate( Tcl_Preserve(rcPtr); - lenObj = Tcl_NewIntObj(length); + lenObj = Tcl_NewWideIntObj(length); Tcl_IncrRefCount(lenObj); if (InvokeTclMethod(rcPtr,METH_TRUNCATE,lenObj,NULL,&resObj)!=TCL_OK) { @@ -3361,7 +3361,7 @@ ForwardProc( break; case ForwardedTruncate: { - Tcl_Obj *lenObj = Tcl_NewIntObj(paramPtr->truncate.length); + Tcl_Obj *lenObj = Tcl_NewWideIntObj(paramPtr->truncate.length); Tcl_IncrRefCount(lenObj); Tcl_Preserve(rcPtr); -- cgit v0.12 From 6116d39ecba828dd74944ff5300d625f40deff4b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 10 Feb 2022 15:17:45 +0000 Subject: Add zlib1.dll for windows-arm64 (cross-compiled with VS2017) --- compat/zlib/win64-arm/zlib1.dll | Bin 0 -> 84480 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100755 compat/zlib/win64-arm/zlib1.dll diff --git a/compat/zlib/win64-arm/zlib1.dll b/compat/zlib/win64-arm/zlib1.dll new file mode 100755 index 0000000..2abef88 Binary files /dev/null and b/compat/zlib/win64-arm/zlib1.dll differ -- cgit v0.12 From 85cb8c27f27b0f3dab72ab181ba1bed5400e13e5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 11 Feb 2022 14:22:09 +0000 Subject: See [https://github.com/tcltk/tcl/pull/11], but (hopefully) slightly better --- .github/workflows/win-build.yml | 4 ++-- win/rules.vc | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/win-build.yml b/.github/workflows/win-build.yml index 370f2de..a470f50 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 @@ -41,7 +41,7 @@ jobs: throw "nmake exit code: $lastexitcode" } gcc: - runs-on: windows-latest + runs-on: windows-2022 defaults: run: shell: msys2 {0} diff --git a/win/rules.vc b/win/rules.vc index 2f01de0..4f103d0 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -548,10 +548,15 @@ NMAKEHLPC = $(_TCLDIR)\win\nmakehlp.c !endif # NMAKEHLPC +nmakehlp: + $(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console + # We always build nmakehlp even if it exists since we do not know # what source it was built from. +!if "$(MACHINE)" == "$(NATIVE_ARCH)" !if [$(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console > nul] !endif +!endif ################################################################ # 5. Test for compiler features -- cgit v0.12 From 21db6889635b43cef6b659b974ec0883a551d4e1 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 11 Feb 2022 16:21:35 +0000 Subject: more tweaks for windows-arm64 --- libtommath/tommath.h | 2 +- win/rules.vc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libtommath/tommath.h b/libtommath/tommath.h index 22951c9..8ccbb89 100644 --- a/libtommath/tommath.h +++ b/libtommath/tommath.h @@ -37,7 +37,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/win/rules.vc b/win/rules.vc index 4f103d0..b68b6b4 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -1384,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 @@ -1412,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 @@ -1474,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 -- cgit v0.12 From 18d3a2a589b6273929881e13028b5c87b1bad96f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 11 Feb 2022 16:34:26 +0000 Subject: Document how to cross-compile with Visual Studio --- win/README | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/win/README b/win/README index d332557..f4cdde4 100644 --- a/win/README +++ b/win/README @@ -56,6 +56,13 @@ using it, are in the comments of "makefile.vc". A quick example would be: There is also a Developer Studio workspace and project file, too, if you would like to use them. +If you want to Cross-compile with Visual Studio (e.g. for X86 or ARM64 +targets, but running on AMD64), first set up the environment for +your host machine and compile nmakehlp.exe: + C:\tcl_source\win\>nmake -f makefile.vc nmakehlp +Then go to your cross-compile environment and run the nmake +command again for whatever you want to build. + If you are building with Linux, Cygwin or Msys, you can use the configure script that lives in the win subdirectory. The Linux/Cygwin/Msys based configure/build process works just like the UNIX one, so you will want -- cgit v0.12 From a2fefd7c501decfa882cddf51b77ec0ebb289d0f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 11 Feb 2022 16:59:53 +0000 Subject: Add more spare unused stub entries --- generic/tcl.decls | 2 +- generic/tclDecls.h | 30 +++++++++++++++++++++++++++--- generic/tclStubInit.c | 10 +++++++++- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/generic/tcl.decls b/generic/tcl.decls index fce6fc0..cea6b93 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -2111,7 +2111,7 @@ declare 579 { # ----- BASELINE -- FOR -- 8.5.0 ----- # -declare 660 { +declare 668 { void TclUnusedStubEntry(void) } diff --git a/generic/tclDecls.h b/generic/tclDecls.h index b7f9223..7a76c4a 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -3492,9 +3492,17 @@ EXTERN void Tcl_AppendPrintfToObj(Tcl_Obj *objPtr, /* Slot 657 is reserved */ /* Slot 658 is reserved */ /* Slot 659 is reserved */ +/* Slot 660 is reserved */ +/* Slot 661 is reserved */ +/* Slot 662 is reserved */ +/* Slot 663 is reserved */ +/* Slot 664 is reserved */ +/* Slot 665 is reserved */ +/* Slot 666 is reserved */ +/* Slot 667 is reserved */ #ifndef TclUnusedStubEntry_TCL_DECLARED #define TclUnusedStubEntry_TCL_DECLARED -/* 660 */ +/* 668 */ EXTERN void TclUnusedStubEntry(void); #endif @@ -4192,7 +4200,15 @@ typedef struct TclStubs { VOID *reserved657; VOID *reserved658; VOID *reserved659; - void (*tclUnusedStubEntry) (void); /* 660 */ + VOID *reserved660; + VOID *reserved661; + VOID *reserved662; + VOID *reserved663; + VOID *reserved664; + VOID *reserved665; + VOID *reserved666; + VOID *reserved667; + void (*tclUnusedStubEntry) (void); /* 668 */ } TclStubs; extern TclStubs *tclStubsPtr; @@ -6625,9 +6641,17 @@ extern TclStubs *tclStubsPtr; /* Slot 657 is reserved */ /* Slot 658 is reserved */ /* Slot 659 is reserved */ +/* Slot 660 is reserved */ +/* Slot 661 is reserved */ +/* Slot 662 is reserved */ +/* Slot 663 is reserved */ +/* Slot 664 is reserved */ +/* Slot 665 is reserved */ +/* Slot 666 is reserved */ +/* Slot 667 is reserved */ #ifndef TclUnusedStubEntry #define TclUnusedStubEntry \ - (tclStubsPtr->tclUnusedStubEntry) /* 660 */ + (tclStubsPtr->tclUnusedStubEntry) /* 668 */ #endif #endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */ diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 6ef561c..1fcd92b 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -1458,7 +1458,15 @@ TclStubs tclStubs = { NULL, /* 657 */ NULL, /* 658 */ NULL, /* 659 */ - TclUnusedStubEntry, /* 660 */ + NULL, /* 660 */ + NULL, /* 661 */ + NULL, /* 662 */ + NULL, /* 663 */ + NULL, /* 664 */ + NULL, /* 665 */ + NULL, /* 666 */ + NULL, /* 667 */ + TclUnusedStubEntry, /* 668 */ }; /* !END!: Do not edit above this line. */ -- cgit v0.12 From 0a7026859d3375cd02acc21c0d0f03732040dda6 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 12 Feb 2022 18:49:45 +0000 Subject: Fix [1720242] (appears the patch was only partially applied) --- unix/configure | 4 ++-- unix/tcl.m4 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/unix/configure b/unix/configure index 0b5fa29..11d7ca4 100755 --- a/unix/configure +++ b/unix/configure @@ -8077,11 +8077,11 @@ fi SHLIB_CFLAGS="" if test "$SHARED_BUILD" = 1; then - SHLIB_LD='ld -shared -expect_unresolved "*"' + SHLIB_LD='${CC} -shared' else - SHLIB_LD='ld -non_shared -expect_unresolved "*"' + SHLIB_LD='${CC} -non_shared' fi diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 6305ef7..739dce3 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1684,9 +1684,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" -- cgit v0.12 From 12315d87b5f80a7528bd95f37286f5a657734a1d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 13 Feb 2022 22:29:11 +0000 Subject: Make a start supporting aarch64-w64-mingw32-clang (WIP) --- compat/zlib/win64-arm/libz.dll.a | Bin 0 -> 13002 bytes compat/zlib/win64-arm/zlib1.dll | Bin 84480 -> 92672 bytes win/README | 16 +++++----------- win/rules.vc | 9 ++++----- win/x86_64-w64-mingw32-nmakehlp.exe | Bin 0 -> 25600 bytes 5 files changed, 9 insertions(+), 16 deletions(-) create mode 100644 compat/zlib/win64-arm/libz.dll.a create mode 100755 win/x86_64-w64-mingw32-nmakehlp.exe diff --git a/compat/zlib/win64-arm/libz.dll.a b/compat/zlib/win64-arm/libz.dll.a new file mode 100644 index 0000000..b6cbde7 Binary files /dev/null and b/compat/zlib/win64-arm/libz.dll.a differ diff --git a/compat/zlib/win64-arm/zlib1.dll b/compat/zlib/win64-arm/zlib1.dll index 2abef88..7d08dd3 100755 Binary files a/compat/zlib/win64-arm/zlib1.dll and b/compat/zlib/win64-arm/zlib1.dll differ diff --git a/win/README b/win/README index f4cdde4..038a7cb 100644 --- a/win/README +++ b/win/README @@ -21,26 +21,27 @@ In order to compile Tcl for Windows, you need the following: and Visual C++ 6 or newer + (win32 or win64, for IX86/AMD64/ARM64) or Linux + MinGW-w64 [https://www.mingw-w64.org/] - (win32 or win64) + (win32 or win64, for IX86/AMD64) or Cygwin + MinGW-w64 [https://cygwin.com/install.html] - (win32 or win64) + (win32 or win64, for IX86/AMD64) or Darwin + MinGW-w64 [https://www.mingw-w64.org/] - (win32 or win64) + (win32 or win64, for IX86/AMD64) or Msys + MinGW-w64 [https://www.mingw-w64.org/] - (win32 or win64) + (win32 or win64, for IX86/AMD64) In practice, this release is built with Visual C++ 6.0 and the TEA @@ -56,13 +57,6 @@ using it, are in the comments of "makefile.vc". A quick example would be: There is also a Developer Studio workspace and project file, too, if you would like to use them. -If you want to Cross-compile with Visual Studio (e.g. for X86 or ARM64 -targets, but running on AMD64), first set up the environment for -your host machine and compile nmakehlp.exe: - C:\tcl_source\win\>nmake -f makefile.vc nmakehlp -Then go to your cross-compile environment and run the nmake -command again for whatever you want to build. - If you are building with Linux, Cygwin or Msys, you can use the configure script that lives in the win subdirectory. The Linux/Cygwin/Msys based configure/build process works just like the UNIX one, so you will want diff --git a/win/rules.vc b/win/rules.vc index b68b6b4..22aa735 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -77,7 +77,7 @@ NEED_TK_SOURCE = 0 # 2. Figure out our build structure in terms of the directory, whether # we are building Tcl or an extension, etc. # 3. Determine the compiler and linker versions -# 4. Build the nmakehlp helper application +# 4. Build the nmakehlp helper application (if not cross-compiling) # 5. Determine the supported compiler options and features # 6. Parse the OPTS macro value for user-specified build configuration # 7. Parse the STATS macro value for statistics instrumentation @@ -548,13 +548,12 @@ NMAKEHLPC = $(_TCLDIR)\win\nmakehlp.c !endif # NMAKEHLPC -nmakehlp: - $(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console - # We always build nmakehlp even if it exists since we do not know # what source it was built from. !if "$(MACHINE)" == "$(NATIVE_ARCH)" -!if [$(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console > nul] +!if [$(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console >NUL] +#else +!if [COPY "$(NMAKEHLPC)$(NMAKEHLPC:nmakehlp.c=x86_64-w64-mingw32-nmakehlp.exe)" nmakehlp.exe] !endif !endif diff --git a/win/x86_64-w64-mingw32-nmakehlp.exe b/win/x86_64-w64-mingw32-nmakehlp.exe new file mode 100755 index 0000000..2564ec9 Binary files /dev/null and b/win/x86_64-w64-mingw32-nmakehlp.exe differ -- cgit v0.12 From 780dda171fc31acc8215cfa314f04c4c44875c96 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 13 Feb 2022 22:46:17 +0000 Subject: Fix determination of HAVE_CPUID with configure script --- win/configure | 2 +- win/tcl.m4 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/win/configure b/win/configure index f815682..ab9771f 100755 --- a/win/configure +++ b/win/configure @@ -3477,7 +3477,7 @@ echo "${ECHO_T}$ac_cv_win32" >&6 echo "$as_me: error: ${CC} cannot produce win32 executables." >&2;} { (exit 1); exit 1; }; } fi - if test "$MACHINE" != "ARM64"; then + if test "$do64bit" != "arm64"; then extra_cflags="$extra_cflags -DHAVE_CPUID=1" fi diff --git a/win/tcl.m4 b/win/tcl.m4 index 26702b6..ddf57f7 100644 --- a/win/tcl.m4 +++ b/win/tcl.m4 @@ -583,7 +583,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" @@ -649,7 +649,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 -- cgit v0.12 From 42b02c426ce627a263ba827a896f81bad0ebdb4d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 13 Feb 2022 23:07:51 +0000 Subject: Add libtommath.dll and libtommath.dll.a for windows-arm64 --- libtommath/win64-arm/libtommath.dll | Bin 0 -> 69120 bytes libtommath/win64-arm/libtommath.dll.a | Bin 0 -> 20816 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100755 libtommath/win64-arm/libtommath.dll create mode 100644 libtommath/win64-arm/libtommath.dll.a diff --git a/libtommath/win64-arm/libtommath.dll b/libtommath/win64-arm/libtommath.dll new file mode 100755 index 0000000..99c57a2 Binary files /dev/null and b/libtommath/win64-arm/libtommath.dll differ diff --git a/libtommath/win64-arm/libtommath.dll.a b/libtommath/win64-arm/libtommath.dll.a new file mode 100644 index 0000000..611522e Binary files /dev/null and b/libtommath/win64-arm/libtommath.dll.a differ -- cgit v0.12 From 7bc41fba5b8194878cdcaa64ad0c4d93e91180b6 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 14 Feb 2022 12:59:58 +0000 Subject: Fix [c59fd034fd]: zdll.lib for windows arm64 is compiled for wrong architecture --- compat/zlib/win64-arm/zdll.lib | Bin 16732 -> 16740 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/compat/zlib/win64-arm/zdll.lib b/compat/zlib/win64-arm/zdll.lib index a1b6c50..0fe0140 100755 Binary files a/compat/zlib/win64-arm/zdll.lib and b/compat/zlib/win64-arm/zdll.lib differ -- cgit v0.12 From 46007941c79dfbd5c661d1f46888db7d54730d2e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 14 Feb 2022 13:54:14 +0000 Subject: Fix tommath.lib, which is missing some (deprecated) symbols. --- libtommath/tommath.def | 11 +++++++++++ libtommath/win64-arm/tommath.lib | Bin 26734 -> 28856 bytes 2 files changed, 11 insertions(+) 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/win64-arm/tommath.lib b/libtommath/win64-arm/tommath.lib index 2721c6c..f14fbe7 100644 Binary files a/libtommath/win64-arm/tommath.lib and b/libtommath/win64-arm/tommath.lib differ -- cgit v0.12 From a6d654648aac247aba2e0877bd39aa807d5d31c7 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 14 Feb 2022 14:17:20 +0000 Subject: re-generate configure script for windows --- win/configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/configure b/win/configure index ab9771f..c553cb7 100755 --- a/win/configure +++ b/win/configure @@ -3353,7 +3353,7 @@ echo "${ECHO_T}$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" -- cgit v0.12 From 1335b4e324414f01c2f79058a90d4ad3c43aecf3 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 14 Feb 2022 15:28:25 +0000 Subject: Re-build zlib and libtommath for AMD64 and ARM64 to use the UCRT runtime (with llvm-clang toolset) --- compat/zlib/win64-arm/zlib1.dll | Bin 92672 -> 92672 bytes compat/zlib/win64/libz.dll.a | Bin 51638 -> 13002 bytes compat/zlib/win64/zlib1.dll | Bin 116736 -> 99840 bytes libtommath/win64-arm/libtommath.dll | Bin 69120 -> 69120 bytes libtommath/win64-arm/libtommath.dll.a | Bin 20816 -> 22478 bytes libtommath/win64/libtommath.dll | Bin 81408 -> 80896 bytes libtommath/win64/libtommath.dll.a | Bin 128166 -> 22478 bytes 7 files changed, 0 insertions(+), 0 deletions(-) diff --git a/compat/zlib/win64-arm/zlib1.dll b/compat/zlib/win64-arm/zlib1.dll index 7d08dd3..1f43308 100755 Binary files a/compat/zlib/win64-arm/zlib1.dll and b/compat/zlib/win64-arm/zlib1.dll differ diff --git a/compat/zlib/win64/libz.dll.a b/compat/zlib/win64/libz.dll.a index 93be06e..b0c8722 100644 Binary files a/compat/zlib/win64/libz.dll.a and b/compat/zlib/win64/libz.dll.a differ diff --git a/compat/zlib/win64/zlib1.dll b/compat/zlib/win64/zlib1.dll index 81195c3..e893cff 100755 Binary files a/compat/zlib/win64/zlib1.dll and b/compat/zlib/win64/zlib1.dll differ diff --git a/libtommath/win64-arm/libtommath.dll b/libtommath/win64-arm/libtommath.dll index 99c57a2..37bccf7 100755 Binary files a/libtommath/win64-arm/libtommath.dll and b/libtommath/win64-arm/libtommath.dll differ diff --git a/libtommath/win64-arm/libtommath.dll.a b/libtommath/win64-arm/libtommath.dll.a index 611522e..0108f90 100644 Binary files a/libtommath/win64-arm/libtommath.dll.a and b/libtommath/win64-arm/libtommath.dll.a differ diff --git a/libtommath/win64/libtommath.dll b/libtommath/win64/libtommath.dll index 2225faf..ace8fce 100755 Binary files a/libtommath/win64/libtommath.dll and b/libtommath/win64/libtommath.dll differ diff --git a/libtommath/win64/libtommath.dll.a b/libtommath/win64/libtommath.dll.a index 40adaf7..81be3c8 100644 Binary files a/libtommath/win64/libtommath.dll.a and b/libtommath/win64/libtommath.dll.a differ -- cgit v0.12 From 11416a8c3aba74bef614771e7e212ebcc4632e7a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 14 Feb 2022 15:39:52 +0000 Subject: Use TCLSH_NATIVE for building the zip-file when cross-compiling --- win/makefile.vc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/makefile.vc b/win/makefile.vc index 68c2aa7..ee29360 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: -- cgit v0.12 From 0fdf8385dfdc3e8f0c7a529590f0e61fcfd40525 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 14 Feb 2022 15:44:03 +0000 Subject: Fix regression caused by [d109376ad]: Move nmakehlp target down, so it doesn't become the default target. --- win/rules.vc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/win/rules.vc b/win/rules.vc index b68b6b4..f8236f4 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -548,9 +548,6 @@ NMAKEHLPC = $(_TCLDIR)\win\nmakehlp.c !endif # NMAKEHLPC -nmakehlp: - $(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console - # We always build nmakehlp even if it exists since we do not know # what source it was built from. !if "$(MACHINE)" == "$(NATIVE_ARCH)" @@ -1613,6 +1610,9 @@ DEFAULT_BUILD_TARGET = $(PROJECT) default-target: $(DEFAULT_BUILD_TARGET) +nmakehlp: + $(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console + !if $(MULTIPLATFORM_INSTALL) default-pkgindex: @echo if {[package vsatisfies [package provide Tcl] 9.0-]} { > $(OUT_DIR)\pkgIndex.tcl -- cgit v0.12 From 79389c01abf1f00ab5d29c677bd86acfe618bd7b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 14 Feb 2022 17:17:05 +0000 Subject: Correct references to libtommath.dll.a/tommath.lib, depending on compiler (was OK for zlib) --- win/configure | 12 ++++++++---- win/configure.ac | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/win/configure b/win/configure index 3ae3d41..56342c0 100755 --- a/win/configure +++ b/win/configure @@ -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]) -- cgit v0.12 From e67e9e8530f03686180b8523847e1a933db359e0 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 14 Feb 2022 17:53:01 +0000 Subject: Always produce windows binaries on windows-2019, even if windows-latest switches to windows-2022 --- .github/workflows/onefiledist.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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} -- cgit v0.12 From b5898cc4d07090ca5d742abc116dd57baa086abc Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 15 Feb 2022 13:18:01 +0000 Subject: See [https://patch-diff.githubusercontent.com/raw/tcltk/tcl/pull/12.patch], but slightly better: If cross-compiling for ARM64, we must be on AMD64, so just use a pre-compile nmakehlp executable --- win/rules.vc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/win/rules.vc b/win/rules.vc index f8236f4..372d70a 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -550,9 +550,12 @@ 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)" == "$(NATIVE_ARCH)" +!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 ################################################################ @@ -1610,9 +1613,6 @@ DEFAULT_BUILD_TARGET = $(PROJECT) default-target: $(DEFAULT_BUILD_TARGET) -nmakehlp: - $(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console - !if $(MULTIPLATFORM_INSTALL) default-pkgindex: @echo if {[package vsatisfies [package provide Tcl] 9.0-]} { > $(OUT_DIR)\pkgIndex.tcl -- cgit v0.12 From dff07b745999cb6df94a2fbe5ef2a22a9f7e24f3 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 15 Feb 2022 13:51:02 +0000 Subject: Add nmakehlp.exe (for AMD64) to distribution, and make it usable in rules-ext.vc too --- unix/Makefile.in | 3 ++- win/makefile.vc | 1 + win/rules-ext.vc | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/unix/Makefile.in b/unix/Makefile.in index 74df6fb..0ab3e9b 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -2141,7 +2141,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/win/makefile.vc b/win/makefile.vc index a4de4c2..395a9ca 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -945,6 +945,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\" @echo Installing package http 1.0 (obsolete) @$(CPY) "$(ROOT)\library\http1.0\*.tcl" \ 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)" != "" -- cgit v0.12 From bf79ff2fca084ddd73434bb646d06f73e0f8380e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 15 Feb 2022 14:09:11 +0000 Subject: update README --- win/README | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/win/README b/win/README index f4cdde4..92cb2c6 100644 --- a/win/README +++ b/win/README @@ -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. @@ -56,21 +61,15 @@ using it, are in the comments of "makefile.vc". A quick example would be: There is also a Developer Studio workspace and project file, too, if you would like to use them. -If you want to Cross-compile with Visual Studio (e.g. for X86 or ARM64 -targets, but running on AMD64), first set up the environment for -your host machine and compile nmakehlp.exe: - C:\tcl_source\win\>nmake -f makefile.vc nmakehlp -Then go to your cross-compile environment and run the nmake -command again for whatever you want to build. - If you are building with Linux, Cygwin or Msys, you can use the configure script that lives in the win subdirectory. The Linux/Cygwin/Msys based 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 -- cgit v0.12 From 2cee7e53be159d0339af06053e2c02673780ad92 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 15 Feb 2022 14:31:42 +0000 Subject: Update win/README --- win/README | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/win/README b/win/README index f4cdde4..86e9e59 100644 --- a/win/README +++ b/win/README @@ -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. @@ -56,21 +61,15 @@ using it, are in the comments of "makefile.vc". A quick example would be: There is also a Developer Studio workspace and project file, too, if you would like to use them. -If you want to Cross-compile with Visual Studio (e.g. for X86 or ARM64 -targets, but running on AMD64), first set up the environment for -your host machine and compile nmakehlp.exe: - C:\tcl_source\win\>nmake -f makefile.vc nmakehlp -Then go to your cross-compile environment and run the nmake -command again for whatever you want to build. - If you are building with Linux, Cygwin or Msys, you can use the configure script that lives in the win subdirectory. The Linux/Cygwin/Msys based 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 @@ -81,9 +80,9 @@ 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 tclsh86.exe, you must ensure that tcl86.dll is -on your path, in the system directory, or in the directory containing -tclsh86.exe. +Note that in order to run tclsh86.exe, you must ensure that tcl86.dll +and zlib1.dll are on your path, in the system directory, or in the +directory containing tclsh86.exe. Note: Tcl no longer provides support for Win32s. -- cgit v0.12 From 6cf6873784a9c4f2488341b1fbf6bc8864d24eb1 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 15 Feb 2022 15:04:48 +0000 Subject: Tcl 8.7 requires Visual Studio 2015 or newer --- win/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/README b/win/README index 3f27f66..3cfcc15 100644 --- a/win/README +++ b/win/README @@ -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 -- cgit v0.12 From 9d7c90707095d35a8f27a6675b2e360c3cb486d2 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 16 Feb 2022 14:33:57 +0000 Subject: Fix [7deeddb36]: signed integer overflow in Tcl_ScanObjCmd() --- generic/tclScan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclScan.c b/generic/tclScan.c index 6ab17bd..f6ff7a9 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -923,7 +923,7 @@ Tcl_ScanObjCmd( if (Tcl_GetWideIntFromObj(NULL, objPtr, &wideValue) != TCL_OK) { wideValue = ~(Tcl_WideUInt)0 >> 1; /* WIDE_MAX */ if (TclGetString(objPtr)[0] == '-') { - wideValue++; /* WIDE_MAX + 1 = WIDE_MIN */ + wideValue += 1U; /* WIDE_MAX + 1 = WIDE_MIN */ } } if ((flags & SCAN_UNSIGNED) && (wideValue < 0)) { -- cgit v0.12 From 530446f68e748c71bcd26835ca42576d1dbdc17e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 16 Feb 2022 14:53:26 +0000 Subject: Fix [89de498973]: signed integer overflow in TclParseNumber() --- generic/tclStrToD.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index 372fe77..1a1c2ac 100644 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -1312,7 +1312,7 @@ TclParseNumber( objPtr->typePtr = &tclWideIntType; if (signum) { objPtr->internalRep.wideValue = - - (Tcl_WideInt) octalSignificandWide; + (Tcl_WideInt) (-octalSignificandWide); } else { objPtr->internalRep.wideValue = (Tcl_WideInt) octalSignificandWide; @@ -1327,7 +1327,7 @@ TclParseNumber( objPtr->typePtr = &tclIntType; if (signum) { objPtr->internalRep.longValue = - - (long) octalSignificandWide; + (long) (-octalSignificandWide); } else { objPtr->internalRep.longValue = (long) octalSignificandWide; @@ -1359,7 +1359,7 @@ TclParseNumber( objPtr->typePtr = &tclWideIntType; if (signum) { objPtr->internalRep.wideValue = - - (Tcl_WideInt) significandWide; + (Tcl_WideInt) (-significandWide); } else { objPtr->internalRep.wideValue = (Tcl_WideInt) significandWide; @@ -1374,7 +1374,7 @@ TclParseNumber( objPtr->typePtr = &tclIntType; if (signum) { objPtr->internalRep.longValue = - - (long) significandWide; + (long) (-significandWide); } else { objPtr->internalRep.longValue = (long) significandWide; -- cgit v0.12 From d203d159b9f52796cd28cad53f0c6d777caadf11 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 16 Feb 2022 15:24:35 +0000 Subject: Fix [c6fea6ba6]: possible signed integer overflow in Tcl_GetLongFromObj(), Tcl_GetWideIntFromObj() --- generic/tclObj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tclObj.c b/generic/tclObj.c index 1fd674f..029d3c0 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -2816,7 +2816,7 @@ Tcl_GetLongFromObj( value = (value << CHAR_BIT) | *bytes++; } if (big.sign) { - *longPtr = - (long) value; + *longPtr = (long) (0-value); } else { *longPtr = (long) value; } @@ -3116,7 +3116,7 @@ Tcl_GetWideIntFromObj( value = (value << CHAR_BIT) | *bytes++; } if (big.sign) { - *wideIntPtr = - (Tcl_WideInt) value; + *wideIntPtr = (Tcl_WideInt) (0-value); } else { *wideIntPtr = (Tcl_WideInt) value; } -- cgit v0.12 From 247cb91a652499e2b90c89568c3995206148c28c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 16 Feb 2022 16:10:22 +0000 Subject: Fix [1c60dca341]: signed integer overflow in Tcl_SetBignumObj() --- generic/tclObj.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/tclObj.c b/generic/tclObj.c index 029d3c0..f7bb44c 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -2816,7 +2816,7 @@ Tcl_GetLongFromObj( value = (value << CHAR_BIT) | *bytes++; } if (big.sign) { - *longPtr = (long) (0-value); + *longPtr = (long) (-value); } else { *longPtr = (long) value; } @@ -3116,7 +3116,7 @@ Tcl_GetWideIntFromObj( value = (value << CHAR_BIT) | *bytes++; } if (big.sign) { - *wideIntPtr = (Tcl_WideInt) (0-value); + *wideIntPtr = (Tcl_WideInt) (-value); } else { *wideIntPtr = (Tcl_WideInt) value; } @@ -3547,7 +3547,7 @@ Tcl_SetBignumObj( goto tooLargeForLong; } if (bignumValue->sign) { - TclSetLongObj(objPtr, -(long)value); + TclSetLongObj(objPtr, (long)(-value)); } else { TclSetLongObj(objPtr, (long)value); } @@ -3573,7 +3573,7 @@ Tcl_SetBignumObj( goto tooLargeForWide; } if (bignumValue->sign) { - TclSetWideIntObj(objPtr, -(Tcl_WideInt)value); + TclSetWideIntObj(objPtr, (Tcl_WideInt)(-value)); } else { TclSetWideIntObj(objPtr, (Tcl_WideInt)value); } -- cgit v0.12 From c9599e745ab10316ab4bb48c8d129ce9f5cee15b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 16 Feb 2022 16:18:08 +0000 Subject: Fix [7f8a3d9818]: signed integer overflow in tclExecute.c --- generic/tclExecute.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 2faf213..97ac1f0 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -1898,7 +1898,7 @@ TclIncrObj( if ((type1 == TCL_NUMBER_LONG) && (type2 == TCL_NUMBER_LONG)) { long augend = *((const long *) ptr1); long addend = *((const long *) ptr2); - long sum = augend + addend; + long sum = (long)((unsigned long)augend + (unsigned long)addend); /* * Overflow when (augend and sum have different sign) and (augend and @@ -1949,7 +1949,7 @@ TclIncrObj( TclGetWideIntFromObj(NULL, valuePtr, &w1); TclGetWideIntFromObj(NULL, incrPtr, &w2); - sum = w1 + w2; + sum = (Tcl_WideInt)((Tcl_WideUInt)w1 + (Tcl_WideUInt)w2); /* * Check for overflow. @@ -3929,7 +3929,7 @@ TEBCresume( if (GetNumberFromObj(NULL, objPtr, &ptr, &type) == TCL_OK) { if (type == TCL_NUMBER_LONG) { long augend = *((const long *)ptr); - long sum = augend + increment; + long sum = (long)((unsigned long)augend + (unsigned long)increment); /* * Overflow when (augend and sum have different sign) and @@ -3977,7 +3977,7 @@ TEBCresume( Tcl_WideInt sum; w = *((const Tcl_WideInt *) ptr); - sum = w + increment; + sum = (Tcl_WideInt)((Tcl_WideUInt)w + (Tcl_WideUInt)increment); /* * Check for overflow. @@ -6506,7 +6506,7 @@ TEBCresume( case INST_ADD: w1 = (Tcl_WideInt) l1; w2 = (Tcl_WideInt) l2; - wResult = w1 + w2; + wResult = (Tcl_WideInt)((Tcl_WideUInt)w1 + (Tcl_WideUInt)w2); #ifdef TCL_WIDE_INT_IS_LONG /* * Check for overflow. @@ -6521,7 +6521,7 @@ TEBCresume( case INST_SUB: w1 = (Tcl_WideInt) l1; w2 = (Tcl_WideInt) l2; - wResult = w1 - w2; + wResult = (Tcl_WideInt)((Tcl_WideUInt)w1 - (Tcl_WideUInt)w2); #ifdef TCL_WIDE_INT_IS_LONG /* * Must check for overflow. The macro tests for overflows in @@ -9146,7 +9146,7 @@ ExecuteExtendedBinaryMathOp( switch (opcode) { case INST_ADD: - wResult = w1 + w2; + wResult = (Tcl_WideInt)((Tcl_WideUInt)w1 + (Tcl_WideUInt)w2); #ifndef TCL_WIDE_INT_IS_LONG if ((type1 == TCL_NUMBER_WIDE) || (type2 == TCL_NUMBER_WIDE)) #endif @@ -9162,7 +9162,7 @@ ExecuteExtendedBinaryMathOp( break; case INST_SUB: - wResult = w1 - w2; + wResult = (Tcl_WideInt)((Tcl_WideUInt)w1 - (Tcl_WideUInt)w2); #ifndef TCL_WIDE_INT_IS_LONG if ((type1 == TCL_NUMBER_WIDE) || (type2 == TCL_NUMBER_WIDE)) #endif -- cgit v0.12 From 8fd0500bc8b2821f46d079ebc6b19bb39a25152e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 17 Feb 2022 09:30:37 +0000 Subject: Addendum to [7deeddb36]: Use WIDE_MIN/WIDE_MAX in more places --- generic/tclObj.c | 2 +- generic/tclScan.c | 35 +++++++++++++++++++---------------- generic/tclStrToD.c | 11 +++++------ 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/generic/tclObj.c b/generic/tclObj.c index f7bb44c..9afcedb 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -3569,7 +3569,7 @@ Tcl_SetBignumObj( while (numBytes-- > 0) { value = (value << CHAR_BIT) | *bytes++; } - if (value > (((~(Tcl_WideUInt)0) >> 1) + bignumValue->sign)) { + if (value > ((UWIDE_MAX >> 1) + bignumValue->sign)) { goto tooLargeForWide; } if (bignumValue->sign) { diff --git a/generic/tclScan.c b/generic/tclScan.c index f6ff7a9..f37f596 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -28,15 +28,17 @@ * character set. */ -typedef struct CharSet { +typedef struct { + Tcl_UniChar start; + Tcl_UniChar end; +} Range; + +typedef struct { int exclude; /* 1 if this is an exclusion set. */ int nchars; Tcl_UniChar *chars; int nranges; - struct Range { - Tcl_UniChar start; - Tcl_UniChar end; - } *ranges; + Range *ranges; } CharSet; /* @@ -101,9 +103,9 @@ BuildCharSet( end += TclUtfToUniChar(end, &ch); } - cset->chars = ckalloc(sizeof(Tcl_UniChar) * (end - format - 1)); + cset->chars = (Tcl_UniChar *)ckalloc(sizeof(Tcl_UniChar) * (end - format - 1)); if (nranges > 0) { - cset->ranges = ckalloc(sizeof(struct Range) * nranges); + cset->ranges = (Range *)ckalloc(sizeof(Range) * nranges); } else { cset->ranges = NULL; } @@ -259,12 +261,12 @@ ValidateFormat( char *end; Tcl_UniChar ch = 0; int objIndex, xpgSize, nspace = numVars; - int *nassign = TclStackAlloc(interp, nspace * sizeof(int)); - char buf[TCL_UTF_MAX+1] = ""; + int *nassign = (int *)TclStackAlloc(interp, nspace * sizeof(int)); Tcl_Obj *errorMsg; /* Place to build an error messages. Note that * these are messy operations because we do * not want to use the formatting engine; * we're inside there! */ + char buf[TCL_UTF_MAX+1] = ""; /* * Initialize an array that records the number of times a variable is @@ -483,7 +485,7 @@ ValidateFormat( } else { nspace += 16; /* formerly STATIC_LIST_SIZE */ } - nassign = TclStackRealloc(interp, nassign, + nassign = (int *)TclStackRealloc(interp, nassign, nspace * sizeof(int)); for (i = value; i < nspace; i++) { nassign[i] = 0; @@ -566,7 +568,6 @@ ValidateFormat( *---------------------------------------------------------------------- */ - /* ARGSUSED */ int Tcl_ScanObjCmd( ClientData dummy, /* Not used. */ @@ -585,6 +586,7 @@ Tcl_ScanObjCmd( Tcl_UniChar ch = 0, sch = 0; Tcl_Obj **objs = NULL, *objPtr = NULL; int flags; + (void)dummy; if (objc < 3) { Tcl_WrongNumArgs(interp, 1, objv, @@ -608,7 +610,7 @@ Tcl_ScanObjCmd( */ if (totalVars > 0) { - objs = ckalloc(sizeof(Tcl_Obj *) * totalVars); + objs = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj *) * totalVars); for (i = 0; i < totalVars; i++) { objs[i] = NULL; } @@ -895,7 +897,7 @@ Tcl_ScanObjCmd( /* * Scan an unsigned or signed integer. */ - objPtr = Tcl_NewLongObj(0); + TclNewIntObj(objPtr, 0); Tcl_IncrRefCount(objPtr); if (width == 0) { width = ~0; @@ -921,9 +923,10 @@ Tcl_ScanObjCmd( } if (flags & SCAN_LONGER) { if (Tcl_GetWideIntFromObj(NULL, objPtr, &wideValue) != TCL_OK) { - wideValue = ~(Tcl_WideUInt)0 >> 1; /* WIDE_MAX */ if (TclGetString(objPtr)[0] == '-') { - wideValue += 1U; /* WIDE_MAX + 1 = WIDE_MIN */ + wideValue = WIDE_MIN; + } else { + wideValue = WIDE_MAX; } } if ((flags & SCAN_UNSIGNED) && (wideValue < 0)) { @@ -950,7 +953,7 @@ Tcl_ScanObjCmd( Tcl_SetWideIntObj(objPtr, (unsigned long)value); #endif } else { - Tcl_SetLongObj(objPtr, value); + TclSetLongObj(objPtr, value); } } objs[objIndex++] = objPtr; diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index 1a1c2ac..61162d0 100644 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -542,8 +542,7 @@ TclParseNumber( int shift = 0; /* Amount to shift when accumulating binary */ int explicitOctal = 0; -#define ALL_BITS (~(Tcl_WideUInt)0) -#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 @@ -703,7 +702,7 @@ TclParseNumber( && (((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt)) || (octalSignificandWide > - (~(Tcl_WideUInt)0 >> shift)))) { + (UWIDE_MAX >> shift)))) { octalSignificandOverflow = 1; TclBNInitBignumFromWideUInt(&octalSignificandBig, octalSignificandWide); @@ -829,7 +828,7 @@ TclParseNumber( if (significandWide != 0 && ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || - significandWide > (~(Tcl_WideUInt)0 >> shift))) { + significandWide > (UWIDE_MAX >> shift))) { significandOverflow = 1; TclBNInitBignumFromWideUInt(&significandBig, significandWide); @@ -881,7 +880,7 @@ TclParseNumber( if (significandWide != 0 && ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || - significandWide > (~(Tcl_WideUInt)0 >> shift))) { + significandWide > (UWIDE_MAX >> shift))) { significandOverflow = 1; TclBNInitBignumFromWideUInt(&significandBig, significandWide); @@ -1545,7 +1544,7 @@ AccumulateDecimalDigit( *wideRepPtr = digit; return 0; } else if (numZeros >= maxpow10_wide - || w > ((~(Tcl_WideUInt)0)-digit)/pow10_wide[numZeros+1]) { + || w > (UWIDE_MAX-digit)/pow10_wide[numZeros+1]) { /* * Wide multiplication will overflow. Expand the number to a * bignum and fall through into the bignum case. -- cgit v0.12