From 8fc378853391cde228bf25c1491e9ba02ebf0f2c Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 7 May 2020 18:23:36 +0000 Subject: New approach to fixing the regression reported in [31aa44375d] builds on recent reforms. Older efforts aborted. --- generic/tclUtf.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 12eb637..8ae4b15 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -381,7 +381,7 @@ Tcl_UtfToUniChar( * characters representing themselves. */ -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 4 /* If *chPtr contains a high surrogate (produced by a previous * Tcl_UtfToUniChar() call) and the next 3 bytes are UTF-8 continuation * bytes, then we must produce a follow-up low surrogate. We only @@ -437,7 +437,7 @@ Tcl_UtfToUniChar( * Four-byte-character lead byte followed by at least two trail bytes. * We don't test the validity of 3th trail byte, see [ed29806ba] */ -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 4 Tcl_UniChar high = (((byte & 0x07) << 8) | ((src[1] & 0x3F) << 2) | ((src[2] & 0x3F) >> 4)) - 0x40; if (high < 0x400) { @@ -446,7 +446,7 @@ Tcl_UtfToUniChar( return 1; } /* out of range, < 0x10000 or > 0x10FFFF */ -#else +#elif TCL_UTF_MAX > 4 if ((src[3] & 0xC0) == 0x80) { *chPtr = (((byte & 0x07) << 18) | ((src[1] & 0x3F) << 12) | ((src[2] & 0x3F) << 6) | (src[3] & 0x3F)); @@ -617,25 +617,11 @@ Tcl_NumUtfChars( */ while (src <= optPtr /* && Tcl_UtfCharComplete(src, endPtr - src) */ ) { -#if TCL_UTF_MAX < 4 - if (((unsigned)UCHAR(*src) - 0xF0) < 5) { - /* treat F0 - F4 as single character */ - ch = 0; - src++; - } else -#endif src += TclUtfToUniChar(src, &ch); i++; } /* Loop over the remaining string where call must happen */ while ((src < endPtr) && Tcl_UtfCharComplete(src, endPtr - src)) { -#if TCL_UTF_MAX < 4 - if (((unsigned)UCHAR(*src) - 0xF0) < 5) { - /* treat F0 - F4 as single character */ - ch = 0; - src++; - } else -#endif src += TclUtfToUniChar(src, &ch); i++; } -- cgit v0.12 From 6d36267ee03ebbf37b1843d0602220bbc299f8e9 Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 7 May 2020 18:36:25 +0000 Subject: split and constrain the failing test. --- tests/encoding.test | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/encoding.test b/tests/encoding.test index 552c97f..84f9ae1 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -335,7 +335,12 @@ test encoding-15.4 {UtfToUtfProc emoji character input} -body { set y [encoding convertfrom utf-8 \xED\xA0\xBD\xED\xB8\x82] list [string length $x] $y } -result "6 \uD83D\uDE02" -test encoding-15.5 {UtfToUtfProc emoji character input} { +test encoding-15.5.0 {UtfToUtfProc emoji character input} ucs2 { + set x \xF0\x9F\x98\x82 + set y [encoding convertfrom utf-8 \xF0\x9F\x98\x82] + list [string length $x] $y +} "4 \xF0\x9F\x98\x82" +test encoding-15.5.1 {UtfToUtfProc emoji character input} fullutf { set x \xF0\x9F\x98\x82 set y [encoding convertfrom utf-8 \xF0\x9F\x98\x82] list [string length $x] $y -- cgit v0.12 From 2f5e983d7aaefadd8f9909a27c26d2d62d049f63 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 8 May 2020 08:09:42 +0000 Subject: More testcases that can run without "testbytestring" constraints. --- tests/utf.test | 72 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/tests/utf.test b/tests/utf.test index a9534f2..394fc48 100644 --- a/tests/utf.test +++ b/tests/utf.test @@ -483,10 +483,10 @@ test utf-6.88 {Tcl_UtfNext, pointing to 2th byte of 3-byte valid sequence} {test test utf-6.89 {Tcl_UtfNext, pointing to 2th byte of 3-byte invalid sequence} {testutfnext testbytestring} { testutfnext [testbytestring \x80\x80\x00] } 1 -test utf-6.90.0 {Tcl_UtfNext, validity check [493dccc2de]} {testutfnext ucs2_utf16} { +test utf-6.90.0 {Tcl_UtfNext, validity check [493dccc2de]} {testutfnext testbytestring ucs2_utf16} { testutfnext [testbytestring \xF4\x8F\xBF\xBF] } 1 -test utf-6.90.1 {Tcl_UtfNext, validity check [493dccc2de]} {testutfnext ucs4} { +test utf-6.90.1 {Tcl_UtfNext, validity check [493dccc2de]} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF4\x8F\xBF\xBF] } 4 test utf-6.91.0 {Tcl_UtfNext, validity check [493dccc2de]} {testutfnext testbytestring ucs2} { @@ -519,23 +519,23 @@ test utf-6.94 {Tcl_UtfNext, pointing to 2th byte of 5-byte invalid sequence} {te test utf-6.95 {Tcl_UtfNext, pointing to 2th byte of 5-byte invalid sequence} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \x80\x80\x80\x80] } 1 -test utf-6.96 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring G] 0 +test utf-6.96 {Tcl_UtfNext, read limits} testutfnext { + testutfnext G 0 } 0 test utf-6.97 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { testutfnext [testbytestring \xA0] 0 } 0 -test utf-6.98 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext A[testbytestring G] 1 +test utf-6.98 {Tcl_UtfNext, read limits} testutfnext { + testutfnext AG 1 } 1 test utf-6.99 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { testutfnext A[testbytestring \xA0] 1 } 1 test utf-6.100 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xD0\xA0G] 1 + testutfnext [testbytestring \xD0\xA0]G 1 } 0 test utf-6.101 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xD0\xA0G] 2 + testutfnext [testbytestring \xD0\xA0]G 2 } 2 test utf-6.102 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { testutfnext [testbytestring \xD0\xA0\xA0] 1 @@ -543,47 +543,47 @@ test utf-6.102 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { test utf-6.103 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { testutfnext [testbytestring \xD0\xA0\xA0] 2 } 2 -test utf-6.104 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xE8\xA0\xA0G] 1 +test utf-6.104 {Tcl_UtfNext, read limits} testutfnext { + testutfnext \u8820G 1 } 0 -test utf-6.105 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xE8\xA0\xA0G] 2 +test utf-6.105 {Tcl_UtfNext, read limits} testutfnext { + testutfnext \u8820G 2 } 0 -test utf-6.106 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xE8\xA0\xA0G] 3 +test utf-6.106 {Tcl_UtfNext, read limits} testutfnext { + testutfnext \u8820G 3 } 3 test utf-6.107 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xE8\xA0\xA0\xA0] 1 + testutfnext \u8820[testbytestring \xA0] 1 } 0 test utf-6.108 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xE8\xA0\xA0\xA0] 2 + testutfnext \u8820[testbytestring \xA0] 2 } 0 test utf-6.109 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xE8\xA0\xA0\xA0] 3 + testutfnext \u8820[testbytestring \xA0] 3 } 3 test utf-6.110.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2_utf16} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0G] 1 + testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 1 } 1 test utf-6.110.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0G] 1 + testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 1 } 0 test utf-6.111.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2_utf16} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0G] 2 + testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 2 } 1 test utf-6.111.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0G] 2 + testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 2 } 0 test utf-6.112.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2_utf16} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0G] 3 + testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 3 } 1 test utf-6.112.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0G] 3 + testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 3 } 0 test utf-6.113.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2_utf16} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0G] 4 + testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 4 } 1 test utf-6.113.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0G] 4 + testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 4 } 4 test utf-6.114.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2_utf16} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 1 @@ -610,28 +610,28 @@ test utf-6.117.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 4 } 4 test utf-6.118 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xA0G] 0 + testutfnext [testbytestring \xA0]G 0 } 0 test utf-6.119 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { - testutfnext [testbytestring \xA0G] 1 + testutfnext [testbytestring \xA0]G 1 } 1 test utf-6.120 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xA0\xA0] 1 } 1 test utf-6.121 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { - testutfnext [testbytestring \xA0\xA0G] 2 + testutfnext [testbytestring \xA0\xA0]G 2 } 1 test utf-6.122 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xA0\xA0\xA0] 2 } 1 test utf-6.123 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { - testutfnext [testbytestring \xA0\xA0\xA0G] 3 + testutfnext [testbytestring \xA0\xA0\xA0]G 3 } 1 test utf-6.124 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xA0\xA0\xA0\xA0] 3 } 1 test utf-6.125 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { - testutfnext [testbytestring \xA0\xA0\xA0\xA0G] 4 + testutfnext [testbytestring \xA0\xA0\xA0\xA0]G 4 } 1 test utf-6.126 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xA0\xA0\xA0\xA0\xA0] 4 @@ -877,7 +877,7 @@ test utf-7.31 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} { test utf-7.32 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} { testutfprev A[testbytestring \xF0\x80\x80\x80] 2 } 1 -test utf-7.33 {Tcl_UtfPrev -- overlong sequence} {testutfprev} { +test utf-7.33 {Tcl_UtfPrev -- overlong sequence} testutfprev { testutfprev A\x00 } 1 test utf-7.34 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} { @@ -913,16 +913,16 @@ test utf-7.41.0 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring test utf-7.41.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xF0\x90\x80\x80] 3 } 1 -test utf-7.42 {Tcl_UtfPrev -- overlong sequence} testutfprev { +test utf-7.42 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} { testutfprev A[testbytestring \xF0\x90\x80\x80] 2 } 1 -test utf-7.43 {Tcl_UtfPrev -- no lead byte at start} testutfprev { +test utf-7.43 {Tcl_UtfPrev -- no lead byte at start} {testutfprev testbytestring} { testutfprev [testbytestring \xA0] } 0 -test utf-7.44 {Tcl_UtfPrev -- no lead byte at start} testutfprev { +test utf-7.44 {Tcl_UtfPrev -- no lead byte at start} {testutfprev testbytestring} { testutfprev [testbytestring \xA0\xA0] } 1 -test utf-7.45 {Tcl_UtfPrev -- no lead byte at start} testutfprev { +test utf-7.45 {Tcl_UtfPrev -- no lead byte at start} {testutfprev testbytestring} { testutfprev [testbytestring \xA0\xA0\xA0] } 2 test utf-7.46.0 {Tcl_UtfPrev -- no lead byte at start} {testutfprev testbytestring ucs2_utf16} { @@ -1479,7 +1479,7 @@ UniCharCaseCmpTest > \U10000 \uFFFF {Uesc ucs4} test utf-26.1 {Tcl_UniCharDString} -setup { testobj freeallvars -} -constraints {teststringobj} -cleanup { +} -constraints {teststringobj testbytestring} -cleanup { testobj freeallvars } -body { teststringobj set 1 foo -- cgit v0.12 From 80317c0d6d466a184a6f8c711981d601541deb89 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 8 May 2020 13:47:57 +0000 Subject: More test-case cleanup. Enhance "testutfnext", so it can detect whether bytes after the string-end are read. The command will return -1 in that case. No need for additional arguments any more. --- generic/tclTest.c | 8 +-- tests/utf.test | 192 +++++++++++++++++++++++++++++------------------------- 2 files changed, 109 insertions(+), 91 deletions(-) diff --git a/generic/tclTest.c b/generic/tclTest.c index ae2d7bb..6923cd6 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -7156,12 +7156,12 @@ TestUtfNextCmd( if (numBytes > (int)sizeof(buffer) - 3) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "\"testutfnext\" can only handle %d bytes", - sizeof(buffer) - 3)); + (int)sizeof(buffer) - 4)); return TCL_ERROR; } memcpy(buffer + 1, bytes, numBytes); - buffer[0] = buffer[numBytes + 1] = buffer[numBytes + 2] = '\x00'; + buffer[0] = buffer[numBytes + 1] = buffer[numBytes + 2] = buffer[numBytes + 3] = '\xA0'; if (!Tcl_UtfCharComplete(buffer + 1, offset)) { /* Cannot scan a complete sequence from the data */ @@ -7184,8 +7184,8 @@ TestUtfNextCmd( /* Run Tcl_UtfNext with many more possible bytes at src[end], all should give the same result */ result = TclUtfNext(buffer + 1); if (first != result) { - Tcl_AppendResult(interp, "Tcl_UtfNext is not supposed to read src[end]", NULL); - return TCL_ERROR; + first = buffer; + break; } } diff --git a/tests/utf.test b/tests/utf.test index b45ce8c..2c16c85 100644 --- a/tests/utf.test +++ b/tests/utf.test @@ -186,15 +186,15 @@ test utf-5.2 {Tcl_UtfFindLast} {testfindlast testbytestring} { testfindlast [testbytestring abcbc] 98 } bc -test utf-6.1 {Tcl_UtfNext} {testutfnext testbytestring} { +test utf-6.1 {Tcl_UtfNext} testutfnext { # This takes the pointer one past the terminating NUL. # This is really an invalid call. testutfnext {} -} 1 -test utf-6.2 {Tcl_UtfNext} {testutfnext testbytestring} { +} -1 +test utf-6.2 {Tcl_UtfNext} testutfnext { testutfnext A } 1 -test utf-6.3 {Tcl_UtfNext} {testutfnext testbytestring} { +test utf-6.3 {Tcl_UtfNext} testutfnext { testutfnext AA } 1 test utf-6.4 {Tcl_UtfNext} {testutfnext testbytestring} { @@ -212,7 +212,13 @@ test utf-6.7 {Tcl_UtfNext} {testutfnext testbytestring} { test utf-6.8 {Tcl_UtfNext} {testutfnext testbytestring} { testutfnext A[testbytestring \xF8] } 1 -test utf-6.9 {Tcl_UtfNext} {testutfnext testbytestring} { +test utf-6.9.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} { + testutfnext [testbytestring \xA0] +} 1 +test utf-6.9.1 {Tcl_UtfNext} {testutfnext testbytestring utf16} { + testutfnext [testbytestring \xA0] +} -1 +test utf-6.9.2 {Tcl_UtfNext} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xA0] } 1 test utf-6.10 {Tcl_UtfNext} {testutfnext testbytestring} { @@ -256,7 +262,7 @@ test utf-6.22 {Tcl_UtfNext} {testutfnext testbytestring} { } 1 test utf-6.23 {Tcl_UtfNext} {testutfnext testbytestring} { testutfnext [testbytestring \xE8] -} 1 +} -1 test utf-6.24 {Tcl_UtfNext} {testutfnext testbytestring} { testutfnext [testbytestring \xE8]G } 1 @@ -275,15 +281,27 @@ test utf-6.28 {Tcl_UtfNext} {testutfnext testbytestring} { test utf-6.29 {Tcl_UtfNext} {testutfnext testbytestring} { testutfnext [testbytestring \xE8\xF8] } 1 -test utf-6.30 {Tcl_UtfNext} {testutfnext testbytestring} { +test utf-6.30.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF2] } 1 +test utf-6.30.1 {Tcl_UtfNext} {testutfnext testbytestring utf16} { + testutfnext [testbytestring \xF2] +} 1 +test utf-6.30.2 {Tcl_UtfNext} {testutfnext testbytestring ucs4} { + testutfnext [testbytestring \xF2] +} -1 test utf-6.31 {Tcl_UtfNext} {testutfnext testbytestring} { testutfnext [testbytestring \xF2]G } 1 -test utf-6.32 {Tcl_UtfNext} {testutfnext testbytestring} { +test utf-6.32.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} { + testutfnext [testbytestring \xF2\xA0] +} 1 +test utf-6.32.1 {Tcl_UtfNext} {testutfnext testbytestring utf16} { testutfnext [testbytestring \xF2\xA0] } 1 +test utf-6.32.2 {Tcl_UtfNext} {testutfnext testbytestring ucs4} { + testutfnext [testbytestring \xF2\xA0] +} -1 test utf-6.33 {Tcl_UtfNext} {testutfnext testbytestring} { testutfnext [testbytestring \xF2\xD0] } 1 @@ -395,7 +413,7 @@ test utf-6.68 {Tcl_UtfNext} {testutfnext testbytestring} { test utf-6.69.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF2\xA0\xA0\xA0] } 1 -test utf-6.69.1 {Tcl_UtfNext} {testutfnext testbytestring fullutf} { +test utf-6.69.1 {Tcl_UtfNext} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF2\xA0\xA0\xA0] } 4 test utf-6.70 {Tcl_UtfNext} {testutfnext testbytestring} { @@ -413,40 +431,40 @@ test utf-6.73 {Tcl_UtfNext} {testutfnext testbytestring} { test utf-6.74.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF2\xA0\xA0\xA0]G } 1 -test utf-6.74.1 {Tcl_UtfNext} {testutfnext testbytestring fullutf} { +test utf-6.74.1 {Tcl_UtfNext} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF2\xA0\xA0\xA0]G } 4 test utf-6.75.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] } 1 -test utf-6.75.1 {Tcl_UtfNext} {testutfnext testbytestring fullutf} { +test utf-6.75.1 {Tcl_UtfNext} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] } 4 test utf-6.76.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xD0] } 1 -test utf-6.76.1 {Tcl_UtfNext} {testutfnext testbytestring fullutf} { +test utf-6.76.1 {Tcl_UtfNext} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xD0] } 4 test utf-6.77.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xE8] } 1 -test utf-6.77.1 {Tcl_UtfNext} {testutfnext testbytestring fullutf} { +test utf-6.77.1 {Tcl_UtfNext} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xE8] } 4 test utf-6.78.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xF2] } 1 -test utf-6.78.1 {Tcl_UtfNext} {testutfnext testbytestring fullutf} { +test utf-6.78.1 {Tcl_UtfNext} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xF2] } 4 test utf-6.79.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF2\xA0\xA0\xA0G\xF8] } 1 -test utf-6.79.1 {Tcl_UtfNext} {testutfnext testbytestring fullutf} { +test utf-6.79.1 {Tcl_UtfNext} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF2\xA0\xA0\xA0G\xF8] } 4 -test utf-6.80 {Tcl_UtfNext - overlong sequences} {testutfnext} { +test utf-6.80 {Tcl_UtfNext - overlong sequences} testutfnext { testutfnext \x00 } 2 test utf-6.81 {Tcl_UtfNext - overlong sequences} {testutfnext testbytestring} { @@ -470,25 +488,25 @@ test utf-6.86 {Tcl_UtfNext - overlong sequences} {testutfnext testbytestring} { test utf-6.87.0 {Tcl_UtfNext - overlong sequences} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF0\x90\x80\x80] } 1 -test utf-6.87.1 {Tcl_UtfNext - overlong sequences} {testutfnext testbytestring fullutf} { +test utf-6.87.1 {Tcl_UtfNext - overlong sequences} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF0\x90\x80\x80] } 4 test utf-6.88 {Tcl_UtfNext, pointing to 2th byte of 3-byte valid sequence} {testutfnext testbytestring} { - testutfnext [testbytestring \xA0\xA0] + testutfnext [testbytestring \xA0\xA0\x00] } 1 test utf-6.89 {Tcl_UtfNext, pointing to 2th byte of 3-byte invalid sequence} {testutfnext testbytestring} { - testutfnext [testbytestring \x80\x80] + testutfnext [testbytestring \x80\x80\x00] } 1 -test utf-6.90.0 {Tcl_UtfNext, validity check [493dccc2de]} {testutfnext ucs2} { +test utf-6.90.0 {Tcl_UtfNext, validity check [493dccc2de]} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF4\x8F\xBF\xBF] } 1 -test utf-6.90.1 {Tcl_UtfNext, validity check [493dccc2de]} {testutfnext fullutf} { +test utf-6.90.1 {Tcl_UtfNext, validity check [493dccc2de]} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF4\x8F\xBF\xBF] } 4 test utf-6.91.0 {Tcl_UtfNext, validity check [493dccc2de]} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF4\x90\x80\x80] } 1 -test utf-6.91.1 {Tcl_UtfNext, validity check [493dccc2de]} {testutfnext testbytestring fullutf} { +test utf-6.91.1 {Tcl_UtfNext, validity check [493dccc2de]} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF4\x90\x80\x80] } 1 test utf-6.92.0 {Tcl_UtfNext, pointing to 2th byte of 4-byte valid sequence} {testutfnext testbytestring ucs2} { @@ -515,23 +533,23 @@ test utf-6.94 {Tcl_UtfNext, pointing to 2th byte of 5-byte invalid sequence} {te test utf-6.95 {Tcl_UtfNext, pointing to 2th byte of 5-byte invalid sequence} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \x80\x80\x80\x80] } 1 -test utf-6.96 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring G] 0 +test utf-6.96 {Tcl_UtfNext, read limits} testutfnext { + testutfnext G 0 } 0 test utf-6.97 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { testutfnext [testbytestring \xA0] 0 } 0 -test utf-6.98 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext A[testbytestring G] 1 +test utf-6.98 {Tcl_UtfNext, read limits} testutfnext { + testutfnext AG 1 } 1 test utf-6.99 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { testutfnext A[testbytestring \xA0] 1 } 1 test utf-6.100 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xD0\xA0G] 1 + testutfnext [testbytestring \xD0\xA0]G 1 } 0 test utf-6.101 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xD0\xA0G] 2 + testutfnext [testbytestring \xD0\xA0]G 2 } 2 test utf-6.102 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { testutfnext [testbytestring \xD0\xA0\xA0] 1 @@ -539,95 +557,95 @@ test utf-6.102 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { test utf-6.103 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { testutfnext [testbytestring \xD0\xA0\xA0] 2 } 2 -test utf-6.104 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xE8\xA0\xA0G] 1 +test utf-6.104 {Tcl_UtfNext, read limits} testutfnext { + testutfnext \u8820G 1 } 0 -test utf-6.105 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xE8\xA0\xA0G] 2 +test utf-6.105 {Tcl_UtfNext, read limits} testutfnext { + testutfnext \u8820G 2 } 0 -test utf-6.106 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xE8\xA0\xA0G] 3 +test utf-6.106 {Tcl_UtfNext, read limits} testutfnext { + testutfnext \u8820G 3 } 3 test utf-6.107 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xE8\xA0\xA0\xA0] 1 + testutfnext \u8820[testbytestring \xA0] 1 } 0 test utf-6.108 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xE8\xA0\xA0\xA0] 2 + testutfnext \u8820[testbytestring \xA0] 2 } 0 test utf-6.109 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xE8\xA0\xA0\xA0] 3 + testutfnext \u8820[testbytestring \xA0] 3 } 3 test utf-6.110.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0G] 1 + testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 1 } 1 -test utf-6.110.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0G] 1 +test utf-6.110.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { + testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 1 } 0 test utf-6.111.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0G] 2 + testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 2 } 1 -test utf-6.111.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0G] 2 +test utf-6.111.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { + testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 2 } 0 test utf-6.112.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0G] 3 + testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 3 } 1 -test utf-6.112.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0G] 3 +test utf-6.112.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { + testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 3 } 0 test utf-6.113.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0G] 4 + testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 4 } 1 -test utf-6.113.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} { - testutfnext [testbytestring \xF2\xA0\xA0\xA0G] 4 +test utf-6.113.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { + testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 4 } 4 test utf-6.114.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 1 } 1 -test utf-6.114.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} { +test utf-6.114.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 1 } 0 test utf-6.115.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 2 } 1 -test utf-6.115.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} { +test utf-6.115.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 2 } 0 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 fullutf} { +test utf-6.116.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 3 } 0 test utf-6.117.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 4 } 1 -test utf-6.117.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} { +test utf-6.117.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 4 } 4 test utf-6.118 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { - testutfnext [testbytestring \xA0G] 0 + testutfnext [testbytestring \xA0]G 0 } 0 test utf-6.119 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { - testutfnext [testbytestring \xA0G] 1 + testutfnext [testbytestring \xA0]G 1 } 1 test utf-6.120 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xA0\xA0] 1 } 1 test utf-6.121 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { - testutfnext [testbytestring \xA0\xA0G] 2 + testutfnext [testbytestring \xA0\xA0]G 2 } 1 test utf-6.122 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xA0\xA0\xA0] 2 } 1 test utf-6.123 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { - testutfnext [testbytestring \xA0\xA0\xA0G] 3 + testutfnext [testbytestring \xA0\xA0\xA0]G 3 } 1 test utf-6.124 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xA0\xA0\xA0\xA0] 3 } 1 test utf-6.125 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { - testutfnext [testbytestring \xA0\xA0\xA0\xA0G] 4 + testutfnext [testbytestring \xA0\xA0\xA0\xA0]G 4 } 1 test utf-6.126 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xA0\xA0\xA0\xA0\xA0] 4 @@ -699,19 +717,19 @@ test utf-7.9.2 {Tcl_UtfPrev} {testutfprev testbytestring} { test utf-7.10.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF2\xA0] } 2 -test utf-7.10.1 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { +test utf-7.10.1 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xF2\xA0] } 1 test utf-7.10.2 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF2\xA0\xA0\xA0] 3 } 2 -test utf-7.10.3 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { +test utf-7.10.3 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xF2\xA0\xA0\xA0] 3 } 1 test utf-7.10.4 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF2\xA0\xF8\xA0] 3 } 2 -test utf-7.10.5 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { +test utf-7.10.5 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xF2\xA0\xF8\xA0] 3 } 1 test utf-7.11 {Tcl_UtfPrev} {testutfprev testbytestring} { @@ -756,19 +774,19 @@ test utf-7.14.2 {Tcl_UtfPrev} {testutfprev testbytestring} { test utf-7.15.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF2\xA0\xA0] } 3 -test utf-7.15.1 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { +test utf-7.15.1 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xF2\xA0\xA0] } 1 test utf-7.15.1.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF2\xA0\xA0\xA0] 4 } 3 -test utf-7.15.1.1 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { +test utf-7.15.1.1 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xF2\xA0\xA0\xA0] 4 } 1 test utf-7.15.2.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF2\xA0\xA0\xF8] 4 } 3 -test utf-7.15.2.1 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { +test utf-7.15.2.1 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xF2\xA0\xA0\xF8] 4 } 1 test utf-7.16 {Tcl_UtfPrev} testutfprev { @@ -792,49 +810,49 @@ test utf-7.17.2 {Tcl_UtfPrev} {testutfprev testbytestring} { test utf-7.18.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xA0\xA0\xA0] } 3 -test utf-7.18.1 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { +test utf-7.18.1 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xA0\xA0\xA0] } 3 test utf-7.18.2 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xA0\xA0\xA0\xA0] 4 } 3 -test utf-7.18.3 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { +test utf-7.18.3 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xA0\xA0\xA0\xA0] 4 } 3 test utf-7.18.4 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xA0\xA0\xA0\xF8] 4 } 3 -test utf-7.18.5 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { +test utf-7.18.5 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xA0\xA0\xA0\xF8] 4 } 3 test utf-7.19.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF8\xA0\xA0\xA0] } 4 -test utf-7.19.1 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { +test utf-7.19.1 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xF8\xA0\xA0\xA0] } 4 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} { +test utf-7.20.1 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xF2\xA0\xA0\xA0] } 1 test utf-7.21.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A\u8820[testbytestring \xA0] } 4 -test utf-7.21.1 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { +test utf-7.21.1 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { testutfprev A\u8820[testbytestring \xA0] } 4 test utf-7.22.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xD0\xA0\xA0\xA0] } 4 -test utf-7.22.1 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { +test utf-7.22.1 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xD0\xA0\xA0\xA0] } 4 test utf-7.23.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xA0\xA0\xA0\xA0] } 4 -test utf-7.23.1 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { +test utf-7.23.1 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xA0\xA0\xA0\xA0] } 4 test utf-7.24 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} { @@ -861,7 +879,7 @@ test utf-7.28.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} test utf-7.29.0 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF0\x80\x80\x80] } 4 -test utf-7.29.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring fullutf} { +test utf-7.29.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xF0\x80\x80\x80] } 4 test utf-7.30 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} { @@ -873,7 +891,7 @@ test utf-7.31 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} { test utf-7.32 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} { testutfprev A[testbytestring \xF0\x80\x80\x80] 2 } 1 -test utf-7.33 {Tcl_UtfPrev -- overlong sequence} {testutfprev} { +test utf-7.33 {Tcl_UtfPrev -- overlong sequence} testutfprev { testutfprev A\x00 } 1 test utf-7.34 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} { @@ -894,43 +912,43 @@ test utf-7.38 {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} { +test utf-7.39.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs4} { 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 -test utf-7.40.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring fullutf} { +test utf-7.40.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xF0\x90\x80\x80] 4 } 1 test utf-7.41.0 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF0\x90\x80\x80] 3 } 2 -test utf-7.41.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring fullutf} { +test utf-7.41.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xF0\x90\x80\x80] 3 } 1 -test utf-7.42 {Tcl_UtfPrev -- overlong sequence} testutfprev { +test utf-7.42 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} { testutfprev A[testbytestring \xF0\x90\x80\x80] 2 } 1 -test utf-7.43 {Tcl_UtfPrev -- no lead byte at start} testutfprev { +test utf-7.43 {Tcl_UtfPrev -- no lead byte at start} {testutfprev testbytestring} { testutfprev [testbytestring \xA0] } 0 -test utf-7.44 {Tcl_UtfPrev -- no lead byte at start} testutfprev { +test utf-7.44 {Tcl_UtfPrev -- no lead byte at start} {testutfprev testbytestring} { testutfprev [testbytestring \xA0\xA0] } 1 -test utf-7.45 {Tcl_UtfPrev -- no lead byte at start} testutfprev { +test utf-7.45 {Tcl_UtfPrev -- no lead byte at start} {testutfprev testbytestring} { testutfprev [testbytestring \xA0\xA0\xA0] } 2 test utf-7.46.0 {Tcl_UtfPrev -- no lead byte at start} {testutfprev testbytestring ucs2} { testutfprev [testbytestring \xA0\xA0\xA0\xA0] } 3 -test utf-7.46.1 {Tcl_UtfPrev -- no lead byte at start} {testutfprev testbytestring fullutf} { +test utf-7.46.1 {Tcl_UtfPrev -- no lead byte at start} {testutfprev testbytestring ucs4} { testutfprev [testbytestring \xA0\xA0\xA0\xA0] } 3 test utf-7.47 {Tcl_UtfPrev, pointing to 3th byte of 3-byte valid sequence} {testutfprev testbytestring} { testutfprev [testbytestring \xE8\xA0] } 0 -test utf-7.47.1 {Tcl_UtfPrev, pointing to 3th byte of 3-byte valid sequence} {testutfprev testbytestring} { +test utf-7.47.1 {Tcl_UtfPrev, pointing to 3th byte of 3-byte valid sequence} testutfprev { testutfprev \u8820 2 } 0 test utf-7.47.2 {Tcl_UtfPrev, pointing to 3th byte of 3-byte invalid sequence} {testutfprev testbytestring} { @@ -939,19 +957,19 @@ test utf-7.47.2 {Tcl_UtfPrev, pointing to 3th byte of 3-byte invalid sequence} { 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 fullutf} { +test utf-7.48.1 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs4} { 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.3 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring fullutf} { +test utf-7.48.3 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xF4\x8F\xBF\xBF] 4 } 1 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.5 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring fullutf} { +test utf-7.48.5 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xF4\x8F\xBF\xBF] 3 } 1 test utf-7.48.6 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring} { @@ -960,7 +978,7 @@ test utf-7.48.6 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbyte test utf-7.49.0 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF4\x90\x80\x80] } 4 -test utf-7.49.1 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring fullutf} { +test utf-7.49.1 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xF4\x90\x80\x80] } 4 test utf-7.49.2 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring} { -- cgit v0.12 From 0733f232745ac3cc9a3bd4913bd5ffb8b58378a5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 10 May 2020 19:28:08 +0000 Subject: Tweak Invalid() function: No need for "return 0" twice in the function. For start bytes F0-F4, case TCL_UTF_MAX=4, Tcl_UtfToUniChar() reads 3 bytes but only advances 1 byte. So Tcl_UtfCharComplete() must make sure 3 bytes are available, not 1. Adapt Tcl_UtfCharComplete() accordingly. No change for TCL_UTF_MAX=[3|6] --- generic/tclUtf.c | 39 +++++++++++++++++++++++++++++++-------- tests/utf.test | 14 +++++++------- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/generic/tclUtf.c b/generic/tclUtf.c index c0de80a..5e0b2e0 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -81,6 +81,30 @@ static const unsigned char totalBytes[256] = { 1,1,1,1,1,1,1,1,1,1,1 }; +static const unsigned char complete[256] = { + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, +#if TCL_UTF_MAX < 4 + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, +#else /* Tcl_UtfCharComplete() might point to 2nd byte of valid 4-byte sequence */ + 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, + 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, +#endif + 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 + 4,4,4,4,4, +#elif TCL_UTF_MAX < 4 + 1,1,1,1,1, +#else + 3,3,3,3,3, +#endif + 1,1,1,1,1,1,1,1,1,1,1 +}; + /* * Functions used only in this module. */ @@ -174,14 +198,13 @@ Invalid( unsigned char byte = UCHAR(*src); int index; - if ((byte & 0xC3) != 0xC0) { + if ((byte & 0xC3) == 0xC0) { /* Only lead bytes 0xC0, 0xE0, 0xF0, 0xF4 need examination */ - return 0; - } - index = (byte - 0xC0) >> 1; - if (UCHAR(src[1]) < bounds[index] || UCHAR(src[1]) > bounds[index+1]) { - /* Out of bounds - report invalid. */ - return 1; + index = (byte - 0xC0) >> 1; + if (UCHAR(src[1]) < bounds[index] || UCHAR(src[1]) > bounds[index+1]) { + /* Out of bounds - report invalid. */ + return 1; + } } return 0; } @@ -568,7 +591,7 @@ Tcl_UtfCharComplete( * a complete UTF-8 character. */ int length) /* Length of above string in bytes. */ { - return length >= totalBytes[UCHAR(*src)]; + return length >= complete[UCHAR(*src)]; } /* diff --git a/tests/utf.test b/tests/utf.test index 1a4b157..8745385 100644 --- a/tests/utf.test +++ b/tests/utf.test @@ -570,13 +570,13 @@ test utf-6.108 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { test utf-6.109 {Tcl_UtfNext, read limits} {testutfnext testbytestring} { testutfnext \u8820[testbytestring \xA0] 3 } 3 -test utf-6.110.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2_utf16} { +test utf-6.110.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 1 } 1 -test utf-6.110.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { +test utf-6.110.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} { testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 1 } 0 -test utf-6.111.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2_utf16} { +test utf-6.111.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 2 } 1 test utf-6.111.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { @@ -594,16 +594,16 @@ test utf-6.113.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2_utf test utf-6.113.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF2\xA0\xA0\xA0]G 4 } 4 -test utf-6.114.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2_utf16} { +test utf-6.114.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 1 } 1 -test utf-6.114.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { +test utf-6.114.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 1 } 0 -test utf-6.115.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2_utf16} { +test utf-6.115.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 2 } 1 -test utf-6.115.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs4} { +test utf-6.115.1 {Tcl_UtfNext, read limits} {testutfnext testbytestring fullutf} { testutfnext [testbytestring \xF2\xA0\xA0\xA0\xA0] 2 } 0 test utf-6.116.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2_utf16} { -- cgit v0.12 From 429a4171cb6436a84c7923dcac6ef6fe3460ce20 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 11 May 2020 07:39:02 +0000 Subject: occurance -> occurrence. --- ChangeLog.2000 | 2 +- generic/tclCmdIL.c | 4 ++-- generic/tclFileName.c | 2 +- generic/tclUtf.c | 6 +++--- tests/README | 6 +++--- tests/encoding.test | 2 +- tests/lsearch.test | 18 +++++++++--------- tests/utf.test | 2 +- tools/mkdepend.tcl | 2 +- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ChangeLog.2000 b/ChangeLog.2000 index 5b62351..7e78c19 100644 --- a/ChangeLog.2000 +++ b/ChangeLog.2000 @@ -1779,7 +1779,7 @@ * generic/tclCmdMZ.c: Fixed infinite loop bug with [regexp -all] [Bug: 4981]. - * tests/*.test: Changed all occurances of "namespace import + * tests/*.test: Changed all occurrences of "namespace import ::tcltest" to "namespace import -force ::tcltest" [Bug: 3948]. 2000-04-09 Brent Welch diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 3ec1c09..e97d495 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -3328,11 +3328,11 @@ Tcl_LsearchObjCmd( /* * Normally, binary search is written to stop when it finds a * match. If there are duplicates of an element in the list, - * our first match might not be the first occurance. + * our first match might not be the first occurrence. * Consider: 0 0 0 1 1 1 2 2 2 * * To maintain consistancy with standard lsearch semantics, we - * must find the leftmost occurance of the pattern in the + * must find the leftmost occurrence of the pattern in the * list. Thus we don't just stop searching here. This * variation means that a search always makes log n * comparisons (normal binary search might "get lucky" with an diff --git a/generic/tclFileName.c b/generic/tclFileName.c index 7afcdaf..8fb9f4d 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -2058,7 +2058,7 @@ TclGlob( * SkipToChar -- * * This function traverses a glob pattern looking for the next unquoted - * occurance of the specified character at the same braces nesting level. + * occurrence of the specified character at the same braces nesting level. * * Results: * Updates stringPtr to point to the matching character, or to the end of diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 5e0b2e0..a6dfb8a 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -653,7 +653,7 @@ Tcl_NumUtfChars( src += TclUtfToUniChar(src, &ch); } else { /* - * src points to incomplete UTF-8 sequence + * src points to incomplete UTF-8 sequence * Treat first byte as character and count it */ src++; @@ -669,7 +669,7 @@ Tcl_NumUtfChars( * * Tcl_UtfFindFirst -- * - * Returns a pointer to the first occurance of the given Unicode character + * Returns a pointer to the first occurrence of the given Unicode character * in the NULL-terminated UTF-8 string. The NULL terminator is considered * part of the UTF-8 string. Equivalent to Plan 9 utfrune(). * @@ -706,7 +706,7 @@ Tcl_UtfFindFirst( * * Tcl_UtfFindLast -- * - * Returns a pointer to the last occurance of the given Unicode character + * Returns a pointer to the last occurrence of the given Unicode character * in the NULL-terminated UTF-8 string. The NULL terminator is considered * part of the UTF-8 string. Equivalent to Plan 9 utfrrune(). * diff --git a/tests/README b/tests/README index ce2382e..e86100f 100644 --- a/tests/README +++ b/tests/README @@ -59,7 +59,7 @@ should correspond to the Tcl or C code file that they are testing. For example, the test file for the C file "tclCmdAH.c" is "cmdAH.test". Test files that contain black-box tests may not correspond to any Tcl or C code file so they should match the pattern -"*_bb.test". +"*_bb.test". Be sure your new test file can be run from any working directory. @@ -72,12 +72,12 @@ as well as an installation environment. If your test file contains tests that should not be run in one or more of those cases, please use the constraints mechanism to skip those tests. -4. Incompatibilities of package tcltest 2.1 with +4. Incompatibilities of package tcltest 2.1 with testing machinery of very old versions of Tcl: ------------------------------------------------ 1) Global variables such as VERBOSE, TESTS, and testConfig of the - old machinery correspond to the [configure -verbose], + old machinery correspond to the [configure -verbose], [configure -match], and [testConstraint] commands of tcltest 2.1, respectively. diff --git a/tests/encoding.test b/tests/encoding.test index efb1518..a2bfe5d 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -294,7 +294,7 @@ test encoding-12.2 {LoadTableEncoding: single-byte encoding} { append x [encoding convertfrom iso8859-3 ab\xD5g] } "ab\xd5gab\u120g" test encoding-12.3 {LoadTableEncoding: multi-byte encoding} { - set x [encoding convertto shiftjis ab\u4E4Eg] + set x [encoding convertto shiftjis ab\u4E4Eg] append x [encoding convertfrom shiftjis ab\x8c\xc1g] } "ab\x8c\xc1gab\u4e4eg" test encoding-12.4 {LoadTableEncoding: double-byte encoding} { diff --git a/tests/lsearch.test b/tests/lsearch.test index 5e8a1f8..7e6a345 100644 --- a/tests/lsearch.test +++ b/tests/lsearch.test @@ -149,14 +149,14 @@ test lsearch-5.2 {binary search} { } set res } $decreasingIntegers -test lsearch-5.3 {binary search finds leftmost occurances} { +test lsearch-5.3 {binary search finds leftmost occurrences} { set res {} for {set i 0} {$i < 10} {incr i} { lappend res [lsearch -integer -sorted $repeatingIncreasingIntegers $i] } set res } [list 0 5 10 15 20 25 30 35 40 45] -test lsearch-5.4 {binary search -decreasing finds leftmost occurances} { +test lsearch-5.4 {binary search -decreasing finds leftmost occurrences} { set res {} for {set i 9} {$i >= 0} {incr i -1} { lappend res [lsearch -sorted -integer -decreasing \ @@ -404,16 +404,16 @@ test lsearch-17.2 {lsearch -index option, basic functionality} { lsearch -index 1 -exact {{a c} {a b} {a a}} a } 2 test lsearch-17.3 {lsearch -index option, basic functionality} { - lsearch -index 1 -glob {{ab cb} {ab bb} {ab ab}} b* + lsearch -index 1 -glob {{ab cb} {ab bb} {ab ab}} b* } 1 test lsearch-17.4 {lsearch -index option, basic functionality} { lsearch -index 1 -regexp {{ab cb} {ab bb} {ab ab}} {[cb]b} -} 0 +} 0 test lsearch-17.5 {lsearch -index option, basic functionality} { lsearch -all -index 0 -exact {{a c} {a b} {d a}} a } {0 1} test lsearch-17.6 {lsearch -index option, basic functionality} { - lsearch -all -index 1 -glob {{ab cb} {ab bb} {db bx}} b* + lsearch -all -index 1 -glob {{ab cb} {ab bb} {db bx}} b* } {1 2} test lsearch-17.7 {lsearch -index option, basic functionality} { lsearch -all -index 1 -regexp {{ab cb} {ab bb} {ab ab}} {[cb]b} @@ -454,11 +454,11 @@ test lsearch-18.2 {lsearch -index option, list as index basic functionality} { lsearch -index {2 0} -exact {{{x x} {x b} {a d}} {{a c} {a b} {a a}}} a } 0 test lsearch-18.3 {lsearch -index option, list as index basic functionality} { - lsearch -index {1 1} -glob {{{ab cb} {ab bb} {ab ab}} {{ab cb} {ab bb} {ab ab}}} b* + lsearch -index {1 1} -glob {{{ab cb} {ab bb} {ab ab}} {{ab cb} {ab bb} {ab ab}}} b* } 0 test lsearch-18.4 {lsearch -index option, list as index basic functionality} { lsearch -index {0 1} -regexp {{{ab cb} {ab bb} {ab ab}} {{ab cb} {ab bb} {ab ab}}} {[cb]b} -} 0 +} 0 test lsearch-18.5 {lsearch -index option, list as index basic functionality} { lsearch -all -index {0 0} -exact {{{a c} {a b} {d a}} {{a c} {a b} {d a}}} a } {0 1} @@ -470,11 +470,11 @@ test lsearch-19.2 {lsearch -subindices option} { lsearch -subindices -index {2 0} -exact {{{x x} {x b} {a d}} {{a c} {a b} {a a}}} a } {0 2 0} test lsearch-19.3 {lsearch -subindices option} { - lsearch -subindices -index {1 1} -glob {{{ab cb} {ab bb} {ab ab}} {{ab cb} {ab bb} {ab ab}}} b* + lsearch -subindices -index {1 1} -glob {{{ab cb} {ab bb} {ab ab}} {{ab cb} {ab bb} {ab ab}}} b* } {0 1 1} test lsearch-19.4 {lsearch -subindices option} { lsearch -subindices -index {0 1} -regexp {{{ab cb} {ab bb} {ab ab}} {{ab cb} {ab bb} {ab ab}}} {[cb]b} -} {0 0 1} +} {0 0 1} test lsearch-19.5 {lsearch -subindices option} { lsearch -subindices -all -index {0 0} -exact {{{a c} {a b} {d a}} {{a c} {a b} {d a}}} a } {{0 0 0} {1 0 0}} diff --git a/tests/utf.test b/tests/utf.test index 8745385..1b427c9 100644 --- a/tests/utf.test +++ b/tests/utf.test @@ -179,7 +179,7 @@ test utf-4.12.1 {Tcl_NumUtfChars: #4-byte UTF-8 character} {testnumutfchars test test utf-4.12.2 {Tcl_NumUtfChars: #4-byte UTF-8 character} {testnumutfchars testbytestring utf16} { testnumutfchars [testbytestring \xF0\x9F\x92\xA9] end } 2 -test utf-4.13 {Tcl_NumUtfChars: end of string} {testnumutfchars testbytestring} { +test utf-4.13 {Tcl_NumUtfChars: end of string} {testnumutfchars testbytestring} { testnumutfchars foobar[testbytestring \xF2\xC2\xA0] end } 8 diff --git a/tools/mkdepend.tcl b/tools/mkdepend.tcl index ecb2206..3d96a5e 100644 --- a/tools/mkdepend.tcl +++ b/tools/mkdepend.tcl @@ -98,7 +98,7 @@ proc readDepends {chan} { } else { # don't include ourselves as a dependency of ourself. if {![string compare $fname $target]} {continue} - # store in an array so multiple occurances are not counted. + # store in an array so multiple occurrences are not counted. set depends($target|$fname) "" } } -- cgit v0.12 From 783b10ecec013f3f096ca5cc2f56b628db6b2fce Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 11 May 2020 10:03:46 +0000 Subject: Tweak the Tcl_UtfPrev() implementation for TCL_UTF_MAX=4. This fixes 10 testcases in 4 groups (utf-7.10, utf-7.15, utf-7.40 and utf-7.48) , where Tcl_UtfPrev() didn't jump to the beginning of the UTF-8 character, even though there was no limitation which prevented that. So, this is actually a bug-fix for the TIP #389 implementation. --- generic/tclUtf.c | 2 +- tests/utf.test | 62 +++++++++++++++++++++++++------------------------------- 2 files changed, 29 insertions(+), 35 deletions(-) diff --git a/generic/tclUtf.c b/generic/tclUtf.c index a6dfb8a..9596aed 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -857,7 +857,7 @@ Tcl_UtfPrev( * it (the fallback) is correct. */ - || (trailBytesSeen >= totalBytes[byte])) { + || (trailBytesSeen >= complete[byte])) { /* * That is, (1 + trailBytesSeen > needed). * We've examined more bytes than needed to complete diff --git a/tests/utf.test b/tests/utf.test index 1b427c9..309b277 100644 --- a/tests/utf.test +++ b/tests/utf.test @@ -173,12 +173,12 @@ test utf-4.11 {Tcl_NumUtfChars: 3 bytes of 4-byte UTF-8 characater} {testnumutfc test utf-4.12.0 {Tcl_NumUtfChars: #4-byte UTF-8 character} {testnumutfchars testbytestring ucs2} { testnumutfchars [testbytestring \xF0\x9F\x92\xA9] end } 4 -test utf-4.12.1 {Tcl_NumUtfChars: #4-byte UTF-8 character} {testnumutfchars testbytestring ucs4} { - testnumutfchars [testbytestring \xF0\x9F\x92\xA9] end -} 1 -test utf-4.12.2 {Tcl_NumUtfChars: #4-byte UTF-8 character} {testnumutfchars testbytestring utf16} { +test utf-4.12.1 {Tcl_NumUtfChars: #4-byte UTF-8 character} {testnumutfchars testbytestring utf16} { testnumutfchars [testbytestring \xF0\x9F\x92\xA9] end } 2 +test utf-4.12.2 {Tcl_NumUtfChars: #4-byte UTF-8 character} {testnumutfchars testbytestring ucs4} { + testnumutfchars [testbytestring \xF0\x9F\x92\xA9] end +} 1 test utf-4.13 {Tcl_NumUtfChars: end of string} {testnumutfchars testbytestring} { testnumutfchars foobar[testbytestring \xF2\xC2\xA0] end } 8 @@ -282,25 +282,19 @@ test utf-6.28 {Tcl_UtfNext} {testutfnext testbytestring} { test utf-6.29 {Tcl_UtfNext} {testutfnext testbytestring} { testutfnext [testbytestring \xE8\xF8] } 1 -test utf-6.30.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} { +test utf-6.30.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2_utf16} { testutfnext [testbytestring \xF2] } 1 -test utf-6.30.1 {Tcl_UtfNext} {testutfnext testbytestring utf16} { - testutfnext [testbytestring \xF2] -} 1 -test utf-6.30.2 {Tcl_UtfNext} {testutfnext testbytestring ucs4} { +test utf-6.30.1 {Tcl_UtfNext} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF2] } -1 test utf-6.31 {Tcl_UtfNext} {testutfnext testbytestring} { testutfnext [testbytestring \xF2]G } 1 -test utf-6.32.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} { - testutfnext [testbytestring \xF2\xA0] -} 1 -test utf-6.32.1 {Tcl_UtfNext} {testutfnext testbytestring utf16} { +test utf-6.32.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2_utf16} { testutfnext [testbytestring \xF2\xA0] } 1 -test utf-6.32.2 {Tcl_UtfNext} {testutfnext testbytestring ucs4} { +test utf-6.32.1 {Tcl_UtfNext} {testutfnext testbytestring ucs4} { testutfnext [testbytestring \xF2\xA0] } -1 test utf-6.33 {Tcl_UtfNext} {testutfnext testbytestring} { @@ -709,22 +703,22 @@ test utf-7.9.1 {Tcl_UtfPrev} {testutfprev testbytestring} { test utf-7.9.2 {Tcl_UtfPrev} {testutfprev testbytestring} { testutfprev A[testbytestring \xF8\xA0\xF8\xA0] 3 } 2 -test utf-7.10.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2_utf16} { +test utf-7.10.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF2\xA0] } 2 -test utf-7.10.1 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { +test utf-7.10.1 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { testutfprev A[testbytestring \xF2\xA0] } 1 -test utf-7.10.2 {Tcl_UtfPrev} {testutfprev testbytestring ucs2_utf16} { +test utf-7.10.2 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF2\xA0\xA0\xA0] 3 } 2 -test utf-7.10.3 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { +test utf-7.10.3 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { testutfprev A[testbytestring \xF2\xA0\xA0\xA0] 3 } 1 -test utf-7.10.4 {Tcl_UtfPrev} {testutfprev testbytestring ucs2_utf16} { +test utf-7.10.4 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF2\xA0\xF8\xA0] 3 } 2 -test utf-7.10.5 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { +test utf-7.10.5 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { testutfprev A[testbytestring \xF2\xA0\xF8\xA0] 3 } 1 test utf-7.11 {Tcl_UtfPrev} {testutfprev testbytestring} { @@ -766,22 +760,22 @@ test utf-7.14.1 {Tcl_UtfPrev} {testutfprev testbytestring} { test utf-7.14.2 {Tcl_UtfPrev} {testutfprev testbytestring} { testutfprev A[testbytestring \xF8\xA0\xA0\xF8] 4 } 3 -test utf-7.15.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2_utf16} { +test utf-7.15.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF2\xA0\xA0] } 3 -test utf-7.15.1 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { +test utf-7.15.1 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { testutfprev A[testbytestring \xF2\xA0\xA0] } 1 -test utf-7.15.1.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2_utf16} { +test utf-7.15.2 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF2\xA0\xA0\xA0] 4 } 3 -test utf-7.15.1.1 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { +test utf-7.15.3 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { testutfprev A[testbytestring \xF2\xA0\xA0\xA0] 4 } 1 -test utf-7.15.2.0 {Tcl_UtfPrev} {testutfprev testbytestring ucs2_utf16} { +test utf-7.15.4 {Tcl_UtfPrev} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF2\xA0\xA0\xF8] 4 } 3 -test utf-7.15.2.1 {Tcl_UtfPrev} {testutfprev testbytestring ucs4} { +test utf-7.15.5 {Tcl_UtfPrev} {testutfprev testbytestring fullutf} { testutfprev A[testbytestring \xF2\xA0\xA0\xF8] 4 } 1 test utf-7.16 {Tcl_UtfPrev} testutfprev { @@ -910,16 +904,16 @@ test utf-7.39.0 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring test utf-7.39.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xF0\x90\x80\x80] } 1 -test utf-7.40.0 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs2_utf16} { +test utf-7.40.0 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF0\x90\x80\x80] 4 } 3 -test utf-7.40.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs4} { +test utf-7.40.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring fullutf} { testutfprev A[testbytestring \xF0\x90\x80\x80] 4 } 1 -test utf-7.41.0 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs2_utf16} { +test utf-7.41.0 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs2} { testutfprev A[testbytestring \xF0\x90\x80\x80] 3 } 2 -test utf-7.41.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring ucs4} { +test utf-7.41.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring fullutf} { testutfprev A[testbytestring \xF0\x90\x80\x80] 3 } 1 test utf-7.42 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} { @@ -955,16 +949,16 @@ test utf-7.48.0 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbyte test utf-7.48.1 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs4} { testutfprev A[testbytestring \xF4\x8F\xBF\xBF] } 1 -test utf-7.48.2 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs2_utf16} { +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.3 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs4} { +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.4 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs2_utf16} { +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.5 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring ucs4} { +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.6 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring} { -- cgit v0.12 From 22648e5ebc9138abf5aba928db74520ac22f23ab Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 11 May 2020 10:41:30 +0000 Subject: Fix [d402ffe76]: Win32 potential crash when using main(). Thanks to Christian Werner for the Bug report and the Fix. --- generic/tclEnv.c | 11 +++++++++++ win/tclWinInit.c | 31 +++++++++++-------------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/generic/tclEnv.c b/generic/tclEnv.c index 1f61e07..15dd8b5 100644 --- a/generic/tclEnv.c +++ b/generic/tclEnv.c @@ -127,6 +127,17 @@ TclSetupEnv( /*msg*/ 0, /*createPart1*/ 0, /*createPart2*/ 0, &arrayPtr); TclFindArrayPtrElements(varPtr, &namesHash); +#if defined(_WIN32) + if (tenviron == NULL) { + /* + * When we are started from main(), the _wenviron array could + * be NULL and will be initialized by the first _wgetenv() call. + */ + + (void) _wgetenv(L"WINDIR"); + } +#endif + /* * Go through the environment array and transfer its values into Tcl. At * the same time, remove those elements we add/update from the hash table diff --git a/win/tclWinInit.c b/win/tclWinInit.c index 4b3b6d4..b1dd0f3 100644 --- a/win/tclWinInit.c +++ b/win/tclWinInit.c @@ -154,7 +154,7 @@ TclpInitPlatform(void) * invoked. */ - TclWinInit(GetModuleHandle(NULL)); + TclWinInit(GetModuleHandleW(NULL)); #endif /* @@ -260,7 +260,7 @@ AppendEnvironment( { int pathc; WCHAR wBuf[MAX_PATH]; - char buf[MAX_PATH * TCL_UTF_MAX]; + char buf[MAX_PATH * 3]; Tcl_Obj *objPtr; Tcl_DString ds; const char **pathv; @@ -273,7 +273,7 @@ AppendEnvironment( for (shortlib = (char *) &lib[strlen(lib)-1]; shortlib>lib ; shortlib--) { if (*shortlib == '/') { - if ((unsigned)(shortlib - lib) == strlen(lib) - 1) { + if ((size_t)(shortlib - lib) == strlen(lib) - 1) { Tcl_Panic("last character in lib cannot be '/'"); } shortlib++; @@ -353,7 +353,7 @@ InitializeDefaultLibraryDir( { HMODULE hModule = TclWinGetTclInstance(); WCHAR wName[MAX_PATH + LIBRARY_SIZE]; - char name[(MAX_PATH + LIBRARY_SIZE) * TCL_UTF_MAX]; + char name[(MAX_PATH + LIBRARY_SIZE) * 3]; char *end, *p; if (GetModuleFileNameW(hModule, wName, MAX_PATH) == 0) { @@ -426,7 +426,7 @@ InitializeSourceLibraryDir( *lengthPtr = strlen(name); *valuePtr = (char *)ckalloc(*lengthPtr + 1); *encodingPtr = NULL; - memcpy(*valuePtr, name, (size_t) *lengthPtr + 1); + memcpy(*valuePtr, name, *lengthPtr + 1); } /* @@ -674,16 +674,6 @@ TclpSetVariables( *---------------------------------------------------------------------- */ -#if defined(_WIN32) -# define tenviron _wenviron -# define tenviron2utfdstr(tenvstr, len, dstr) \ - Tcl_WinTCharToUtf((TCHAR *)tenvstr, len, dstr) -#else -# define tenviron environ -# define tenviron2utfdstr(tenvstr, len, dstr) \ - Tcl_ExternalToUtfDString(NULL, tenvstr, len, dstr) -#endif - int TclpFindVariable( const char *name, /* Name of desired environment variable @@ -694,7 +684,8 @@ TclpFindVariable( * searches). */ { int i, length, result = -1; - register const char *env, *p1, *p2; + const WCHAR *env; + const char *p1, *p2; char *envUpper, *nameUpper; Tcl_DString envString; @@ -704,20 +695,20 @@ TclpFindVariable( length = strlen(name); nameUpper = (char *)ckalloc(length + 1); - memcpy(nameUpper, name, (size_t) length+1); + memcpy(nameUpper, name, length+1); Tcl_UtfToUpper(nameUpper); Tcl_DStringInit(&envString); - for (i = 0, env = (const char *)tenviron[i]; + for (i = 0, env = _wenviron[i]; env != NULL; - i++, env = (const char *)tenviron[i]) { + i++, env = _wenviron[i]) { /* * Chop the env string off after the equal sign, then Convert the name * to all upper case, so we do not have to convert all the characters * after the equal sign. */ - envUpper = tenviron2utfdstr(env, -1, &envString); + envUpper = Tcl_WinTCharToUtf((TCHAR *)env, -1, &envString); p1 = strchr(envUpper, '='); if (p1 == NULL) { continue; -- cgit v0.12