diff options
-rw-r--r-- | generic/tclCmdMZ.c | 20 | ||||
-rw-r--r-- | generic/tclEncoding.c | 14 | ||||
-rw-r--r-- | generic/tclExecute.c | 4 | ||||
-rw-r--r-- | generic/tclParse.c | 6 | ||||
-rw-r--r-- | generic/tclScan.c | 2 | ||||
-rw-r--r-- | generic/tclStringObj.c | 8 | ||||
-rw-r--r-- | generic/tclStubInit.c | 4 | ||||
-rw-r--r-- | generic/tclUtf.c | 113 | ||||
-rw-r--r-- | generic/tclZipfs.c | 22 | ||||
-rw-r--r-- | win/tclWin32Dll.c | 8 |
10 files changed, 95 insertions, 106 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index c17c4f1..a289a5c 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -1221,7 +1221,7 @@ Tcl_SplitObjCmd( fullchar = ch; #if TCL_UTF_MAX <= 4 - if ((len == 1) && ((ch & 0xFC00) == 0xD800)) { + if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(stringPtr + len, &ch); fullchar = (((fullchar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000; } @@ -1447,8 +1447,8 @@ StringIndexCmd( char buf[4]; length = Tcl_UniCharToUtf(ch, buf); - if (!length) { - length = Tcl_UniCharToUtf(-1, buf); + if ((ch >= 0xD800) && (length < 3)) { + length = Tcl_UniCharToUtf(-1, buf + length); } Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, length)); } @@ -1854,7 +1854,7 @@ StringIsCmd( length2 = TclUtfToUniChar(string1, &ch); fullchar = ch; #if TCL_UTF_MAX <= 4 - if ((length2 == 1) && ((ch & 0xFC00) == 0xD800)) { + if ((ch >= 0xD800) && (length2 < 3)) { length2 += TclUtfToUniChar(string1 + length2, &ch); fullchar = (((fullchar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000; } @@ -1935,7 +1935,7 @@ StringMapCmd( const char *string = TclGetStringFromObj(objv[1], &length2); if ((length2 > 1) && - strncmp(string, "-nocase", (size_t) length2) == 0) { + strncmp(string, "-nocase", length2) == 0) { nocase = 1; } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -2203,7 +2203,7 @@ StringMatchCmd( const char *string = TclGetStringFromObj(objv[1], &length); if ((length > 1) && - strncmp(string, "-nocase", (size_t) length) == 0) { + strncmp(string, "-nocase", length) == 0) { nocase = TCL_MATCH_NOCASE; } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -2605,10 +2605,10 @@ StringEqualCmd( for (i = 1; i < objc-2; i++) { string2 = TclGetStringFromObj(objv[i], &length); - if ((length > 1) && !strncmp(string2, "-nocase", (size_t)length)) { + if ((length > 1) && !strncmp(string2, "-nocase", length)) { nocase = 1; } else if ((length > 1) - && !strncmp(string2, "-length", (size_t)length)) { + && !strncmp(string2, "-length", length)) { if (i+1 >= objc-2) { goto str_cmp_args; } @@ -2703,10 +2703,10 @@ TclStringCmpOpts( for (i = 1; i < objc-2; i++) { string = TclGetStringFromObj(objv[i], &length); - if ((length > 1) && !strncmp(string, "-nocase", (size_t)length)) { + if ((length > 1) && !strncmp(string, "-nocase", length)) { *nocase = 1; } else if ((length > 1) - && !strncmp(string, "-length", (size_t)length)) { + && !strncmp(string, "-length", length)) { if (i+1 >= objc-2) { goto str_cmp_args; } diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index b5517bc..08a0de3 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -2167,7 +2167,7 @@ BinaryProc( *srcReadPtr = srcLen; *dstWrotePtr = srcLen; *dstCharsPtr = srcLen; - memcpy(dst, src, (size_t) srcLen); + memcpy(dst, src, srcLen); return result; } @@ -2384,7 +2384,7 @@ UtfToUtfProc( src += len; dst += Tcl_UniCharToUtf(*chPtr, dst); #if TCL_UTF_MAX <= 4 - if ((len == 1) && ((*chPtr & 0xFC00) == 0xD800)) { + if ((*chPtr >= 0xD800) && (len < 3)) { src += TclUtfToUniChar(src + len, chPtr); dst += Tcl_UniCharToUtf(*chPtr, dst); } @@ -3006,7 +3006,7 @@ Iso88591FromUtfProc( if (ch > 0xff #if TCL_UTF_MAX <= 4 - || ((len == 1) && ((ch & 0xFC00) == 0xD800)) + || ((ch >= 0xD800) && (len < 3)) #endif ) { if (flags & TCL_ENCODING_STOPONERROR) { @@ -3014,7 +3014,7 @@ Iso88591FromUtfProc( break; } #if TCL_UTF_MAX <= 4 - if ((len == 1) && ((ch & 0xFC00) == 0xD800)) len = 4; + if ((ch >= 0xD800) && (len < 3)) len = 4; #endif /* * Plunge on, using '?' as a fallback character. @@ -3364,7 +3364,7 @@ EscapeFromUtfProc( *dstWrotePtr = 0; return TCL_CONVERT_NOSPACE; } - memcpy(dst, dataPtr->init, (size_t)dataPtr->initLen); + memcpy(dst, dataPtr->init, dataPtr->initLen); dst += dataPtr->initLen; } else { state = PTR2INT(*statePtr); @@ -3443,7 +3443,7 @@ EscapeFromUtfProc( break; } memcpy(dst, subTablePtr->sequence, - (size_t) subTablePtr->sequenceLen); + subTablePtr->sequenceLen); dst += subTablePtr->sequenceLen; } } @@ -3486,7 +3486,7 @@ EscapeFromUtfProc( memcpy(dst, dataPtr->subTables[0].sequence, len); dst += len; } - memcpy(dst, dataPtr->final, (size_t) dataPtr->finalLen); + memcpy(dst, dataPtr->final, dataPtr->finalLen); dst += dataPtr->finalLen; state &= ~TCL_ENCODING_END; } diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 17ad0bb..3ae5571 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -5227,8 +5227,8 @@ TEBCresume( objResultPtr = Tcl_NewObj(); } else { length = Tcl_UniCharToUtf(ch, buf); - if (!length) { - length = Tcl_UniCharToUtf(-1, buf); + if ((ch >= 0xD800) && (length < 3)) { + length = Tcl_UniCharToUtf(-1, buf + length); } objResultPtr = Tcl_NewStringObj(buf, length); } diff --git a/generic/tclParse.c b/generic/tclParse.c index ccb648c..8d07f7f 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -939,9 +939,9 @@ TclParseBackslash( *readPtr = count; } count = Tcl_UniCharToUtf(result, dst); - if (!count) { - /* Special case for handling upper surrogates. */ - count = Tcl_UniCharToUtf(-1, dst); + if ((result >= 0xD800) && (count < 3)) { + /* Special case for handling high surrogates. */ + count += Tcl_UniCharToUtf(-1, dst + count); } return count; } diff --git a/generic/tclScan.c b/generic/tclScan.c index 45035f1..21ad953 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -882,7 +882,7 @@ Tcl_ScanObjCmd( offset = TclUtfToUniChar(string, &sch); i = (int)sch; #if TCL_UTF_MAX == 4 - if ((offset == 1) && ((sch & 0xFC00) == 0xD800)) { + if (((sch & 0xFC00) == 0xD800) && (offset < 3)) { offset += TclUtfToUniChar(string+offset, &sch); i = (((i<<10) & 0x0FFC00) + 0x10000) + (sch & 0x3FF); } diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 72ca7cd..1ef7b9a 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -2048,9 +2048,9 @@ Tcl_AppendFormatToObj( goto error; } length = Tcl_UniCharToUtf(code, buf); - if (!length) { - /* Special case for handling upper surrogates. */ - length = Tcl_UniCharToUtf(-1, buf); + if ((code >= 0xD800) && (length < 3)) { + /* Special case for handling high surrogates. */ + length += Tcl_UniCharToUtf(-1, buf + length); } segment = Tcl_NewStringObj(buf, length); Tcl_IncrRefCount(segment); @@ -4287,7 +4287,7 @@ ExtendStringRepWithUnicode( copyBytes: dst = objPtr->bytes + origLength; for (i = 0; i < numChars; i++) { - dst += Tcl_UniCharToUtf((int) unicode[i], dst); + dst += Tcl_UniCharToUtf(unicode[i], dst); } *dst = '\0'; objPtr->length = dst - objPtr->bytes; diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 8429a2f..66bb305 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -333,7 +333,7 @@ Tcl_WinTCharToUtf( wEnd = (wchar_t *)string + len; for (w = (wchar_t *)string; w < wEnd; ) { if (!blen && ((*w & 0xFC00) != 0xDC00)) { - /* Special case for handling upper surrogates. */ + /* Special case for handling high surrogates. */ p += Tcl_UniCharToUtf(-1, p); } blen = Tcl_UniCharToUtf(*w, p); @@ -341,7 +341,7 @@ Tcl_WinTCharToUtf( w++; } if (!blen) { - /* Special case for handling upper surrogates. */ + /* Special case for handling high surrogates. */ p += Tcl_UniCharToUtf(-1, p); } Tcl_DStringSetLength(dsPtr, oldLength + (p - result)); diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 2227d45..6b63ecb 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -147,17 +147,17 @@ Tcl_UniCharToUtf( /* Low surrogate */ if (((buf[0] & 0xF8) == 0xF0) && ((buf[1] & 0xC0) == 0x80) && ((buf[2] & 0xCF) == 0)) { - /* Previous Tcl_UniChar was a High surrogate, so combine */ + /* Previous Tcl_UniChar was a high surrogate, so combine */ buf[3] = (char) ((ch & 0x3F) | 0x80); buf[2] |= (char) (((ch >> 6) & 0x0F) | 0x80); return 4; } - /* Previous Tcl_UniChar was not a High surrogate, so just output */ + /* Previous Tcl_UniChar was not a high surrogate, so just output */ } else { /* High surrogate */ ch += 0x40; /* Fill buffer with specific 3-byte (invalid) byte combination, - so following Low surrogate can recognize it and combine */ + so following low surrogate can recognize it and combine */ buf[2] = (char) ((ch << 4) & 0x30); buf[1] = (char) (((ch >> 2) & 0x3F) | 0x80); buf[0] = (char) (((ch >> 8) & 0x07) | 0xF0); @@ -232,15 +232,18 @@ Tcl_UniCharToUtfDString( wEnd = uniStr + uniLength; for (w = uniStr; w < wEnd; ) { if (!len && ((*w & 0xFC00) != 0xDC00)) { - /* Special case for handling upper surrogates. */ + /* Special case for handling high surrogates. */ p += Tcl_UniCharToUtf(-1, p); } len = Tcl_UniCharToUtf(*w, p); p += len; + if ((*w >= 0xD800) && (len < 3)) { + len = 0; /* Indication that high surrogate was found */ + } w++; } if (!len) { - /* Special case for handling upper surrogates. */ + /* Special case for handling high surrogates. */ p += Tcl_UniCharToUtf(-1, p); } Tcl_DStringSetLength(dsPtr, oldLength + (p - string)); @@ -296,7 +299,7 @@ Tcl_UtfToUniChar( register Tcl_UniChar *chPtr)/* Filled with the Tcl_UniChar represented by * the UTF-8 string. */ { - register int byte; + Tcl_UniChar byte; /* * Unroll 1 to 3 (or 4) byte UTF-8 sequences. @@ -326,10 +329,10 @@ Tcl_UtfToUniChar( return 3; } #endif - if ((unsigned)(byte-0x80) < (unsigned) 0x20) { - *chPtr = (Tcl_UniChar) cp1252[byte-0x80]; + if (byte-0x80 < 0x20) { + *chPtr = cp1252[byte-0x80]; } else { - *chPtr = (Tcl_UniChar) byte; + *chPtr = byte; } return 1; } else if (byte < 0xE0) { @@ -338,7 +341,7 @@ Tcl_UtfToUniChar( * Two-byte-character lead-byte followed by a trail-byte. */ - *chPtr = (Tcl_UniChar) (((byte & 0x1F) << 6) | (src[1] & 0x3F)); + *chPtr = (((byte & 0x1F) << 6) | (src[1] & 0x3F)); if ((unsigned)(*chPtr - 1) >= (UNICODE_SELF - 1)) { return 2; } @@ -354,7 +357,7 @@ Tcl_UtfToUniChar( * Three-byte-character lead byte followed by two trail bytes. */ - *chPtr = (Tcl_UniChar) (((byte & 0x0F) << 12) + *chPtr = (((byte & 0x0F) << 12) | ((src[1] & 0x3F) << 6) | (src[2] & 0x3F)); if (*chPtr > 0x7FF) { return 3; @@ -374,7 +377,7 @@ Tcl_UtfToUniChar( #if TCL_UTF_MAX <= 4 byte = (((byte & 0x07) << 8) | ((src[1] & 0x3F) << 2) | ((src[2] & 0x3F) >> 4)) - 0x40; - if ((unsigned) byte >= 0x400) { + if (byte >= 0x400) { /* out of range, < 0x10000 or > 0x10ffff */ } else { /* produce high surrogate, advance source pointer */ @@ -382,9 +385,9 @@ Tcl_UtfToUniChar( return 1; } #else - *chPtr = (Tcl_UniChar) (((byte & 0x07) << 18) | ((src[1] & 0x3F) << 12) + *chPtr = (((byte & 0x07) << 18) | ((src[1] & 0x3F) << 12) | ((src[2] & 0x3F) << 6) | (src[3] & 0x3F)); - if ((unsigned)(*chPtr - 0x10000) <= 0xFFFFF) { + if ((*chPtr - 0x10000) <= 0xFFFFF) { return 4; } #endif @@ -396,7 +399,7 @@ Tcl_UtfToUniChar( */ } - *chPtr = (Tcl_UniChar) byte; + *chPtr = byte; return 1; } @@ -457,8 +460,8 @@ Tcl_UtfToUniCharDString( while (p < end) { if (Tcl_UtfCharComplete(p, end-p)) { p += TclUtfToUniChar(p, &ch); - } else if ((unsigned)((UCHAR(*p)-0x80)) < (unsigned) 0x20) { - ch = (Tcl_UniChar) cp1252[UCHAR(*p++)-0x80]; + } else if (((UCHAR(*p)-0x80)) < 0x20) { + ch = cp1252[UCHAR(*p++)-0x80]; } else { ch = UCHAR(*p++); } @@ -589,7 +592,7 @@ Tcl_UtfFindFirst( len = TclUtfToUniChar(src, &find); fullchar = find; #if TCL_UTF_MAX <= 4 - if ((len == 1) && ((ch & 0xFC00) == 0xD800)) { + if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(src + len, &find); fullchar = (((fullchar & 0x3ff) << 10) | (find & 0x3ff)) + 0x10000; } @@ -637,7 +640,7 @@ Tcl_UtfFindLast( len = TclUtfToUniChar(src, &find); fullchar = find; #if TCL_UTF_MAX <= 4 - if ((len == 1) && ((ch & 0xFC00) == 0xD800)) { + if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(src + len, &find); fullchar = (((fullchar & 0x3ff) << 10) | (find & 0x3ff)) + 0x10000; } @@ -680,8 +683,8 @@ Tcl_UtfNext( int len = TclUtfToUniChar(src, &ch); #if TCL_UTF_MAX <= 4 - if ((len == 1) && ((ch & 0xFC00) == 0xD800)) { - len += TclUtfToUniChar(src + len, &ch); + if ((ch >= 0xD800) && (len < 3)) { + len += TclUtfToUniChar(src + len, &ch); } #endif return src + len; @@ -774,8 +777,8 @@ Tcl_UniCharAtIndex( } fullchar = ch; #if TCL_UTF_MAX <= 4 - if ((len == 1) && ((ch & 0xFC00) == 0xD800)) { - /* If last Tcl_UniChar was an upper surrogate, combine with lower surrogate */ + if ((ch >= 0xD800) && (len < 3)) { + /* If last Tcl_UniChar was an high surrogate, combine with low surrogate */ (void)TclUtfToUniChar(src + len, &ch); fullchar = (((fullchar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000; } @@ -815,7 +818,7 @@ Tcl_UtfAtIndex( src += len; } #if TCL_UTF_MAX <= 4 - if ((len == 1) && ((ch & 0xFC00) == 0xD800)) { + if ((ch >= 0xD800) && (len < 3)) { /* Index points at character following High Surrogate */ src += TclUtfToUniChar(src, &ch); } @@ -901,7 +904,7 @@ Tcl_UtfToUpper( Tcl_UniChar ch = 0; int upChar; char *src, *dst; - int bytes; + int len; /* * Iterate over the string until we hit the terminating null. @@ -909,11 +912,11 @@ Tcl_UtfToUpper( src = dst = str; while (*src) { - bytes = TclUtfToUniChar(src, &ch); + len = TclUtfToUniChar(src, &ch); upChar = ch; #if TCL_UTF_MAX <= 4 - if ((bytes == 1) && ((ch & 0xFC00) == 0xD800)) { - bytes += TclUtfToUniChar(src + bytes, &ch); + if ((ch >= 0xD800) && (len < 3)) { + len += TclUtfToUniChar(src + len, &ch); /* Combine surrogates */ upChar = (((upChar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000; } @@ -926,13 +929,13 @@ Tcl_UtfToUpper( * char to dst if its size is <= the original char. */ - if ((bytes < TclUtfCount(upChar)) || ((upChar & 0xF800) == 0xD800)) { - memcpy(dst, src, (size_t) bytes); - dst += bytes; + if ((len < TclUtfCount(upChar)) || ((upChar & 0xF800) == 0xD800)) { + memcpy(dst, src, len); + dst += len; } else { dst += Tcl_UniCharToUtf(upChar, dst); } - src += bytes; + src += len; } *dst = '\0'; return (dst - str); @@ -963,7 +966,7 @@ Tcl_UtfToLower( Tcl_UniChar ch = 0; int lowChar; char *src, *dst; - int bytes; + int len; /* * Iterate over the string until we hit the terminating null. @@ -971,11 +974,11 @@ Tcl_UtfToLower( src = dst = str; while (*src) { - bytes = TclUtfToUniChar(src, &ch); + len = TclUtfToUniChar(src, &ch); lowChar = ch; #if TCL_UTF_MAX <= 4 - if ((bytes == 1) && ((ch & 0xFC00) == 0xD800)) { - bytes += TclUtfToUniChar(src + bytes, &ch); + if ((ch >= 0xD800) && (len < 3)) { + len += TclUtfToUniChar(src + len, &ch); /* Combine surrogates */ lowChar = (((lowChar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000; } @@ -988,13 +991,13 @@ Tcl_UtfToLower( * char to dst if its size is <= the original char. */ - if ((bytes < TclUtfCount(lowChar)) || ((lowChar & 0xF800) == 0xD800)) { - memcpy(dst, src, (size_t) bytes); - dst += bytes; + if ((len < TclUtfCount(lowChar)) || ((lowChar & 0xF800) == 0xD800)) { + memcpy(dst, src, len); + dst += len; } else { dst += Tcl_UniCharToUtf(lowChar, dst); } - src += bytes; + src += len; } *dst = '\0'; return (dst - str); @@ -1026,7 +1029,7 @@ Tcl_UtfToTitle( Tcl_UniChar ch = 0; int titleChar, lowChar; char *src, *dst; - int bytes; + int len; /* * Capitalize the first character and then lowercase the rest of the @@ -1036,31 +1039,31 @@ Tcl_UtfToTitle( src = dst = str; if (*src) { - bytes = TclUtfToUniChar(src, &ch); + len = TclUtfToUniChar(src, &ch); titleChar = ch; #if TCL_UTF_MAX <= 4 - if ((bytes == 1) && ((ch & 0xFC00) == 0xD800)) { - bytes += TclUtfToUniChar(src + bytes, &ch); + if ((ch >= 0xD800) && (len < 3)) { + len += TclUtfToUniChar(src + len, &ch); /* Combine surrogates */ titleChar = (((titleChar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000; } #endif titleChar = Tcl_UniCharToTitle(titleChar); - if ((bytes < TclUtfCount(titleChar)) || ((titleChar & 0xF800) == 0xD800)) { - memcpy(dst, src, (size_t) bytes); - dst += bytes; + if ((len < TclUtfCount(titleChar)) || ((titleChar & 0xF800) == 0xD800)) { + memcpy(dst, src, len); + dst += len; } else { dst += Tcl_UniCharToUtf(titleChar, dst); } - src += bytes; + src += len; } while (*src) { - bytes = TclUtfToUniChar(src, &ch); + len = TclUtfToUniChar(src, &ch); lowChar = ch; #if TCL_UTF_MAX <= 4 - if ((bytes == 1) && ((ch & 0xFC00) == 0xD800)) { - bytes += TclUtfToUniChar(src + bytes, &ch); + if ((ch >= 0xD800) && (len < 3)) { + len += TclUtfToUniChar(src + len, &ch); /* Combine surrogates */ lowChar = (((lowChar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000; } @@ -1070,13 +1073,13 @@ Tcl_UtfToTitle( lowChar = Tcl_UniCharToLower(lowChar); } - if ((bytes < TclUtfCount(lowChar)) || ((lowChar & 0xF800) == 0xD800)) { - memcpy(dst, src, (size_t) bytes); - dst += bytes; + if ((len < TclUtfCount(lowChar)) || ((lowChar & 0xF800) == 0xD800)) { + memcpy(dst, src, len); + dst += len; } else { dst += Tcl_UniCharToUtf(lowChar, dst); } - src += bytes; + src += len; } *dst = '\0'; return (dst - str); diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index d02a2da..64a12a3 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -3155,21 +3155,6 @@ ZipFSListObjCmd( #ifdef _WIN32 #define LIBRARY_SIZE 64 - -static inline int -WCharToUtf( - const WCHAR *wSrc, - char *dst) -{ - char *start = dst; - - while (*wSrc != '\0') { - dst += Tcl_UniCharToUtf(*wSrc, dst); - wSrc++; - } - *dst = '\0'; - return (int) (dst - start); -} #endif /* _WIN32 */ Tcl_Obj * @@ -3213,11 +3198,8 @@ TclZipfs_TclLibrary(void) #if defined(_WIN32) hModule = TclWinGetTclInstance(); - if (GetModuleFileNameW(hModule, wName, MAX_PATH) == 0) { - GetModuleFileNameA(hModule, dllName, MAX_PATH); - } else { - WCharToUtf(wName, dllName); - } + GetModuleFileNameW(hModule, wName, MAX_PATH); + WideCharToMultiByte(CP_UTF8, 0, wName, -1, dllName, sizeof(dllName), NULL, NULL); if (ZipfsAppHookFindTclInit(dllName) == TCL_OK) { return Tcl_NewStringObj(zipfs_literal_tcl_library, -1); diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index ddfa0d6..c39d2c1 100644 --- a/win/tclWin32Dll.c +++ b/win/tclWin32Dll.c @@ -567,15 +567,19 @@ Tcl_WinTCharToUtf( wEnd = (TCHAR *)string + len; for (w = (TCHAR *)string; w < wEnd; ) { if (!blen && ((*w & 0xFC00) != 0xDC00)) { - /* Special case for handling upper surrogates. */ + /* Special case for handling high surrogates. */ p += Tcl_UniCharToUtf(-1, p); } blen = Tcl_UniCharToUtf(*w, p); p += blen; + if ((*w >= 0xD800) && (blen < 3)) { + /* Indication that high surrogate is handled */ + blen = 0; + } w++; } if (!blen) { - /* Special case for handling upper surrogates. */ + /* Special case for handling high surrogates. */ p += Tcl_UniCharToUtf(-1, p); } Tcl_DStringSetLength(dsPtr, oldLength + (p - result)); |