Attachment "1122671-tk.patch" to
ticket [1122671fff]
added by
hobbs
2005-02-16 07:38:53.
Index: unix/tkUnixFont.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/unix/tkUnixFont.c,v
retrieving revision 1.18.2.3
diff -u -r1.18.2.3 tkUnixFont.c
--- unix/tkUnixFont.c 29 Oct 2003 01:07:46 -0000 1.18.2.3
+++ unix/tkUnixFont.c 16 Feb 2005 00:29:33 -0000
@@ -190,7 +190,11 @@
{"tis620", "tis620*"},
{"ksc5601", "ksc5601*"},
{"dingbats", "*dingbats"},
+#ifdef WORDS_BIGENDIAN
+ {"unicode", "iso10646-1"},
+#else
{"ucs-2be", "iso10646-1"},
+#endif
{NULL, NULL}
};
@@ -327,7 +331,7 @@
Tcl_EncodingType type;
SubFont dummy;
int i;
-
+
if (tsdPtr->controlFamily.encoding == NULL) {
type.encodingName = "X11ControlChars";
type.toUtfProc = ControlUtfProc;
@@ -335,7 +339,7 @@
type.freeProc = NULL;
type.clientData = NULL;
type.nullSize = 0;
-
+
tsdPtr->controlFamily.refCount = 2;
tsdPtr->controlFamily.encoding = Tcl_CreateEncoding(&type);
tsdPtr->controlFamily.isTwoByteFont = 0;
@@ -347,6 +351,7 @@
FontMapInsert(&dummy, i + 0x80);
}
+#ifndef WORDS_BIGENDIAN
/*
* UCS-2BE is unicode in big-endian format.
* It is used in iso10646 fonts.
@@ -359,6 +364,7 @@
type.clientData = NULL;
type.nullSize = 2;
Tcl_CreateEncoding(&type);
+#endif
Tcl_CreateThreadExitHandler(FontPkgCleanup, NULL);
}
}
@@ -503,7 +509,7 @@
CONST Tcl_UniChar *wSrc, *wSrcStart, *wSrcEnd;
char *dstEnd, *dstStart;
int result, numChars;
-
+
result = TCL_OK;
if ((srcLen % sizeof(Tcl_UniChar)) != 0) {
result = TCL_CONVERT_MULTIBYTE;
@@ -583,10 +589,10 @@
* correspond to the bytes stored in the
* output buffer. */
{
- CONST char *srcStart, *srcEnd, *srcClose;
- Tcl_UniChar *wDst, *wDstStart, *wDstEnd;
+ CONST char *srcStart, *srcEnd, *srcClose, *dstStart, *dstEnd;
int result, numChars;
-
+ Tcl_UniChar ch;
+
srcStart = src;
srcEnd = src + srcLen;
srcClose = srcEnd;
@@ -594,9 +600,8 @@
srcClose -= TCL_UTF_MAX;
}
- wDst = (Tcl_UniChar *) dst;
- wDstStart = (Tcl_UniChar *) dst;
- wDstEnd = (Tcl_UniChar *) (dst + dstLen - sizeof(Tcl_UniChar));
+ dstStart = dst;
+ dstEnd = dst + dstLen;
result = TCL_OK;
for (numChars = 0; src < srcEnd; numChars++) {
@@ -609,19 +614,20 @@
result = TCL_CONVERT_MULTIBYTE;
break;
}
- if (wDst > wDstEnd) {
+ if (dst > dstEnd) {
result = TCL_CONVERT_NOSPACE;
break;
}
- src += Tcl_UtfToUniChar(src, wDst);
+ src += Tcl_UtfToUniChar(src, &ch);
/*
- * Byte swap for little-endian machines.
+ * Ensure big-endianness (store big bits first).
+ * XXX: This hard-codes the assumed size of Tcl_UniChar as 2.
*/
- *wDst = htons(*wDst);
- wDst++;
+ *dst++ = (ch >> 8);
+ *dst++ = (ch & 0xFF);
}
*srcReadPtr = src - srcStart;
- *dstWrotePtr = (char *) wDst - (char *) wDstStart;
+ *dstWrotePtr = dst - dstStart;
*dstCharsPtr = numChars;
return result;
}