summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-12 11:08:43 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-12 11:08:43 (GMT)
commit9cc2036c6436600b0dea8f4c153fa7a71fb1feeb (patch)
tree9f70d3bc02f25d998c6f0e525936d4f7b771ca0d
parentc1d202b1121381431982ea7d40375e9ce0651f41 (diff)
parent6256643a39bd87d514f7c7455652ace83dd7f95c (diff)
downloadtcl-9cc2036c6436600b0dea8f4c153fa7a71fb1feeb.zip
tcl-9cc2036c6436600b0dea8f4c153fa7a71fb1feeb.tar.gz
tcl-9cc2036c6436600b0dea8f4c153fa7a71fb1feeb.tar.bz2
Merge testcase cleanup. Make Tcl_UtfPrev() behave the same for any TCL_UTF_MAX value, since we didn't figure out yet how it should behave for TCL_UTF_MAX>3.
-rw-r--r--generic/tclUtf.c8
-rw-r--r--tests/utf.test37
2 files changed, 22 insertions, 23 deletions
diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index f2d2b3b..730a8b7 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -887,12 +887,12 @@ Tcl_UtfPrev(
} while (trailBytesSeen < 3);
/*
- * We've seen 3 (or 4) trail bytes, so we know there will not be a
+ * We've seen 3 trail bytes, so we know there will not be a
* properly formed byte sequence to find, and we can stop looking,
- * accepting the fallback (for TCL_UTF_MAX > 4) or just go back as
- * far as we can.
+ * accepting the fallback.
*/
- return src - 3;
+
+ return fallback;
}
/*
diff --git a/tests/utf.test b/tests/utf.test
index f3815d3..1955766 100644
--- a/tests/utf.test
+++ b/tests/utf.test
@@ -21,7 +21,6 @@ testConstraint fullutf [expr {[format %c 0x010000] ne "\uFFFD"}]
testConstraint utf16 [expr {[string length [format %c 0x10000]] == 2}]
testConstraint ucs4 [expr {[testConstraint fullutf]
&& [string length [format %c 0x10000]] == 1}]
-testConstraint ucs2_utf16 [expr {![testConstraint ucs4]}]
testConstraint Uesc [expr {"\U0041" eq "A"}]
testConstraint pre388 [expr {"\x741" eq "A"}]
@@ -104,13 +103,13 @@ test utf-2.6 {Tcl_UtfToUniChar: lead (3-byte) followed by 1 trail} testbytestrin
test utf-2.7 {Tcl_UtfToUniChar: lead (3-byte) followed by 2 trail} testbytestring {
string length [testbytestring \xE4\xB9\x8E]
} 1
-test utf-2.8.0 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} {testbytestring ucs2_utf16} {
+test utf-2.8.0 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} {testbytestring ucs2} {
string length [testbytestring \xF0\x90\x80\x80]
} 2
test utf-2.8.1 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} {testbytestring ucs4} {
string length [testbytestring \xF0\x90\x80\x80]
} 1
-test utf-2.9.0 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} {testbytestring ucs2_utf16} {
+test utf-2.9.0 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} {testbytestring ucs2} {
string length [testbytestring \xF4\x8F\xBF\xBF]
} 2
test utf-2.9.1 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} {Uesc ucs4} {
@@ -164,7 +163,7 @@ test utf-4.10 {Tcl_NumUtfChars: #x00, calc len, overcomplete} {testnumutfchars t
test utf-4.11 {Tcl_NumUtfChars: 3 bytes of 4-byte UTF-8 characater} {testnumutfchars testbytestring} {
testnumutfchars [testbytestring \xF0\x9F\x92\xA9] end-1
} 3
-test utf-4.12.0 {Tcl_NumUtfChars: #4-byte UTF-8 character} {testnumutfchars testbytestring ucs2_utf16} {
+test utf-4.12.0 {Tcl_NumUtfChars: #4-byte UTF-8 character} {testnumutfchars testbytestring ucs2} {
testnumutfchars [testbytestring \xF0\x9F\x92\xA9] end
} 2
test utf-4.12.1 {Tcl_NumUtfChars: #4-byte UTF-8 character} {testnumutfchars testbytestring ucs4} {
@@ -525,7 +524,7 @@ test utf-6.111.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} {
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_utf16} {
+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 ucs4} {
@@ -546,7 +545,7 @@ test utf-6.115.0 {Tcl_UtfNext, read limits} {testutfnext testbytestring ucs2} {
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} {
+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 ucs4} {
@@ -723,28 +722,28 @@ test utf-7.17.2 {Tcl_UtfPrev} {testutfprev testbytestring} {
} 3
test utf-7.18.0 {Tcl_UtfPrev} {testutfprev testbytestring} {
testutfprev A[testbytestring \xA0\xA0\xA0]
-} 1
+} 3
test utf-7.18.1 {Tcl_UtfPrev} {testutfprev testbytestring} {
testutfprev A[testbytestring \xA0\xA0\xA0\xA0] 4
-} 1
+} 3
test utf-7.18.2 {Tcl_UtfPrev} {testutfprev testbytestring} {
testutfprev A[testbytestring \xA0\xA0\xA0\xF8] 4
-} 1
+} 3
test utf-7.19 {Tcl_UtfPrev} {testutfprev testbytestring} {
testutfprev A[testbytestring \xF8\xA0\xA0\xA0]
-} 2
+} 4
test utf-7.20 {Tcl_UtfPrev} {testutfprev testbytestring} {
testutfprev A[testbytestring \xF2\xA0\xA0\xA0]
-} 2
+} 4
test utf-7.21 {Tcl_UtfPrev} {testutfprev testbytestring} {
testutfprev A\u8820[testbytestring \xA0]
-} 2
+} 4
test utf-7.22 {Tcl_UtfPrev} {testutfprev testbytestring} {
testutfprev A[testbytestring \xD0\xA0\xA0\xA0]
-} 2
+} 4
test utf-7.23 {Tcl_UtfPrev} {testutfprev testbytestring} {
testutfprev A[testbytestring \xA0\xA0\xA0\xA0]
-} 2
+} 4
test utf-7.24 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
testutfprev A[testbytestring \xC0\x81]
} 2
@@ -768,7 +767,7 @@ test utf-7.28.1 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring}
} 1
test utf-7.29 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
testutfprev A[testbytestring \xF0\x80\x80\x80]
-} 2
+} 4
test utf-7.30 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
testutfprev A[testbytestring \xF0\x80\x80\x80] 4
} 3
@@ -798,7 +797,7 @@ test utf-7.38 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
} 1
test utf-7.39 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
testutfprev A[testbytestring \xF0\x90\x80\x80]
-} 2
+} 4
test utf-7.40 {Tcl_UtfPrev -- overlong sequence} {testutfprev testbytestring} {
testutfprev A[testbytestring \xF0\x90\x80\x80] 4
} 3
@@ -819,7 +818,7 @@ test utf-7.45 {Tcl_UtfPrev -- no lead byte at start} {testutfprev testbytestrin
} 2
test utf-7.46 {Tcl_UtfPrev -- no lead byte at start} {testutfprev testbytestring} {
testutfprev [testbytestring \xA0\xA0\xA0\xA0]
-} 1
+} 3
test utf-7.47 {Tcl_UtfPrev, pointing to 3th byte of 3-byte valid sequence} {testutfprev testbytestring} {
testutfprev [testbytestring \xE8\xA0]
} 0
@@ -831,7 +830,7 @@ test utf-7.47.2 {Tcl_UtfPrev, pointing to 3th byte of 3-byte invalid sequence} {
} 0
test utf-7.48.0 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring} {
testutfprev A[testbytestring \xF4\x8F\xBF\xBF]
-} 2
+} 4
test utf-7.48.1 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring} {
testutfprev A[testbytestring \xF4\x8F\xBF\xBF] 4
} 3
@@ -843,7 +842,7 @@ test utf-7.48.3 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbyte
} 1
test utf-7.49.0 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring} {
testutfprev A[testbytestring \xF4\x90\x80\x80]
-} 2
+} 4
test utf-7.49.1 {Tcl_UtfPrev, validity check [493dccc2de]} {testutfprev testbytestring} {
testutfprev A[testbytestring \xF4\x90\x80\x80] 4
} 3