From f3a48000e4c73654b48530a402518c8c89c3be06 Mon Sep 17 00:00:00 2001 From: nijtmans Date: Wed, 3 Nov 2010 12:09:23 +0000 Subject: [FRQ 2965056]: Windows build with -DUNICODE (more clean-ups for pre-win2000 stuff) --- ChangeLog | 6 ++++++ win/tclWinFCmd.c | 16 ++++++++-------- win/tclWinFile.c | 16 +++++++++------- win/tclWinReg.c | 28 +++------------------------- 4 files changed, 26 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index af082ba..922b42b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-11-03 Jan Nijtmans + + * win/tclWinFcmd.c: [FRQ 2965056]: Windows build with -DUNICODE + * win/tclWinFile.c: (more clean-ups for pre-win2000 stuff) + * win/tclWinReg.c: + 2010-11-03 Donal K. Fellows * generic/tclCmdMZ.c (TryPostBody): Ensure that errors when setting diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c index a35cc3b..8de5e9f 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.69 2010/10/12 10:21:55 nijtmans Exp $ + * RCS: @(#) $Id: tclWinFCmd.c,v 1.70 2010/11/03 12:09:23 nijtmans Exp $ */ #include "tclWinInt.h" @@ -1278,7 +1278,7 @@ TraverseWinTree( return traverseProc(nativeSource, nativeTarget, DOTREE_F, errorPtr); } - Tcl_DStringAppend(sourcePtr, (char *) L"\\*.*", 4 * sizeof(WCHAR) + 1); + Tcl_DStringAppend(sourcePtr, (char *) TEXT("\\*.*"), 4 * sizeof(TCHAR) + 1); Tcl_DStringSetLength(sourcePtr, Tcl_DStringLength(sourcePtr) - 1); nativeSource = (TCHAR *) Tcl_DStringValue(sourcePtr); @@ -1302,15 +1302,15 @@ TraverseWinTree( return result; } - sourceLen = oldSourceLen + sizeof(WCHAR); - Tcl_DStringAppend(sourcePtr, (char *) L"\\", sizeof(WCHAR) + 1); + sourceLen = oldSourceLen + sizeof(TCHAR); + Tcl_DStringAppend(sourcePtr, (char *) TEXT("\\"), sizeof(TCHAR) + 1); Tcl_DStringSetLength(sourcePtr, sourceLen); if (targetPtr != NULL) { oldTargetLen = Tcl_DStringLength(targetPtr); targetLen = oldTargetLen; - targetLen += sizeof(WCHAR); - Tcl_DStringAppend(targetPtr, (char *) L"\\", sizeof(WCHAR) + 1); + targetLen += sizeof(TCHAR); + Tcl_DStringAppend(targetPtr, (char *) TEXT("\\"), sizeof(TCHAR) + 1); Tcl_DStringSetLength(targetPtr, targetLen); } @@ -1319,7 +1319,7 @@ TraverseWinTree( TCHAR *nativeName; int len; - WCHAR *wp = data.cFileName; + TCHAR *wp = data.cFileName; if (*wp == '.') { wp++; if (*wp == '.') { @@ -1330,7 +1330,7 @@ TraverseWinTree( } } nativeName = (TCHAR *) data.cFileName; - len = wcslen(data.cFileName) * sizeof(WCHAR); + len = _tcslen(data.cFileName) * sizeof(TCHAR); /* * Append name after slash, and recurse on the file. diff --git a/win/tclWinFile.c b/win/tclWinFile.c index e3d674b..6ef6f8c 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.115 2010/10/12 10:21:55 nijtmans Exp $ + * RCS: @(#) $Id: tclWinFile.c,v 1.116 2010/11/03 12:09:23 nijtmans Exp $ */ #include "tclWinInt.h" @@ -573,6 +573,7 @@ WinReadLinkDirectory( */ offset = 0; +#ifdef UNICODE if (reparseBuffer->MountPointReparseBuffer.PathBuffer[0] == L'\\') { /* * Check whether this is a mounted volume. @@ -634,6 +635,7 @@ WinReadLinkDirectory( offset = 4; } } +#endif /* UNICODE */ Tcl_WinTCharToUtf((const TCHAR *) reparseBuffer->MountPointReparseBuffer.PathBuffer, @@ -1712,19 +1714,19 @@ static int NativeIsExec( const TCHAR *path) { - int len = wcslen(path); + int len = _tcslen(path); if (len < 5) { return 0; } - if (path[len-4] != L'.') { + if (path[len-4] != TEXT('.')) { return 0; } - if ((_wcsicmp(path+len-3, L"exe") == 0) - || (_wcsicmp(path+len-3, L"com") == 0) - || (_wcsicmp(path+len-3, L"bat") == 0)) { + if ((_tcsicmp(path+len-3, TEXT("exe")) == 0) + || (_tcsicmp(path+len-3, TEXT("com")) == 0) + || (_tcsicmp(path+len-3, TEXT("bat")) == 0)) { return 1; } return 0; @@ -3128,7 +3130,7 @@ TclNativeDupInternalRep( return NULL; } - len = sizeof(TCHAR) * (_tcslen((const WCHAR *) clientData) + 1); + len = sizeof(TCHAR) * (_tcslen((const TCHAR *) clientData) + 1); copy = (char *) ckalloc(len); memcpy(copy, clientData, len); diff --git a/win/tclWinReg.c b/win/tclWinReg.c index 26ad6df..96aa3d8 100644 --- a/win/tclWinReg.c +++ b/win/tclWinReg.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: tclWinReg.c,v 1.55 2010/10/11 12:11:53 nijtmans Exp $ + * RCS: @(#) $Id: tclWinReg.c,v 1.56 2010/11/03 12:09:23 nijtmans Exp $ */ #undef STATIC_BUILD @@ -1491,34 +1491,12 @@ AppendSystemError( MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (TCHAR *) tMsgPtrPtr, 0, NULL); if (length == 0) { - char *msgPtr; - - length = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM - | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, error, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (char *) &msgPtr, - 0, NULL); - if (length > 0) { - tMsgPtr = (TCHAR *) - LocalAlloc(LPTR, (length + 1) * sizeof(TCHAR)); - MultiByteToWideChar(CP_ACP, 0, msgPtr, length + 1, tMsgPtr, - length + 1); - LocalFree(msgPtr); - } - } - if (length == 0) { - if (error == ERROR_CALL_NOT_IMPLEMENTED) { - strcpy(msgBuf, "function not supported under Win32s"); - } else { - sprintf(msgBuf, "unknown error: %ld", error); - } + sprintf(msgBuf, "unknown error: %ld", error); msg = msgBuf; } else { - Tcl_Encoding encoding; char *msgPtr; - encoding = Tcl_GetEncoding(NULL, "unicode"); - Tcl_ExternalToUtfDString(encoding, (char *) tMsgPtr, -1, &ds); - Tcl_FreeEncoding(encoding); + Tcl_WinTCharToUtf(tMsgPtr, -1, &ds); LocalFree(tMsgPtr); msgPtr = Tcl_DStringValue(&ds); -- cgit v0.12