From 13b1a0635f7e5f4c9fce04fe3474d16418d57522 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 15 Feb 2021 12:35:33 +0000 Subject: More testcases from Christian Werner, regarding "string reverse" with Emoji. Those testcases fail in all Tcl 8.6.x releases. --- tests/string.test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/string.test b/tests/string.test index c7cf8d5..3f0a04b 100644 --- a/tests/string.test +++ b/tests/string.test @@ -1828,6 +1828,24 @@ test string-24.15 {string reverse command - pure bytearray} { binary scan [tcl::string::reverse [binary format H* 010203]] H* x set x } 030201 +test string-24.16 {string reverse command - surrogates} knownBug { + string reverse \u0444bulb\uD83D\uDE02 +} \uD83D\uDE02blub\u0444 +test string-24.17 {string reverse command - surrogates} knownBug { + string reverse \uD83D\uDE02hello\uD83D\uDE02 +} \uD83D\uDE02olleh\uD83D\uDE02 +test string-24.18 {string reverse command - surrogates} knownBug { + set s \u0444bulb\uD83D\uDE02 + # shim shimmery ... + string index $s 0 + string reverse $s +} \uD83D\uDE02blub\u0444 +test string-24.19 {string reverse command - surrogates} knownBug { + set s \uD83D\uDE02hello\uD83D\uDE02 + # shim shimmery ... + string index $s 0 + string reverse $s +} \uD83D\uDE02olleh\uD83D\uDE02 test string-25.1 {string is list} { string is list {a b c} -- cgit v0.12 From b4660a7ff9a3dac758b033af3fd7618db6a68b9d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 15 Feb 2021 15:41:55 +0000 Subject: Remove unused variable in win32 static build --- generic/tclZipfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index 50653ff..0d646aa 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -3113,7 +3113,7 @@ TclZipfs_TclLibrary(void) { Tcl_Obj *vfsInitScript; int found; -#ifdef _WIN32 +#if defined(_WIN32) && !defined(STATIC_BUILD) HMODULE hModule; WCHAR wName[MAX_PATH + LIBRARY_SIZE]; char dllName[(MAX_PATH + LIBRARY_SIZE) * 3]; -- cgit v0.12 From c6e348a28b0d74bc880f56b2f2db6f8c97f1b6ca Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 15 Feb 2021 16:13:15 +0000 Subject: Fix [d43f96c1a8]: string trimright is broken for Emoji --- generic/tclUtil.c | 17 +++++++++-------- tests/string.test | 8 ++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/generic/tclUtil.c b/generic/tclUtil.c index d7baedd..0e3449d 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -1686,7 +1686,7 @@ TclTrimRight( * rely on (trim[numTrim] == '\0'). */ { const char *pp, *p = bytes + numBytes; - Tcl_UniChar ch1 = 0; + int ch1, ch2; /* Empty strings -> nothing to do */ if ((numBytes == 0) || (numTrim == 0)) { @@ -1700,12 +1700,14 @@ TclTrimRight( do { const char *q = trim; int pInc = 0, bytesLeft = numTrim; - Tcl_UniChar ch2 = 0; pp = TclUtfPrev(p, bytes); +#if TCL_UTF_MAX <= 4 + pp = TclUtfPrev(pp, bytes); +#endif do { pp += pInc; - pInc = TclUtfToUniChar(pp, &ch1); + pInc = TclUtfToUCS4(pp, &ch1); } while (pp + pInc < p); /* @@ -1713,7 +1715,7 @@ TclTrimRight( */ do { - int qInc = TclUtfToUniChar(q, &ch2); + int qInc = TclUtfToUCS4(q, &ch2); if (ch1 == ch2) { break; @@ -1766,7 +1768,7 @@ TclTrimLeft( * rely on (trim[numTrim] == '\0'). */ { const char *p = bytes; - Tcl_UniChar ch1 = 0; + int ch1, ch2; /* Empty strings -> nothing to do */ if ((numBytes == 0) || (numTrim == 0)) { @@ -1778,8 +1780,7 @@ TclTrimLeft( */ do { - Tcl_UniChar ch2 = 0; - int pInc = TclUtfToUniChar(p, &ch1); + int pInc = TclUtfToUCS4(p, &ch1); const char *q = trim; int bytesLeft = numTrim; @@ -1788,7 +1789,7 @@ TclTrimLeft( */ do { - int qInc = TclUtfToUniChar(q, &ch2); + int qInc = TclUtfToUCS4(q, &ch2); if (ch1 == ch2) { break; diff --git a/tests/string.test b/tests/string.test index 3f0a04b..3ac3060 100644 --- a/tests/string.test +++ b/tests/string.test @@ -1645,13 +1645,13 @@ test string-21.13 {string wordend, unicode} { test string-21.14 {string wordend, unicode} { string wordend "\uC700\uC700 abc" 8 } 6 -test string-21.17 {string trim, unicode} knownBug { +test string-21.17 {string trim, unicode} { string trim "\uD83D\uDE02Hello world!\uD83D\uDE02" \uD83D\uDE02 } "Hello world!" test string-21.18 {string trimleft, unicode} { string trimleft "\uD83D\uDE02Hello world!\uD83D\uDE02" \uD83D\uDE02 } "Hello world!\uD83D\uDE02" -test string-21.19 {string trimright, unicode} knownBug { +test string-21.19 {string trimright, unicode} { string trimright "\uD83D\uDE02Hello world!\uD83D\uDE02" \uD83D\uDE02 } "\uD83D\uDE02Hello world!" test string-21.20 {string trim, unicode} { @@ -1663,13 +1663,13 @@ test string-21.21 {string trimleft, unicode} { test string-21.22 {string trimright, unicode} { string trimright "\uF602Hello world!\uF602" \uD83D\uDE02 } "\uF602Hello world!\uF602" -test string-21.23 {string trim, unicode} knownBug { +test string-21.23 {string trim, unicode} { string trim "\uD83D\uDE02Hello world!\uD83D\uDE02" \uD93D\uDE02 } "\uD83D\uDE02Hello world!\uD83D\uDE02" test string-21.24 {string trimleft, unicode} { string trimleft "\uD83D\uDE02Hello world!\uD83D\uDE02" \uD93D\uDE02 } "\uD83D\uDE02Hello world!\uD83D\uDE02" -test string-21.25 {string trimright, unicode} knownBug { +test string-21.25 {string trimright, unicode} { string trimright "\uD83D\uDE02Hello world!\uD83D\uDE02" \uD93D\uDE02 } "\uD83D\uDE02Hello world!\uD83D\uDE02" -- cgit v0.12 From 3eb07e538c3bf623b1b048ccf5c866ea118b4e4f Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 15 Feb 2021 17:06:47 +0000 Subject: Switch to version 1.3 of macher for the onefiledist --- .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 158542a..df98bec 100644 --- a/.github/workflows/onefiledist.yml +++ b/.github/workflows/onefiledist.yml @@ -55,7 +55,7 @@ jobs: run: | mkdir 1dist touch generic/tclStubInit.c generic/tclOOStubInit.c || true - wget https://github.com/culler/macher/releases/download/v1.2/macher + wget https://github.com/culler/macher/releases/download/v1.3/macher sudo cp macher /usr/local/bin sudo chmod a+x /usr/local/bin/macher echo "VER_PATH=$(cd tools; pwd)/addVerToFile.tcl" >> $GITHUB_ENV -- cgit v0.12 From d97e25b2ad96e4be2e23c349c2d0e6d44cab07e4 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 16 Feb 2021 08:10:34 +0000 Subject: Fix Tcl_UtfPrev for TCL_UTF_MAX>3, so it can jump back over Emoji. Backported from 8.7, no change for TCL_UTF_MAX=3. This way, the previous fix can be slightly more simplified, and working for TCL_UTF_MAX>3 too. --- generic/tclUtf.c | 2 +- generic/tclUtil.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 5ae977a..f99c497 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -888,7 +888,7 @@ Tcl_UtfPrev( /* Continue the search backwards... */ look--; - } while (trailBytesSeen < 3); + } while (trailBytesSeen < (TCL_UTF_MAX < 4 ? 3 : 4)); /* * We've seen 3 trail bytes, so we know there will not be a diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 0e3449d..450f3bf 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -1702,7 +1702,7 @@ TclTrimRight( int pInc = 0, bytesLeft = numTrim; pp = TclUtfPrev(p, bytes); -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX < 4 pp = TclUtfPrev(pp, bytes); #endif do { @@ -1715,14 +1715,14 @@ TclTrimRight( */ do { - int qInc = TclUtfToUCS4(q, &ch2); + pInc = TclUtfToUCS4(q, &ch2); if (ch1 == ch2) { break; } - q += qInc; - bytesLeft -= qInc; + q += pInc; + bytesLeft -= pInc; } while (bytesLeft); if (bytesLeft == 0) { -- cgit v0.12 From 4b639c1ec59a558f0feda5d8f16f0c8482f22f85 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 16 Feb 2021 09:00:14 +0000 Subject: Fix Tcl_UtfPrev expected testcases for TCL_UTF_MAX>3 --- tests/utf.test | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/tests/utf.test b/tests/utf.test index 99d4c36..8e886ae 100644 --- a/tests/utf.test +++ b/tests/utf.test @@ -781,9 +781,12 @@ test utf-7.18.2 {Tcl_UtfPrev} {testutfprev testbytestring} { test utf-7.19 {Tcl_UtfPrev} {testutfprev testbytestring} { testutfprev A[testbytestring \xF8\xA0\xA0\xA0] } 4 -test utf-7.20 {Tcl_UtfPrev} {testutfprev testbytestring} { +test utf-7.20.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF2\xA0\xA0\xA0] } 4 +test utf-7.20.1 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { + testutfprev A[testbytestring \xF2\xA0\xA0\xA0] +} 1 test utf-7.21 {Tcl_UtfPrev} {testutfprev testbytestring} { testutfprev A\u8820[testbytestring \xA0] } 4 @@ -844,9 +847,12 @@ test utf-7.37 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} { test utf-7.38 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} { testutfprev A[testbytestring \xE0\xA0\x80] 2 } 1 -test utf-7.39 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} { +test utf-7.39.0 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF0\x90\x80\x80] } 4 +test utf-7.39.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring fullutf} { + testutfprev A[testbytestring \xF0\x90\x80\x80] +} 1 test utf-7.40.0 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF0\x90\x80\x80] 4 } 3 @@ -883,22 +889,25 @@ test utf-7.47.1 {Tcl_UtfPrev, pointing to 3th byte of 3-byte valid sequence} tes test utf-7.47.2 {Tcl_UtfPrev, pointing to 3th byte of 3-byte invalid sequence} {testutfprev testbytestring} { testutfprev [testbytestring \xE8\xA0\x00] 2 } 0 -test utf-7.48.0 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring} { +test utf-7.48.0 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF4\x8F\xBF\xBF] } 4 -test utf-7.48.1 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs2} { +test utf-7.48.1 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring fullutf} { + testutfprev A[testbytestring \xF4\x8F\xBF\xBF] +} 1 +test utf-7.48.2 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF4\x8F\xBF\xBF] 4 } 3 -test utf-7.48.2 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring fullutf} { +test utf-7.48.3 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring fullutf} { testutfprev A[testbytestring \xF4\x8F\xBF\xBF] 4 } 1 -test utf-7.48.3 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs2} { +test utf-7.48.4 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF4\x8F\xBF\xBF] 3 } 2 -test utf-7.48.4 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring fullutf} { +test utf-7.48.5 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring fullutf} { testutfprev A[testbytestring \xF4\x8F\xBF\xBF] 3 } 1 -test utf-7.48.5 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring} { +test utf-7.48.6 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring} { testutfprev A[testbytestring \xF4\x8F\xBF\xBF] 2 } 1 test utf-7.49.0 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring} { -- cgit v0.12