summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tkFrame.c1
-rw-r--r--generic/tkInt.h10
-rw-r--r--generic/tkUtil.c80
-rw-r--r--generic/tkWindow.c2
-rw-r--r--macosx/tkMacOSXFont.c4
-rw-r--r--macosx/tkMacOSXSubwindows.c2
-rw-r--r--macosx/tkMacOSXXStubs.c2
-rw-r--r--unix/tkUnixFont.c2
-rw-r--r--unix/tkUnixRFont.c6
-rw-r--r--win/rules.vc5
-rw-r--r--win/tkWinFont.c2
-rw-r--r--win/tkWinKey.c21
12 files changed, 108 insertions, 29 deletions
diff --git a/generic/tkFrame.c b/generic/tkFrame.c
index f6edfb0..0f1a1b3 100644
--- a/generic/tkFrame.c
+++ b/generic/tkFrame.c
@@ -458,7 +458,6 @@ TkListCreateFrame(
* window associated with the interpreter.
* Gives the base name to use for the new
* application. */
-
{
int objc;
Tcl_Obj **objv;
diff --git a/generic/tkInt.h b/generic/tkInt.h
index dd5dcad..1615a81 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -1196,7 +1196,7 @@ MODULE_SCOPE void TkUnderlineCharsInContext(Display *display,
const char *string, int numBytes, int x, int y,
int firstByte, int lastByte);
MODULE_SCOPE void TkpGetFontAttrsForChar(Tk_Window tkwin, Tk_Font tkfont,
- Tcl_UniChar c, struct TkFontAttributes *faPtr);
+ int c, struct TkFontAttributes *faPtr);
MODULE_SCOPE Tcl_Obj * TkNewWindowObj(Tk_Window tkwin);
MODULE_SCOPE void TkpShowBusyWindow(TkBusy busy);
MODULE_SCOPE void TkpHideBusyWindow(TkBusy busy);
@@ -1232,6 +1232,14 @@ MODULE_SCOPE Status TkParseColor (Display * display,
MODULE_SCOPE void TkUnixSetXftClipRegion(TkRegion clipRegion);
#endif
+#if TCL_UTF_MAX > 4
+# define TkUtfToUniChar Tcl_UtfToUniChar
+# define TkUniCharToUtf Tcl_UniCharToUtf
+#else
+ MODULE_SCOPE int TkUtfToUniChar(const char *, int *);
+ MODULE_SCOPE int TkUniCharToUtf(int, char *);
+#endif
+
/*
* Unsupported commands.
*/
diff --git a/generic/tkUtil.c b/generic/tkUtil.c
index 6563165..e686826 100644
--- a/generic/tkUtil.c
+++ b/generic/tkUtil.c
@@ -1192,6 +1192,86 @@ TkSendVirtualEvent(
Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL);
}
+
+#if TCL_UTF_MAX <= 4
+/*
+ *---------------------------------------------------------------------------
+ *
+ * TkUtfToUniChar --
+ *
+ * Almost the same as Tcl_UtfToUniChar but using int instead of Tcl_UniChar.
+ * This function is capable of collapsing a upper/lower surrogate pair to a
+ * single unicode character. So, up to 6 bytes might be consumed.
+ *
+ * Results:
+ * *chPtr is filled with the Tcl_UniChar, and the return value is the
+ * number of bytes from the UTF-8 string that were consumed.
+ *
+ * Side effects:
+ * None.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+int
+TkUtfToUniChar(
+ const char *src, /* The UTF-8 string. */
+ int *chPtr) /* Filled with the Tcl_UniChar represented by
+ * the UTF-8 string. */
+{
+ Tcl_UniChar uniChar = 0;
+
+ int len = Tcl_UtfToUniChar(src, &uniChar);
+ if ((uniChar & 0xfc00) == 0xd800) {
+ Tcl_UniChar high = uniChar;
+ /* This can only happen if Tcl is compiled with TCL_UTF_MAX=4,
+ * or when a high surrogate character is detected in UTF-8 form */
+ int len2 = Tcl_UtfToUniChar(src+len, &uniChar);
+ if ((uniChar & 0xfc00) == 0xdc00) {
+ *chPtr = (((high & 0x3ff) << 10) | (uniChar & 0x3ff)) + 0x10000;
+ len += len2;
+ } else {
+ *chPtr = high;
+ }
+ } else {
+ *chPtr = uniChar;
+ }
+ return len;
+}
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * TkUniCharToUtf --
+ *
+ * Almost the same as Tcl_UniCharToUtf but producing surrogates if
+ * TCL_UTF_MAX==3. So, up to 6 bytes might be produced.
+ *
+ * Results:
+ * *buf is filled with the UTF-8 string, and the return value is the
+ * number of bytes produced.
+ *
+ * Side effects:
+ * None.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+int TkUniCharToUtf(int ch, char *buf)
+{
+ int size = Tcl_UniCharToUtf(ch, buf);
+ if ((ch > 0xffff) && (ch <= 0x10ffff) && (size < 4)) {
+ /* Hey, this is wrong, we must be running TCL_UTF_MAX==3
+ * The best thing we can do is spit out 2 surrogates */
+ ch -= 0x10000;
+ size = Tcl_UniCharToUtf(((ch >> 10) | 0xd800), buf);
+ size += Tcl_UniCharToUtf(((ch & 0x3ff) | 0xdc00), buf+size);
+ }
+ return size;
+}
+
+
+#endif
/*
* Local Variables:
* mode: c
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index 0c60321..5855b7c 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -3101,7 +3101,7 @@ Initialize(
Tcl_ListObjAppendElement(NULL, cmd,
Tcl_NewStringObj("::safe::TkInit", -1));
Tcl_ListObjAppendElement(NULL, cmd, Tcl_GetObjResult(master));
-
+
/*
* Step 2 : Eval in the master. The argument is the *reversed* interp
* path of the slave.
diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c
index c48e56e..d3e0e41 100644
--- a/macosx/tkMacOSXFont.c
+++ b/macosx/tkMacOSXFont.c
@@ -672,14 +672,14 @@ void
TkpGetFontAttrsForChar(
Tk_Window tkwin, /* Window on the font's display */
Tk_Font tkfont, /* Font to query */
- Tcl_UniChar c, /* Character of interest */
+ int c, /* Character of interest */
TkFontAttributes* faPtr) /* Output: Font attributes */
{
MacFont *fontPtr = (MacFont *) tkfont;
NSFont *nsFont = fontPtr->nsFont;
*faPtr = fontPtr->font.fa;
if (nsFont && ![[nsFont coveredCharacterSet] characterIsMember:c]) {
- UTF16Char ch = c;
+ UTF16Char ch = (UTF16Char) c;
nsFont = [nsFont bestMatchingFontForCharacters:&ch
length:1 attributes:nil actualCoveredLength:NULL];
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index 9851474..f92d260 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -365,7 +365,7 @@ XMoveResizeWindow(
CGFloat Y = (CGFloat)y;
CGFloat Width = (CGFloat)width;
CGFloat Height = (CGFloat)height;
- CGFloat XOff = (CGFloat)macWin->winPtr->wmInfoPtr->xInParent;
+ CGFloat XOff = (CGFloat)macWin->winPtr->wmInfoPtr->xInParent;
CGFloat YOff = (CGFloat)macWin->winPtr->wmInfoPtr->yInParent;
NSRect r = NSMakeRect(X + XOff,
tkMacOSXZeroScreenHeight - Y - YOff - Height,
diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c
index a2d175b..1ed526d 100644
--- a/macosx/tkMacOSXXStubs.c
+++ b/macosx/tkMacOSXXStubs.c
@@ -897,7 +897,7 @@ XGetImage(
* We do not support any other values here.
*/
int scalefactor = 1;
- if (win && [win respondsToSelector:@selector(backingScaleFactor)]) {
+ if (win && [win respondsToSelector:@selector(backingScaleFactor)]) {
scalefactor = ([win backingScaleFactor] == 2.0) ? 2 : 1;
}
int scaled_height = height * scalefactor;
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index a4998aa..af9bb95 100644
--- a/unix/tkUnixFont.c
+++ b/unix/tkUnixFont.c
@@ -946,7 +946,7 @@ void
TkpGetFontAttrsForChar(
Tk_Window tkwin, /* Window on the font's display */
Tk_Font tkfont, /* Font to query */
- Tcl_UniChar c, /* Character of interest */
+ int c, /* Character of interest */
TkFontAttributes *faPtr) /* Output: Font attributes */
{
FontAttributes atts;
diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c
index 36e5462..8caa5ff 100644
--- a/unix/tkUnixRFont.c
+++ b/unix/tkUnixRFont.c
@@ -615,7 +615,7 @@ void
TkpGetFontAttrsForChar(
Tk_Window tkwin, /* Window on the font's display */
Tk_Font tkfont, /* Font to query */
- Tcl_UniChar c, /* Character of interest */
+ int c, /* Character of interest */
TkFontAttributes *faPtr) /* Output: Font attributes */
{
UnixFtFont *fontPtr = (UnixFtFont *) tkfont;
@@ -778,7 +778,7 @@ LookUpColor(Display *display, /* Display to lookup colors on */
i >= 0; last2 = last, last = i, i = fontPtr->colors[i].next) {
if (pixel == fontPtr->colors[i].color.pixel) {
- /*
+ /*
* Color found in cache. Move it to the front of the list and return it.
*/
if (last >= 0) {
@@ -802,7 +802,7 @@ LookUpColor(Display *display, /* Display to lookup colors on */
last = fontPtr->ncolors++;
}
- /*
+ /*
* Translate the pixel value to a color. Needs a server round-trip.
*/
xcolor.pixel = pixel;
diff --git a/win/rules.vc b/win/rules.vc
index 6fd079a..2cd711b 100644
--- a/win/rules.vc
+++ b/win/rules.vc
@@ -230,6 +230,10 @@ STATIC_BUILD = 1
!else
STATIC_BUILD = 0
!endif
+!if [nmakehlp -f $(OPTS) "nomsvcrt"]
+!message *** Doing nomsvcrt
+MSVCRT = 0
+!else
!if [nmakehlp -f $(OPTS) "msvcrt"]
!message *** Doing msvcrt
MSVCRT = 1
@@ -240,6 +244,7 @@ MSVCRT = 1
MSVCRT = 0
!endif
!endif
+!endif
!if [nmakehlp -f $(OPTS) "staticpkg"] && $(STATIC_BUILD)
!message *** Doing staticpkg
TCL_USE_STATIC_PACKAGES = 1
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index 940bc10..10ea1b9 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -743,7 +743,7 @@ void
TkpGetFontAttrsForChar(
Tk_Window tkwin, /* Window on the font's display */
Tk_Font tkfont, /* Font to query */
- Tcl_UniChar c, /* Character of interest */
+ int c, /* Character of interest */
TkFontAttributes *faPtr) /* Output: Font attributes */
{
WinFont *fontPtr = (WinFont *) tkfont;
diff --git a/win/tkWinKey.c b/win/tkWinKey.c
index 2698c4d..a567653 100644
--- a/win/tkWinKey.c
+++ b/win/tkWinKey.c
@@ -88,6 +88,8 @@ TkpGetString(
* result. */
{
XKeyEvent *keyEv = &eventPtr->xkey;
+ char buf[6];
+ int len;
Tcl_DStringInit(dsPtr);
if (keyEv->send_event == -1) {
@@ -102,8 +104,6 @@ TkpGetString(
*/
int unichar;
- char buf[XMaxTransChars];
- int len;
unichar = keyEv->trans_chars[1] & 0xff;
unichar <<= 8;
@@ -114,22 +114,12 @@ TkpGetString(
Tcl_DStringAppend(dsPtr, buf, len);
} else if (keyEv->send_event == -3) {
- char buf[XMaxTransChars];
- int len;
-
/*
* Special case for WM_UNICHAR.
*/
- len = Tcl_UniCharToUtf(keyEv->keycode, buf);
- if ((keyEv->keycode <= 0xffff) || (len == XMaxTransChars)) {
- Tcl_DStringAppend(dsPtr, buf, len);
- } else {
- Tcl_UniCharToUtf(((keyEv->keycode - 0x10000) >> 10) | 0xd800, buf);
- Tcl_DStringAppend(dsPtr, buf, 3);
- Tcl_UniCharToUtf(((keyEv->keycode - 0x10000) & 0x3ff) | 0xdc00, buf);
- Tcl_DStringAppend(dsPtr, buf, 3);
- }
+ len = TkUniCharToUtf(keyEv->keycode, buf);
+ Tcl_DStringAppend(dsPtr, buf, len);
} else {
/*
* This is an event generated from generic code. It has no nchars or
@@ -140,9 +130,6 @@ TkpGetString(
if (((keysym != NoSymbol) && (keysym > 0) && (keysym < 256))
|| (keysym == XK_Return) || (keysym == XK_Tab)) {
- char buf[XMaxTransChars];
- int len;
-
len = Tcl_UniCharToUtf((Tcl_UniChar) (keysym & 255), buf);
Tcl_DStringAppend(dsPtr, buf, len);
}