diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-03-24 07:56:41 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-03-24 07:56:41 (GMT) |
commit | bc56730d2abae5198c3667a55729e01684f3cb29 (patch) | |
tree | a67f18bf70f2081877ab48b4aecd142c54848262 /generic | |
parent | abbe37191732849b4d22072a8572f29205025457 (diff) | |
download | tk-bc56730d2abae5198c3667a55729e01684f3cb29.zip tk-bc56730d2abae5198c3667a55729e01684f3cb29.tar.gz tk-bc56730d2abae5198c3667a55729e01684f3cb29.tar.bz2 |
Replace all instances of Tcl_WinTCharToUtf()/Tcl_WinUtfToTChar() with Tcl_UniCharToUtfDString()/Tcl_UtfToUniCharDString(), if possible (only for -DTCL_UTF_MAX=3, which is the default and only supported option)
Backported, as far as possible, from 8.7. This helps moving away from Tcl_WinTCharToUtf()/Tcl_WinUtfToTChar(), even though it only becomes deprecated in 8.7.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkInt.h | 10 | ||||
-rw-r--r-- | generic/tkMain.c | 12 |
2 files changed, 17 insertions, 5 deletions
diff --git a/generic/tkInt.h b/generic/tkInt.h index c1bd562d..8f958ab 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -59,6 +59,16 @@ # endif #endif +#if defined(_WIN32) && (TCL_MAJOR_VERSION < 9) && (TCL_MINOR_VERSION < 7) +# if TCL_UTF_MAX > 3 +# define Tcl_WCharToUtfDString(a,b,c) Tcl_WinTCharToUtf((TCHAR *)(a),(b)*sizeof(WCHAR),c) +# define Tcl_UtfToWCharDString(a,b,c) (WCHAR *)Tcl_WinUtfToTChar(a,b,c) +# else +# define Tcl_WCharToUtfDString ((char * (*)(const WCHAR *, int len, Tcl_DString *))Tcl_UniCharToUtfDString) +# define Tcl_UtfToWCharDString ((WCHAR * (*)(const char *, int len, Tcl_DString *))Tcl_UtfToUniCharDString) +# endif +#endif + /* * Macros used to cast between pointers and integers (e.g. when storing an int * in ClientData), on 64-bit architectures they avoid gcc warning about "cast diff --git a/generic/tkMain.c b/generic/tkMain.c index 784f2f8..c6c9835 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.c @@ -70,8 +70,9 @@ NewNativeObj( Tcl_Obj *obj; Tcl_DString ds; -#ifdef UNICODE - Tcl_WinTCharToUtf(string, -1, &ds); +#if defined(_WIN32) && defined(UNICODE) + Tcl_DStringInit(&ds); + Tcl_WCharToUtfDString(string, wcslen(string), &ds); #else Tcl_ExternalToUtfDString(NULL, (char *) string, -1, &ds); #endif @@ -401,17 +402,18 @@ Tk_MainEx( *---------------------------------------------------------------------- */ - /* ARGSUSED */ static void StdinProc( ClientData clientData, /* The state of interactive cmd line */ int mask) /* Not used. */ { char *cmd; - int code, count; - InteractiveState *isPtr = clientData; + int code; + int count; + InteractiveState *isPtr = (InteractiveState *)clientData; Tcl_Channel chan = isPtr->input; Tcl_Interp *interp = isPtr->interp; + (void)mask; count = Tcl_Gets(chan, &isPtr->line); |