summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornijtmans <nijtmans>2009-08-02 10:41:09 (GMT)
committernijtmans <nijtmans>2009-08-02 10:41:09 (GMT)
commitad16cb700076b09c515d59baee67ff5e235326eb (patch)
treedb13aa69d3445775988e5d32e7501e656f8e6403
parent71048d27d0a64c0fa11da33a09037c820babf6e5 (diff)
downloadtcl-ad16cb700076b09c515d59baee67ff5e235326eb.zip
tcl-ad16cb700076b09c515d59baee67ff5e235326eb.tar.gz
tcl-ad16cb700076b09c515d59baee67ff5e235326eb.tar.bz2
eliminate TclWinResetInterfaceEncodings, because
it does exactly the same as TclWinEncodingsCleanup, make sure that tclWinProcs and tclWinTCharEncoding are always set and reset concurrently.
-rw-r--r--ChangeLog8
-rw-r--r--win/tclWin32Dll.c28
-rw-r--r--win/tclWinFCmd.c6
-rw-r--r--win/tclWinInit.c33
-rw-r--r--win/tclWinInt.h37
5 files changed, 46 insertions, 66 deletions
diff --git a/ChangeLog b/ChangeLog
index b3463a9..eb400b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-08-02 Jan Nijtmans <nijtmans@users.sf.net>
+
+ * win/tclWin32Dll.c eliminate TclWinResetInterfaceEncodings, because
+ * win/tclWinInit.c it does exactly the same as TclWinEncodingsCleanup,
+ * win/tclWinInt.h make sure that tclWinProcs and tclWinTCharEncoding
+ are always set and reset concurrently.
+ * win/tclWinFCmd.c: correct check for win95
+
2009-07-31 Don Porter <dgp@users.sourceforge.net>
* generic/tclStringObj.c: Corrected failure to grow buffer
diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c
index eb50cb1..1295c26 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.59 2009/07/01 14:38:07 patthoyts Exp $
+ * RCS: @(#) $Id: tclWin32Dll.c,v 1.60 2009/08/02 10:41:09 nijtmans Exp $
*/
#include "tclWinInt.h"
@@ -184,10 +184,10 @@ 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
};
-TclWinProcs *tclWinProcs;
+TclWinProcs *tclWinProcs = &asciiProcs;
static Tcl_Encoding tclWinTCharEncoding;
/*
@@ -354,7 +354,7 @@ TclWinInit(
Tcl_Panic("Win32s is not a supported platform");
}
- tclWinProcs = &asciiProcs;
+ TclWinResetInterfaces();
}
/*
@@ -370,6 +370,7 @@ TclWinInit(
* VER_PLATFORM_WIN32s Win32s on Windows 3.1. (not supported)
* VER_PLATFORM_WIN32_WINDOWS Win32 on Windows 95, 98, ME.
* VER_PLATFORM_WIN32_NT Win32 on Windows NT, 2000, XP
+ * VER_PLATFORM_WIN32_CE Win32 on Windows CE
*
* Side effects:
* None.
@@ -442,7 +443,7 @@ TclWinSetInterfaces(
int wide) /* Non-zero to use wide interfaces, 0
* otherwise. */
{
- Tcl_FreeEncoding(tclWinTCharEncoding);
+ TclWinResetInterfaces();
if (wide) {
tclWinProcs = &unicodeProcs;
@@ -504,8 +505,6 @@ TclWinSetInterfaces(
}
}
} else {
- tclWinProcs = &asciiProcs;
- tclWinTCharEncoding = NULL;
if (tclWinProcs->getFileAttributesExProc == NULL) {
HINSTANCE hInstance = LoadLibraryA("kernel32");
if (hInstance != NULL) {
@@ -543,7 +542,7 @@ TclWinSetInterfaces(
/*
*---------------------------------------------------------------------------
*
- * TclWinResetInterfaceEncodings --
+ * TclWinEncodingsCleanup --
*
* Called during finalization to free up any encodings we use. The
* tclWinProcs-> look up table is still ok to use after this call,
@@ -563,14 +562,11 @@ TclWinSetInterfaces(
*/
void
-TclWinResetInterfaceEncodings(void)
+TclWinEncodingsCleanup(void)
{
MountPointMap *dlIter, *dlIter2;
- if (tclWinTCharEncoding != NULL) {
- Tcl_FreeEncoding(tclWinTCharEncoding);
- tclWinTCharEncoding = NULL;
- }
+ TclWinResetInterfaces();
/*
* Clean up the mount point map.
@@ -607,7 +603,11 @@ TclWinResetInterfaceEncodings(void)
void
TclWinResetInterfaces(void)
{
- tclWinProcs = &asciiProcs;
+ if (tclWinTCharEncoding != NULL) {
+ Tcl_FreeEncoding(tclWinTCharEncoding);
+ tclWinTCharEncoding = NULL;
+ }
+ tclWinProcs = &asciiProcs;
}
/*
diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c
index 5b8e0d8..6f5cd8d 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.57 2009/02/03 23:10:58 nijtmans Exp $
+ * RCS: @(#) $Id: tclWinFCmd.c,v 1.58 2009/08/02 10:41:09 nijtmans Exp $
*/
#include "tclWinInt.h"
@@ -1108,12 +1108,12 @@ DoRemoveJustDirectory(
}
/*
- * Windows 95 and Win32s report removing a non-empty directory as
+ * Windows 95 reports removing a non-empty directory as
* EACCES, not EEXIST. If the directory is not empty, change errno
* so caller knows what's going on.
*/
- if (TclWinGetPlatformId() != VER_PLATFORM_WIN32_NT) {
+ if (TclWinGetPlatformId() == VER_PLATFORM_WIN32_WINDOWS) {
const char *path, *find;
HANDLE handle;
WIN32_FIND_DATAA data;
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index 8d709e9..8043971 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.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: tclWinInit.c,v 1.82 2009/07/01 14:38:07 patthoyts Exp $
+ * RCS: @(#) $Id: tclWinInit.c,v 1.83 2009/08/02 10:41:09 nijtmans Exp $
*/
#include "tclWinInt.h"
@@ -397,31 +397,6 @@ ToUtf(
/*
*---------------------------------------------------------------------------
*
- * TclWinEncodingsCleanup --
- *
- * Reset information to its original state in finalization to allow for
- * reinitialization to be possible. This must not be called until after
- * the filesystem has been finalised, or exit crashes may occur when
- * using virtual filesystems.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Static information reset to startup state.
- *
- *---------------------------------------------------------------------------
- */
-
-void
-TclWinEncodingsCleanup(void)
-{
- TclWinResetInterfaceEncodings();
-}
-
-/*
- *---------------------------------------------------------------------------
- *
* TclpSetInitialEncodings --
*
* Based on the locale, determine the encoding of the operating system
@@ -457,11 +432,9 @@ TclpSetInitialEncodings(void)
void
TclpSetInterfaces(void)
{
- int platformId, useWide;
+ int useWide;
- platformId = TclWinGetPlatformId();
- useWide = ((platformId == VER_PLATFORM_WIN32_NT)
- || (platformId == VER_PLATFORM_WIN32_CE));
+ useWide = (TclWinGetPlatformId() != VER_PLATFORM_WIN32_WINDOWS);
TclWinSetInterfaces(useWide);
}
diff --git a/win/tclWinInt.h b/win/tclWinInt.h
index 546cf17..c0222f9 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.31 2009/07/01 14:38:08 patthoyts Exp $
+ * RCS: @(#) $Id: tclWinInt.h,v 1.32 2009/08/02 10:41:09 nijtmans Exp $
*/
#ifndef _TCLWININT
@@ -38,7 +38,7 @@
#endif
/*
- * The following structure keeps track of whether we are using the
+ * The following structure keeps track of whether we are using the
* multi-byte or the wide-character interfaces to the operating system.
* System calls should be made through the following function table.
*/
@@ -55,10 +55,10 @@ typedef struct TclWinProcs {
TCHAR *(WINAPI *charLowerProc)(TCHAR *);
BOOL (WINAPI *copyFileProc)(const TCHAR *, const TCHAR *, BOOL);
BOOL (WINAPI *createDirectoryProc)(const TCHAR *, LPSECURITY_ATTRIBUTES);
- HANDLE (WINAPI *createFileProc)(const TCHAR *, DWORD, DWORD,
+ HANDLE (WINAPI *createFileProc)(const TCHAR *, DWORD, DWORD,
LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
- BOOL (WINAPI *createProcessProc)(const TCHAR *, TCHAR *,
- LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD,
+ BOOL (WINAPI *createProcessProc)(const TCHAR *, TCHAR *,
+ LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD,
LPVOID, const TCHAR *, LPSTARTUPINFOA, LPPROCESS_INFORMATION);
BOOL (WINAPI *deleteFileProc)(const TCHAR *);
HANDLE (WINAPI *findFirstFileProc)(const TCHAR *, WIN32_FIND_DATAT *);
@@ -66,35 +66,35 @@ 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,
+ DWORD (WINAPI *getFullPathNameProc)(const TCHAR *, DWORD nBufferLength,
WCHAR *, TCHAR **);
DWORD (WINAPI *getModuleFileNameProc)(HMODULE, WCHAR *, int);
- DWORD (WINAPI *getShortPathNameProc)(const TCHAR *, WCHAR *, DWORD);
- UINT (WINAPI *getTempFileNameProc)(const TCHAR *, const TCHAR *, UINT,
+ DWORD (WINAPI *getShortPathNameProc)(const TCHAR *, WCHAR *, DWORD);
+ UINT (WINAPI *getTempFileNameProc)(const TCHAR *, const TCHAR *, UINT,
WCHAR *);
DWORD (WINAPI *getTempPathProc)(DWORD, WCHAR *);
- BOOL (WINAPI *getVolumeInformationProc)(const TCHAR *, WCHAR *, DWORD,
+ BOOL (WINAPI *getVolumeInformationProc)(const TCHAR *, WCHAR *, DWORD,
LPDWORD, LPDWORD, LPDWORD, WCHAR *, DWORD);
HINSTANCE (WINAPI *loadLibraryProc)(const TCHAR *);
TCHAR (WINAPI *lstrcpyProc)(WCHAR *, const TCHAR *);
BOOL (WINAPI *moveFileProc)(const TCHAR *, const TCHAR *);
BOOL (WINAPI *removeDirectoryProc)(const TCHAR *);
- DWORD (WINAPI *searchPathProc)(const TCHAR *, const TCHAR *,
+ DWORD (WINAPI *searchPathProc)(const TCHAR *, const TCHAR *,
const TCHAR *, DWORD, WCHAR *, TCHAR **);
BOOL (WINAPI *setCurrentDirectoryProc)(const TCHAR *);
BOOL (WINAPI *setFileAttributesProc)(const TCHAR *, DWORD);
- /*
+ /*
* These two function pointers will only be set when
* Tcl_FindExecutable is called. If you don't ever call that
* function, the application will crash whenever WinTcl tries to call
* functions through these null pointers. That is not a bug in Tcl
* -- Tcl_FindExecutable is obligatory in recent Tcl releases.
*/
- BOOL (WINAPI *getFileAttributesExProc)(const TCHAR *,
+ BOOL (WINAPI *getFileAttributesExProc)(const TCHAR *,
GET_FILEEX_INFO_LEVELS, LPVOID);
- BOOL (WINAPI *createHardLinkProc)(const TCHAR*, const TCHAR*,
+ 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,
@@ -102,7 +102,7 @@ typedef struct TclWinProcs {
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.
@@ -110,9 +110,9 @@ typedef struct TclWinProcs {
BOOL (WINAPI *getFileSecurityProc)(LPCTSTR lpFileName,
SECURITY_INFORMATION RequestedInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor,
- DWORD nLength,
+ DWORD nLength,
LPDWORD lpnLengthNeeded);
- BOOL (WINAPI *impersonateSelfProc) (SECURITY_IMPERSONATION_LEVEL
+ BOOL (WINAPI *impersonateSelfProc) (SECURITY_IMPERSONATION_LEVEL
ImpersonationLevel);
BOOL (WINAPI *openThreadTokenProc) (HANDLE ThreadHandle,
DWORD DesiredAccess, BOOL OpenAsSelf,
@@ -165,12 +165,11 @@ MODULE_SCOPE Tcl_Channel TclWinOpenFileChannel(HANDLE handle, char *channelName,
int permissions, int appendMode);
MODULE_SCOPE Tcl_Channel TclWinOpenSerialChannel(HANDLE handle,
char *channelName, int permissions);
-MODULE_SCOPE void TclWinResetInterfaceEncodings();
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 TclWinSymLinkDelete(const TCHAR* LinkOriginal,
int linkOnly);
#if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
MODULE_SCOPE void TclWinFreeAllocCache(void);