diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-01-12 16:30:03 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-01-12 16:30:03 (GMT) |
commit | f0b9b9fbb6d6275b0be9047cee3a2fbdfb9ecdd4 (patch) | |
tree | c8f5508e0e76991c70aa2c0d58514db18ed3aeb5 /generic/tclStubInit.c | |
parent | 88233497abccd1215abfc8e09aeda7bf4fea2931 (diff) | |
parent | 244885a03e8d66f5500058eaf820d6b47f292007 (diff) | |
download | tcl-f0b9b9fbb6d6275b0be9047cee3a2fbdfb9ecdd4.zip tcl-f0b9b9fbb6d6275b0be9047cee3a2fbdfb9ecdd4.tar.gz tcl-f0b9b9fbb6d6275b0be9047cee3a2fbdfb9ecdd4.tar.bz2 |
merge core-8-branch
Diffstat (limited to 'generic/tclStubInit.c')
-rw-r--r-- | generic/tclStubInit.c | 88 |
1 files changed, 55 insertions, 33 deletions
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index dbde64f..2c11612 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -49,7 +49,7 @@ #undef TclWinNToHS /* See bug 510001: TclSockMinimumBuffers needs plat imp */ -#if defined(_WIN64) || defined(TCL_NO_DEPRECATED) +#if defined(_WIN64) || defined(TCL_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8 # define TclSockMinimumBuffersOld 0 #else #define TclSockMinimumBuffersOld sockMinimumBuffersOld @@ -59,16 +59,18 @@ static int TclSockMinimumBuffersOld(int sock, int size) } #endif -#if defined(TCL_NO_DEPRECATED) +#if defined(TCL_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8 # define TclSetStartupScriptPath 0 # define TclGetStartupScriptPath 0 # define TclSetStartupScriptFileName 0 # define TclGetStartupScriptFileName 0 +# define TclPrecTraceProc 0 # define TclpInetNtoa 0 # define TclWinGetServByName 0 # define TclWinGetSockOpt 0 # define TclWinSetSockOpt 0 # define TclWinNToHS 0 +# define TclWinGetPlatformId 0 # define TclBNInitBignumFromWideUInt 0 # define TclBNInitBignumFromWideInt 0 # define TclBNInitBignumFromLong 0 @@ -108,10 +110,33 @@ static const char *TclGetStartupScriptFileName(void) #if defined(_WIN32) || defined(__CYGWIN__) #undef TclWinNToHS +#undef TclWinGetPlatformId +#undef TclWinResetInterfaces +#undef TclWinSetInterfaces +static void +doNothing(void) +{ + /* dummy implementation, no need to do anything */ +} +#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 #define TclWinNToHS winNToHS static unsigned short TclWinNToHS(unsigned short ns) { return ntohs(ns); } +#define TclWinGetPlatformId winGetPlatformId +static int +TclWinGetPlatformId(void) +{ + return 2; /* VER_PLATFORM_WIN32_NT */; +} +#define TclWinResetInterfaces doNothing +#define TclWinSetInterfaces (void (*) (int)) doNothing +#else +#define TclWinNToHS 0 +#define TclWinGetPlatformId 0 +#define TclWinResetInterfaces 0 +#define TclWinSetInterfaces 0 +#endif #endif # define TclBNInitBignumFromWideUInt TclInitBignumFromWideUInt # define TclBNInitBignumFromWideInt TclInitBignumFromWideInt @@ -126,12 +151,8 @@ static unsigned short TclWinNToHS(unsigned short ns) { # define TclpIsAtty 0 #elif defined(__CYGWIN__) # define TclpIsAtty TclPlatIsAtty -# define TclWinSetInterfaces (void (*) (int)) doNothing # define TclWinAddProcess (void (*) (void *, unsigned int)) doNothing # define TclWinFlushDirtyChannels doNothing -# define TclWinResetInterfaces doNothing - -static Tcl_Encoding winTCharEncoding; static int TclpIsAtty(int fd) @@ -139,24 +160,15 @@ TclpIsAtty(int fd) return isatty(fd); } -#define TclWinGetPlatformId winGetPlatformId -static int -TclWinGetPlatformId() -{ - /* Don't bother to determine the real platform on cygwin, - * because VER_PLATFORM_WIN32_NT is the only supported platform */ - return 2; /* VER_PLATFORM_WIN32_NT */; -} - void *TclWinGetTclInstance() { void *hInstance = NULL; GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, - (const char *)&winTCharEncoding, &hInstance); + (const char *)&TclpIsAtty, &hInstance); return hInstance; } -#ifndef TCL_NO_DEPRECATED +#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 #define TclWinSetSockOpt winSetSockOpt static int TclWinSetSockOpt(SOCKET s, int level, int optname, @@ -201,23 +213,23 @@ TclpGetPid(Tcl_Pid pid) return (int) (size_t) pid; } -static void -doNothing(void) -{ - /* dummy implementation, no need to do anything */ -} - char * Tcl_WinUtfToTChar( const char *string, int len, Tcl_DString *dsPtr) { - if (!winTCharEncoding) { - winTCharEncoding = Tcl_GetEncoding(0, "unicode"); - } - return Tcl_UtfToExternalDString(winTCharEncoding, - string, len, dsPtr); + WCHAR *wp; + int size = MultiByteToWideChar(CP_UTF8, 0, string, len, 0, 0); + + Tcl_DStringInit(dsPtr); + Tcl_DStringSetLength(dsPtr, 2*size+2); + wp = (WCHAR *)Tcl_DStringValue(dsPtr); + MultiByteToWideChar(CP_UTF8, 0, string, len, wp, size+1); + if (len == -1) --size; /* account for 0-byte at string end */ + Tcl_DStringSetLength(dsPtr, 2*size); + wp[size] = 0; + return (char *)wp; } char * @@ -226,11 +238,21 @@ Tcl_WinTCharToUtf( int len, Tcl_DString *dsPtr) { - if (!winTCharEncoding) { - winTCharEncoding = Tcl_GetEncoding(0, "unicode"); + char *p; + int size; + + if (len > 0) { + len /= 2; } - return Tcl_ExternalToUtfDString(winTCharEncoding, - string, len, dsPtr); + size = WideCharToMultiByte(CP_UTF8, 0, string, len, 0, 0, NULL, NULL); + Tcl_DStringInit(dsPtr); + Tcl_DStringSetLength(dsPtr, size+1); + p = (char *)Tcl_DStringValue(dsPtr); + WideCharToMultiByte(CP_UTF8, 0, string, len, p, size, NULL, NULL); + if (len == -1) --size; /* account for 0-byte at string end */ + Tcl_DStringSetLength(dsPtr, size); + p[size] = 0; + return p; } #if defined(TCL_WIDE_INT_IS_LONG) @@ -318,7 +340,7 @@ static int formatInt(char *buffer, int n){ #endif /* __CYGWIN__ */ -#ifdef TCL_NO_DEPRECATED +#if defined(TCL_NO_DEPRECATED) # define Tcl_SeekOld 0 # define Tcl_TellOld 0 # undef Tcl_SetBooleanObj |