From dbd3d4eff073d7b97d82ad5927cb6d60542f8541 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 16 Dec 2019 10:08:07 +0000 Subject: Only use OPTS=msvcrt in combination with "static", otherwise it's a NOOP. Disable pragma warning:C4146 (backported from 8.6), since it only gives misleading warnings. --- .travis.yml | 8 ++++---- win/tclWinPort.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 28fd387..b1ed4e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -201,8 +201,8 @@ matrix: before_install: *vcpreinst install: [] script: - - cmd.exe /C 'vcvarsall.bat x64 && nmake OPTS=symbols,msvcrt,threads -f makefile.vc all tcltest' - - cmd.exe /C 'vcvarsall.bat x64 && nmake OPTS=symbols,msvcrt,threads -f makefile.vc test' + - cmd.exe /C 'vcvarsall.bat x64 && nmake OPTS=symbols,threads -f makefile.vc all tcltest' + - cmd.exe /C 'vcvarsall.bat x64 && nmake OPTS=symbols,threads -f makefile.vc test' # Test on Windows with MSVC native (32-bit) - name: "Windows/MSVC-x86/Shared" os: windows @@ -229,8 +229,8 @@ matrix: before_install: *vcpreinst install: [] script: - - cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=symbols,msvcrt,threads -f makefile.vc all tcltest' - - cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=symbols,msvcrt,threads -f makefile.vc test' + - cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=symbols,threads -f makefile.vc all tcltest' + - cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=symbols,threads -f makefile.vc test' # Test on Windows with GCC native - name: "Windows/GCC/Shared" os: windows diff --git a/win/tclWinPort.h b/win/tclWinPort.h index e9ae9dc..3cab385 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -384,6 +384,7 @@ typedef DWORD_PTR * PDWORD_PTR; * (_MSC_VER is 1200 for VC6, 1300 or 1310 for vc7.net, 1400 for 8.0) */ #if defined(_MSC_VER) +# pragma warning(disable:4146) # pragma warning(disable:4244) # if _MSC_VER >= 1400 # pragma warning(disable:4267) -- cgit v0.12 From 3a7b07be0d7da9b0c0b0397913d4cce60c8160a5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 16 Dec 2019 10:09:40 +0000 Subject: Better fix for [3390638]: making the intVal variable unsigned prevents the need for using sprintf() altogether. --- generic/tclUtil.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/generic/tclUtil.c b/generic/tclUtil.c index d065069..f858bb4 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -3316,10 +3316,10 @@ TclFormatInt(buffer, n) * formatted characters are written. */ long n; /* The integer to format. */ { - long intVal; + unsigned long intVal; int i; int numFormatted, j; - char *digits = "0123456789"; + static const char digits[] = "0123456789"; /* * Check first whether "n" is zero. @@ -3332,27 +3332,16 @@ TclFormatInt(buffer, n) } /* - * Check whether "n" is the maximum negative value. This is - * -2^(m-1) for an m-bit word, and has no positive equivalent; - * negating it produces the same value. - */ - - intVal = -n; /* [Bug 3390638] Workaround for*/ - if (n == -n || intVal == n) { /* broken compiler optimizers. */ - return sprintf(buffer, "%ld", n); - } - - /* * Generate the characters of the result backwards in the buffer. */ - intVal = (n < 0? -n : n); + intVal = (n < 0 ? -n : n); i = 0; buffer[0] = '\0'; do { i++; buffer[i] = digits[intVal % 10]; - intVal = intVal/10; + intVal = intVal / 10; } while (intVal > 0); if (n < 0) { i++; -- cgit v0.12 From 6fa04d74e058900e8929c9cbb45c994145691d6b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 19 Dec 2019 22:09:46 +0000 Subject: Add type-cast, making sure that the unary minus is handled correctly on any compiler --- generic/tclUtil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclUtil.c b/generic/tclUtil.c index f858bb4..874e2a5 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -3335,7 +3335,7 @@ TclFormatInt(buffer, n) * Generate the characters of the result backwards in the buffer. */ - intVal = (n < 0 ? -n : n); + intVal = (n < 0 ? -(unsigned long)n : (unsigned long)n); i = 0; buffer[0] = '\0'; do { -- cgit v0.12