From 61d8bcc4f631c8b3bd8a14a2a8bf68d7c0749809 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 18 May 2020 12:47:18 +0000 Subject: If Tcl is built with external libtommath (TCL_WITH_EXTERNAL_TOMMATH is defined), do the tests with the external libtommath too. Also, don't try to include if BN_H_ is already defined. --- generic/tclTest.c | 8 +++++++- generic/tclTomMath.h | 10 ++++++---- win/tclWinTest.c | 6 +++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/generic/tclTest.c b/generic/tclTest.c index a6c3b83..8cca744 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -20,7 +20,11 @@ # define USE_TCL_STUBS #endif #include "tclInt.h" -#include "tclTomMath.h" +#ifdef TCL_WITH_EXTERNAL_TOMMATH +# include "tommath.h" +#else +# include "tclTomMath.h" +#endif #include "tclOO.h" #include @@ -446,9 +450,11 @@ Tcltest_Init( if (Tcl_InitStubs(interp, "8.5-", 0) == NULL) { return TCL_ERROR; } +#ifndef TCL_WITH_EXTERNAL_TOMMATH if (Tcl_TomMath_InitStubs(interp, "8.5-") == NULL) { return TCL_ERROR; } +#endif if (Tcl_OOInitStubs(interp) == NULL) { return TCL_ERROR; } diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h index e9257a0..0d2d320 100644 --- a/generic/tclTomMath.h +++ b/generic/tclTomMath.h @@ -2,13 +2,15 @@ #define BN_TCL_H_ #ifdef MP_NO_STDINT -#ifdef HAVE_STDINT_H -# include +# ifdef HAVE_STDINT_H +# include #else -# include "../compat/stdint.h" +# include "../compat/stdint.h" +# endif #endif +#ifndef BN_H_ /* If BN_H_ already defined, don't try to include tommath.h again. */ +# include "tommath.h" #endif -#include "tommath.h" #include "tclTomMathDecls.h" #endif diff --git a/win/tclWinTest.c b/win/tclWinTest.c index 5841509..91a3010 100644 --- a/win/tclWinTest.c +++ b/win/tclWinTest.c @@ -13,7 +13,11 @@ # define USE_TCL_STUBS #endif #include "tclInt.h" -#include "tclTomMath.h" +#ifdef TCL_WITH_EXTERNAL_TOMMATH +# include "tommath.h" +#else +# include "tclTomMath.h" +#endif /* * For TestplatformChmod on Windows -- cgit v0.12 From e54cad6de1c547761044db23d6b9358b00db2230 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 18 May 2020 20:23:30 +0000 Subject: Tiny fix for TCL_UTF_MAX=4 build only: Since Tcl_UtfNext() verifies 4 bytes for lead bytes F0-F5, Tcl_UtfCharComplete() should guarantee that those 4 bytes are available, not 3. --- generic/tclUtf.c | 2 +- tests/utf.test | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 4454558..ed9138b 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -87,7 +87,7 @@ static const unsigned char complete[256] = { /* End of "continuation byte section" */ 2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, -#if TCL_UTF_MAX > 4 +#if TCL_UTF_MAX > 3 4,4,4,4,4, #else 3,3,3,3,3, diff --git a/tests/utf.test b/tests/utf.test index 69ef1f4..14b2198 100644 --- a/tests/utf.test +++ b/tests/utf.test @@ -210,7 +210,7 @@ test utf-6.8 {Tcl_UtfNext} {testutfnext testbytestring} { testutfnext A[testbytestring \xF8] } 1 test utf-6.9 {Tcl_UtfNext} {testutfnext testbytestring} { - testutfnext [testbytestring \xA0] + testutfnext [testbytestring \xA0\x00] } 1 test utf-6.10 {Tcl_UtfNext} {testutfnext testbytestring} { testutfnext [testbytestring \xA0]G @@ -554,10 +554,7 @@ test utf-6.111 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { test utf-6.112.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 3 } 1 -test utf-6.112.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring utf16} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 3 -} 4 -test utf-6.112.3 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { +test utf-6.112.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} { testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 3 } 0 test utf-6.113.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { @@ -575,10 +572,7 @@ test utf-6.115 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { test utf-6.116.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 3 } 1 -test utf-6.116.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring utf16} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 3 -} 4 -test utf-6.116.2 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { +test utf-6.116.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 3 } 0 test utf-6.117.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { -- cgit v0.12 From 6de32c896abb44a00ad7368892924e9c9de5db11 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 20 May 2020 19:09:25 +0000 Subject: Adapt some comments, which are not correct for Tcl 8.7 any more --- generic/tcl.h | 4 ++-- generic/tclUtf.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/generic/tcl.h b/generic/tcl.h index 369a894..02ef01e 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -2114,8 +2114,8 @@ typedef struct Tcl_EncodingType { * The maximum number of bytes that are necessary to represent a single * Unicode character in UTF-8. The valid values are 3 and 4 * (or perhaps 1 if we want to support a non-unicode enabled core). If 3, - * then Tcl_UniChar must be 2-bytes in size (UCS-2) (the default). If > 3, - * then Tcl_UniChar must be 4-bytes in size (UCS-4). At this time UCS-2 mode + * then Tcl_UniChar must be 2-bytes in size (UTF-16) (the default). If > 3, + * then Tcl_UniChar must be 4-bytes in size (UCS-4). At this time UTF-16 mode * is the default and recommended mode. */ diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 309a344..2eb959e 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -55,7 +55,7 @@ #define UNICODE_SELF 0x80 /* - * The following structures are used when mapping between Unicode (UCS-2) and + * The following structures are used when mapping between Unicode and * UTF-8. */ -- cgit v0.12