From d51db74e5f9c0be32cbd0cfeeff0797a74cfd4ba Mon Sep 17 00:00:00 2001 From: nijtmans Date: Mon, 15 Feb 2010 22:56:19 +0000 Subject: reverted earlier rename from tcl*Stubs to tcl*ConstStubs, it's not necessary at all. tclEnsemble.c: Fix signed-unsigned mismatch make tclWinProcs "const" Add first part of mslu support, See [Feature Request #2819611] --- ChangeLog | 21 ++++++ compat/unicows/license.txt | 19 +++++ compat/unicows/readme.txt | 163 ++++++++++++++++++++++++++++++++++++++++++ compat/unicows/unicows.lib | Bin 0 -> 492330 bytes generic/tclBasic.c | 8 +-- generic/tclEnsemble.c | 4 +- generic/tclOO.c | 6 +- generic/tclOOStubInit.c | 10 +-- generic/tclStubInit.c | 20 +++--- generic/tclTomMathInterface.c | 6 +- tools/genStubs.tcl | 8 +-- win/.cvsignore | 2 + win/tclWin32Dll.c | 122 ++++++++++++++++++++++--------- win/tclWinFCmd.c | 12 ++-- win/tclWinFile.c | 12 ++-- win/tclWinInt.h | 84 +++++++--------------- win/tclWinLoad.c | 4 +- win/tclWinPipe.c | 12 ++-- win/tclWinSerial.c | 4 +- 19 files changed, 372 insertions(+), 145 deletions(-) create mode 100644 compat/unicows/license.txt create mode 100644 compat/unicows/readme.txt create mode 100644 compat/unicows/unicows.lib diff --git a/ChangeLog b/ChangeLog index bb536c7..2061a09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2010-02-15 Jan Nijtmans + + * tools/genStubs.tcl reverted earlier rename from tcl*Stubs to + * generic/tclBasic.c tcl*ConstStubs, it's not necessary at all. + * generic/tclOO.c + * generic/tclTomMathInterface.c + * generic/tclStubInit.c (regenerated) + * generic/tclOOStubInit.c (regenerated) + * generic/tclEnsemble.c Fix signed-unsigned mismatch + * win/tclWinInt.h make tclWinProcs "const" + * win/tclWin32Dll.c + * win/tclWinFCmd.c + * win/tclWinFile.c + * win/tclWinLoad.c + * win/tclWinPipe.c + * win/tclWinSerial.c + * win/.cvsignore + * compat/unicows/readme.txt Add first part of mslu support + * compat/unicows/license.txt See [Feature Request #2819611] + * compat/unicows/unicows.lib + 2010-02-15 Donal K. Fellows * generic/tclOO.c (AllocObject, SquelchedNsFirst, ObjectRenamedTrace): diff --git a/compat/unicows/license.txt b/compat/unicows/license.txt new file mode 100644 index 0000000..46f4d0b --- /dev/null +++ b/compat/unicows/license.txt @@ -0,0 +1,19 @@ +Copyright (c) 2001-2008 Vaclav Slavik + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + \ No newline at end of file diff --git a/compat/unicows/readme.txt b/compat/unicows/readme.txt new file mode 100644 index 0000000..00967fc --- /dev/null +++ b/compat/unicows/readme.txt @@ -0,0 +1,163 @@ + + + ============================================= + libunicows + ------------------------------------- + Import library for + Microsoft Layer for Unicode (unicows.dll) + + http://libunicows.sourceforge.net + ============================================= + + + About +======= + +Traditionally, win32 Unicode API was only available on Windows NT or 2000. If +you wanted to take advantage of Unicode in your application and support Windows +95/98 at the same time, your only option was to deploy two executables, one for +NT and one for 9X. + +Fortunately, this changed in 2001 when MS (finally!) released MSLU runtime that +allows Unicode applications to run under Windows 9X. + +See these pages for details: + + http://www.microsoft.com/globaldev/handson/dev/mslu_announce.mspx + http://msdn.microsoft.com/msdnmag/nettop.asp?page=/msdnmag/issues/01/10/MSLU/MSLU.asp&ad=ads.ddj.com/msdnmag/premium.htm + +Less fortunately, this solution requires that you use a special statically +linked import library that decides at runtime whether to load symbols from +system libraries like kernel32.dll or user32.dll (in case of Windows NT) or +from unicows.dll (which provides Unicode emulation layer under 9X). This import +library is only available for Microsoft Visual C++ and is only part of the new +Platform SDK, which is rather huge package. + +This library contains independent implementation of the import library. It can +be used with any C compiler (although it was only tested with Mingw32 and MSVC +so far). + + + + Installing libunicows +======================= + + Mingw32 +--------- + +Simply copy libunicows.a to the lib subdirectory of your Mingw32 installation +(e.g. c:\mingw32\lib). + + + Microsoft Visual C++ +---------------------- + +Copy unicows.lib to C:\Program Files\Visual Studio\VC98\Lib (assuming you +installed MSVC into C:\Program Files\Visual Studio and that you have version +6.0, the path may vary otherwise). + +Note: This was tested only with MSVC++ 6.0, but should work with other versions + as well. + + + Borland C++ +------------- + +Copy unicows.lib to %BORLAND%\lib where %BORLAND% is where you installed BC++ +(this directory should contain import32.lib). + + + Watcom C/C++ +------------- + +Copy unicows.lib to %WATCOM%\lib386\nt where %WATCOM% is where you installed +the compiler. + + + Usage +======= + +1) Add the unicows import library BEFORE other win32 libraries on your command +line. For example, if your command line for Mingw32 was + + c++ foo.o bar.o -o foo -lkernel32 -luser32 -lgdi32 -lcomdlg32 + +change it to + + c++ foo.o bar.o -o foo -lunicows -lkernel32 -luser32 -lgdi32 -lcomdlg32 + +No other change is neccessary, you don't have to include any special headers in +your source files. + + +2) Download Unicows runtime from + + http://www.microsoft.com/downloads/release.asp?releaseid=30039 + +or + + http://download.microsoft.com/download/platformsdk/Redist/1.0/W9XMe/EN-US/unicows.exe + +Extract unicows.dll from the package and distribute it with your application. +Do *not* install it to Windows system directory, always copy the DLL to your +application's directory! (Nobody wants any more of DLL hell...). + +If your application uses Common Controls DLL (very likely) or Rich Edit control, +make sure the installer installs new enough versions that fully support Unicode +(Common Controls DLL version 5.80 and RichEdit 4.0). + + + Compiling from sources +======================== + +1) Download the source package (libunicows-$version-src.tar.gz) + +2) [optional step] Run generate.py to create assembler stubs. You will need + Python (http://www.python.org) to run it. You don't have to do this unless + you modified symbols.txt or src\template.asm, because generated stubs are + already included in source package (in src\gen_asm). + +3) Change to 'src' subdirectory and compile the library. You will need + NASM (http://nasm.sourceforge.net). + + Mingw32: run make -f makefile.mingw32 + MSVC: run nmake -f makefile.vc6 + + If your compiler is not supported, you will have to create a makefile/project + file for it. You can gen inspiration from existing makefiles. If you do so, + please send the makefile (and if possible, compiled unicows.lib) to me, + so that I can include it in the next release of libunicows. Thanks! + + + Compiling and using unicows_wrapper.dll +========================================= + +If precompiled version of libunicows is not available for your compiler, you +can use unicows_wrapper.dll (at the cost of marginally slower calls and +the need to install unicows_wrapper.dll on NT/2k/XP boxes, too). Create +an import library for it in the same way you would do for any other DLL +and same the created import library as unicows.lib (or whatever name convention +your compiler uses, the point is to not name it unicows_wrapper.lib). For +example, this is how to do it with Borland C++ tools: + + implib unicows.lib unicows_wrapper.dll + +That is. Use the library as with other compilers, i.e. put unicows.lib as the +first one on your command line, so that the symbols are found in unicows.lib +and not in e.g. kernel32.lib. + +Unlike with the "native" import libraries, using unicows_wrapper.dll will make +your application depend on unicows_wrapper.dll even when installed on +Windows NT/2000/XP. Therefore, your installer must install following files +in addition to your application's binary and data: + +9x/ME: unicows.dll, unicows_wrapper.dll +NT/2k/XP: unicows_wrapper.dll + + + + Contacting the author +======================= + +I can be reached at this email address: vslavik@fastmail.fm + \ No newline at end of file diff --git a/compat/unicows/unicows.lib b/compat/unicows/unicows.lib new file mode 100644 index 0000000..e130334 Binary files /dev/null and b/compat/unicows/unicows.lib differ diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 97b4a5c..0a191bb 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -16,7 +16,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclBasic.c,v 1.443 2010/02/09 20:51:54 dkf Exp $ + * RCS: @(#) $Id: tclBasic.c,v 1.444 2010/02/15 22:56:19 nijtmans Exp $ */ #include "tclInt.h" @@ -167,7 +167,7 @@ static Tcl_NRPostProc TEOV_RestoreVarFrame; static Tcl_NRPostProc TEOV_RunLeaveTraces; static Tcl_NRPostProc YieldToCallback; -MODULE_SCOPE const TclStubs tclConstStubs; +MODULE_SCOPE const TclStubs tclStubs; /* * The following structure define the commands in the Tcl core. @@ -677,7 +677,7 @@ Tcl_CreateInterp(void) * Initialise the stub table pointer. */ - iPtr->stubTable = &tclConstStubs; + iPtr->stubTable = &tclStubs; /* * Initialize the ensemble error message rewriting support. @@ -906,7 +906,7 @@ Tcl_CreateInterp(void) */ Tcl_PkgProvideEx(interp, "Tcl", TCL_PATCH_LEVEL, - (ClientData) &tclConstStubs); + (ClientData) &tclStubs); if (TclTommath_Init(interp) != TCL_OK) { Tcl_Panic(Tcl_GetString(Tcl_GetObjResult(interp))); diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c index 49d0ed9..3108793 100644 --- a/generic/tclEnsemble.c +++ b/generic/tclEnsemble.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclEnsemble.c,v 1.2 2010/02/14 13:37:33 dkf Exp $ + * RCS: @(#) $Id: tclEnsemble.c,v 1.3 2010/02/15 22:56:20 nijtmans Exp $ */ #include "tclInt.h" @@ -2743,7 +2743,7 @@ TclCompileEnsemble( } for (i=0 ; i -MODULE_SCOPE const TclTomMathStubs tclTomMathConstStubs; +MODULE_SCOPE const TclTomMathStubs tclTomMathStubs; /* *---------------------------------------------------------------------- @@ -45,7 +45,7 @@ TclTommath_Init( /* TIP #268: Full patchlevel instead of just major.minor */ if (Tcl_PkgProvideEx(interp, "tcl::tommath", TCL_PATCH_LEVEL, - (ClientData) &tclTomMathConstStubs) != TCL_OK) { + (ClientData) &tclTomMathStubs) != TCL_OK) { return TCL_ERROR; } return TCL_OK; diff --git a/tools/genStubs.tcl b/tools/genStubs.tcl index 613d62f..7a77314 100644 --- a/tools/genStubs.tcl +++ b/tools/genStubs.tcl @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: genStubs.tcl,v 1.38 2010/02/09 14:08:53 ferrieux Exp $ +# RCS: @(#) $Id: genStubs.tcl,v 1.39 2010/02/15 22:56:20 nijtmans Exp $ package require Tcl 8.4 @@ -983,7 +983,7 @@ proc genStubs::emitInit {name textVar} { append text "\nstatic const ${capName}StubHooks ${name}StubHooks = \{\n" set sep " " foreach sub $hooks($name) { - append text $sep "&${sub}ConstStubs" + append text $sep "&${sub}Stubs" set sep ",\n " } append text "\n\};\n" @@ -998,9 +998,9 @@ proc genStubs::emitInit {name textVar} { } if {$root} { - append text "\nconst ${capName}Stubs ${name}ConstStubs = \{\n" + append text "\nconst ${capName}Stubs ${name}Stubs = \{\n" } else { - append text "\nstatic const ${capName}Stubs ${name}ConstStubs = \{\n" + append text "\nstatic const ${capName}Stubs ${name}Stubs = \{\n" } append text " TCL_STUB_MAGIC,\n" if {[info exists hooks($name)]} { diff --git a/win/.cvsignore b/win/.cvsignore index 3f15505..7a35fbb 100644 --- a/win/.cvsignore +++ b/win/.cvsignore @@ -24,3 +24,5 @@ tcl.suo *.res *.exp *.lib +*.pdb +*.ilk diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index 1295c26..76fc642 100644 --- a/win/tclWin32Dll.c +++ b/win/tclWin32Dll.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWin32Dll.c,v 1.60 2009/08/02 10:41:09 nijtmans Exp $ + * RCS: @(#) $Id: tclWin32Dll.c,v 1.61 2010/02/15 22:56:19 nijtmans Exp $ */ #include "tclWinInt.h" @@ -63,6 +63,53 @@ typedef struct EXCEPTION_REGISTRATION { #define cpuid __asm __emit 0fh __asm __emit 0a2h #endif +static Tcl_Encoding winTCharEncoding = NULL; + +static const TCHAR *utf2win( + const char *string, /* Source string in UTF-8. */ + int len, /* Source string length in bytes, or < 0 for + * strlen(). */ + Tcl_DString *dsPtr) /* Uninitialized or free DString in which the + * converted string is stored. */ +{ + return (const TCHAR *) Tcl_UtfToExternalDString(NULL, string, len, dsPtr); +} + +static const TCHAR *utf2wchar( + const char *string, /* Source string in UTF-8. */ + int len, /* Source string length in bytes, or < 0 for + * strlen(). */ + Tcl_DString *dsPtr) /* Uninitialized or free DString in which the + * converted string is stored. */ +{ + return (const TCHAR *) Tcl_UtfToExternalDString(winTCharEncoding, + string, len, dsPtr); +} + +static const char *win2utf( + const TCHAR *string, /* Source string in Unicode when running NT, + * ANSI when running 95. */ + int len, /* Source string length in bytes, or < 0 for + * platform-specific string length. */ + Tcl_DString *dsPtr) /* Uninitialized or free DString in which the + * converted string is stored. */ +{ + return Tcl_ExternalToUtfDString(NULL, + (const char *) string, len, dsPtr); +} + +static const char *wchar2utf( + const TCHAR *string, /* Source string in Unicode when running NT, + * ANSI when running 95. */ + int len, /* Source string length in bytes, or < 0 for + * platform-specific string length. */ + Tcl_DString *dsPtr) /* Uninitialized or free DString in which the + * converted string is stored. */ +{ + return Tcl_ExternalToUtfDString(winTCharEncoding, + (const char *) string, len, dsPtr); +} + /* * The following function tables are used to dispatch to either the * wide-character or multi-byte versions of the operating system calls, @@ -71,7 +118,6 @@ typedef struct EXCEPTION_REGISTRATION { static TclWinProcs asciiProcs = { 0, - (BOOL (WINAPI *)(const TCHAR *, LPDCB)) BuildCommDCBA, (TCHAR *(WINAPI *)(TCHAR *)) CharLowerA, (BOOL (WINAPI *)(const TCHAR *, const TCHAR *, BOOL)) CopyFileA, @@ -115,7 +161,6 @@ static TclWinProcs asciiProcs = { NULL, NULL, - /* deleted (int (__cdecl*)(const TCHAR *, struct _utimbuf *)) _utime, */ NULL, NULL, /* getLongPathNameProc */ @@ -125,12 +170,13 @@ static TclWinProcs asciiProcs = { /* ReadConsole and WriteConsole */ (BOOL (WINAPI *)(HANDLE, LPVOID, DWORD, LPDWORD, LPVOID)) ReadConsoleA, (BOOL (WINAPI *)(HANDLE, const void*, DWORD, LPDWORD, LPVOID)) WriteConsoleA, - (BOOL (WINAPI *)(LPTSTR, LPDWORD)) GetUserNameA + (BOOL (WINAPI *)(LPTSTR, LPDWORD)) GetUserNameA, + utf2win, + win2utf }; static TclWinProcs unicodeProcs = { 1, - (BOOL (WINAPI *)(const TCHAR *, LPDCB)) BuildCommDCBW, (TCHAR *(WINAPI *)(TCHAR *)) CharLowerW, (BOOL (WINAPI *)(const TCHAR *, const TCHAR *, BOOL)) CopyFileW, @@ -174,7 +220,6 @@ static TclWinProcs unicodeProcs = { NULL, NULL, - /* deleted (int (__cdecl*)(const TCHAR *, struct _utimbuf *)) _wutime, */ NULL, NULL, /* getLongPathNameProc */ @@ -184,11 +229,12 @@ static TclWinProcs unicodeProcs = { /* ReadConsole and WriteConsole */ (BOOL (WINAPI *)(HANDLE, LPVOID, DWORD, LPDWORD, LPVOID)) ReadConsoleW, (BOOL (WINAPI *)(HANDLE, const void*, DWORD, LPDWORD, LPVOID)) WriteConsoleW, - (BOOL (WINAPI *)(LPTSTR, LPDWORD)) GetUserNameW + (BOOL (WINAPI *)(LPTSTR, LPDWORD)) GetUserNameW, + utf2wchar, + wchar2utf }; -TclWinProcs *tclWinProcs = &asciiProcs; -static Tcl_Encoding tclWinTCharEncoding; +const TclWinProcs *tclWinProcs = &asciiProcs; /* * The following declaration is for the VC++ DLL entry point. @@ -446,54 +492,53 @@ TclWinSetInterfaces( TclWinResetInterfaces(); if (wide) { - tclWinProcs = &unicodeProcs; - tclWinTCharEncoding = Tcl_GetEncoding(NULL, "unicode"); - if (tclWinProcs->getFileAttributesExProc == NULL) { + winTCharEncoding = Tcl_GetEncoding(NULL, "unicode"); + if (unicodeProcs.getFileAttributesExProc == NULL) { HINSTANCE hInstance = LoadLibraryA("kernel32"); if (hInstance != NULL) { - tclWinProcs->getFileAttributesExProc = + unicodeProcs.getFileAttributesExProc = (BOOL (WINAPI *)(const TCHAR *, GET_FILEEX_INFO_LEVELS, LPVOID)) GetProcAddress(hInstance, "GetFileAttributesExW"); - tclWinProcs->createHardLinkProc = + unicodeProcs.createHardLinkProc = (BOOL (WINAPI *)(const TCHAR *, const TCHAR*, LPSECURITY_ATTRIBUTES)) GetProcAddress(hInstance, "CreateHardLinkW"); - tclWinProcs->findFirstFileExProc = + unicodeProcs.findFirstFileExProc = (HANDLE (WINAPI *)(const TCHAR*, UINT, LPVOID, UINT, LPVOID, DWORD)) GetProcAddress(hInstance, "FindFirstFileExW"); - tclWinProcs->getVolumeNameForVMPProc = + unicodeProcs.getVolumeNameForVMPProc = (BOOL (WINAPI *)(const TCHAR*, TCHAR*, DWORD)) GetProcAddress(hInstance, "GetVolumeNameForVolumeMountPointW"); - tclWinProcs->getLongPathNameProc = + unicodeProcs.getLongPathNameProc = (DWORD (WINAPI *)(const TCHAR*, TCHAR*, DWORD)) GetProcAddress(hInstance, "GetLongPathNameW"); FreeLibrary(hInstance); } hInstance = LoadLibraryA("advapi32"); if (hInstance != NULL) { - tclWinProcs->getFileSecurityProc = (BOOL (WINAPI *)( + unicodeProcs.getFileSecurityProc = (BOOL (WINAPI *)( LPCTSTR lpFileName, SECURITY_INFORMATION RequestedInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength, LPDWORD lpnLengthNeeded)) GetProcAddress(hInstance, "GetFileSecurityW"); - tclWinProcs->impersonateSelfProc = (BOOL (WINAPI *) ( + unicodeProcs.impersonateSelfProc = (BOOL (WINAPI *) ( SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)) GetProcAddress(hInstance, "ImpersonateSelf"); - tclWinProcs->openThreadTokenProc = (BOOL (WINAPI *) ( + unicodeProcs.openThreadTokenProc = (BOOL (WINAPI *) ( HANDLE ThreadHandle, DWORD DesiredAccess, BOOL OpenAsSelf, PHANDLE TokenHandle)) GetProcAddress(hInstance, "OpenThreadToken"); - tclWinProcs->revertToSelfProc = (BOOL (WINAPI *) (void)) + unicodeProcs.revertToSelfProc = (BOOL (WINAPI *) (void)) GetProcAddress(hInstance, "RevertToSelf"); - tclWinProcs->mapGenericMaskProc = (void (WINAPI *) ( + unicodeProcs.mapGenericMaskProc = (void (WINAPI *) ( PDWORD AccessMask, PGENERIC_MAPPING GenericMapping)) GetProcAddress(hInstance, "MapGenericMask"); - tclWinProcs->accessCheckProc = (BOOL (WINAPI *)( + unicodeProcs.accessCheckProc = (BOOL (WINAPI *)( PSECURITY_DESCRIPTOR pSecurityDescriptor, HANDLE ClientToken, DWORD DesiredAccess, PGENERIC_MAPPING GenericMapping, @@ -504,20 +549,21 @@ TclWinSetInterfaces( FreeLibrary(hInstance); } } + tclWinProcs = &unicodeProcs; } else { - if (tclWinProcs->getFileAttributesExProc == NULL) { + if (asciiProcs.getFileAttributesExProc == NULL) { HINSTANCE hInstance = LoadLibraryA("kernel32"); if (hInstance != NULL) { - tclWinProcs->getFileAttributesExProc = + asciiProcs.getFileAttributesExProc = (BOOL (WINAPI *)(const TCHAR *, GET_FILEEX_INFO_LEVELS, LPVOID)) GetProcAddress(hInstance, "GetFileAttributesExA"); - tclWinProcs->createHardLinkProc = + asciiProcs.createHardLinkProc = (BOOL (WINAPI *)(const TCHAR *, const TCHAR*, LPSECURITY_ATTRIBUTES)) GetProcAddress(hInstance, "CreateHardLinkA"); - tclWinProcs->findFirstFileExProc = NULL; - tclWinProcs->getLongPathNameProc = NULL; + asciiProcs.findFirstFileExProc = NULL; + asciiProcs.getLongPathNameProc = NULL; /* * The 'findFirstFileExProc' function exists on some of * 95/98/ME, but it seems not to work as anticipated. @@ -529,7 +575,7 @@ TclWinSetInterfaces( * LPVOID, UINT, LPVOID, DWORD)) GetProcAddress(hInstance, * "FindFirstFileExA"); */ - tclWinProcs->getVolumeNameForVMPProc = + asciiProcs.getVolumeNameForVMPProc = (BOOL (WINAPI *)(const TCHAR*, TCHAR*, DWORD)) GetProcAddress(hInstance, "GetVolumeNameForVolumeMountPointA"); @@ -603,9 +649,9 @@ TclWinEncodingsCleanup(void) void TclWinResetInterfaces(void) { - if (tclWinTCharEncoding != NULL) { - Tcl_FreeEncoding(tclWinTCharEncoding); - tclWinTCharEncoding = NULL; + if (winTCharEncoding != NULL) { + Tcl_FreeEncoding(winTCharEncoding); + winTCharEncoding = NULL; } tclWinProcs = &asciiProcs; } @@ -826,7 +872,11 @@ Tcl_WinUtfToTChar( Tcl_DString *dsPtr) /* Uninitialized or free DString in which the * converted string is stored. */ { - return (TCHAR *) Tcl_UtfToExternalDString(tclWinTCharEncoding, + Tcl_Encoding encoding = NULL; + if (platformId != VER_PLATFORM_WIN32_WINDOWS) { + encoding = winTCharEncoding; + } + return (TCHAR *) Tcl_UtfToExternalDString(encoding, string, len, dsPtr); } @@ -839,7 +889,11 @@ Tcl_WinTCharToUtf( Tcl_DString *dsPtr) /* Uninitialized or free DString in which the * converted string is stored. */ { - return Tcl_ExternalToUtfDString(tclWinTCharEncoding, + Tcl_Encoding encoding = NULL; + if (platformId != VER_PLATFORM_WIN32_WINDOWS) { + encoding = winTCharEncoding; + } + return Tcl_ExternalToUtfDString(encoding, (const char *) string, len, dsPtr); } diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c index 6f5cd8d..67ba3eb 100644 --- a/win/tclWinFCmd.c +++ b/win/tclWinFCmd.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinFCmd.c,v 1.58 2009/08/02 10:41:09 nijtmans Exp $ + * RCS: @(#) $Id: tclWinFCmd.c,v 1.59 2010/02/15 22:56:19 nijtmans Exp $ */ #include "tclWinInt.h" @@ -930,8 +930,8 @@ TclpObjCopyDirectory( return TCL_ERROR; } - Tcl_WinUtfToTChar(Tcl_GetString(normSrcPtr), -1, &srcString); - Tcl_WinUtfToTChar(Tcl_GetString(normDestPtr), -1, &dstString); + tclWinProcs->utf2tchar(Tcl_GetString(normSrcPtr), -1, &srcString); + tclWinProcs->utf2tchar(Tcl_GetString(normDestPtr), -1, &dstString); ret = TraverseWinTree(TraversalCopy, &srcString, &dstString, &ds); @@ -1003,7 +1003,7 @@ TclpObjRemoveDirectory( if (normPtr == NULL) { return TCL_ERROR; } - Tcl_WinUtfToTChar(Tcl_GetString(normPtr), -1, &native); + tclWinProcs->utf2tchar(Tcl_GetString(normPtr), -1, &native); ret = DoRemoveDirectory(&native, recursive, &ds); Tcl_DStringFree(&native); } else { @@ -1720,7 +1720,7 @@ ConvertFileNameFormat( Tcl_Obj *tempPath; Tcl_DString ds; Tcl_DString dsTemp; - TCHAR *nativeName; + const TCHAR *nativeName; const char *tempString; int tempLen; WIN32_FIND_DATAT data; @@ -1737,7 +1737,7 @@ ConvertFileNameFormat( Tcl_DStringInit(&ds); tempString = Tcl_GetStringFromObj(tempPath,&tempLen); - nativeName = Tcl_WinUtfToTChar(tempString, tempLen, &ds); + nativeName = tclWinProcs->utf2tchar(tempString, tempLen, &ds); Tcl_DecrRefCount(tempPath); handle = tclWinProcs->findFirstFileProc(nativeName, &data); if (handle == INVALID_HANDLE_VALUE) { diff --git a/win/tclWinFile.c b/win/tclWinFile.c index f18ca7e..57a9aef 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinFile.c,v 1.102 2010/01/13 06:46:56 nijtmans Exp $ + * RCS: @(#) $Id: tclWinFile.c,v 1.103 2010/02/15 22:56:19 nijtmans Exp $ */ /* #define _WIN32_WINNT 0x0500 */ @@ -1003,7 +1003,7 @@ TclpMatchInDirectory( dirName = Tcl_DStringAppend(&dsOrig, "*.*", 3); } - native = Tcl_WinUtfToTChar(dirName, -1, &ds); + native = tclWinProcs->utf2tchar(dirName, -1, &ds); if (tclWinProcs->findFirstFileExProc == NULL || (types == NULL) || (types->type != TCL_GLOB_TYPE_DIR)) { handle = tclWinProcs->findFirstFileProc(native, &data); @@ -2225,7 +2225,7 @@ NativeDev( } else { p++; } - nativeVol = Tcl_WinUtfToTChar(fullPath, p - fullPath, &volString); + nativeVol = tclWinProcs->utf2tchar(fullPath, p - fullPath, &volString); dw = (DWORD) -1; tclWinProcs->getVolumeInformationProc(nativeVol, NULL, 0, &dw, NULL, NULL, NULL, 0); @@ -2750,7 +2750,7 @@ TclpObjNormalizePath( */ WIN32_FILE_ATTRIBUTE_DATA data; - const char *nativePath = Tcl_WinUtfToTChar(path, + const char *nativePath = tclWinProcs->utf2tchar(path, currentPathEndPosition - path, &ds); if (tclWinProcs->getFileAttributesExProc(nativePath, @@ -2945,7 +2945,7 @@ TclpObjNormalizePath( if (1) { WCHAR wpath[MAX_PATH]; const char *nativePath = - Tcl_WinUtfToTChar(path, lastValidPathEnd - path, &ds); + tclWinProcs->utf2tchar(path, lastValidPathEnd - path, &ds); DWORD wpathlen = tclWinProcs->getLongPathNameProc(nativePath, (TCHAR *) wpath, MAX_PATH); @@ -3248,7 +3248,7 @@ TclNativeCreateNativeRep( } } } - Tcl_WinUtfToTChar(str, len, &ds); + tclWinProcs->utf2tchar(str, len, &ds); if (tclWinProcs->useWide) { len = Tcl_DStringLength(&ds) + sizeof(WCHAR); } else { diff --git a/win/tclWinInt.h b/win/tclWinInt.h index 7257afe..13d25ef 100644 --- a/win/tclWinInt.h +++ b/win/tclWinInt.h @@ -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: tclWinInt.h,v 1.33 2010/02/05 10:03:24 nijtmans Exp $ + * RCS: @(#) $Id: tclWinInt.h,v 1.34 2010/02/15 22:56:19 nijtmans Exp $ */ #ifndef _TCLWININT @@ -17,14 +17,6 @@ #include "tclInt.h" /* - * The following specifies how much stack space TclpCheckStackSpace() - * ensures is available. TclpCheckStackSpace() is called by Tcl_EvalObj() - * to help avoid overflowing the stack in the case of infinite recursion. - */ - -#define TCL_WIN_STACK_THRESHOLD 0x8000 - -/* * Some versions of Borland C have a define for the OSVERSIONINFO for * Win32s and for NT, but not for Windows 95. * Define VER_PLATFORM_WIN32_CE for those without newer headers. @@ -50,7 +42,6 @@ typedef union { typedef struct TclWinProcs { int useWide; - BOOL (WINAPI *buildCommDCBProc)(const TCHAR *, LPDCB); TCHAR * (WINAPI *charLowerProc)(TCHAR *); BOOL (WINAPI *copyFileProc)(const TCHAR *, const TCHAR *, BOOL); @@ -66,8 +57,8 @@ typedef struct TclWinProcs { BOOL (WINAPI *getComputerNameProc)(WCHAR *, LPDWORD); DWORD (WINAPI *getCurrentDirectoryProc)(DWORD, WCHAR *); DWORD (WINAPI *getFileAttributesProc)(const TCHAR *); - DWORD (WINAPI *getFullPathNameProc)(const TCHAR *, DWORD nBufferLength, - WCHAR *, TCHAR **); + DWORD (WINAPI *getFullPathNameProc)(const TCHAR *, DWORD, WCHAR *, + TCHAR **); DWORD (WINAPI *getModuleFileNameProc)(HMODULE, WCHAR *, int); DWORD (WINAPI *getShortPathNameProc)(const TCHAR *, WCHAR *, DWORD); UINT (WINAPI *getTempFileNameProc)(const TCHAR *, const TCHAR *, UINT, @@ -92,62 +83,39 @@ typedef struct TclWinProcs { */ BOOL (WINAPI *getFileAttributesExProc)(const TCHAR *, GET_FILEEX_INFO_LEVELS, LPVOID); - BOOL (WINAPI *createHardLinkProc)(const TCHAR*, const TCHAR*, - LPSECURITY_ATTRIBUTES); + BOOL (WINAPI *createHardLinkProc)(const TCHAR *, const TCHAR *, + LPSECURITY_ATTRIBUTES); - /* deleted INT (__cdecl *utimeProc)(const TCHAR*, struct _utimbuf *); */ /* These two are also NULL at start; see comment above */ - HANDLE (WINAPI *findFirstFileExProc)(const TCHAR*, UINT, - LPVOID, UINT, - LPVOID, DWORD); - BOOL (WINAPI *getVolumeNameForVMPProc)(const TCHAR*, TCHAR*, DWORD); - DWORD (WINAPI *getLongPathNameProc)(const TCHAR*, TCHAR*, DWORD); + HANDLE (WINAPI *findFirstFileExProc)(const TCHAR *, UINT, + LPVOID, UINT, LPVOID, DWORD); + BOOL (WINAPI *getVolumeNameForVMPProc)(const TCHAR *, TCHAR *, DWORD); + DWORD (WINAPI *getLongPathNameProc)(const TCHAR *, TCHAR *, DWORD); /* * These six are for the security sdk to get correct file * permissions on NT, 2000, XP, etc. On 95,98,ME they are * always null. */ - BOOL (WINAPI *getFileSecurityProc)(LPCTSTR lpFileName, - SECURITY_INFORMATION RequestedInformation, - PSECURITY_DESCRIPTOR pSecurityDescriptor, - DWORD nLength, - LPDWORD lpnLengthNeeded); - BOOL (WINAPI *impersonateSelfProc) (SECURITY_IMPERSONATION_LEVEL - ImpersonationLevel); - BOOL (WINAPI *openThreadTokenProc) (HANDLE ThreadHandle, - DWORD DesiredAccess, BOOL OpenAsSelf, - PHANDLE TokenHandle); + BOOL (WINAPI *getFileSecurityProc)(LPCTSTR, SECURITY_INFORMATION, + PSECURITY_DESCRIPTOR, DWORD, LPDWORD); + BOOL (WINAPI *impersonateSelfProc) (SECURITY_IMPERSONATION_LEVEL); + BOOL (WINAPI *openThreadTokenProc) (HANDLE, DWORD, BOOL, PHANDLE); BOOL (WINAPI *revertToSelfProc) (void); - void (WINAPI *mapGenericMaskProc) (PDWORD AccessMask, - PGENERIC_MAPPING GenericMapping); - BOOL (WINAPI *accessCheckProc)(PSECURITY_DESCRIPTOR pSecurityDescriptor, - HANDLE ClientToken, DWORD DesiredAccess, - PGENERIC_MAPPING GenericMapping, - PPRIVILEGE_SET PrivilegeSet, - LPDWORD PrivilegeSetLength, - LPDWORD GrantedAccess, - LPBOOL AccessStatus); + void (WINAPI *mapGenericMaskProc) (PDWORD, PGENERIC_MAPPING); + BOOL (WINAPI *accessCheckProc)(PSECURITY_DESCRIPTOR, HANDLE, DWORD, + PGENERIC_MAPPING, PPRIVILEGE_SET, LPDWORD, LPDWORD, LPBOOL); /* * Unicode console support. WriteConsole and ReadConsole */ - BOOL (WINAPI *readConsoleProc)( - HANDLE hConsoleInput, - LPVOID lpBuffer, - DWORD nNumberOfCharsToRead, - LPDWORD lpNumberOfCharsRead, - LPVOID lpReserved - ); - BOOL (WINAPI *writeConsoleProc)( - HANDLE hConsoleOutput, - const void* lpBuffer, - DWORD nNumberOfCharsToWrite, - LPDWORD lpNumberOfCharsWritten, - LPVOID lpReserved - ); - BOOL (WINAPI *getUserName)(LPTSTR lpBuffer, LPDWORD lpnSize); + BOOL (WINAPI *readConsoleProc)(HANDLE, LPVOID, DWORD, LPDWORD, LPVOID); + BOOL (WINAPI *writeConsoleProc)(HANDLE, const void *, DWORD, LPDWORD, + LPVOID); + BOOL (WINAPI *getUserName)(LPTSTR, LPDWORD); + const TCHAR *(*utf2tchar)(const char *, int, Tcl_DString *); + const char *(*tchar2utf)(const TCHAR *, int, Tcl_DString *); } TclWinProcs; -MODULE_SCOPE TclWinProcs *tclWinProcs; +MODULE_SCOPE const TclWinProcs *tclWinProcs; /* * Declarations of functions that are not accessible by way of the @@ -167,9 +135,9 @@ MODULE_SCOPE Tcl_Channel TclWinOpenSerialChannel(HANDLE handle, char *channelName, int permissions); MODULE_SCOPE HANDLE TclWinSerialReopen(HANDLE handle, const TCHAR *name, DWORD access); -MODULE_SCOPE int TclWinSymLinkCopyDirectory(const TCHAR* LinkOriginal, - const TCHAR* LinkCopy); -MODULE_SCOPE int TclWinSymLinkDelete(const TCHAR* LinkOriginal, +MODULE_SCOPE int TclWinSymLinkCopyDirectory(const TCHAR *LinkOriginal, + const TCHAR *LinkCopy); +MODULE_SCOPE int TclWinSymLinkDelete(const TCHAR *LinkOriginal, int linkOnly); #if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC) MODULE_SCOPE void TclWinFreeAllocCache(void); diff --git a/win/tclWinLoad.c b/win/tclWinLoad.c index af19ff1..26f50a4 100644 --- a/win/tclWinLoad.c +++ b/win/tclWinLoad.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinLoad.c,v 1.23 2009/02/03 23:10:57 nijtmans Exp $ + * RCS: @(#) $Id: tclWinLoad.c,v 1.24 2010/02/15 22:56:19 nijtmans Exp $ */ #include "tclWinInt.h" @@ -68,7 +68,7 @@ TclpDlopen( Tcl_DString ds; const char *fileName = Tcl_GetString(pathPtr); - nativeName = Tcl_WinUtfToTChar(fileName, -1, &ds); + nativeName = tclWinProcs->utf2tchar(fileName, -1, &ds); handle = tclWinProcs->loadLibraryProc(nativeName); Tcl_DStringFree(&ds); } diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index fda862e..b7dddaa 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinPipe.c,v 1.74 2010/01/22 13:02:50 nijtmans Exp $ + * RCS: @(#) $Id: tclWinPipe.c,v 1.75 2010/02/15 22:56:19 nijtmans Exp $ */ #include "tclWinInt.h" @@ -597,7 +597,7 @@ TclpOpenFile( break; } - nativePath = Tcl_WinUtfToTChar(path, -1, &ds); + nativePath = tclWinProcs->utf2tchar(path, -1, &ds); /* * If the file is not being created, use the existing file attributes. @@ -1399,7 +1399,7 @@ ApplicationType( for (i = 0; i < (int) (sizeof(extensions) / sizeof(extensions[0])); i++) { Tcl_DStringSetLength(&nameBuf, nameLen); Tcl_DStringAppend(&nameBuf, extensions[i], -1); - nativeName = Tcl_WinUtfToTChar(Tcl_DStringValue(&nameBuf), + nativeName = tclWinProcs->utf2tchar(Tcl_DStringValue(&nameBuf), Tcl_DStringLength(&nameBuf), &ds); found = tclWinProcs->searchPathProc(NULL, nativeName, NULL, MAX_PATH, nativeFullPath, &rest); @@ -1624,7 +1624,7 @@ BuildCommandLine( } } Tcl_DStringFree(linePtr); - Tcl_WinUtfToTChar(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds), linePtr); + tclWinProcs->utf2tchar(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds), linePtr); Tcl_DStringFree(&ds); } @@ -3196,7 +3196,7 @@ TclpOpenTemporaryFile( if (basenameObj) { const char *string = Tcl_GetStringFromObj(basenameObj, &length); - Tcl_WinUtfToTChar(string, length, &buf); + tclWinProcs->utf2tchar(string, length, &buf); memcpy(namePtr, Tcl_DStringValue(&buf), Tcl_DStringLength(&buf)); namePtr += Tcl_DStringLength(&buf); Tcl_DStringFree(&buf); @@ -3217,7 +3217,7 @@ TclpOpenTemporaryFile( sprintf(number, "%d.TMP", counter); counter = (unsigned short) (counter + 1); - Tcl_WinUtfToTChar(number, strlen(number), &buf); + tclWinProcs->utf2tchar(number, strlen(number), &buf); memcpy(namePtr, Tcl_DStringValue(&buf), Tcl_DStringLength(&buf)); if (tclWinProcs->useWide) { *(WCHAR *)(namePtr + Tcl_DStringLength(&buf) + 1) = '\0'; diff --git a/win/tclWinSerial.c b/win/tclWinSerial.c index c3144e3..f05207f 100644 --- a/win/tclWinSerial.c +++ b/win/tclWinSerial.c @@ -11,7 +11,7 @@ * * Serial functionality implemented by Rolf.Schroedter@dlr.de * - * RCS: @(#) $Id: tclWinSerial.c,v 1.41 2010/01/13 06:46:56 nijtmans Exp $ + * RCS: @(#) $Id: tclWinSerial.c,v 1.42 2010/02/15 22:56:19 nijtmans Exp $ */ #include "tclWinInt.h" @@ -1682,7 +1682,7 @@ SerialSetOptionProc( } return TCL_ERROR; } - native = Tcl_WinUtfToTChar(value, -1, &ds); + native = tclWinProcs->utf2tchar(value, -1, &ds); result = tclWinProcs->buildCommDCBProc(native, &dcb); Tcl_DStringFree(&ds); -- cgit v0.12