summaryrefslogtreecommitdiffstats
path: root/generic/tclEncoding.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-10-20 20:27:45 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-10-20 20:27:45 (GMT)
commit7f8b256581b9fa5564137271b2f24df3ccd5b9fa (patch)
tree0b8bd61fa018971572e574854124d3c0bde2d23a /generic/tclEncoding.c
parent49260f096b04c4fadf36fe575d1b43a4736e2ef2 (diff)
downloadtcl-7f8b256581b9fa5564137271b2f24df3ccd5b9fa.zip
tcl-7f8b256581b9fa5564137271b2f24df3ccd5b9fa.tar.gz
tcl-7f8b256581b9fa5564137271b2f24df3ccd5b9fa.tar.bz2
Code cleanup (comments, bracing)
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 fad9faa..6fe81e8 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 */
@@ -2253,15 +2253,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.
*/
@@ -2353,7 +2353,7 @@ UtfToUtfProc(
*dstCharsPtr = numChars;
return result;
}
-
+
/*
*-------------------------------------------------------------------------
*
@@ -2449,7 +2449,7 @@ Utf32ToUtfProc(
*dstCharsPtr = numChars;
return result;
}
-
+
/*
*-------------------------------------------------------------------------
*
@@ -2530,13 +2530,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);
}
}
@@ -3048,11 +3048,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