diff options
author | stanton <stanton> | 1999-05-22 02:05:31 (GMT) |
---|---|---|
committer | stanton <stanton> | 1999-05-22 02:05:31 (GMT) |
commit | 36f3e6e9af15906c7d459a8c80ee9f4e995b59f6 (patch) | |
tree | d52e19e2cc99c6dabb7105a1011d65d927c690df | |
parent | a912f987cc4a42b842e46d5ba8953533bd39c115 (diff) | |
download | tk-36f3e6e9af15906c7d459a8c80ee9f4e995b59f6.zip tk-36f3e6e9af15906c7d459a8c80ee9f4e995b59f6.tar.gz tk-36f3e6e9af15906c7d459a8c80ee9f4e995b59f6.tar.bz2 |
Fixed bug in Windows clipboard code when dealing with selections that don't contain locale information.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | win/tkWinClipboard.c | 67 |
2 files changed, 40 insertions, 32 deletions
@@ -1,3 +1,8 @@ +1999-05-21 <stanton@scriptics.com> + + * win/tkWinClipboard.c: Fixed clipboard code to handle lack of + CF_LOCALE information (e.g. from command.com). + 1999-05-20 <redman@scriptics.com> * library/console.tcl: Changed copyright string to read 1999 diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c index cb7d1a8..18fb1f1 100644 --- a/win/tkWinClipboard.c +++ b/win/tkWinClipboard.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinClipboard.c,v 1.4 1999/05/22 01:59:22 stanton Exp $ + * RCS: @(#) $Id: tkWinClipboard.c,v 1.5 1999/05/22 02:05:31 stanton Exp $ */ #include "tkWinInt.h" @@ -79,44 +79,43 @@ TkSelGetSelection(interp, tkwin, selection, target, proc, clientData) Tcl_UniCharToUtfDString((Tcl_UniChar *)data, Tcl_UniCharLen((Tcl_UniChar *)data), &ds); GlobalUnlock(handle); - } else if (IsClipboardFormatAvailable(CF_TEXT) - && IsClipboardFormatAvailable(CF_LOCALE)) { + } else if (IsClipboardFormatAvailable(CF_TEXT)) { /* * Determine the encoding to use to convert this text. */ - handle = GetClipboardData(CF_LOCALE); - if (!handle) { - CloseClipboard(); - goto error; - } + if (IsClipboardFormatAvailable(CF_LOCALE)) { + handle = GetClipboardData(CF_LOCALE); + if (!handle) { + CloseClipboard(); + goto error; + } - /* - * Get the locale identifier, determine the proper code page to use, - * and find the corresponding encoding. - */ + /* + * Get the locale identifier, determine the proper code page + * to use, and find the corresponding encoding. + */ - Tcl_DStringInit(&ds); - Tcl_DStringAppend(&ds, "cp######", -1); - data = GlobalLock(handle); - + Tcl_DStringInit(&ds); + Tcl_DStringAppend(&ds, "cp######", -1); + data = GlobalLock(handle); + - /* - * Even though the documentation claims that GetLocaleInfo expects an - * LCID, on Windows 9x it really seems to expect a LanguageID. - */ + /* + * Even though the documentation claims that GetLocaleInfo + * expects an LCID, on Windows 9x it really seems to expect + * a LanguageID. + */ - locale = LANGIDFROMLCID(*((int*)data)); - GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE, - Tcl_DStringValue(&ds)+2, Tcl_DStringLength(&ds)-2); - GlobalUnlock(handle); - - encoding = Tcl_GetEncoding(NULL, Tcl_DStringValue(&ds)); - Tcl_DStringFree(&ds); + locale = LANGIDFROMLCID(*((int*)data)); + GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE, + Tcl_DStringValue(&ds)+2, Tcl_DStringLength(&ds)-2); + GlobalUnlock(handle); - if (!encoding) { - CloseClipboard(); - goto error; + encoding = Tcl_GetEncoding(NULL, Tcl_DStringValue(&ds)); + Tcl_DStringFree(&ds); + } else { + encoding = NULL; } /* @@ -125,14 +124,18 @@ TkSelGetSelection(interp, tkwin, selection, target, proc, clientData) handle = GetClipboardData(CF_TEXT); if (!handle) { - Tcl_FreeEncoding(encoding); + if (encoding) { + Tcl_FreeEncoding(encoding); + } CloseClipboard(); goto error; } data = GlobalLock(handle); Tcl_ExternalToUtfDString(encoding, data, -1, &ds); GlobalUnlock(handle); - Tcl_FreeEncoding(encoding); + if (encoding) { + Tcl_FreeEncoding(encoding); + } } else { CloseClipboard(); |