summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2023-02-22 20:44:13 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2023-02-22 20:44:13 (GMT)
commit1d76ffb03b359c7f557943523fd9b0c49a312554 (patch)
treec4c056892a69a3a291075a9518f4a78838eb573b /generic
parent8f37d5c24ef176d5df911feafb5f8159098a5cc2 (diff)
downloadtcl-1d76ffb03b359c7f557943523fd9b0c49a312554.zip
tcl-1d76ffb03b359c7f557943523fd9b0c49a312554.tar.gz
tcl-1d76ffb03b359c7f557943523fd9b0c49a312554.tar.bz2
minor bug-fix in utf-16/utf-32: 2 testcases failed in Tcl 9 compatibility mode (-DTCL_NO_DEPRECATED)
Diffstat (limited to 'generic')
-rw-r--r--generic/tclEncoding.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 0490831..8e13b43 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -237,8 +237,13 @@ static Tcl_EncodingConvertProc Iso88591ToUtfProc;
*/
static const Tcl_ObjType encodingType = {
- "encoding", FreeEncodingInternalRep, DupEncodingInternalRep, NULL, NULL
+ "encoding",
+ FreeEncodingInternalRep,
+ DupEncodingInternalRep,
+ NULL,
+ NULL
};
+
#define EncodingSetInternalRep(objPtr, encoding) \
do { \
Tcl_ObjInternalRep ir; \
@@ -461,7 +466,7 @@ FillEncodingFileMap(void)
map = Tcl_NewDictObj();
Tcl_IncrRefCount(map);
- for (i = numDirs-1; i >= 0; i--) {
+ for (i = numDirs-1; i != TCL_INDEX_NONE; i--) {
/*
* Iterate backwards through the search path so as we overwrite
* entries found, we favor files earlier on the search path.
@@ -1182,7 +1187,7 @@ Tcl_ExternalToUtfDString(
* Tcl_ExternalToUtfDStringEx --
*
* Convert a source buffer from the specified encoding into UTF-8.
-* The parameter flags controls the behavior, if any of the bytes in
+ * The parameter flags controls the behavior, if any of the bytes in
* the source buffer are invalid or cannot be represented in utf-8.
* Possible flags values:
* TCL_ENCODING_STOPONERROR: don't replace invalid characters/bytes but
@@ -1458,8 +1463,9 @@ Tcl_UtfToExternalDStringEx(
char *dst;
Tcl_EncodingState state;
const Encoding *encodingPtr;
- int dstLen, result, soFar, srcRead, dstWrote, dstChars;
+ int result, soFar, srcRead, dstWrote, dstChars;
const char *srcStart = src;
+ int dstLen;
Tcl_DStringInit(dstPtr);
dst = Tcl_DStringValue(dstPtr);
@@ -2627,9 +2633,10 @@ Utf32ToUtfProc(
result = TCL_CONVERT_NOSPACE;
} else {
/* destination is not full, so we really are at the end now */
- if (flags & TCL_ENCODING_STOPONERROR) {
+ if ((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT) {
result = TCL_CONVERT_SYNTAX;
} else {
+ result = TCL_OK;
dst += Tcl_UniCharToUtf(0xFFFD, dst);
numChars++;
src += bytesLeft;
@@ -2854,9 +2861,10 @@ Utf16ToUtfProc(
result = TCL_CONVERT_NOSPACE;
} else {
/* destination is not full, so we really are at the end now */
- if (flags & TCL_ENCODING_STOPONERROR) {
+ if (((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT)) {
result = TCL_CONVERT_SYNTAX;
} else {
+ result = TCL_OK;
dst += Tcl_UniCharToUtf(0xFFFD, dst);
numChars++;
src++;