summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2023-03-20 11:31:14 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2023-03-20 11:31:14 (GMT)
commit2475fa8cb8310271c733ae65497746174c93a889 (patch)
treecf743c26fa7e0cdb7e4cd958bd0978f1fdf4222d /generic
parent921b0dfdeab784bd9d8f8071100db8156c48a1ae (diff)
parent5d63902332fb63571e32e9124190aa3f9c98526b (diff)
downloadtcl-2475fa8cb8310271c733ae65497746174c93a889.zip
tcl-2475fa8cb8310271c733ae65497746174c93a889.tar.gz
tcl-2475fa8cb8310271c733ae65497746174c93a889.tar.bz2
Merge 8.7
Diffstat (limited to 'generic')
-rw-r--r--generic/tclEncoding.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index ec9e130..27e7278 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -3444,18 +3444,23 @@ TableToUtfProc(
if (prefixBytes[byte]) {
src++;
if (src >= srcEnd) {
- /*
- * TODO - this is broken. For consistency with other
- * decoders, an error should be raised only if strict.
- * However, doing that check cause a whole bunch of test
- * failures. Need to verify if those tests are in fact
- * correct.
- */
- src--;
- result = TCL_CONVERT_MULTIBYTE;
- break;
+ if (!(flags & TCL_ENCODING_END)) {
+ src--;
+ result = TCL_CONVERT_MULTIBYTE;
+ break;
+ } else if (PROFILE_STRICT(flags)) {
+ src--;
+ result = TCL_CONVERT_SYNTAX;
+ break;
+ } else if (PROFILE_REPLACE(flags)) {
+ ch = UNICODE_REPLACE_CHAR;
+ } else {
+ numChars++; /* Silently consume */
+ break;
+ }
+ } else {
+ ch = toUnicode[byte][*((unsigned char *)src)];
}
- ch = toUnicode[byte][*((unsigned char *)src)];
ch = toUnicode[byte][*((unsigned char *) src)];
} else {
ch = pageZero[byte];
@@ -3479,7 +3484,7 @@ TableToUtfProc(
* Special case for 1-byte utf chars for speed.
*/
- if (ch && ch < 0x80) {
+ if ((unsigned)ch - 1 < 0x7F) {
*dst++ = (char) ch;
} else {
dst += Tcl_UniCharToUtf(ch, dst);
@@ -3680,7 +3685,7 @@ Iso88591ToUtfProc(
* Special case for 1-byte utf chars for speed.
*/
- if (ch && ch < 0x80) {
+ if ((unsigned)ch - 1 < 0x7F) {
*dst++ = (char) ch;
} else {
dst += Tcl_UniCharToUtf(ch, dst);