summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-03-30 10:07:10 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-03-30 10:07:10 (GMT)
commit42b07af6c35e293f6f7ecdf76ca84495f67b87e4 (patch)
tree1d2b1b68ab636526b98238a160828dbacfb7f1d8 /generic
parent9fb8027cf65024e499873614e710122af9044cf0 (diff)
parent1f1f43fcd2bfa68c8bff1a9d6dbb8ecab4be43e7 (diff)
downloadtcl-42b07af6c35e293f6f7ecdf76ca84495f67b87e4.zip
tcl-42b07af6c35e293f6f7ecdf76ca84495f67b87e4.tar.gz
tcl-42b07af6c35e293f6f7ecdf76ca84495f67b87e4.tar.bz2
Merge 8.7
Diffstat (limited to 'generic')
-rw-r--r--generic/tclEncoding.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index fd5c52b..72f7690 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -511,8 +511,8 @@ FillEncodingFileMap(void)
*/
/* Those flags must not conflict with other TCL_ENCODING_* flags in tcl.h */
-#define TCL_ENCODING_LE 0x40 /* Little-endian encoding */
-#define TCL_ENCODING_EXTERNAL 0x80 /* Converting from internal to external variant */
+#define TCL_ENCODING_MODIFIED 0x20 /* Converting NULL bytes to 0xC0 0x80 */
+#define TCL_ENCODING_LE 0x80 /* Little-endian encoding, for ucs-2/utf-16 only */
void
TclInitEncodingSubsystem(void)
@@ -1153,7 +1153,7 @@ Tcl_ExternalToUtfDStringEx(
srcLen = encodingPtr->lengthProc(src);
}
- flags |= TCL_ENCODING_START | TCL_ENCODING_END;
+ flags |= TCL_ENCODING_START | TCL_ENCODING_END | TCL_ENCODING_MODIFIED;
while (1) {
result = encodingPtr->toUtfProc(encodingPtr->clientData, src, srcLen,
@@ -1262,25 +1262,24 @@ Tcl_ExternalToUtf(
if (!noTerminate) {
/*
* If there are any null characters in the middle of the buffer,
- * they will converted to the UTF-8 null character (\xC080). To get
+ * they will converted to the UTF-8 null character (\xC0\x80). To get
* the actual \0 at the end of the destination buffer, we need to
* append it manually. First make room for it...
*/
dstLen--;
}
+ flags |= TCL_ENCODING_MODIFIED;
do {
- int savedFlags = flags;
Tcl_EncodingState savedState = *statePtr;
result = encodingPtr->toUtfProc(encodingPtr->clientData, src, srcLen,
- flags, statePtr, dst, dstLen, srcReadPtr, dstWrotePtr,
+ flags , statePtr, dst, dstLen, srcReadPtr, dstWrotePtr,
dstCharsPtr);
if (*dstCharsPtr <= maxChars) {
break;
}
dstLen = Tcl_UtfAtIndex(dst, maxChars) - dst + (TCL_UTF_MAX - 1);
- flags = savedFlags;
*statePtr = savedState;
} while (1);
if (!noTerminate) {
@@ -1461,7 +1460,7 @@ Tcl_UtfToExternal(
dstLen -= encodingPtr->nullSize;
result = encodingPtr->fromUtfProc(encodingPtr->clientData, src, srcLen,
- flags | TCL_ENCODING_EXTERNAL, statePtr, dst, dstLen, srcReadPtr,
+ flags, statePtr, dst, dstLen, srcReadPtr,
dstWrotePtr, dstCharsPtr);
if (encodingPtr->nullSize == 2) {
dst[*dstWrotePtr + 1] = '\0';
@@ -2256,7 +2255,7 @@ UtfToUtfProc(
result = TCL_CONVERT_NOSPACE;
break;
}
- if (UCHAR(*src) < 0x80 && !(UCHAR(*src) == 0 && !(flags & TCL_ENCODING_EXTERNAL))) {
+ 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.
@@ -2264,7 +2263,7 @@ UtfToUtfProc(
*dst++ = *src++;
} else if (UCHAR(*src) == 0xC0 && (src + 1 < srcEnd)
- && UCHAR(src[1]) == 0x80 && (flags & TCL_ENCODING_EXTERNAL)) {
+ && UCHAR(src[1]) == 0x80 && !(flags & TCL_ENCODING_MODIFIED)) {
/*
* Convert 0xC080 to real nulls when we are in output mode.
*/