summaryrefslogtreecommitdiffstats
path: root/generic/tclEncoding.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-11-08 23:11:16 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-11-08 23:11:16 (GMT)
commit5ad22cafaf30e790570411e299b644551c4826a5 (patch)
tree2bf6833eff476bdd45350195b780a3ca0d56c4cf /generic/tclEncoding.c
parentf3ce97fe147b1c809f1aba0267c6aa3de12b1597 (diff)
parentfa56430c8b7ebbd159d6e3b45ecfd04f2a193d9b (diff)
downloadtcl-5ad22cafaf30e790570411e299b644551c4826a5.zip
tcl-5ad22cafaf30e790570411e299b644551c4826a5.tar.gz
tcl-5ad22cafaf30e790570411e299b644551c4826a5.tar.bz2
Merge 8.7
Diffstat (limited to 'generic/tclEncoding.c')
-rw-r--r--generic/tclEncoding.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 8d9ae15..57c6148 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -517,7 +517,7 @@ FillEncodingFileMap(void)
/* Those flags must not conflict with other TCL_ENCODING_* flags in tcl.h */
/* Since TCL_ENCODING_MODIFIED is only used for utf-8/cesu-8 and
- * TCL_ENCODING_LE is only used for utf-16/ucs-2. re-use the same value */
+ * TCL_ENCODING_LE is only used for utf-16/utf-32/ucs-2. re-use the same value */
#define TCL_ENCODING_MODIFIED 0x20 /* Converting NULL bytes to 0xC0 0x80 */
#define TCL_ENCODING_LE TCL_ENCODING_MODIFIED /* Little-endian encoding */
#define TCL_ENCODING_UTF 0x200 /* For UTF-8 encoding, allow 4-byte output sequences */
@@ -2254,15 +2254,15 @@ UtfToUtfProc(
result = TCL_CONVERT_NOSPACE;
break;
}
- if (UCHAR(*src) < 0x80 && !(UCHAR(*src) == 0 && (flags & TCL_ENCODING_MODIFIED))) {
+ if (UCHAR(*src) < 0x80 && !((UCHAR(*src) == 0) && (flags & TCL_ENCODING_MODIFIED))) {
/*
* Copy 7bit characters, but skip null-bytes when we are in input
* mode, so that they get converted to 0xC080.
*/
*dst++ = *src++;
- } else if (UCHAR(*src) == 0xC0 && (src + 1 < srcEnd)
- && UCHAR(src[1]) == 0x80 && !(flags & TCL_ENCODING_MODIFIED)) {
+ } else if ((UCHAR(*src) == 0xC0) && (src + 1 < srcEnd)
+ && (UCHAR(src[1]) == 0x80) && !(flags & TCL_ENCODING_MODIFIED)) {
/*
* Convert 0xC080 to real nulls when we are in output mode.
*/
@@ -2354,7 +2354,7 @@ UtfToUtfProc(
*dstCharsPtr = numChars;
return result;
}
-
+
/*
*-------------------------------------------------------------------------
*
@@ -2450,7 +2450,7 @@ Utf32ToUtfProc(
*dstCharsPtr = numChars;
return result;
}
-
+
/*
*-------------------------------------------------------------------------
*
@@ -2531,13 +2531,13 @@ UtfToUtf32Proc(
src += len;
if (flags & TCL_ENCODING_LE) {
*dst++ = (ch & 0xFF);
- *dst++ = ((ch >> 8) & 0xff);
- *dst++ = ((ch >> 16) & 0xff);
- *dst++ = ((ch >> 24) & 0xff);
+ *dst++ = ((ch >> 8) & 0xFF);
+ *dst++ = ((ch >> 16) & 0xFF);
+ *dst++ = ((ch >> 24) & 0xFF);
} else {
- *dst++ = ((ch >> 24) & 0xff);
- *dst++ = ((ch >> 16) & 0xff);
- *dst++ = ((ch >> 8) & 0xff);
+ *dst++ = ((ch >> 24) & 0xFF);
+ *dst++ = ((ch >> 16) & 0xFF);
+ *dst++ = ((ch >> 8) & 0xFF);
*dst++ = (ch & 0xFF);
}
}
@@ -3049,11 +3049,7 @@ TableFromUtfProc(
len = TclUtfToUniChar(src, &ch);
#if TCL_UTF_MAX > 3
- /*
- * This prevents a crash condition. More evaluation is required for
- * full support of int Tcl_UniChar. [Bug 1004065]
- */
-
+ /* Unicode chars > +U0FFFF cannot be represented in any table encoding */
if (ch & 0xFFFF0000) {
word = 0;
} else