Compare commits

...
Author SHA1 Message Date
jan.nijtmans e0087267df Merge 8.6 and fix Travis build on Windows 2019-09-27 11:42:12 +00:00
sebres 052144cb1f merge 8.5 2019-09-26 16:22:42 +00:00
sebres f1550da616 amend to [fec0c17d39] - reduce max count of nested compiles to 1500 2019-09-26 16:21:25 +00:00
jan.nijtmans a2bc74984c Merge 8.6 2019-09-26 12:14:20 +00:00
sebres db3ee6681b merge-point 2019-09-25 20:02:52 +00:00
sebres ead525956c cherry-pick [f5b6b83de7] - namespace.test: add missing clean-up (allow repetition of test within -singleproc 1) 2019-09-25 20:01:35 +00:00
jan.nijtmans 81bf9a7925 Merge 8.5 2019-09-25 13:07:03 +00:00
jan.nijtmans 988da40f48 Fix failing test-case iocmd-21.20 on Travis 2019-09-25 12:18:14 +00:00
jan.nijtmans 55d9c007c0 Use consistantly "/D" in stead of "-D" for Microsoft compilers (MSVC) 2019-09-25 12:17:29 +00:00
jan.nijtmans 03dea312bd (cherry-pick): Update TZ info to tzdata2019c. 2019-09-25 11:54:18 +00:00
sebres ee57084f05 namespace.test: add missing clean-up (allow repetition of test within -singleproc 1) 2019-09-24 20:01:06 +00:00
jan.nijtmans 1e9e53cfec Merge 8.6 2019-09-20 21:38:17 +00:00
jan.nijtmans 0a6728c33d Let's use GetWindowLongW/SetWindowLongW on Win32 directly. Missed them because they are not used in Win64. 2019-09-20 21:01:44 +00:00
jan.nijtmans 2137118693 Modify registry/dde such that they no longer need to be compiled with -DUNICODE. Also no longer use Tcl_WinTCharToUtf/Tcl_WinUtfToTchar but the unicode conversions functions to do WCHAR <=> UTF-8 conversions.
When compiled with Tcl >= 8.7, use the TIP #548 wchar_t functions in stead for registry/dde. 
No need to update the registry/dde version numbers (1.3.3 resp. 1.4.1), because those were recentely bumped already, after the Tcl 8.6.9 release.
2019-09-20 15:02:42 +00:00
jan.nijtmans 1ed3c75ba4 Modify registry/dde such that they no longer need to be compiled with -DUNICODE. Also no longer use Tcl_WinTCharToUtf/Tcl_WinUtfToTchar but the unicode conversions functions to do WCHAR <=> UTF-8 conversions.
When compiled with Tcl >= 8.7, use the TIP #548 wchar_t functions in stead for registry/dde.
2019-09-20 14:59:18 +00:00
jan.nijtmans 3147adf346 Some more *A() -> *W() Win32 API changes, making Unicode calls Explicit. 2019-09-19 15:09:38 +00:00
jan.nijtmans 91258f5572 Don't build the Tcl library in Unicode mode any more. Just tclAppInit.c (and cat32 on Windows) 2019-09-19 11:36:21 +00:00
sebres ddd29dbbd3 all.tcl: replacement for exit, if calling direct only (avoid rewrite exit if it is inlined or interactive shell) 2019-09-18 22:58:32 +00:00
sebres 63660abb4f TEBC: avoid error "unitialized variable" if called in debug mode (or with analysis tools) - objv = NULL, similar to objc = 0 (e. g. calling parser.test, in doYield by INTERP_DEBUG_FRAME) 2019-09-18 22:43:08 +00:00
jan.nijtmans 3a94aaa6cb TCHAR -> WCHAR converions (and corresponding Win32 API call changes), since we are impicitly compiling with -DUNICODE 2019-09-18 15:11:23 +00:00
jan.nijtmans f2f4614f5c Add missing constraints to test-cases 2019-09-17 13:01:46 +00:00
jan.nijtmans caa904131a Bugfix in Tcl_UtfPrev/Tcl_UtfNext: When handling 4-byte UTF-8 byte sequences, those should be able to move back/forward 4 bytes if TCL_UTF_MAX <= 4. Update comment accordingly.
Bugfix in Tcl_UtfFindFirst/Tcl_UtfFindLast: Those functions should be able to find both the high surrogate (if asked for) as also the full character (combination of both surrogates)
2019-09-16 21:18:21 +00:00
jan.nijtmans 746ce9535f Add 32-bit windows builds (both MSVC and GCC) to Travis 2019-09-16 18:55:50 +00:00
jan.nijtmans 21ad94030a Add 32-bit Windows builds, both with MSVC and GCC, to Travis.
Backport various test-suite changes fro 8.6 to 8.5, mainly "knownBug" markers and comments
2019-09-16 18:45:38 +00:00
sebres 906d03c8cb execute.test: fix tests (if test started using -singleproc 1) 2019-09-16 16:33:30 +00:00
jan.nijtmans e10b32c27a try xcode 10.3 2019-09-15 00:01:34 +00:00
jan.nijtmans ef1b90ad7a Merge 8.5 2019-09-13 13:29:42 +00:00
jan.nijtmans facb6a3102 merge-mark 2019-09-13 13:28:07 +00:00
jan.nijtmans 7d5b0dc33c Make test-cases (hopefully) work on Travis, e.g. by adding nonPortable marks to test-cases which are nonPortable in 8.6 as well. 2019-09-13 13:27:05 +00:00
jan.nijtmans f38c8594fb Merge 8.5. Mark a few more tests nonPortable (for 8.5, not to be merged to 8.6!) 2019-09-12 15:03:53 +00:00
jan.nijtmans 01634e6c3b Merge 8.5 2019-09-11 13:53:57 +00:00
jan.nijtmans 3d2df2eae1 Run all test-cases with -verbose sbtel, so we can see which test-case actually hangs. 2019-09-10 11:59:29 +00:00
jan.nijtmans c939eccf4a Add 32-bit (Windows-x86) builds to travis, both with MSVC and GCC 2019-09-10 08:02:55 +00:00
34 changed files with 837 additions and 774 deletions
+59 -20
View File
@@ -15,18 +15,15 @@ matrix:
dist: xenial
compiler: gcc
env:
- CFGOPT=--disable-shared
- CFGOPT="--disable-shared"
- BUILD_DIR=unix
# Debug build. Running test-cases disabled, because it is currently failing.
- name: "Linux/GCC/Debug/no test"
- name: "Linux/GCC/Debug"
os: linux
dist: xenial
compiler: gcc
env:
- BUILD_DIR=unix
- CFGOPT=--enable-symbols=all
script:
- make all tcltest
- CFGOPT="--enable-symbols"
# Older versions of GCC...
- name: "Linux/GCC 7/Shared"
os: linux
@@ -88,18 +85,15 @@ matrix:
dist: xenial
compiler: clang
env:
- CFGOPT=--disable-shared
- CFGOPT="--disable-shared"
- BUILD_DIR=unix
# Debug build. Running test-cases disabled, because it is currently failing.
- name: "Linux/Clang/Debug/no test"
- name: "Linux/Clang/Debug"
os: linux
dist: xenial
compiler: clang
env:
- BUILD_DIR=unix
- CFGOPT=--enable-symbols=all
script:
- make all tcltest
- CFGOPT="--enable-symbols"
# Testing on Mac, various styles
- name: "macOS/Xcode 11/Shared/Unix-like"
os: osx
@@ -118,7 +112,7 @@ matrix:
- make test styles=develop
- name: "macOS/Xcode 10/Shared"
os: osx
osx_image: xcode10.2
osx_image: xcode10.3
env:
- BUILD_DIR=macosx
install: []
@@ -246,6 +240,34 @@ matrix:
script:
- cmd.exe /C 'vcvarsall.bat x64 && nmake OPTS=symbols,msvcrt,threads -f makefile.vc all tcltest'
- cmd.exe /C 'vcvarsall.bat x64 && nmake OPTS=symbols,msvcrt,threads -f makefile.vc test'
# Test on Windows with MSVC native (32-bit)
- name: "Windows/MSVC-x86/Shared"
os: windows
compiler: cl
env: *vcenv
before_install: *vcpreinst
install: []
script:
- cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=threads -f makefile.vc all tcltest'
- cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=threads -f makefile.vc test'
- name: "Windows/MSVC-x86/Static"
os: windows
compiler: cl
env: *vcenv
before_install: *vcpreinst
install: []
script:
- cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=static,msvcrt,threads -f makefile.vc all tcltest'
- cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=static,msvcrt,threads -f makefile.vc test'
- name: "Windows/MSVC-x86/Debug"
os: windows
compiler: cl
env: *vcenv
before_install: *vcpreinst
install: []
script:
- cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=symbols,msvcrt,threads -f makefile.vc all tcltest'
- cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=symbols,msvcrt,threads -f makefile.vc test'
# Test on Windows with GCC native
- name: "Windows/GCC/Shared"
os: windows
@@ -253,7 +275,7 @@ matrix:
env:
- BUILD_DIR=win
- CFGOPT="--enable-64bit"
before_install:
before_install: &makepreinst
- choco install make
- cd ${BUILD_DIR}
- name: "Windows/GCC/Static"
@@ -262,18 +284,35 @@ matrix:
env:
- BUILD_DIR=win
- CFGOPT="--enable-64bit --disable-shared"
before_install:
- choco install make
- cd ${BUILD_DIR}
before_install: *makepreinst
- name: "Windows/GCC/Debug"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
- CFGOPT="--enable-64bit --enable-symbols"
before_install:
- choco install make
- cd ${BUILD_DIR}
before_install: *makepreinst
# Test on Windows with GCC native (32-bit)
- name: "Windows/GCC-x86/Shared"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
before_install: *makepreinst
- name: "Windows/GCC-x86/Static"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
- CFGOPT="--disable-shared"
before_install: *makepreinst
- name: "Windows/GCC-x86/Debug"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
- CFGOPT="--enable-symbols"
before_install: *makepreinst
before_install:
- cd ${BUILD_DIR}
install:
+1 -1
View File
@@ -2178,7 +2178,7 @@ TEBCresume(
*/
Tcl_Obj *objPtr, *valuePtr, *value2Ptr, *part1Ptr, *part2Ptr, *tmpPtr;
Tcl_Obj **objv;
Tcl_Obj **objv = NULL;
int objc = 0;
int opnd, length, pcAdjustment;
Var *varPtr, *arrayPtr;
+1 -1
View File
@@ -29,7 +29,7 @@ static const char *gai_strerror(int code) {
} else {
tsdPtr->initialized = 1;
}
Tcl_WinTCharToUtf(gai_strerrorW(code), -1, &tsdPtr->errorMsg);
Tcl_WinTCharToUtf((TCHAR *)gai_strerrorW(code), -1, &tsdPtr->errorMsg);
return Tcl_DStringValue(&tsdPtr->errorMsg);
}
#endif
+1 -1
View File
@@ -4669,7 +4669,7 @@ Tcl_FSGetFileSystemForPath(
* Tcl_FSGetNativePath --
*
* This function is for use by the Win/Unix native filesystems, so that
* they can easily retrieve the native (char* or TCHAR*) representation
* they can easily retrieve the native (char* or WCHAR*) representation
* of a path. Other filesystems will probably want to implement similar
* functions. They basically act as a safety net around
* Tcl_FSGetInternalRep. Normally your file-system functions will always
+18 -35
View File
@@ -17,21 +17,11 @@
*/
/*
* On Windows, this file needs to be compiled twice, once with TCL_ASCII_MAIN
* defined. This way both Tcl_Main and Tcl_MainExW can be implemented, sharing
* the same source code.
* On Windows, this file needs to be compiled twice, once with UNICODE and
* _UNICODE defined. This way both Tcl_Main and Tcl_MainExW can be
* implemented, sharing the same source code.
*/
#if defined(TCL_ASCII_MAIN)
# ifdef UNICODE
# undef UNICODE
# undef _UNICODE
# else
# define UNICODE
# define _UNICODE
# endif
#endif
#include "tclInt.h"
/*
@@ -53,26 +43,19 @@
# define _tcscmp strcmp
#endif
/*
* Further on, in UNICODE mode we just use Tcl_NewUnicodeObj, otherwise
* NewNativeObj is needed (which provides proper conversion from native
* encoding to UTF-8).
*/
#ifdef UNICODE
# define NewNativeObj Tcl_NewUnicodeObj
#else /* !UNICODE */
static inline Tcl_Obj *
NewNativeObj(
char *string,
int length)
TCHAR *string)
{
Tcl_DString ds;
Tcl_ExternalToUtfDString(NULL, string, length, &ds);
#ifdef UNICODE
Tcl_WinTCharToUtf(string, -1, &ds);
#else
Tcl_ExternalToUtfDString(NULL, (char *) string, -1, &ds);
#endif
return TclDStringToObj(&ds);
}
#endif /* !UNICODE */
/*
* Declarations for various library functions and variables (don't want to
@@ -134,7 +117,7 @@ static void Prompt(Tcl_Interp *interp, InteractiveState *isPtr);
static void StdinProc(ClientData clientData, int mask);
static void FreeMainInterp(ClientData clientData);
#ifndef TCL_ASCII_MAIN
#if !defined(_WIN32) || defined(UNICODE)
static Tcl_ThreadDataKey dataKey;
/*
@@ -279,7 +262,7 @@ Tcl_SourceRCFile(
Tcl_DStringFree(&temp);
}
}
#endif /* !TCL_ASCII_MAIN */
#endif /* !UNICODE */
/*----------------------------------------------------------------------
*
@@ -341,14 +324,14 @@ Tcl_MainEx(
if ((argc > 3) && (0 == _tcscmp(TEXT("-encoding"), argv[1]))
&& ('-' != argv[3][0])) {
Tcl_Obj *value = NewNativeObj(argv[2], -1);
Tcl_SetStartupScript(NewNativeObj(argv[3], -1),
Tcl_Obj *value = NewNativeObj(argv[2]);
Tcl_SetStartupScript(NewNativeObj(argv[3]),
Tcl_GetString(value));
Tcl_DecrRefCount(value);
argc -= 3;
argv += 3;
} else if ((argc > 1) && ('-' != argv[1][0])) {
Tcl_SetStartupScript(NewNativeObj(argv[1], -1), NULL);
Tcl_SetStartupScript(NewNativeObj(argv[1]), NULL);
argc--;
argv++;
}
@@ -356,7 +339,7 @@ Tcl_MainEx(
path = Tcl_GetStartupScript(&encodingName);
if (path == NULL) {
appName = NewNativeObj(argv[0], -1);
appName = NewNativeObj(argv[0]);
} else {
appName = path;
}
@@ -368,7 +351,7 @@ Tcl_MainEx(
argvPtr = Tcl_NewListObj(0, NULL);
while (argc--) {
Tcl_ListObjAppendElement(NULL, argvPtr, NewNativeObj(*argv++, -1));
Tcl_ListObjAppendElement(NULL, argvPtr, NewNativeObj(*argv++));
}
Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
@@ -650,7 +633,7 @@ Tcl_Main(
}
#endif /* TCL_MAJOR_VERSION == 8 && !UNICODE */
#ifndef TCL_ASCII_MAIN
#if !defined(_WIN32) || defined(UNICODE)
/*
*---------------------------------------------------------------
@@ -741,7 +724,7 @@ TclFullFinalizationRequested(void)
return finalize;
#endif /* PURIFY */
}
#endif /* !TCL_ASCII_MAIN */
#endif /* UNICODE */
/*
*----------------------------------------------------------------------
+7 -7
View File
@@ -275,7 +275,7 @@ Tcl_UniCharToUtfDString(
* Tcl_UtfCharComplete() before calling this routine to ensure that
* enough bytes remain in the string.
*
* If TCL_UTF_MAX == 4, special handling of Surrogate pairs is done:
* If TCL_UTF_MAX <= 4, special handling of Surrogate pairs is done:
* For any UTF-8 string containing a character outside of the BMP, the
* first call to this function will fill *chPtr with the high surrogate
* and generate a return value of 0. Calling Tcl_UtfToUniChar again
@@ -584,8 +584,8 @@ Tcl_UtfFindFirst(
while (1) {
len = TclUtfToUniChar(src, &find);
fullchar = find;
#if TCL_UTF_MAX == 4
if ((ch >= 0xD800) && (len < 3)) {
#if TCL_UTF_MAX <= 4
if ((fullchar != ch) && (find >= 0xD800) && (len < 3)) {
len += TclUtfToUniChar(src + len, &find);
fullchar = (((fullchar & 0x3ff) << 10) | (find & 0x3ff)) + 0x10000;
}
@@ -632,8 +632,8 @@ Tcl_UtfFindLast(
while (1) {
len = TclUtfToUniChar(src, &find);
fullchar = find;
#if TCL_UTF_MAX == 4
if ((ch >= 0xD800) && (len < 3)) {
#if TCL_UTF_MAX <= 4
if ((fullchar != ch) && (find >= 0xD800) && (len < 3)) {
len += TclUtfToUniChar(src + len, &find);
fullchar = (((fullchar & 0x3ff) << 10) | (find & 0x3ff)) + 0x10000;
}
@@ -675,7 +675,7 @@ Tcl_UtfNext(
Tcl_UniChar ch = 0;
int len = TclUtfToUniChar(src, &ch);
#if TCL_UTF_MAX == 4
#if TCL_UTF_MAX <= 4
if ((ch >= 0xD800) && (len < 3)) {
len += TclUtfToUniChar(src + len, &ch);
}
@@ -714,7 +714,7 @@ Tcl_UtfPrev(
int i, byte;
look = --src;
for (i = 0; i < TCL_UTF_MAX; i++) {
for (i = 0; i < 4; i++) {
if (look < start) {
if (src < start) {
src = start;
+6 -1
View File
@@ -25,4 +25,9 @@ if {[singleProcess]} {
set ErrorOnFailures [info exists env(ERROR_ON_FAILURES)]
unset -nocomplain env(ERROR_ON_FAILURES)
if {[runAllTests] && $ErrorOnFailures} {exit 1}
proc exit args {}
# if calling direct only (avoid rewrite exit if inlined or interactive):
if { [info exists ::argv0] && [file tail $::argv0] eq [file tail [info script]]
&& !([info exists ::tcl_interactive] && $::tcl_interactive)
} {
proc exit args {}
}
+1 -1
View File
@@ -968,7 +968,7 @@ test basic-48.24.$noComp {expansion: empty not canonical list, regression test,
run {list [list {*}{ }] [list {*}[format %c 32]] [list {*}[set a { }]]}
} -result [lrepeat 3 {}] -cleanup {unset -nocomplain a}
test basic-48.25.$noComp {Bug cc191552c: expansion: empty non-canonical list} -setup {
test basic-48.25.$noComp {Bug cc191552c: expansion: empty non-canonical list} -constraints $constraints -setup {
unset -nocomplain ::CRLF
set ::CRLF "\r\n"
} -body {
+3 -3
View File
@@ -494,10 +494,10 @@ test compile-13.2 {TclCompileScript: testing expected nested scripts compilation
ti eval {set result {}}
} -body {
# Test different compilation variants (instructions evalStk, invokeStk, etc),
# with 2000 (1000 in debug) nested scripts (bodies). If you get SO/SF exceptions on some low-stack
# with 1500 (1000 in debug) nested scripts (bodies). If you get SO/SF exceptions on some low-stack
# boxes or systems, please don't decrease it (either provide a constraint)
ti eval {foreach cmd {eval "if 1" try catch} {
set c [gencode [expr {![::tcl::pkgconfig get debug] ? 2000 : 1000}] $cmd]
set c [gencode [expr {![::tcl::pkgconfig get debug] ? 1500 : 1000}] $cmd]
if 1 $c
}}
ti eval {set result}
@@ -511,7 +511,7 @@ test compile-13.3 {TclCompileScript: testing check of max depth by nested script
# with 500 nested scripts (bodies). It must generate "too many nested compilations"
# error for any variant we're testing here:
ti eval {foreach cmd {eval "if 1" try catch} {
set c [gencode [expr {![info exists ::tcl_platform(debug)] ? 2000 : 1000}] $cmd]
set c [gencode 500 $cmd]
lappend errors [catch $c e] $e
}}
#puts $errors
+2 -1
View File
@@ -1054,7 +1054,7 @@ test execute-8.7 {Compile epoch bump in global level (bug [fa6bf38d07]), excepti
test execute-9.1 {Interp result resetting [Bug 1522803]} {
set c 0
catch {
catch {set foo}
catch {error foo}
expr {1/$c}
}
if {[string match *foo* $::errorInfo]} {
@@ -1089,6 +1089,7 @@ test execute-10.3 {Bug 3072640} -setup {
proc t {args} {
incr ::foo
}
set ::foo 0
trace add execution ::generate enterstep ::t
} -body {
coroutine coro generate 5
+3 -4
View File
@@ -25,7 +25,6 @@ package require tcltests
# Custom constraints used in this file
testConstraint testchannel [llength [info commands testchannel]]
testConstraint knownMsvcBug [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match windows $::env(TRAVIS_OS_NAME)]}]
#----------------------------------------------------------------------
@@ -793,7 +792,7 @@ test iocmd-21.19 {chan create, init failure -> no channel, no finalize} -match g
rename foo {}
set res
} -result {{} {initialize rc* {read write}} 1 {*all required methods*} {}}
test iocmd-21.20 {Bug 88aef05cda} -constraints knownMsvcBug -setup {
test iocmd-21.20 {Bug 88aef05cda} -setup {
proc foo {method chan args} {
switch -- $method blocking {
chan configure $chan -blocking [lindex $args 0]
@@ -807,11 +806,11 @@ test iocmd-21.20 {Bug 88aef05cda} -constraints knownMsvcBug -setup {
}
set ch [chan create {read write} foo]
} -body {
list [catch {chan configure $ch -blocking 0} m] $m
chan configure $ch -blocking 0
} -cleanup {
close $ch
rename foo {}
} -match glob -result {1 {*nested eval*}}
} -match glob -returnCodes 1 -result {*(infinite loop?)*}
test iocmd-21.21 {[close] in [read] segfaults} -setup {
proc foo {method chan args} {
switch -- $method initialize {
+8 -4
View File
@@ -134,15 +134,19 @@ test lrange-3.7b.2 {not compiled on empty not list object, 2nd regression test,
list [$cmd {} 0 1] [$cmd [lindex a -1] 0 1] [$cmd [set a {}] 0 1] \
[$cmd {} 0-1 end+1] [$cmd [lindex a -1] 0-1 end+1] [$cmd $a 0-1 end+1]
} [lrepeat 6 {}]
test lrange-3.7c.2 {compiled on empty pure bytes object, 2nd regression test, bug [cc1e91552c]} {
test lrange-3.7c.2 {compiled on empty pure bytes object, 2nd regression test, bug [cc1e91552c]} -constraints {
testpurebytesobj
} -body {
list [lrange [testpurebytesobj] 0 1] [lrange [testpurebytesobj { }] 0 1] [lrange [set a [testpurebytesobj {}]] 0 1] \
[lrange [testpurebytesobj] 0-1 end+1] [lrange [testpurebytesobj { }] 0-1 end+1] [lrange $a 0-1 end+1]
} [lrepeat 6 {}]
test lrange-3.7d.2 {not compiled on empty pure bytes object, 2nd regression test, bug [cc1e91552c]} {
} -result [lrepeat 6 {}]
test lrange-3.7d.2 {not compiled on empty pure bytes object, 2nd regression test, bug [cc1e91552c]} -constraints {
testpurebytesobj
} -body {
set cmd lrange
list [$cmd [testpurebytesobj] 0 1] [$cmd [testpurebytesobj { }] 0 1] [$cmd [set a [testpurebytesobj {}]] 0 1] \
[$cmd [testpurebytesobj] 0-1 end+1] [$cmd [testpurebytesobj { }] 0-1 end+1] [$cmd $a 0-1 end+1]
} [lrepeat 6 {}]
} -result [lrepeat 6 {}]
# cleanup
+1
View File
@@ -2624,6 +2624,7 @@ test namespace-51.6 {name resolution path control} -body {
namespace delete ::test_ns_1
catch {rename ::pathtestB {}}
catch {rename ::pathtestD {}}
catch {rename ::pathtestC {}}
}
test namespace-51.7 {name resolution path control} -body {
namespace eval ::test_ns_1 {
+3 -3
View File
@@ -231,7 +231,7 @@ typedef struct {
void *hbrBackground;
void *lpszMenuName;
const void *lpszClassName;
} WNDCLASS;
} WNDCLASSW;
extern void __stdcall CloseHandle(void *);
extern void *__stdcall CreateEventW(void *, unsigned char, unsigned char,
@@ -248,7 +248,7 @@ extern unsigned char __stdcall PeekMessageW(MSG *, void *, int, int, int);
extern unsigned char __stdcall PostMessageW(void *, unsigned int, void *,
void *);
extern void __stdcall PostQuitMessage(int);
extern void *__stdcall RegisterClassW(const WNDCLASS *);
extern void *__stdcall RegisterClassW(const WNDCLASSW *);
extern unsigned char __stdcall ResetEvent(void *);
extern unsigned char __stdcall TranslateMessage(const MSG *);
@@ -337,7 +337,7 @@ Tcl_InitNotifier(void)
*/
if (tsdPtr->waitCVinitialized == 0) {
#ifdef __CYGWIN__
WNDCLASS class;
WNDCLASSW class;
class.style = 0;
class.cbClsExtra = 0;
+8 -8
View File
@@ -82,7 +82,7 @@ CFLAGS_OPTIMIZE = @CFLAGS_OPTIMIZE@
#CFLAGS = $(CFLAGS_DEBUG)
#CFLAGS = $(CFLAGS_OPTIMIZE)
#CFLAGS = $(CFLAGS_DEBUG) $(CFLAGS_OPTIMIZE)
CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ -DUNICODE -D_UNICODE -D_ATL_XP_TARGETING
CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ -D_ATL_XP_TARGETING
# To compile without backward compatibility and deprecated code uncomment the
# following
@@ -270,8 +270,8 @@ GENERIC_OBJS = \
tclLiteral.$(OBJEXT) \
tclListObj.$(OBJEXT) \
tclLoad.$(OBJEXT) \
tclMainW.$(OBJEXT) \
tclMain.$(OBJEXT) \
tclMain2.$(OBJEXT) \
tclNamesp.$(OBJEXT) \
tclNotify.$(OBJEXT) \
tclOO.$(OBJEXT) \
@@ -473,7 +473,7 @@ $(TCLSH): $(TCLSH_OBJS) @LIBRARIES@ $(TCL_STUB_LIB_FILE) tclsh.$(RES)
@VC_MANIFEST_EMBED_EXE@
cat32.$(OBJEXT): cat.c
$(CC) -c $(CC_SWITCHES) @DEPARG@ $(CC_OBJNAME)
$(CC) -c $(CC_SWITCHES) -DUNICODE -D_UNICODE @DEPARG@ $(CC_OBJNAME)
$(CAT32): cat32.$(OBJEXT)
$(CC) $(CFLAGS) cat32.$(OBJEXT) $(CC_EXENAME) $(LIBS) $(LDFLAGS_CONSOLE)
@@ -534,7 +534,7 @@ ${ZLIB_DLL_FILE}: ${TCL_STUB_LIB_FILE}
# Special case object targets
tclTestMain.${OBJEXT}: tclAppInit.c
$(CC) -c $(CC_SWITCHES) -DTCL_TEST -DBUILD_tcl $(EXTFLAGS) $(CC_OBJNAME) $(WIN_DIR)/tclAppInit.c
$(CC) -c $(CC_SWITCHES) -DTCL_TEST -DUNICODE -D_UNICODE $(EXTFLAGS) @DEPARG@ $(CC_OBJNAME)
tclWinInit.${OBJEXT}: tclWinInit.c
$(CC) -c $(CC_SWITCHES) -DBUILD_tcl $(EXTFLAGS) @DEPARG@ $(CC_OBJNAME)
@@ -548,11 +548,11 @@ tclWinReg.${OBJEXT}: tclWinReg.c
tclWinDde.${OBJEXT}: tclWinDde.c
$(CC) -c $(CC_SWITCHES) $(EXTFLAGS) @DEPARG@ $(CC_OBJNAME)
testMain.${OBJEXT}: tclAppInit.c
$(CC) -c $(CC_SWITCHES) -DTCL_TEST @DEPARG@ $(CC_OBJNAME)
tclAppInit.${OBJEXT}: tclAppInit.c
$(CC) -c $(CC_SWITCHES) $(EXTFLAGS) -DUNICODE -D_UNICODE @DEPARG@ $(CC_OBJNAME)
tclMain2.${OBJEXT}: tclMain.c
$(CC) -c $(CC_SWITCHES) -DBUILD_tcl -DTCL_ASCII_MAIN @DEPARG@ $(CC_OBJNAME)
tclMainW.${OBJEXT}: tclMain.c
$(CC) -c $(CC_SWITCHES) -DBUILD_tcl -DUNICODE -D_UNICODE @DEPARG@ $(CC_OBJNAME)
# TIP #59, embedding of configuration information into the binary library.
#
+24 -32
View File
@@ -260,8 +260,8 @@ COREOBJS = \
$(TMP_DIR)\tclListObj.obj \
$(TMP_DIR)\tclLiteral.obj \
$(TMP_DIR)\tclLoad.obj \
$(TMP_DIR)\tclMainW.obj \
$(TMP_DIR)\tclMain.obj \
$(TMP_DIR)\tclMain2.obj \
$(TMP_DIR)\tclNamesp.obj \
$(TMP_DIR)\tclNotify.obj \
$(TMP_DIR)\tclOO.obj \
@@ -420,7 +420,7 @@ PKGSDIR = $(ROOT)\pkgs
# Additional include and C macro definitions for the implicit rules
# defined in rules.vc
PRJ_INCLUDES = -I"$(TOMMATHDIR)"
PRJ_DEFINES = -DTCL_TOMMATH -DMP_PREC=4 -Dinline=__inline -DHAVE_ZLIB=1 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
PRJ_DEFINES = /DTCL_TOMMATH /DMP_PREC=4 /Dinline=__inline /DHAVE_ZLIB=1 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE
# Additional Link libraries needed beyond those in rules.vc
PRJ_LIBS = netapi32.lib user32.lib userenv.lib ws2_32.lib
@@ -547,7 +547,8 @@ clean-pkgs:
)
$(CAT32): $(WIN_DIR)\cat.c
$(cc32) $(cflags) $(crt) -D_CRT_NONSTDC_NO_DEPRECATE -DCONSOLE -Fo$(TMP_DIR)\ $?
$(cc32) $(cflags) $(crt) /D_CRT_NONSTDC_NO_DEPRECATE /DCONSOLE \
/DUNICODE /D_UNICODE -Fo$(TMP_DIR)\ $?
$(CONEXECMD) -stack:16384 $(TMP_DIR)\cat.obj
$(_VC_MANIFEST_EMBED_EXE)
@@ -646,7 +647,6 @@ CORE_MACHINE = $(MACHINE)
CORE_DEBUG = $(DEBUG)
CORE_TCL_THREADS = $(TCL_THREADS)
CORE_USE_THREAD_ALLOC = $(USE_THREAD_ALLOC)
CORE_USE_WIDECHAR_API = $(USE_WIDECHAR_API)
<<
#---------------------------------------------------------------------
@@ -733,12 +733,12 @@ gendate:
#---------------------------------------------------------------------
$(TMP_DIR)\testMain.obj: $(WIN_DIR)\tclAppInit.c
$(cc32) $(appcflags) -DTCL_TEST \
-DTCL_USE_STATIC_PACKAGES=$(TCL_USE_STATIC_PACKAGES) \
$(cc32) $(appcflags) /DTCL_TEST /DUNICODE /D_UNICODE \
/DTCL_USE_STATIC_PACKAGES=$(TCL_USE_STATIC_PACKAGES) \
-Fo$@ $?
$(TMP_DIR)\tclMain2.obj: $(GENERICDIR)\tclMain.c
$(cc32) $(pkgcflags) -DTCL_ASCII_MAIN \
$(TMP_DIR)\tclMainW.obj: $(GENERICDIR)\tclMain.c
$(cc32) $(pkgcflags) /DUNICODE /D_UNICODE \
-Fo$@ $?
$(TMP_DIR)\tclTest.obj: $(GENERICDIR)\tclTest.c
@@ -755,40 +755,32 @@ $(TMP_DIR)\tclZlib.obj: $(GENERICDIR)\tclZlib.c
$(TMP_DIR)\tclPkgConfig.obj: $(GENERICDIR)\tclPkgConfig.c
$(cc32) $(pkgcflags) \
-DCFG_INSTALL_LIBDIR="\"$(LIB_INSTALL_DIR:\=\\)\"" \
-DCFG_INSTALL_BINDIR="\"$(BIN_INSTALL_DIR:\=\\)\"" \
-DCFG_INSTALL_SCRDIR="\"$(SCRIPT_INSTALL_DIR:\=\\)\"" \
-DCFG_INSTALL_INCDIR="\"$(INCLUDE_INSTALL_DIR:\=\\)\"" \
-DCFG_INSTALL_DOCDIR="\"$(DOC_INSTALL_DIR:\=\\)\"" \
-DCFG_RUNTIME_LIBDIR="\"$(LIB_INSTALL_DIR:\=\\)\"" \
-DCFG_RUNTIME_BINDIR="\"$(BIN_INSTALL_DIR:\=\\)\"" \
-DCFG_RUNTIME_SCRDIR="\"$(SCRIPT_INSTALL_DIR:\=\\)\"" \
-DCFG_RUNTIME_INCDIR="\"$(INCLUDE_INSTALL_DIR:\=\\)\"" \
-DCFG_RUNTIME_DOCDIR="\"$(DOC_INSTALL_DIR:\=\\)\"" \
/DCFG_INSTALL_LIBDIR="\"$(LIB_INSTALL_DIR:\=\\)\"" \
/DCFG_INSTALL_BINDIR="\"$(BIN_INSTALL_DIR:\=\\)\"" \
/DCFG_INSTALL_SCRDIR="\"$(SCRIPT_INSTALL_DIR:\=\\)\"" \
/DCFG_INSTALL_INCDIR="\"$(INCLUDE_INSTALL_DIR:\=\\)\"" \
/DCFG_INSTALL_DOCDIR="\"$(DOC_INSTALL_DIR:\=\\)\"" \
/DCFG_RUNTIME_LIBDIR="\"$(LIB_INSTALL_DIR:\=\\)\"" \
/DCFG_RUNTIME_BINDIR="\"$(BIN_INSTALL_DIR:\=\\)\"" \
/DCFG_RUNTIME_SCRDIR="\"$(SCRIPT_INSTALL_DIR:\=\\)\"" \
/DCFG_RUNTIME_INCDIR="\"$(INCLUDE_INSTALL_DIR:\=\\)\"" \
/DCFG_RUNTIME_DOCDIR="\"$(DOC_INSTALL_DIR:\=\\)\"" \
-Fo$@ $?
$(TMP_DIR)\tclAppInit.obj: $(WIN_DIR)\tclAppInit.c
$(cc32) $(appcflags) \
-DTCL_USE_STATIC_PACKAGES=$(TCL_USE_STATIC_PACKAGES) \
$(cc32) $(appcflags) /DUNICODE /D_UNICODE \
/DTCL_USE_STATIC_PACKAGES=$(TCL_USE_STATIC_PACKAGES) \
-Fo$@ $?
### The following objects should be built using the stub interfaces
### *ALL* extensions need to built with -DTCL_THREADS=1
### *ALL* extensions need to built with /DTCL_THREADS=1
$(TMP_DIR)\tclWinReg.obj: $(WIN_DIR)\tclWinReg.c
!if $(STATIC_BUILD)
$(cc32) $(appcflags) -DSTATIC_BUILD -Fo$@ $?
!else
$(cc32) $(appcflags) -DUSE_TCL_STUBS -Fo$@ $?
!endif
$(cc32) $(appcflags) /DUSE_TCL_STUBS -Fo$@ $?
$(TMP_DIR)\tclWinDde.obj: $(WIN_DIR)\tclWinDde.c
!if $(STATIC_BUILD)
$(cc32) $(appcflags) -DSTATIC_BUILD -Fo$@ $?
!else
$(cc32) $(appcflags) -DUSE_TCL_STUBS -Fo$@ $?
!endif
$(cc32) $(appcflags) /DUSE_TCL_STUBS -Fo$@ $?
### The following objects are part of the stub library and should not
@@ -823,7 +815,7 @@ depend:
@echo Build tclsh first!
!else
$(TCLSH) $(TOOLSDIR:\=/)/mkdepend.tcl -vc32 -out:"$(OUT_DIR)\depend.mk" \
-passthru:"-DBUILD_tcl $(TCL_INCLUDES) $(PRJ_INCLUDES)" $(GENERICDIR),$$(GENERICDIR) \
-passthru:"/DBUILD_tcl $(TCL_INCLUDES) $(PRJ_INCLUDES)" $(GENERICDIR),$$(GENERICDIR) \
$(COMPATDIR),$$(COMPATDIR) $(TOMMATHDIR),$$(TOMMATHDIR) $(WIN_DIR),$$(WIN_DIR) @<<
$(TCLOBJS)
<<
+31 -48
View File
@@ -1277,86 +1277,69 @@ INCLUDE_INSTALL_DIR = $(_INSTALLDIR)\..\include
# baselibs - minimum Windows libraries required. Parent makefile can
# define PRJ_LIBS before including rules.rc if additional libs are needed
OPTDEFINES = -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) -DSTDC_HEADERS
OPTDEFINES = /DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) /DSTDC_HEADERS
!if $(TCL_MEM_DEBUG)
OPTDEFINES = $(OPTDEFINES) -DTCL_MEM_DEBUG
OPTDEFINES = $(OPTDEFINES) /DTCL_MEM_DEBUG
!endif
!if $(TCL_COMPILE_DEBUG)
OPTDEFINES = $(OPTDEFINES) -DTCL_COMPILE_DEBUG -DTCL_COMPILE_STATS
OPTDEFINES = $(OPTDEFINES) /DTCL_COMPILE_DEBUG /DTCL_COMPILE_STATS
!endif
!if $(TCL_THREADS) && $(TCL_VERSION) < 87
OPTDEFINES = $(OPTDEFINES) -DTCL_THREADS=1
OPTDEFINES = $(OPTDEFINES) /DTCL_THREADS=1
!if $(USE_THREAD_ALLOC) && $(TCL_VERSION) < 87
OPTDEFINES = $(OPTDEFINES) -DUSE_THREAD_ALLOC=1
OPTDEFINES = $(OPTDEFINES) /DUSE_THREAD_ALLOC=1
!endif
!endif
!if $(STATIC_BUILD)
OPTDEFINES = $(OPTDEFINES) -DSTATIC_BUILD
OPTDEFINES = $(OPTDEFINES) /DSTATIC_BUILD
!endif
!if $(TCL_NO_DEPRECATED)
OPTDEFINES = $(OPTDEFINES) -DTCL_NO_DEPRECATED
OPTDEFINES = $(OPTDEFINES) /DTCL_NO_DEPRECATED
!endif
!if $(USE_STUBS)
# Note we do not define USE_TCL_STUBS even when building tk since some
# test targets in tk do not use stubs
!if ! $(DOING_TCL)
USE_STUBS_DEFS = -DUSE_TCL_STUBS -DUSE_TCLOO_STUBS
USE_STUBS_DEFS = /DUSE_TCL_STUBS /DUSE_TCLOO_STUBS
!if $(NEED_TK)
USE_STUBS_DEFS = $(USE_STUBS_DEFS) -DUSE_TK_STUBS
USE_STUBS_DEFS = $(USE_STUBS_DEFS) /DUSE_TK_STUBS
!endif
!endif
!endif # USE_STUBS
!if !$(DEBUG)
OPTDEFINES = $(OPTDEFINES) -DNDEBUG
OPTDEFINES = $(OPTDEFINES) /DNDEBUG
!if $(OPTIMIZING)
OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_OPTIMIZED
OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_OPTIMIZED
!endif
!endif
!if $(PROFILE)
OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_PROFILED
OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_PROFILED
!endif
!if "$(MACHINE)" == "AMD64"
OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT
OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_DO64BIT
!endif
!if $(VCVERSION) < 1300
OPTDEFINES = $(OPTDEFINES) -DNO_STRTOI64
OPTDEFINES = $(OPTDEFINES) /DNO_STRTOI64
!endif
!if "$(_USE_64BIT_TIME_T)" == "1"
OPTDEFINES = $(OPTDEFINES) -D_USE_64BIT_TIME_T
OPTDEFINES = $(OPTDEFINES) /D_USE_64BIT_TIME_T
!endif
# _ATL_XP_TARGETING - Newer SDK's need this to build for XP
COMPILERFLAGS = /D_ATL_XP_TARGETING
# Following is primarily for the benefit of extensions. Tcl 8.5 builds
# Tcl without /DUNICODE, while 8.6 builds with it defined. When building
# an extension, it is advisable (but not mandated) to use the same Windows
# API as the Tcl build. This is accordingly defaulted below. A particular
# extension can override this by pre-definining USE_WIDECHAR_API.
!ifndef USE_WIDECHAR_API
!if $(TCL_VERSION) > 85
USE_WIDECHAR_API = 1
!else
USE_WIDECHAR_API = 0
!endif
!endif
!if $(USE_WIDECHAR_API)
COMPILERFLAGS = $(COMPILERFLAGS) /DUNICODE /D_UNICODE
!endif
# Like the TEA system only set this non empty for non-Tk extensions
# Note: some extensions use PACKAGE_NAME and others use PACKAGE_TCLNAME
# so we pass both
!if !$(DOING_TCL) && !$(DOING_TK)
PKGNAMEFLAGS = -DPACKAGE_NAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \
-DPACKAGE_TCLNAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \
-DPACKAGE_VERSION="\"$(DOTVERSION)\"" \
-DMODULE_SCOPE=extern
PKGNAMEFLAGS = /DPACKAGE_NAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \
/DPACKAGE_TCLNAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \
/DPACKAGE_VERSION="\"$(DOTVERSION)\"" \
/DMODULE_SCOPE=extern
!endif
# crt picks the C run time based on selected OPTS
@@ -1403,7 +1386,7 @@ cwarn = $(cwarn) -wd4311 -wd4312
### Common compiler options that are architecture specific
!if "$(MACHINE)" == "ARM"
carch = -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
carch = /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
!else
carch =
!endif
@@ -1433,11 +1416,11 @@ cflags = -nologo -c $(COMPILERFLAGS) $(carch) $(cwarn) -Fp$(TMP_DIR)^\ $(cdebug)
appcflags_nostubs = $(cflags) $(crt) $(INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES)
appcflags = $(appcflags_nostubs) $(USE_STUBS_DEFS)
pkgcflags = $(appcflags) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT)
pkgcflags_nostubs = $(appcflags_nostubs) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT)
pkgcflags = $(appcflags) $(PKGNAMEFLAGS) /DBUILD_$(PROJECT)
pkgcflags_nostubs = $(appcflags_nostubs) $(PKGNAMEFLAGS) /DBUILD_$(PROJECT)
# stubscflags contains $(cflags) plus flags used for building a stubs
# library for the package. Note: -DSTATIC_BUILD is defined in
# library for the package. Note: /DSTATIC_BUILD is defined in
# $(OPTDEFINES) only if the OPTS configuration indicates a static
# library. However the stubs library is ALWAYS static hence included
# here irrespective of the OPTS setting.
@@ -1447,7 +1430,7 @@ pkgcflags_nostubs = $(appcflags_nostubs) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT)
# so we do not remove it from cflags. -GL may prevent extensions
# compiled with one VC version to fail to link against stubs library
# compiled with another VC version. Check for this and fix accordingly.
stubscflags = $(cflags) $(PKGNAMEFLAGS) $(PRJ_DEFINES) $(OPTDEFINES) -Zl -DSTATIC_BUILD $(INCLUDES) $(USE_STUBS_DEFS)
stubscflags = $(cflags) $(PKGNAMEFLAGS) $(PRJ_DEFINES) $(OPTDEFINES) -Zl /DSTATIC_BUILD $(INCLUDES) $(USE_STUBS_DEFS)
# Link flags
@@ -1524,13 +1507,13 @@ CONEXECMD = $(link32) $(conlflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs)
GUIEXECMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs)
RESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \
$(TCL_INCLUDES) \
-DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \
-DCOMMAVERSION=$(DOTVERSION:.=,),0 \
-DDOTVERSION=\"$(DOTVERSION)\" \
-DVERSION=\"$(VERSION)\" \
-DSUFX=\"$(SUFX)\" \
-DPROJECT=\"$(PROJECT)\" \
-DPRJLIBNAME=\"$(PRJLIBNAME)\"
/DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \
/DCOMMAVERSION=$(DOTVERSION:.=,),0 \
/DDOTVERSION=\"$(DOTVERSION)\" \
/DVERSION=\"$(VERSION)\" \
/DSUFX=\"$(SUFX)\" \
/DPROJECT=\"$(PROJECT)\" \
/DPRJLIBNAME=\"$(PRJLIBNAME)\"
!ifndef DEFAULT_BUILD_TARGET
DEFAULT_BUILD_TARGET = $(PROJECT)
+24 -22
View File
@@ -47,8 +47,8 @@ BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason,
*/
typedef struct MountPointMap {
TCHAR *volumeName; /* Native wide string volume name. */
TCHAR driveLetter; /* Drive letter corresponding to the volume
WCHAR *volumeName; /* Native wide string volume name. */
WCHAR driveLetter; /* Drive letter corresponding to the volume
* name. */
struct MountPointMap *nextPtr;
/* Pointer to next structure in list, or
@@ -120,6 +120,8 @@ DllMain(
DWORD reason, /* Reason this function is being called. */
LPVOID reserved) /* Not used. */
{
(void)reserved;
switch (reason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hInst);
@@ -362,11 +364,11 @@ TclWinResetInterfaces(void)
char
TclWinDriveLetterForVolMountPoint(
const TCHAR *mountPoint)
const WCHAR *mountPoint)
{
MountPointMap *dlIter, *dlPtr2;
TCHAR Target[55]; /* Target of mount at mount point */
TCHAR drive[4] = TEXT("A:\\");
WCHAR Target[55]; /* Target of mount at mount point */
WCHAR drive[4] = L"A:\\";
/*
* Detect the volume mounted there. Unfortunately, there is no simple way
@@ -377,22 +379,22 @@ TclWinDriveLetterForVolMountPoint(
Tcl_MutexLock(&mountPointMap);
dlIter = driveLetterLookup;
while (dlIter != NULL) {
if (_tcscmp(dlIter->volumeName, mountPoint) == 0) {
if (wcscmp(dlIter->volumeName, mountPoint) == 0) {
/*
* We need to check whether this information is still valid, since
* either the user or various programs could have adjusted the
* mount points on the fly.
*/
drive[0] = (TCHAR) dlIter->driveLetter;
drive[0] = (WCHAR) dlIter->driveLetter;
/*
* Try to read the volume mount point and see where it points.
*/
if (GetVolumeNameForVolumeMountPoint(drive,
if (GetVolumeNameForVolumeMountPointW(drive,
Target, 55) != 0) {
if (_tcscmp(dlIter->volumeName, Target) == 0) {
if (wcscmp(dlIter->volumeName, Target) == 0) {
/*
* Nothing has changed.
*/
@@ -449,13 +451,13 @@ TclWinDriveLetterForVolMountPoint(
* Try to read the volume mount point and see where it points.
*/
if (GetVolumeNameForVolumeMountPoint(drive,
if (GetVolumeNameForVolumeMountPointW(drive,
Target, 55) != 0) {
int alreadyStored = 0;
for (dlIter = driveLetterLookup; dlIter != NULL;
dlIter = dlIter->nextPtr) {
if (_tcscmp(dlIter->volumeName, Target) == 0) {
if (wcscmp(dlIter->volumeName, Target) == 0) {
alreadyStored = 1;
break;
}
@@ -476,7 +478,7 @@ TclWinDriveLetterForVolMountPoint(
for (dlIter = driveLetterLookup; dlIter != NULL;
dlIter = dlIter->nextPtr) {
if (_tcscmp(dlIter->volumeName, mountPoint) == 0) {
if (wcscmp(dlIter->volumeName, mountPoint) == 0) {
Tcl_MutexUnlock(&mountPointMap);
return (char) dlIter->driveLetter;
}
@@ -523,7 +525,7 @@ TclWinDriveLetterForVolMountPoint(
* nativeBuffer <- UtfToExternal(encoding, utfBuffer);
* Tcl_FreeEncoding(encoding);
*
* By convention, in Windows a TCHAR is a Unicode character. If you plan
* By convention, in Windows a WCHAR is a Unicode character. If you plan
* on targeting a Unicode interface when running on Windows, these
* functions should be used. If you plan on targetting a "char" oriented
* function on Windows, use Tcl_UtfToExternal() with an encoding of NULL.
@@ -581,8 +583,8 @@ Tcl_WinUtfToTChar(
while (p < end) {
p += TclUtfToUniChar(p, &ch);
if (ch > 0xFFFF) {
*w++ = (wchar_t) (0xD800 + ((ch -= 0x10000) >> 10));
*w++ = (wchar_t) (0xDC00 | (ch & 0x3FF));
*w++ = (WCHAR) (0xD800 + ((ch -= 0x10000) >> 10));
*w++ = (WCHAR) (0xDC00 | (ch & 0x3FF));
} else {
*w++ = ch;
}
@@ -595,8 +597,8 @@ Tcl_WinUtfToTChar(
ch = UCHAR(*p++);
}
if (ch > 0xFFFF) {
*w++ = (wchar_t) (0xD800 + ((ch -= 0x10000) >> 10));
*w++ = (wchar_t) (0xDC00 | (ch & 0x3FF));
*w++ = (WCHAR) (0xD800 + ((ch -= 0x10000) >> 10));
*w++ = (WCHAR) (0xDC00 | (ch & 0x3FF));
} else {
*w++ = ch;
}
@@ -607,7 +609,7 @@ Tcl_WinUtfToTChar(
return wString;
#else
return Tcl_UtfToUniCharDString(string, len, dsPtr);
return (TCHAR *)Tcl_UtfToUniCharDString(string, len, dsPtr);
#endif
}
@@ -620,7 +622,7 @@ Tcl_WinTCharToUtf(
* converted string is stored. */
{
#if TCL_UTF_MAX > 4
const TCHAR *w, *wEnd;
const WCHAR *w, *wEnd;
char *p, *result;
int oldLength, blen = 1;
#endif
@@ -630,7 +632,7 @@ Tcl_WinTCharToUtf(
return NULL;
}
if (len < 0) {
len = wcslen((TCHAR *)string);
len = wcslen((WCHAR *)string);
} else {
len /= 2;
}
@@ -640,8 +642,8 @@ Tcl_WinTCharToUtf(
result = Tcl_DStringValue(dsPtr) + oldLength;
p = result;
wEnd = (TCHAR *)string + len;
for (w = (TCHAR *)string; w < wEnd; ) {
wEnd = (WCHAR *)string + len;
for (w = (WCHAR *)string; w < wEnd; ) {
if (!blen && ((*w & 0xFC00) != 0xDC00)) {
/* Special case for handling high surrogates. */
p += Tcl_UniCharToUtf(-1, p);
+5 -5
View File
@@ -95,7 +95,7 @@ static void FileThreadActionProc(ClientData instanceData,
static int FileTruncateProc(ClientData instanceData,
Tcl_WideInt length);
static DWORD FileGetType(HANDLE handle);
static int NativeIsComPort(const TCHAR *nativeName);
static int NativeIsComPort(const WCHAR *nativeName);
/*
* This structure describes the channel type structure for file based IO.
*/
@@ -836,7 +836,7 @@ TclpOpenFileChannel(
Tcl_Channel channel = 0;
int channelPermissions = 0;
DWORD accessMode = 0, createMode, shareMode, flags;
const TCHAR *nativeName;
const WCHAR *nativeName;
HANDLE handle;
char channelName[16 + TCL_INTEGER_SPACE];
TclFile readFile = NULL, writeFile = NULL;
@@ -932,7 +932,7 @@ TclpOpenFileChannel(
flags = FILE_ATTRIBUTE_READONLY;
}
} else {
flags = GetFileAttributes(nativeName);
flags = GetFileAttributesW(nativeName);
if (flags == 0xFFFFFFFF) {
flags = 0;
}
@@ -948,7 +948,7 @@ TclpOpenFileChannel(
* Now we get to create the file.
*/
handle = CreateFile(nativeName, accessMode, shareMode,
handle = CreateFileW(nativeName, accessMode, shareMode,
NULL, createMode, flags, (HANDLE) NULL);
if (handle == INVALID_HANDLE_VALUE) {
@@ -1540,7 +1540,7 @@ FileGetType(
static int
NativeIsComPort(
const TCHAR *nativePath) /* Path of file to access, native encoding. */
const WCHAR *nativePath) /* Path of file to access, native encoding. */
{
const WCHAR *p = (const WCHAR *) nativePath;
int i, len = wcslen(p);
+9 -15
View File
@@ -193,8 +193,8 @@ static const Tcl_ChannelType consoleChannelType = {
*
* ReadConsoleBytes, WriteConsoleBytes --
*
* Wrapper for ReadConsole{A,W}, that takes and returns number of bytes
* instead of number of TCHARS.
* Wrapper for ReadConsoleW, that takes and returns number of bytes
* instead of number of WCHARS.
*
*----------------------------------------------------------------------
*/
@@ -208,7 +208,6 @@ ReadConsoleBytes(
{
DWORD ntchars;
BOOL result;
int tcharsize = sizeof(TCHAR);
/*
* If user types a Ctrl-Break or Ctrl-C, ReadConsole will return
@@ -221,11 +220,11 @@ ReadConsoleBytes(
* will run and take whatever action it deems appropriate.
*/
do {
result = ReadConsole(hConsole, lpBuffer, nbytes / tcharsize, &ntchars,
result = ReadConsoleW(hConsole, lpBuffer, nbytes / sizeof(WCHAR), &ntchars,
NULL);
} while (result && ntchars == 0 && GetLastError() == ERROR_OPERATION_ABORTED);
if (nbytesread != NULL) {
*nbytesread = ntchars * tcharsize;
*nbytesread = ntchars * sizeof(WCHAR);
}
return result;
}
@@ -239,12 +238,11 @@ WriteConsoleBytes(
{
DWORD ntchars;
BOOL result;
int tcharsize = sizeof(TCHAR);
result = WriteConsole(hConsole, lpBuffer, nbytes / tcharsize, &ntchars,
result = WriteConsoleW(hConsole, lpBuffer, nbytes / sizeof(WCHAR), &ntchars,
NULL);
if (nbyteswritten != NULL) {
*nbyteswritten = ntchars * tcharsize;
*nbyteswritten = ntchars * sizeof(WCHAR);
}
return result;
}
@@ -1037,7 +1035,7 @@ WaitForRead(
return 1;
}
if (PeekConsoleInput(handle, &input, 1, &count) == FALSE) {
if (PeekConsoleInputW(handle, &input, 1, &count) == FALSE) {
/*
* Check to see if the peek failed because of EOF.
*/
@@ -1337,7 +1335,7 @@ TclWinOpenConsoleChannel(
modes |= ENABLE_LINE_INPUT;
SetConsoleMode(infoPtr->handle, modes);
infoPtr->reader.readyEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
infoPtr->reader.readyEvent = CreateEventW(NULL, TRUE, TRUE, NULL);
infoPtr->reader.thread = CreateThread(NULL, 256, ConsoleReaderThread,
TclPipeThreadCreateTI(&infoPtr->reader.TI, infoPtr,
infoPtr->reader.readyEvent), 0, NULL);
@@ -1346,7 +1344,7 @@ TclWinOpenConsoleChannel(
if (permissions & TCL_WRITABLE) {
infoPtr->writer.readyEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
infoPtr->writer.readyEvent = CreateEventW(NULL, TRUE, TRUE, NULL);
infoPtr->writer.thread = CreateThread(NULL, 256, ConsoleWriterThread,
TclPipeThreadCreateTI(&infoPtr->writer.TI, infoPtr,
infoPtr->writer.readyEvent), 0, NULL);
@@ -1360,11 +1358,7 @@ TclWinOpenConsoleChannel(
Tcl_SetChannelOption(NULL, infoPtr->channel, "-translation", "auto");
Tcl_SetChannelOption(NULL, infoPtr->channel, "-eofchar", "\032 {}");
#ifdef UNICODE
Tcl_SetChannelOption(NULL, infoPtr->channel, "-encoding", "unicode");
#else
Tcl_SetChannelOption(NULL, infoPtr->channel, "-encoding", encoding);
#endif
return infoPtr->channel;
}
+166 -127
View File
@@ -34,7 +34,7 @@ typedef struct RegisteredInterp {
struct RegisteredInterp *nextPtr;
/* The next interp this application knows
* about. */
TCHAR *name; /* Interpreter's name (malloc-ed). */
WCHAR *name; /* Interpreter's name (malloc-ed). */
Tcl_Obj *handlerPtr; /* The server handler command */
Tcl_Interp *interp; /* The interpreter attached to this name. */
} RegisteredInterp;
@@ -81,8 +81,8 @@ static int ddeIsServer = 0;
#define TCL_DDE_VERSION "1.4.1"
#define TCL_DDE_PACKAGE_NAME "dde"
#define TCL_DDE_SERVICE_NAME TEXT("TclEval")
#define TCL_DDE_EXECUTE_RESULT TEXT("$TCLEVAL$EXECUTE$RESULT")
#define TCL_DDE_SERVICE_NAME L"TclEval"
#define TCL_DDE_EXECUTE_RESULT L"$TCLEVAL$EXECUTE$RESULT"
#define DDE_FLAG_ASYNC 1
#define DDE_FLAG_BINARY 2
@@ -99,24 +99,34 @@ static LRESULT CALLBACK DdeClientWindowProc(HWND hwnd, UINT uMsg,
static int DdeCreateClient(DdeEnumServices *es);
static BOOL CALLBACK DdeEnumWindowsCallback(HWND hwndTarget,
LPARAM lParam);
static void DdeExitProc(ClientData clientData);
static void DdeExitProc(void *clientData);
static int DdeGetServicesList(Tcl_Interp *interp,
const TCHAR *serviceName, const TCHAR *topicName);
const WCHAR *serviceName, const WCHAR *topicName);
static HDDEDATA CALLBACK DdeServerProc(UINT uType, UINT uFmt, HCONV hConv,
HSZ ddeTopic, HSZ ddeItem, HDDEDATA hData,
DWORD dwData1, DWORD dwData2);
static LRESULT DdeServicesOnAck(HWND hwnd, WPARAM wParam,
LPARAM lParam);
static void DeleteProc(ClientData clientData);
static void DeleteProc(void *clientData);
static Tcl_Obj * ExecuteRemoteObject(RegisteredInterp *riPtr,
Tcl_Obj *ddeObjectPtr);
static int MakeDdeConnection(Tcl_Interp *interp,
const TCHAR *name, HCONV *ddeConvPtr);
const WCHAR *name, HCONV *ddeConvPtr);
static void SetDdeError(Tcl_Interp *interp);
static int DdeObjCmd(ClientData clientData,
static int DdeObjCmd(void *clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
#if (TCL_MAJOR_VERSION < 9) && (TCL_MINOR_VERSION < 7)
# if TCL_UTF_MAX > 3
# define Tcl_WCharToUtfDString(a,b,c) Tcl_WinTCharToUtf(a,(b)*sizeof(WCHAR),c)
# define Tcl_UtfToWCharDString(a,b,c) Tcl_WinUtfToTChar(a,b,c)
# else
# define Tcl_WCharToUtfDString Tcl_UniCharToUtfDString
# define Tcl_UtfToWCharDString Tcl_UtfToUniCharDString
# endif
#endif
static unsigned char *
getByteArrayFromObj(
Tcl_Obj *objPtr,
@@ -136,8 +146,14 @@ getByteArrayFromObj(
return result;
}
#ifdef __cplusplus
extern "C" {
#endif
DLLEXPORT int Dde_Init(Tcl_Interp *interp);
DLLEXPORT int Dde_SafeInit(Tcl_Interp *interp);
#ifdef __cplusplus
}
#endif
/*
*----------------------------------------------------------------------
@@ -159,13 +175,13 @@ int
Dde_Init(
Tcl_Interp *interp)
{
if (!Tcl_InitStubs(interp, "8.1", 0)) {
if (!Tcl_InitStubs(interp, "8.5-", 0)) {
return TCL_ERROR;
}
Tcl_CreateObjCommand(interp, "dde", DdeObjCmd, NULL, NULL);
Tcl_CreateExitHandler(DdeExitProc, NULL);
return Tcl_PkgProvide(interp, TCL_DDE_PACKAGE_NAME, TCL_DDE_VERSION);
return Tcl_PkgProvideEx(interp, TCL_DDE_PACKAGE_NAME, TCL_DDE_VERSION, NULL);
}
/*
@@ -235,7 +251,7 @@ Initialize(void)
if (ddeInstance == 0) {
Tcl_MutexLock(&ddeMutex);
if (ddeInstance == 0) {
if (DdeInitialize(&ddeInstance, (PFNCALLBACK) DdeServerProc,
if (DdeInitializeW(&ddeInstance, (PFNCALLBACK) DdeServerProc,
CBF_SKIP_REGISTRATIONS | CBF_SKIP_UNREGISTRATIONS
| CBF_FAIL_POKES, 0) != DMLERR_NO_ERROR) {
ddeInstance = 0;
@@ -248,7 +264,7 @@ Initialize(void)
if ((ddeServiceGlobal == 0) && (nameFound != 0)) {
ddeIsServer = 1;
Tcl_CreateExitHandler(DdeExitProc, NULL);
ddeServiceGlobal = DdeCreateStringHandle(ddeInstance,
ddeServiceGlobal = DdeCreateStringHandleW(ddeInstance,
TCL_DDE_SERVICE_NAME, CP_WINUNICODE);
DdeNameService(ddeInstance, ddeServiceGlobal, 0L, DNS_REGISTER);
} else {
@@ -283,10 +299,10 @@ Initialize(void)
*----------------------------------------------------------------------
*/
static const TCHAR *
static const WCHAR *
DdeSetServerName(
Tcl_Interp *interp,
const TCHAR *name, /* The name that will be used to refer to the
const WCHAR *name, /* The name that will be used to refer to the
* interpreter in later "send" commands. Must
* be globally unique. */
int flags, /* DDE_FLAG_FORCE or 0 */
@@ -296,7 +312,7 @@ DdeSetServerName(
int suffix, offset;
RegisteredInterp *riPtr, *prevPtr;
Tcl_DString dString;
const TCHAR *actualName;
const WCHAR *actualName;
Tcl_Obj *srvListPtr = NULL, **srvPtrPtr = NULL;
int n, srvCount = 0, lastSuffix, r = TCL_OK;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
@@ -334,7 +350,7 @@ DdeSetServerName(
* current interp, but it doesn't have a name.
*/
return TEXT("");
return L"";
}
/*
@@ -355,8 +371,8 @@ DdeSetServerName(
&srvPtrPtr);
}
if (r != TCL_OK) {
Tcl_WinUtfToTChar(Tcl_GetStringResult(interp), -1, &dString);
OutputDebugString((TCHAR *) Tcl_DStringValue(&dString));
Tcl_DStringInit(&dString);
OutputDebugStringW(Tcl_UtfToWCharDString(Tcl_GetString(Tcl_GetObjResult(interp)), -1, &dString));
Tcl_DStringFree(&dString);
return NULL;
}
@@ -374,14 +390,14 @@ DdeSetServerName(
lastSuffix = suffix;
if (suffix > 1) {
if (suffix == 2) {
Tcl_DStringAppend(&dString, (char *)name, _tcslen(name) * sizeof(TCHAR));
Tcl_DStringAppend(&dString, (char *)TEXT(" #"), 2 * sizeof(TCHAR));
Tcl_DStringAppend(&dString, (char *)name, wcslen(name) * sizeof(WCHAR));
Tcl_DStringAppend(&dString, (char *)L" #", 2 * sizeof(WCHAR));
offset = Tcl_DStringLength(&dString);
Tcl_DStringSetLength(&dString, offset + sizeof(TCHAR) * TCL_INTEGER_SPACE);
actualName = (TCHAR *) Tcl_DStringValue(&dString);
Tcl_DStringSetLength(&dString, offset + sizeof(WCHAR) * TCL_INTEGER_SPACE);
actualName = (WCHAR *) Tcl_DStringValue(&dString);
}
_sntprintf((TCHAR *) (Tcl_DStringValue(&dString) + offset),
TCL_INTEGER_SPACE, TEXT("%d"), suffix);
_snwprintf((WCHAR *) (Tcl_DStringValue(&dString) + offset),
TCL_INTEGER_SPACE, L"%d", suffix);
}
/*
@@ -393,8 +409,9 @@ DdeSetServerName(
Tcl_DString ds;
Tcl_ListObjIndex(interp, srvPtrPtr[n], 1, &namePtr);
Tcl_WinUtfToTChar(Tcl_GetString(namePtr), -1, &ds);
if (_tcscmp(actualName, (TCHAR *)Tcl_DStringValue(&ds)) == 0) {
Tcl_DStringInit(&ds);
Tcl_UtfToWCharDString(Tcl_GetString(namePtr), -1, &ds);
if (wcscmp(actualName, (WCHAR *)Tcl_DStringValue(&ds)) == 0) {
suffix++;
Tcl_DStringFree(&ds);
break;
@@ -410,14 +427,14 @@ DdeSetServerName(
riPtr = (RegisteredInterp *) Tcl_Alloc(sizeof(RegisteredInterp));
riPtr->interp = interp;
riPtr->name = (TCHAR *) Tcl_Alloc((_tcslen(actualName) + 1) * sizeof(TCHAR));
riPtr->name = (WCHAR *) Tcl_Alloc((wcslen(actualName) + 1) * sizeof(WCHAR));
riPtr->nextPtr = tsdPtr->interpListPtr;
riPtr->handlerPtr = handlerPtr;
if (riPtr->handlerPtr != NULL) {
Tcl_IncrRefCount(riPtr->handlerPtr);
}
tsdPtr->interpListPtr = riPtr;
_tcscpy(riPtr->name, actualName);
wcscpy(riPtr->name, actualName);
if (Tcl_IsSafe(interp)) {
Tcl_ExposeCommand(interp, "dde", "dde");
@@ -489,8 +506,7 @@ DdeGetRegistrationPtr(
static void
DeleteProc(
ClientData clientData) /* The interp we are deleting passed as
* ClientData. */
void *clientData) /* The interp we are deleting. */
{
RegisteredInterp *riPtr = (RegisteredInterp *) clientData;
RegisteredInterp *searchPtr, *prevPtr;
@@ -627,18 +643,20 @@ DdeServerProc(
HSZ ddeTopic, HSZ ddeItem, /* String handles. Transaction-type
* dependent. */
HDDEDATA hData, /* DDE data. Transaction-type dependent. */
DWORD dwData1, DWORD dwData2)
DWORD unused1, DWORD unused2)
/* Transaction-dependent data. */
{
Tcl_DString dString;
size_t len;
DWORD dlen;
TCHAR *utilString;
WCHAR *utilString;
Tcl_Obj *ddeObjectPtr;
HDDEDATA ddeReturn = NULL;
RegisteredInterp *riPtr;
Conversation *convPtr, *prevConvPtr;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
(void)unused1;
(void)unused2;
switch(uType) {
case XTYP_CONNECT:
@@ -647,16 +665,16 @@ DdeServerProc(
* sure we have a valid topic.
*/
len = DdeQueryString(ddeInstance, ddeTopic, NULL, 0, CP_WINUNICODE);
len = DdeQueryStringW(ddeInstance, ddeTopic, NULL, 0, CP_WINUNICODE);
Tcl_DStringInit(&dString);
Tcl_DStringSetLength(&dString, (len + 1) * sizeof(TCHAR) - 1);
utilString = (TCHAR *) Tcl_DStringValue(&dString);
DdeQueryString(ddeInstance, ddeTopic, utilString, (DWORD) len + 1,
Tcl_DStringSetLength(&dString, (len + 1) * sizeof(WCHAR) - 1);
utilString = (WCHAR *) Tcl_DStringValue(&dString);
DdeQueryStringW(ddeInstance, ddeTopic, utilString, (DWORD) len + 1,
CP_WINUNICODE);
for (riPtr = tsdPtr->interpListPtr; riPtr != NULL;
riPtr = riPtr->nextPtr) {
if (_tcsicmp(utilString, riPtr->name) == 0) {
if (_wcsicmp(utilString, riPtr->name) == 0) {
Tcl_DStringFree(&dString);
return (HDDEDATA) TRUE;
}
@@ -672,15 +690,15 @@ DdeServerProc(
* result to return in an XTYP_REQUEST.
*/
len = DdeQueryString(ddeInstance, ddeTopic, NULL, 0, CP_WINUNICODE);
len = DdeQueryStringW(ddeInstance, ddeTopic, NULL, 0, CP_WINUNICODE);
Tcl_DStringInit(&dString);
Tcl_DStringSetLength(&dString, (len + 1) * sizeof(TCHAR) - 1);
utilString = (TCHAR *) Tcl_DStringValue(&dString);
DdeQueryString(ddeInstance, ddeTopic, utilString, (DWORD) len + 1,
Tcl_DStringSetLength(&dString, (len + 1) * sizeof(WCHAR) - 1);
utilString = (WCHAR *) Tcl_DStringValue(&dString);
DdeQueryStringW(ddeInstance, ddeTopic, utilString, (DWORD) len + 1,
CP_WINUNICODE);
for (riPtr = tsdPtr->interpListPtr; riPtr != NULL;
riPtr = riPtr->nextPtr) {
if (_tcsicmp(riPtr->name, utilString) == 0) {
if (_wcsicmp(riPtr->name, utilString) == 0) {
convPtr = (Conversation *) Tcl_Alloc(sizeof(Conversation));
convPtr->nextPtr = tsdPtr->currentConversations;
convPtr->returnPackagePtr = NULL;
@@ -740,21 +758,22 @@ DdeServerProc(
Tcl_DString dsBuf;
char *returnString;
len = DdeQueryString(ddeInstance, ddeItem, NULL, 0, CP_WINUNICODE);
len = DdeQueryStringW(ddeInstance, ddeItem, NULL, 0, CP_WINUNICODE);
Tcl_DStringInit(&dString);
Tcl_DStringInit(&dsBuf);
Tcl_DStringSetLength(&dString, (len + 1) * sizeof(TCHAR) - 1);
utilString = (TCHAR *) Tcl_DStringValue(&dString);
DdeQueryString(ddeInstance, ddeItem, utilString, (DWORD) len + 1,
Tcl_DStringSetLength(&dString, (len + 1) * sizeof(WCHAR) - 1);
utilString = (WCHAR *) Tcl_DStringValue(&dString);
DdeQueryStringW(ddeInstance, ddeItem, utilString, (DWORD) len + 1,
CP_WINUNICODE);
if (_tcsicmp(utilString, TCL_DDE_EXECUTE_RESULT) == 0) {
if (_wcsicmp(utilString, TCL_DDE_EXECUTE_RESULT) == 0) {
returnString =
Tcl_GetString(convPtr->returnPackagePtr);
len = convPtr->returnPackagePtr->length;
if (uFmt != CF_TEXT) {
Tcl_WinUtfToTChar(returnString, len, &dsBuf);
Tcl_DStringInit(&dsBuf);
Tcl_UtfToWCharDString(returnString, len, &dsBuf);
returnString = Tcl_DStringValue(&dsBuf);
len = Tcl_DStringLength(&dsBuf) + sizeof(TCHAR) - 1;
len = Tcl_DStringLength(&dsBuf) + sizeof(WCHAR) - 1;
}
ddeReturn = DdeCreateDataHandle(ddeInstance, (BYTE *)returnString,
(DWORD) len+1, 0, ddeItem, uFmt, 0);
@@ -765,7 +784,8 @@ DdeServerProc(
Tcl_DString ds;
Tcl_Obj *variableObjPtr;
Tcl_WinTCharToUtf(utilString, -1, &ds);
Tcl_DStringInit(&ds);
Tcl_WCharToUtfDString(utilString, wcslen(utilString), &ds);
variableObjPtr = Tcl_GetVar2Ex(
convPtr->riPtr->interp, Tcl_DStringValue(&ds), NULL,
TCL_GLOBAL_ONLY);
@@ -773,9 +793,10 @@ DdeServerProc(
returnString = Tcl_GetString(variableObjPtr);
len = variableObjPtr->length;
if (uFmt != CF_TEXT) {
Tcl_WinUtfToTChar(returnString, len, &dsBuf);
Tcl_DStringInit(&dsBuf);
Tcl_UtfToWCharDString(returnString, len, &dsBuf);
returnString = Tcl_DStringValue(&dsBuf);
len = Tcl_DStringLength(&dsBuf) + sizeof(TCHAR) - 1;
len = Tcl_DStringLength(&dsBuf) + sizeof(WCHAR) - 1;
}
ddeReturn = DdeCreateDataHandle(ddeInstance,
(BYTE *)returnString, (DWORD) len+1, 0, ddeItem,
@@ -817,17 +838,19 @@ DdeServerProc(
Tcl_DStringInit(&dString);
Tcl_DStringInit(&ds2);
len = DdeQueryString(ddeInstance, ddeItem, NULL, 0, CP_WINUNICODE);
Tcl_DStringSetLength(&dString, (len + 1) * sizeof(TCHAR) - 1);
utilString = (TCHAR *) Tcl_DStringValue(&dString);
DdeQueryString(ddeInstance, ddeItem, utilString, (DWORD) len + 1,
len = DdeQueryStringW(ddeInstance, ddeItem, NULL, 0, CP_WINUNICODE);
Tcl_DStringSetLength(&dString, (len + 1) * sizeof(WCHAR) - 1);
utilString = (WCHAR *) Tcl_DStringValue(&dString);
DdeQueryStringW(ddeInstance, ddeItem, utilString, (DWORD) len + 1,
CP_WINUNICODE);
Tcl_WinTCharToUtf(utilString, -1, &ds);
utilString = (TCHAR *) DdeAccessData(hData, &len2);
Tcl_DStringInit(&ds);
Tcl_WCharToUtfDString(utilString, wcslen(utilString), &ds);
utilString = (WCHAR *) DdeAccessData(hData, &len2);
len = len2;
if (uFmt != CF_TEXT) {
Tcl_WinTCharToUtf(utilString, -1, &ds2);
utilString = (TCHAR *) Tcl_DStringValue(&ds2);
Tcl_DStringInit(&ds2);
Tcl_WCharToUtfDString(utilString, wcslen(utilString), &ds2);
utilString = (WCHAR *) Tcl_DStringValue(&ds2);
}
variableObjPtr = Tcl_NewStringObj((char *)utilString, -1);
@@ -862,7 +885,7 @@ DdeServerProc(
return (HDDEDATA) DDE_FNOTPROCESSED;
}
utilString = (TCHAR *) DdeAccessData(hData, &dlen);
utilString = (WCHAR *) DdeAccessData(hData, &dlen);
string = (char *) utilString;
if (!dlen) {
/* Empty binary array. */
@@ -877,7 +900,8 @@ DdeServerProc(
/* unicode */
Tcl_DString dsBuf;
Tcl_WinTCharToUtf(utilString, dlen - sizeof(TCHAR), &dsBuf);
Tcl_DStringInit(&dsBuf);
Tcl_WCharToUtfDString(utilString, (dlen>>1) - 1, &dsBuf);
ddeObjectPtr = Tcl_NewStringObj(Tcl_DStringValue(&dsBuf),
Tcl_DStringLength(&dsBuf));
Tcl_DStringFree(&dsBuf);
@@ -932,9 +956,9 @@ DdeServerProc(
len = dlen;
for (i = 0, riPtr = tsdPtr->interpListPtr; i < numItems;
i++, riPtr = riPtr->nextPtr) {
returnPtr[i].hszSvc = DdeCreateStringHandle(ddeInstance,
returnPtr[i].hszSvc = DdeCreateStringHandleW(ddeInstance,
TCL_DDE_SERVICE_NAME, CP_WINUNICODE);
returnPtr[i].hszTopic = DdeCreateStringHandle(ddeInstance,
returnPtr[i].hszTopic = DdeCreateStringHandleW(ddeInstance,
riPtr->name, CP_WINUNICODE);
}
returnPtr[i].hszSvc = NULL;
@@ -966,8 +990,9 @@ DdeServerProc(
static void
DdeExitProc(
ClientData clientData) /* Not used in this handler. */
void *dummy) /* Not used. */
{
(void)dummy;
DdeNameService(ddeInstance, NULL, 0, DNS_UNREGISTER);
DdeUninitialize(ddeInstance);
ddeInstance = 0;
@@ -993,14 +1018,14 @@ DdeExitProc(
static int
MakeDdeConnection(
Tcl_Interp *interp, /* Used to report errors. */
const TCHAR *name, /* The connection to use. */
const WCHAR *name, /* The connection to use. */
HCONV *ddeConvPtr)
{
HSZ ddeTopic, ddeService;
HCONV ddeConv;
ddeService = DdeCreateStringHandle(ddeInstance, TCL_DDE_SERVICE_NAME, CP_WINUNICODE);
ddeTopic = DdeCreateStringHandle(ddeInstance, name, CP_WINUNICODE);
ddeService = DdeCreateStringHandleW(ddeInstance, TCL_DDE_SERVICE_NAME, CP_WINUNICODE);
ddeTopic = DdeCreateStringHandleW(ddeInstance, name, CP_WINUNICODE);
ddeConv = DdeConnect(ddeInstance, ddeService, ddeTopic, NULL);
DdeFreeStringHandle(ddeInstance, ddeService);
@@ -1010,7 +1035,8 @@ MakeDdeConnection(
if (interp != NULL) {
Tcl_DString dString;
Tcl_WinTCharToUtf(name, -1, &dString);
Tcl_DStringInit(&dString);
Tcl_WCharToUtfDString(name, wcslen(name), &dString);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"no registered server named \"%s\"", Tcl_DStringValue(&dString)));
Tcl_DStringFree(&dString);
@@ -1047,9 +1073,9 @@ static int
DdeCreateClient(
DdeEnumServices *es)
{
WNDCLASSEX wc;
static const TCHAR *szDdeClientClassName = TEXT("TclEval client class");
static const TCHAR *szDdeClientWindowName = TEXT("TclEval client window");
WNDCLASSEXW wc;
static const WCHAR *szDdeClientClassName = L"TclEval client class";
static const WCHAR *szDdeClientWindowName = L"TclEval client window";
memset(&wc, 0, sizeof(wc));
wc.cbSize = sizeof(wc);
@@ -1061,8 +1087,8 @@ DdeCreateClient(
* Register and create the callback window.
*/
RegisterClassEx(&wc);
es->hwnd = CreateWindowEx(0, szDdeClientClassName, szDdeClientWindowName,
RegisterClassExW(&wc);
es->hwnd = CreateWindowExW(0, szDdeClientClassName, szDdeClientWindowName,
WS_POPUP, 0, 0, 0, 0, NULL, NULL, NULL, (LPVOID)es);
return TCL_OK;
}
@@ -1081,16 +1107,16 @@ DdeClientWindowProc(
(DdeEnumServices *) lpcs->lpCreateParams;
#ifdef _WIN64
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) es);
SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) es);
#else
SetWindowLong(hwnd, GWL_USERDATA, (LONG) es);
SetWindowLongW(hwnd, GWL_USERDATA, (LONG) es);
#endif
return (LRESULT) 0L;
}
case WM_DDE_ACK:
return DdeServicesOnAck(hwnd, wParam, lParam);
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}
}
@@ -1104,13 +1130,13 @@ DdeServicesOnAck(
ATOM service = (ATOM)LOWORD(lParam);
ATOM topic = (ATOM)HIWORD(lParam);
DdeEnumServices *es;
TCHAR sz[255];
WCHAR sz[255];
Tcl_DString dString;
#ifdef _WIN64
es = (DdeEnumServices *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
es = (DdeEnumServices *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
#else
es = (DdeEnumServices *) GetWindowLong(hwnd, GWL_USERDATA);
es = (DdeEnumServices *) GetWindowLongW(hwnd, GWL_USERDATA);
#endif
if (((es->service == (ATOM)0) || (es->service == service))
@@ -1118,12 +1144,14 @@ DdeServicesOnAck(
Tcl_Obj *matchPtr = Tcl_NewListObj(0, NULL);
Tcl_Obj *resultPtr = Tcl_GetObjResult(es->interp);
GlobalGetAtomName(service, sz, 255);
Tcl_WinTCharToUtf(sz, -1, &dString);
GlobalGetAtomNameW(service, sz, 255);
Tcl_DStringInit(&dString);
Tcl_WCharToUtfDString(sz, wcslen(sz), &dString);
Tcl_ListObjAppendElement(NULL, matchPtr, Tcl_NewStringObj(Tcl_DStringValue(&dString), -1));
Tcl_DStringFree(&dString);
GlobalGetAtomName(topic, sz, 255);
Tcl_WinTCharToUtf(sz, -1, &dString);
GlobalGetAtomNameW(topic, sz, 255);
Tcl_DStringInit(&dString);
Tcl_WCharToUtfDString(sz, wcslen(sz), &dString);
Tcl_ListObjAppendElement(NULL, matchPtr, Tcl_NewStringObj(Tcl_DStringValue(&dString), -1));
Tcl_DStringFree(&dString);
@@ -1151,7 +1179,7 @@ DdeServicesOnAck(
* Tell the server we are no longer interested.
*/
PostMessage(hwndRemote, WM_DDE_TERMINATE, (WPARAM)hwnd, 0L);
PostMessageW(hwndRemote, WM_DDE_TERMINATE, (WPARAM)hwnd, 0L);
return 0L;
}
@@ -1163,7 +1191,7 @@ DdeEnumWindowsCallback(
DWORD_PTR dwResult = 0;
DdeEnumServices *es = (DdeEnumServices *) lParam;
SendMessageTimeout(hwndTarget, WM_DDE_INITIATE, (WPARAM)es->hwnd,
SendMessageTimeoutW(hwndTarget, WM_DDE_INITIATE, (WPARAM)es->hwnd,
MAKELONG(es->service, es->topic), SMTO_ABORTIFHUNG, 1000,
&dwResult);
return TRUE;
@@ -1172,16 +1200,16 @@ DdeEnumWindowsCallback(
static int
DdeGetServicesList(
Tcl_Interp *interp,
const TCHAR *serviceName,
const TCHAR *topicName)
const WCHAR *serviceName,
const WCHAR *topicName)
{
DdeEnumServices es;
es.interp = interp;
es.result = TCL_OK;
es.service = (serviceName == NULL)
? (ATOM)0 : GlobalAddAtom(serviceName);
es.topic = (topicName == NULL) ? (ATOM)0 : GlobalAddAtom(topicName);
? (ATOM)0 : GlobalAddAtomW(serviceName);
es.topic = (topicName == NULL) ? (ATOM)0 : GlobalAddAtomW(topicName);
Tcl_ResetResult(interp); /* our list is to be appended to result. */
DdeCreateClient(&es);
@@ -1265,7 +1293,7 @@ SetDdeError(
static int
DdeObjCmd(
ClientData clientData, /* Used only for deletion */
void *dummy, /* Not used. */
Tcl_Interp *interp, /* The interp we are sending from */
int objc, /* Number of arguments */
Tcl_Obj *const *objv) /* The arguments */
@@ -1302,11 +1330,12 @@ DdeObjCmd(
HSZ ddeService = NULL, ddeTopic = NULL, ddeItem = NULL, ddeCookie = NULL;
HDDEDATA ddeData = NULL, ddeItemData = NULL, ddeReturn;
HCONV hConv = NULL;
const TCHAR *serviceName = NULL, *topicName = NULL;
const WCHAR *serviceName = NULL, *topicName = NULL;
const char *string;
DWORD ddeResult;
Tcl_Obj *objPtr, *handlerPtr = NULL;
Tcl_DString serviceBuf, topicBuf, itemBuf;
(void)dummy;
/*
* Initialize DDE server/client
@@ -1462,9 +1491,10 @@ DdeObjCmd(
const char *src = Tcl_GetString(objv[firstArg]);
length = objv[firstArg]->length;
Tcl_WinUtfToTChar(src, length, &serviceBuf);
serviceName = (TCHAR *) Tcl_DStringValue(&serviceBuf);
length = Tcl_DStringLength(&serviceBuf) / sizeof(TCHAR);
Tcl_DStringInit(&serviceBuf);
Tcl_UtfToWCharDString(src, length, &serviceBuf);
serviceName = (WCHAR *) Tcl_DStringValue(&serviceBuf);
length = Tcl_DStringLength(&serviceBuf) / sizeof(WCHAR);
} else {
length = 0;
}
@@ -1472,7 +1502,7 @@ DdeObjCmd(
if (length == 0) {
serviceName = NULL;
} else if ((index != DDE_SERVERNAME) && (index != DDE_EVAL)) {
ddeService = DdeCreateStringHandle(ddeInstance, (void *) serviceName,
ddeService = DdeCreateStringHandleW(ddeInstance, serviceName,
CP_WINUNICODE);
}
@@ -1480,12 +1510,13 @@ DdeObjCmd(
const char *src = Tcl_GetString(objv[firstArg + 1]);
length = objv[firstArg + 1]->length;
topicName = Tcl_WinUtfToTChar(src, length, &topicBuf);
length = Tcl_DStringLength(&topicBuf) / sizeof(TCHAR);
Tcl_DStringInit(&topicBuf);
topicName = Tcl_UtfToWCharDString(src, length, &topicBuf);
length = Tcl_DStringLength(&topicBuf) / sizeof(WCHAR);
if (length == 0) {
topicName = NULL;
} else {
ddeTopic = DdeCreateStringHandle(ddeInstance, (void *) topicName,
ddeTopic = DdeCreateStringHandleW(ddeInstance, topicName,
CP_WINUNICODE);
}
}
@@ -1497,7 +1528,8 @@ DdeObjCmd(
if (serviceName != NULL) {
Tcl_DString dsBuf;
Tcl_WinTCharToUtf(serviceName, -1, &dsBuf);
Tcl_DStringInit(&dsBuf);
Tcl_WCharToUtfDString(serviceName, wcslen(serviceName), &dsBuf);
Tcl_SetObjResult(interp, Tcl_NewStringObj(Tcl_DStringValue(&dsBuf),
Tcl_DStringLength(&dsBuf)));
Tcl_DStringFree(&dsBuf);
@@ -1520,9 +1552,10 @@ DdeObjCmd(
src = Tcl_GetString(objv[firstArg + 2]);
dataLength = objv[firstArg + 2]->length;
dataString = (const TCHAR *)
Tcl_WinUtfToTChar(src, dataLength, &dsBuf);
dataLength = Tcl_DStringLength(&dsBuf) + sizeof(TCHAR);
Tcl_DStringInit(&dsBuf);
dataString =
Tcl_UtfToWCharDString(src, dataLength, &dsBuf);
dataLength = Tcl_DStringLength(&dsBuf) + sizeof(WCHAR);
}
if (dataLength + 1 < 2) {
@@ -1568,13 +1601,14 @@ DdeObjCmd(
break;
}
case DDE_REQUEST: {
const TCHAR *itemString;
const WCHAR *itemString;
const char *src;
src = Tcl_GetString(objv[firstArg + 2]);
length = objv[firstArg + 2]->length;
itemString = Tcl_WinUtfToTChar(src, length, &itemBuf);
length = Tcl_DStringLength(&itemBuf) / sizeof(TCHAR);
Tcl_DStringInit(&itemBuf);
itemString = Tcl_UtfToWCharDString(src, length, &itemBuf);
length = Tcl_DStringLength(&itemBuf) / sizeof(WCHAR);
if (length == 0) {
Tcl_SetObjResult(interp,
@@ -1592,7 +1626,7 @@ DdeObjCmd(
result = TCL_ERROR;
} else {
Tcl_Obj *returnObjPtr;
ddeItem = DdeCreateStringHandle(ddeInstance, (void *) itemString,
ddeItem = DdeCreateStringHandleW(ddeInstance, itemString,
CP_WINUNICODE);
if (ddeItem != NULL) {
ddeData = DdeClientTransaction(NULL, 0, hConv, ddeItem,
@@ -1602,7 +1636,7 @@ DdeObjCmd(
result = TCL_ERROR;
} else {
DWORD tmp;
TCHAR *dataString = (TCHAR *) DdeAccessData(ddeData, &tmp);
WCHAR *dataString = (WCHAR *) DdeAccessData(ddeData, &tmp);
if (flags & DDE_FLAG_BINARY) {
returnObjPtr =
@@ -1610,11 +1644,12 @@ DdeObjCmd(
} else {
Tcl_DString dsBuf;
if ((tmp >= sizeof(TCHAR))
&& !dataString[tmp / sizeof(TCHAR) - 1]) {
tmp -= sizeof(TCHAR);
if ((tmp >= sizeof(WCHAR))
&& !dataString[tmp / sizeof(WCHAR) - 1]) {
tmp -= sizeof(WCHAR);
}
Tcl_WinTCharToUtf(dataString, tmp, &dsBuf);
Tcl_DStringInit(&dsBuf);
Tcl_WCharToUtfDString(dataString, tmp>>1, &dsBuf);
returnObjPtr =
Tcl_NewStringObj(Tcl_DStringValue(&dsBuf),
Tcl_DStringLength(&dsBuf));
@@ -1633,14 +1668,15 @@ DdeObjCmd(
}
case DDE_POKE: {
Tcl_DString dsBuf;
const TCHAR *itemString;
const WCHAR *itemString;
BYTE *dataString;
const char *src;
src = Tcl_GetString(objv[firstArg + 2]);
length = objv[firstArg + 2]->length;
itemString = Tcl_WinUtfToTChar(src, length, &itemBuf);
length = Tcl_DStringLength(&itemBuf) / sizeof(TCHAR);
Tcl_DStringInit(&itemBuf);
itemString = Tcl_UtfToWCharDString(src, length, &itemBuf);
length = Tcl_DStringLength(&itemBuf) / sizeof(WCHAR);
if (length == 0) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("cannot have a null item", -1));
@@ -1656,9 +1692,10 @@ DdeObjCmd(
const char *data =
Tcl_GetString(objv[firstArg + 3]);
length = objv[firstArg + 3]->length;
Tcl_DStringInit(&dsBuf);
dataString = (BYTE *)
Tcl_WinUtfToTChar(data, length, &dsBuf);
length = Tcl_DStringLength(&dsBuf) + sizeof(TCHAR);
Tcl_UtfToWCharDString(data, length, &dsBuf);
length = Tcl_DStringLength(&dsBuf) + sizeof(WCHAR);
}
hConv = DdeConnect(ddeInstance, ddeService, ddeTopic, NULL);
@@ -1669,7 +1706,7 @@ DdeObjCmd(
SetDdeError(interp);
result = TCL_ERROR;
} else {
ddeItem = DdeCreateStringHandle(ddeInstance, (void *) itemString,
ddeItem = DdeCreateStringHandleW(ddeInstance, itemString,
CP_WINUNICODE);
if (ddeItem != NULL) {
ddeData = DdeClientTransaction(dataString, (DWORD) length,
@@ -1717,7 +1754,7 @@ DdeObjCmd(
for (riPtr = tsdPtr->interpListPtr; riPtr != NULL;
riPtr = riPtr->nextPtr) {
if (_tcsicmp(serviceName, riPtr->name) == 0) {
if (_wcsicmp(serviceName, riPtr->name) == 0) {
break;
}
}
@@ -1820,9 +1857,10 @@ DdeObjCmd(
objPtr = Tcl_ConcatObj(objc, objv);
string = Tcl_GetString(objPtr);
length = objPtr->length;
Tcl_WinUtfToTChar(string, length, &dsBuf);
Tcl_DStringInit(&dsBuf);
Tcl_UtfToWCharDString(string, length, &dsBuf);
string = Tcl_DStringValue(&dsBuf);
length = Tcl_DStringLength(&dsBuf) + sizeof(TCHAR);
length = Tcl_DStringLength(&dsBuf) + sizeof(WCHAR);
ddeItemData = DdeCreateDataHandle(ddeInstance, (BYTE *) string,
(DWORD) length, 0, 0, CF_UNICODETEXT, 0);
Tcl_DStringFree(&dsBuf);
@@ -1837,7 +1875,7 @@ DdeObjCmd(
0xFFFFFFFF, hConv, 0,
CF_UNICODETEXT, XTYP_EXECUTE, 30000, NULL);
if (ddeData != 0) {
ddeCookie = DdeCreateStringHandle(ddeInstance,
ddeCookie = DdeCreateStringHandleW(ddeInstance,
TCL_DDE_EXECUTE_RESULT, CP_WINUNICODE);
ddeData = DdeClientTransaction(NULL, 0, hConv, ddeCookie,
CF_UNICODETEXT, XTYP_REQUEST, 30000, NULL);
@@ -1854,7 +1892,7 @@ DdeObjCmd(
if (!(flags & DDE_FLAG_ASYNC)) {
Tcl_Obj *resultPtr;
TCHAR *ddeDataString;
WCHAR *ddeDataString;
/*
* The return handle has a two or four element list in it. The
@@ -1866,12 +1904,13 @@ DdeObjCmd(
*/
length = DdeGetData(ddeData, NULL, 0, 0);
ddeDataString = (TCHAR *) Tcl_Alloc(length);
ddeDataString = (WCHAR *) Tcl_Alloc(length);
DdeGetData(ddeData, (BYTE *) ddeDataString, (DWORD) length, 0);
if (length > sizeof(TCHAR)) {
length -= sizeof(TCHAR);
if (length > sizeof(WCHAR)) {
length -= sizeof(WCHAR);
}
Tcl_WinTCharToUtf(ddeDataString, length, &dsBuf);
Tcl_DStringInit(&dsBuf);
Tcl_WCharToUtfDString(ddeDataString, length>>1, &dsBuf);
resultPtr = Tcl_NewStringObj(Tcl_DStringValue(&dsBuf),
Tcl_DStringLength(&dsBuf));
Tcl_DStringFree(&dsBuf);
+123 -123
View File
@@ -71,7 +71,7 @@ const TclFileAttrProcs tclpFileAttrProcs[] = {
* Prototype for the TraverseWinTree callback function.
*/
typedef int (TraversalProc)(const TCHAR *srcPtr, const TCHAR *dstPtr,
typedef int (TraversalProc)(const WCHAR *srcPtr, const WCHAR *dstPtr,
int type, Tcl_DString *errorPtr);
/*
@@ -82,18 +82,18 @@ static void StatError(Tcl_Interp *interp, Tcl_Obj *fileName);
static int ConvertFileNameFormat(Tcl_Interp *interp,
int objIndex, Tcl_Obj *fileName, int longShort,
Tcl_Obj **attributePtrPtr);
static int DoCopyFile(const TCHAR *srcPtr, const TCHAR *dstPtr);
static int DoCreateDirectory(const TCHAR *pathPtr);
static int DoRemoveJustDirectory(const TCHAR *nativeSrc,
static int DoCopyFile(const WCHAR *srcPtr, const WCHAR *dstPtr);
static int DoCreateDirectory(const WCHAR *pathPtr);
static int DoRemoveJustDirectory(const WCHAR *nativeSrc,
int ignoreError, Tcl_DString *errorPtr);
static int DoRemoveDirectory(Tcl_DString *pathPtr, int recursive,
Tcl_DString *errorPtr);
static int DoRenameFile(const TCHAR *nativeSrc,
const TCHAR *dstPtr);
static int TraversalCopy(const TCHAR *srcPtr, const TCHAR *dstPtr,
static int DoRenameFile(const WCHAR *nativeSrc,
const WCHAR *dstPtr);
static int TraversalCopy(const WCHAR *srcPtr, const WCHAR *dstPtr,
int type, Tcl_DString *errorPtr);
static int TraversalDelete(const TCHAR *srcPtr,
const TCHAR *dstPtr, int type,
static int TraversalDelete(const WCHAR *srcPtr,
const WCHAR *dstPtr, int type,
Tcl_DString *errorPtr);
static int TraverseWinTree(TraversalProc *traverseProc,
Tcl_DString *sourcePtr, Tcl_DString *dstPtr,
@@ -151,9 +151,9 @@ TclpObjRenameFile(
static int
DoRenameFile(
const TCHAR *nativeSrc, /* Pathname of file or dir to be renamed
const WCHAR *nativeSrc, /* Pathname of file or dir to be renamed
* (native). */
const TCHAR *nativeDst) /* New pathname for file or directory
const WCHAR *nativeDst) /* New pathname for file or directory
* (native). */
{
#if defined(HAVE_NO_SEH) && !defined(_WIN64)
@@ -163,7 +163,7 @@ DoRenameFile(
int retval = -1;
/*
* The MoveFile API acts differently under Win95/98 and NT WRT NULL and
* The MoveFileW API acts differently under Win95/98 and NT WRT NULL and
* "". Avoid passing these values.
*/
@@ -174,7 +174,7 @@ DoRenameFile(
}
/*
* The MoveFile API would throw an exception under NT if one of the
* The MoveFileW API would throw an exception under NT if one of the
* arguments is a char block device.
*/
@@ -195,7 +195,7 @@ DoRenameFile(
/*
* Construct an TCLEXCEPTION_REGISTRATION to protect the call to
* MoveFile.
* MoveFileW.
*/
"leal %[registration], %%edx" "\n\t"
@@ -214,17 +214,17 @@ DoRenameFile(
"movl %%edx, %%fs:0" "\n\t"
/*
* Call MoveFile(nativeSrc, nativeDst)
* Call MoveFileW(nativeSrc, nativeDst)
*/
"pushl %%ebx" "\n\t"
"pushl %%ecx" "\n\t"
"movl %[moveFile], %%eax" "\n\t"
"movl %[moveFileW], %%eax" "\n\t"
"call *%%eax" "\n\t"
/*
* Come here on normal exit. Recover the TCLEXCEPTION_REGISTRATION and
* put the status return from MoveFile into it.
* put the status return from MoveFileW into it.
*/
"movl %%fs:0, %%edx" "\n\t"
@@ -256,7 +256,7 @@ DoRenameFile(
[registration] "m" (registration),
[nativeDst] "m" (nativeDst),
[nativeSrc] "m" (nativeSrc),
[moveFile] "r" (MoveFile)
[moveFileW] "r" (MoveFileW)
:
"%eax", "%ebx", "%ecx", "%edx", "memory"
);
@@ -267,7 +267,7 @@ DoRenameFile(
#ifndef HAVE_NO_SEH
__try {
#endif
if ((*MoveFile)(nativeSrc, nativeDst) != FALSE) {
if ((*MoveFileW)(nativeSrc, nativeDst) != FALSE) {
retval = TCL_OK;
}
#ifndef HAVE_NO_SEH
@@ -281,10 +281,10 @@ DoRenameFile(
TclWinConvertError(GetLastError());
srcAttr = GetFileAttributes(nativeSrc);
dstAttr = GetFileAttributes(nativeDst);
srcAttr = GetFileAttributesW(nativeSrc);
dstAttr = GetFileAttributesW(nativeDst);
if (srcAttr == 0xffffffff) {
if (GetFullPathName(nativeSrc, 0, NULL,
if (GetFullPathNameW(nativeSrc, 0, NULL,
NULL) >= MAX_PATH) {
errno = ENAMETOOLONG;
return TCL_ERROR;
@@ -292,7 +292,7 @@ DoRenameFile(
srcAttr = 0;
}
if (dstAttr == 0xffffffff) {
if (GetFullPathName(nativeDst, 0, NULL,
if (GetFullPathNameW(nativeDst, 0, NULL,
NULL) >= MAX_PATH) {
errno = ENAMETOOLONG;
return TCL_ERROR;
@@ -307,29 +307,29 @@ DoRenameFile(
if (errno == EACCES) {
decode:
if (srcAttr & FILE_ATTRIBUTE_DIRECTORY) {
TCHAR *nativeSrcRest, *nativeDstRest;
WCHAR *nativeSrcRest, *nativeDstRest;
const char **srcArgv, **dstArgv;
int size, srcArgc, dstArgc;
TCHAR nativeSrcPath[MAX_PATH];
TCHAR nativeDstPath[MAX_PATH];
WCHAR nativeSrcPath[MAX_PATH];
WCHAR nativeDstPath[MAX_PATH];
Tcl_DString srcString, dstString;
const char *src, *dst;
size = GetFullPathName(nativeSrc, MAX_PATH,
size = GetFullPathNameW(nativeSrc, MAX_PATH,
nativeSrcPath, &nativeSrcRest);
if ((size == 0) || (size > MAX_PATH)) {
return TCL_ERROR;
}
size = GetFullPathName(nativeDst, MAX_PATH,
size = GetFullPathNameW(nativeDst, MAX_PATH,
nativeDstPath, &nativeDstRest);
if ((size == 0) || (size > MAX_PATH)) {
return TCL_ERROR;
}
CharLower(nativeSrcPath);
CharLower(nativeDstPath);
CharLowerW(nativeSrcPath);
CharLowerW(nativeDstPath);
src = Tcl_WinTCharToUtf(nativeSrcPath, -1, &srcString);
dst = Tcl_WinTCharToUtf(nativeDstPath, -1, &dstString);
src = Tcl_WinTCharToUtf((TCHAR *)nativeSrcPath, -1, &srcString);
dst = Tcl_WinTCharToUtf((TCHAR *)nativeDstPath, -1, &dstString);
/*
* Check whether the destination path is actually inside the
@@ -369,7 +369,7 @@ DoRenameFile(
* errno should be EXDEV. It is very important to get this
* behavior, so that the caller can respond to a cross
* filesystem rename by simulating it with copy and delete.
* The MoveFile system call already handles the case of moving
* The MoveFileW system call already handles the case of moving
* a file between filesystems.
*/
@@ -408,7 +408,7 @@ DoRenameFile(
* directory back, for completeness.
*/
if (MoveFile(nativeSrc,
if (MoveFileW(nativeSrc,
nativeDst) != FALSE) {
return TCL_OK;
}
@@ -419,8 +419,8 @@ DoRenameFile(
*/
TclWinConvertError(GetLastError());
CreateDirectory(nativeDst, NULL);
SetFileAttributes(nativeDst, dstAttr);
CreateDirectoryW(nativeDst, NULL);
SetFileAttributesW(nativeDst, dstAttr);
if (Tcl_GetErrno() == EACCES) {
/*
* Decode the EACCES to a more meaningful error.
@@ -445,39 +445,39 @@ DoRenameFile(
* back to old name.
*/
TCHAR *nativeRest, *nativeTmp, *nativePrefix;
WCHAR *nativeRest, *nativeTmp, *nativePrefix;
int result, size;
TCHAR tempBuf[MAX_PATH];
WCHAR tempBuf[MAX_PATH];
size = GetFullPathName(nativeDst, MAX_PATH,
size = GetFullPathNameW(nativeDst, MAX_PATH,
tempBuf, &nativeRest);
if ((size == 0) || (size > MAX_PATH) || (nativeRest == NULL)) {
return TCL_ERROR;
}
nativeTmp = (TCHAR *) tempBuf;
nativeTmp = (WCHAR *) tempBuf;
nativeRest[0] = L'\0';
result = TCL_ERROR;
nativePrefix = (TCHAR *) L"tclr";
if (GetTempFileName(nativeTmp, nativePrefix,
nativePrefix = (WCHAR *) L"tclr";
if (GetTempFileNameW(nativeTmp, nativePrefix,
0, tempBuf) != 0) {
/*
* Strictly speaking, need the following DeleteFile and
* MoveFile to be joined as an atomic operation so no
* MoveFileW to be joined as an atomic operation so no
* other app comes along in the meantime and creates the
* same temp file.
*/
nativeTmp = tempBuf;
DeleteFile(nativeTmp);
if (MoveFile(nativeDst, nativeTmp) != FALSE) {
if (MoveFile(nativeSrc, nativeDst) != FALSE) {
SetFileAttributes(nativeTmp, FILE_ATTRIBUTE_NORMAL);
DeleteFile(nativeTmp);
DeleteFileW(nativeTmp);
if (MoveFileW(nativeDst, nativeTmp) != FALSE) {
if (MoveFileW(nativeSrc, nativeDst) != FALSE) {
SetFileAttributesW(nativeTmp, FILE_ATTRIBUTE_NORMAL);
DeleteFileW(nativeTmp);
return TCL_OK;
} else {
DeleteFile(nativeDst);
MoveFile(nativeTmp, nativeDst);
DeleteFileW(nativeDst);
MoveFileW(nativeTmp, nativeDst);
}
}
@@ -540,8 +540,8 @@ TclpObjCopyFile(
static int
DoCopyFile(
const TCHAR *nativeSrc, /* Pathname of file to be copied (native). */
const TCHAR *nativeDst) /* Pathname of file to copy to (native). */
const WCHAR *nativeSrc, /* Pathname of file to be copied (native). */
const WCHAR *nativeDst) /* Pathname of file to copy to (native). */
{
#if defined(HAVE_NO_SEH) && !defined(_WIN64)
TCLEXCEPTION_REGISTRATION registration;
@@ -601,10 +601,10 @@ DoCopyFile(
"movl %%edx, %%fs:0" "\n\t"
/*
* Call CopyFile(nativeSrc, nativeDst, 0)
* Call CopyFileW(nativeSrc, nativeDst, 0)
*/
"movl %[copyFile], %%eax" "\n\t"
"movl %[copyFileW], %%eax" "\n\t"
"pushl $0" "\n\t"
"pushl %%ebx" "\n\t"
"pushl %%ecx" "\n\t"
@@ -644,7 +644,7 @@ DoCopyFile(
[registration] "m" (registration),
[nativeDst] "m" (nativeDst),
[nativeSrc] "m" (nativeSrc),
[copyFile] "r" (CopyFile)
[copyFileW] "r" (CopyFileW)
:
"%eax", "%ebx", "%ecx", "%edx", "memory"
);
@@ -655,7 +655,7 @@ DoCopyFile(
#ifndef HAVE_NO_SEH
__try {
#endif
if (CopyFile(nativeSrc, nativeDst, 0) != FALSE) {
if (CopyFileW(nativeSrc, nativeDst, 0) != FALSE) {
retval = TCL_OK;
}
#ifndef HAVE_NO_SEH
@@ -675,8 +675,8 @@ DoCopyFile(
if (Tcl_GetErrno() == EACCES) {
DWORD srcAttr, dstAttr;
srcAttr = GetFileAttributes(nativeSrc);
dstAttr = GetFileAttributes(nativeDst);
srcAttr = GetFileAttributesW(nativeSrc);
dstAttr = GetFileAttributesW(nativeDst);
if (srcAttr != 0xffffffff) {
if (dstAttr == 0xffffffff) {
dstAttr = 0;
@@ -692,9 +692,9 @@ DoCopyFile(
Tcl_SetErrno(EISDIR);
}
if (dstAttr & FILE_ATTRIBUTE_READONLY) {
SetFileAttributes(nativeDst,
SetFileAttributesW(nativeDst,
dstAttr & ~((DWORD)FILE_ATTRIBUTE_READONLY));
if (CopyFile(nativeSrc, nativeDst,
if (CopyFileW(nativeSrc, nativeDst,
0) != FALSE) {
return TCL_OK;
}
@@ -705,7 +705,7 @@ DoCopyFile(
*/
TclWinConvertError(GetLastError());
SetFileAttributes(nativeDst, dstAttr);
SetFileAttributesW(nativeDst, dstAttr);
}
}
}
@@ -749,7 +749,7 @@ TclpDeleteFile(
const void *nativePath) /* Pathname of file to be removed (native). */
{
DWORD attr;
const TCHAR *path = nativePath;
const WCHAR *path = nativePath;
/*
* The DeleteFile API acts differently under Win95/98 and NT WRT NULL and
@@ -761,13 +761,13 @@ TclpDeleteFile(
return TCL_ERROR;
}
if (DeleteFile(path) != FALSE) {
if (DeleteFileW(path) != FALSE) {
return TCL_OK;
}
TclWinConvertError(GetLastError());
if (Tcl_GetErrno() == EACCES) {
attr = GetFileAttributes(path);
attr = GetFileAttributesW(path);
if (attr != 0xffffffff) {
if (attr & FILE_ATTRIBUTE_DIRECTORY) {
if (attr & FILE_ATTRIBUTE_REPARSE_POINT) {
@@ -788,21 +788,21 @@ TclpDeleteFile(
Tcl_SetErrno(EISDIR);
} else if (attr & FILE_ATTRIBUTE_READONLY) {
int res = SetFileAttributes(path,
int res = SetFileAttributesW(path,
attr & ~((DWORD) FILE_ATTRIBUTE_READONLY));
if ((res != 0) &&
(DeleteFile(path) != FALSE)) {
(DeleteFileW(path) != FALSE)) {
return TCL_OK;
}
TclWinConvertError(GetLastError());
if (res != 0) {
SetFileAttributes(path, attr);
SetFileAttributesW(path, attr);
}
}
}
} else if (Tcl_GetErrno() == ENOENT) {
attr = GetFileAttributes(path);
attr = GetFileAttributesW(path);
if (attr != 0xffffffff) {
if (attr & FILE_ATTRIBUTE_DIRECTORY) {
/*
@@ -859,9 +859,9 @@ TclpObjCreateDirectory(
static int
DoCreateDirectory(
const TCHAR *nativePath) /* Pathname of directory to create (native). */
const WCHAR *nativePath) /* Pathname of directory to create (native). */
{
if (CreateDirectory(nativePath, NULL) == 0) {
if (CreateDirectoryW(nativePath, NULL) == 0) {
DWORD error = GetLastError();
TclWinConvertError(error);
@@ -1009,7 +1009,7 @@ TclpObjRemoveDirectory(
static int
DoRemoveJustDirectory(
const TCHAR *nativePath, /* Pathname of directory to be removed
const WCHAR *nativePath, /* Pathname of directory to be removed
* (native). */
int ignoreError, /* If non-zero, don't initialize the errorPtr
* under some circumstances on return. */
@@ -1030,7 +1030,7 @@ DoRemoveJustDirectory(
return TCL_ERROR;
}
attr = GetFileAttributes(nativePath);
attr = GetFileAttributesW(nativePath);
if (attr & FILE_ATTRIBUTE_REPARSE_POINT) {
/*
@@ -1044,7 +1044,7 @@ DoRemoveJustDirectory(
* Ordinary directory.
*/
if (RemoveDirectory(nativePath) != FALSE) {
if (RemoveDirectoryW(nativePath) != FALSE) {
return TCL_OK;
}
}
@@ -1052,7 +1052,7 @@ DoRemoveJustDirectory(
TclWinConvertError(GetLastError());
if (Tcl_GetErrno() == EACCES) {
attr = GetFileAttributes(nativePath);
attr = GetFileAttributesW(nativePath);
if (attr != 0xffffffff) {
if ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0) {
/*
@@ -1076,15 +1076,15 @@ DoRemoveJustDirectory(
if (attr & FILE_ATTRIBUTE_READONLY) {
attr &= ~FILE_ATTRIBUTE_READONLY;
if (SetFileAttributes(nativePath,
if (SetFileAttributesW(nativePath,
attr) == FALSE) {
goto end;
}
if (RemoveDirectory(nativePath) != FALSE) {
if (RemoveDirectoryW(nativePath) != FALSE) {
return TCL_OK;
}
TclWinConvertError(GetLastError());
SetFileAttributes(nativePath,
SetFileAttributesW(nativePath,
attr | FILE_ATTRIBUTE_READONLY);
}
}
@@ -1109,7 +1109,7 @@ DoRemoveJustDirectory(
end:
if (errorPtr != NULL) {
char *p = Tcl_WinTCharToUtf(nativePath, -1, errorPtr);
char *p = Tcl_WinTCharToUtf((TCHAR *)nativePath, -1, errorPtr);
for (; *p; ++p) {
if (*p == '\\') *p = '/';
}
@@ -1129,7 +1129,7 @@ DoRemoveDirectory(
* filled with UTF-8 name of file causing
* error. */
{
int res = DoRemoveJustDirectory((const TCHAR *)Tcl_DStringValue(pathPtr), recursive,
int res = DoRemoveJustDirectory((const WCHAR *)Tcl_DStringValue(pathPtr), recursive,
errorPtr);
if ((res == TCL_ERROR) && (recursive != 0) && (Tcl_GetErrno() == EEXIST)) {
@@ -1180,21 +1180,21 @@ TraverseWinTree(
* error. */
{
DWORD sourceAttr;
TCHAR *nativeSource, *nativeTarget, *nativeErrfile;
WCHAR *nativeSource, *nativeTarget, *nativeErrfile;
int result, found, sourceLen, targetLen = 0, oldSourceLen, oldTargetLen;
HANDLE handle;
WIN32_FIND_DATA data;
WIN32_FIND_DATAW data;
nativeErrfile = NULL;
result = TCL_OK;
oldTargetLen = 0; /* lint. */
nativeSource = (TCHAR *) Tcl_DStringValue(sourcePtr);
nativeTarget = (TCHAR *)
nativeSource = (WCHAR *) Tcl_DStringValue(sourcePtr);
nativeTarget = (WCHAR *)
(targetPtr == NULL ? NULL : Tcl_DStringValue(targetPtr));
oldSourceLen = Tcl_DStringLength(sourcePtr);
sourceAttr = GetFileAttributes(nativeSource);
sourceAttr = GetFileAttributesW(nativeSource);
if (sourceAttr == 0xffffffff) {
nativeErrfile = nativeSource;
goto end;
@@ -1217,11 +1217,11 @@ TraverseWinTree(
return traverseProc(nativeSource, nativeTarget, DOTREE_F, errorPtr);
}
Tcl_DStringAppend(sourcePtr, (char *) TEXT("\\*.*"), 4 * sizeof(TCHAR) + 1);
Tcl_DStringAppend(sourcePtr, (char *) L"\\*.*", 4 * sizeof(WCHAR) + 1);
Tcl_DStringSetLength(sourcePtr, Tcl_DStringLength(sourcePtr) - 1);
nativeSource = (TCHAR *) Tcl_DStringValue(sourcePtr);
handle = FindFirstFile(nativeSource, &data);
nativeSource = (WCHAR *) Tcl_DStringValue(sourcePtr);
handle = FindFirstFileW(nativeSource, &data);
if (handle == INVALID_HANDLE_VALUE) {
/*
* Can't read directory.
@@ -1241,24 +1241,24 @@ TraverseWinTree(
return result;
}
sourceLen = oldSourceLen + sizeof(TCHAR);
Tcl_DStringAppend(sourcePtr, (char *) TEXT("\\"), sizeof(TCHAR) + 1);
sourceLen = oldSourceLen + sizeof(WCHAR);
Tcl_DStringAppend(sourcePtr, (char *) L"\\", sizeof(WCHAR) + 1);
Tcl_DStringSetLength(sourcePtr, sourceLen);
if (targetPtr != NULL) {
oldTargetLen = Tcl_DStringLength(targetPtr);
targetLen = oldTargetLen;
targetLen += sizeof(TCHAR);
Tcl_DStringAppend(targetPtr, (char *) TEXT("\\"), sizeof(TCHAR) + 1);
targetLen += sizeof(WCHAR);
Tcl_DStringAppend(targetPtr, (char *) L"\\", sizeof(WCHAR) + 1);
Tcl_DStringSetLength(targetPtr, targetLen);
}
found = 1;
for (; found; found = FindNextFile(handle, &data)) {
TCHAR *nativeName;
int len;
for (; found; found = FindNextFileW(handle, &data)) {
WCHAR *nativeName;
size_t len;
TCHAR *wp = data.cFileName;
WCHAR *wp = data.cFileName;
if (*wp == '.') {
wp++;
if (*wp == '.') {
@@ -1268,8 +1268,8 @@ TraverseWinTree(
continue;
}
}
nativeName = (TCHAR *) data.cFileName;
len = _tcslen(data.cFileName) * sizeof(TCHAR);
nativeName = (WCHAR *) data.cFileName;
len = wcslen(data.cFileName) * sizeof(WCHAR);
/*
* Append name after slash, and recurse on the file.
@@ -1314,8 +1314,8 @@ TraverseWinTree(
* files in that directory.
*/
result = traverseProc((const TCHAR *)Tcl_DStringValue(sourcePtr),
(const TCHAR *)(targetPtr == NULL ? NULL : Tcl_DStringValue(targetPtr)),
result = traverseProc((const WCHAR *)Tcl_DStringValue(sourcePtr),
(const WCHAR *)(targetPtr == NULL ? NULL : Tcl_DStringValue(targetPtr)),
DOTREE_POSTD, errorPtr);
}
@@ -1323,7 +1323,7 @@ TraverseWinTree(
if (nativeErrfile != NULL) {
TclWinConvertError(GetLastError());
if (errorPtr != NULL) {
Tcl_WinTCharToUtf(nativeErrfile, -1, errorPtr);
Tcl_WinTCharToUtf((TCHAR *)nativeErrfile, -1, errorPtr);
}
result = TCL_ERROR;
}
@@ -1350,8 +1350,8 @@ TraverseWinTree(
static int
TraversalCopy(
const TCHAR *nativeSrc, /* Source pathname to copy. */
const TCHAR *nativeDst, /* Destination pathname of copy. */
const WCHAR *nativeSrc, /* Source pathname to copy. */
const WCHAR *nativeDst, /* Destination pathname of copy. */
int type, /* Reason for call - see TraverseWinTree() */
Tcl_DString *errorPtr) /* If non-NULL, initialized DString filled
* with UTF-8 name of file causing error. */
@@ -1369,9 +1369,9 @@ TraversalCopy(
break;
case DOTREE_PRED:
if (DoCreateDirectory(nativeDst) == TCL_OK) {
DWORD attr = GetFileAttributes(nativeSrc);
DWORD attr = GetFileAttributesW(nativeSrc);
if (SetFileAttributes(nativeDst,
if (SetFileAttributesW(nativeDst,
attr) != FALSE) {
return TCL_OK;
}
@@ -1388,7 +1388,7 @@ TraversalCopy(
*/
if (errorPtr != NULL) {
Tcl_WinTCharToUtf(nativeDst, -1, errorPtr);
Tcl_WinTCharToUtf((TCHAR *)nativeDst, -1, errorPtr);
}
return TCL_ERROR;
}
@@ -1416,8 +1416,8 @@ TraversalCopy(
static int
TraversalDelete(
const TCHAR *nativeSrc, /* Source pathname to delete. */
const TCHAR *dstPtr, /* Not used. */
const WCHAR *nativeSrc, /* Source pathname to delete. */
const WCHAR *dstPtr, /* Not used. */
int type, /* Reason for call - see TraverseWinTree() */
Tcl_DString *errorPtr) /* If non-NULL, initialized DString filled
* with UTF-8 name of file causing error. */
@@ -1443,7 +1443,7 @@ TraversalDelete(
}
if (errorPtr != NULL) {
Tcl_WinTCharToUtf(nativeSrc, -1, errorPtr);
Tcl_WinTCharToUtf((TCHAR *)nativeSrc, -1, errorPtr);
}
return TCL_ERROR;
}
@@ -1503,11 +1503,11 @@ GetWinFileAttributes(
Tcl_Obj **attributePtrPtr) /* A pointer to return the object with. */
{
DWORD result;
const TCHAR *nativeName;
const WCHAR *nativeName;
int attr;
nativeName = Tcl_FSGetNativePath(fileName);
result = GetFileAttributes(nativeName);
result = GetFileAttributesW(nativeName);
if (result == 0xffffffff) {
StatError(interp, fileName);
@@ -1636,10 +1636,10 @@ ConvertFileNameFormat(
Tcl_Obj *tempPath;
Tcl_DString ds;
Tcl_DString dsTemp;
const TCHAR *nativeName;
const WCHAR *nativeName;
const char *tempString;
int tempLen;
WIN32_FIND_DATA data;
WIN32_FIND_DATAW data;
HANDLE handle;
DWORD attr;
@@ -1653,18 +1653,18 @@ ConvertFileNameFormat(
Tcl_DStringInit(&ds);
tempString = Tcl_GetStringFromObj(tempPath,&tempLen);
nativeName = Tcl_WinUtfToTChar(tempString, tempLen, &ds);
nativeName = (WCHAR *)Tcl_WinUtfToTChar(tempString, tempLen, &ds);
Tcl_DecrRefCount(tempPath);
handle = FindFirstFile(nativeName, &data);
handle = FindFirstFileW(nativeName, &data);
if (handle == INVALID_HANDLE_VALUE) {
/*
* FindFirstFile() doesn't like root directories. We would
* FindFirstFileW() doesn't like root directories. We would
* only get a root directory here if the caller specified "c:"
* or "c:." and the current directory on the drive was the
* root directory
*/
attr = GetFileAttributes(nativeName);
attr = GetFileAttributesW(nativeName);
if ((attr!=0xFFFFFFFF) && (attr & FILE_ATTRIBUTE_DIRECTORY)) {
Tcl_DStringFree(&ds);
goto simple;
@@ -1685,7 +1685,7 @@ ConvertFileNameFormat(
}
} else {
if (data.cAlternateFileName[0] == '\0') {
nativeName = (TCHAR *) data.cFileName;
nativeName = (WCHAR *) data.cFileName;
}
}
@@ -1702,7 +1702,7 @@ ConvertFileNameFormat(
*/
Tcl_DStringInit(&dsTemp);
Tcl_WinTCharToUtf(nativeName, -1, &dsTemp);
Tcl_WinTCharToUtf((TCHAR *)nativeName, -1, &dsTemp);
Tcl_DStringFree(&ds);
/*
@@ -1831,10 +1831,10 @@ SetWinFileAttributes(
{
DWORD fileAttributes, old;
int yesNo, result;
const TCHAR *nativeName;
const WCHAR *nativeName;
nativeName = Tcl_FSGetNativePath(fileName);
fileAttributes = old = GetFileAttributes(nativeName);
fileAttributes = old = GetFileAttributesW(nativeName);
if (fileAttributes == 0xffffffff) {
StatError(interp, fileName);
@@ -1853,7 +1853,7 @@ SetWinFileAttributes(
}
if ((fileAttributes != old)
&& !SetFileAttributes(nativeName, fileAttributes)) {
&& !SetFileAttributesW(nativeName, fileAttributes)) {
StatError(interp, fileName);
return TCL_ERROR;
}
@@ -1926,10 +1926,10 @@ TclpObjListVolumes(void)
if (GetLogicalDriveStringsA(sizeof(buf), buf) == 0) {
/*
* GetVolumeInformation() will detects all drives, but causes
* GetVolumeInformationW() will detect all drives, but causes
* chattering on empty floppy drives. We only do this if
* GetLogicalDriveStrings() didn't work. It has also been reported
* that on some laptops it takes a while for GetVolumeInformation() to
* that on some laptops it takes a while for GetVolumeInformationW() to
* return when pinging an empty floppy drive, another reason to try to
* avoid calling it.
*/
+112 -122
View File
@@ -156,27 +156,27 @@ static void FromCTime(time_t posixTime, FILETIME *fileTime);
* Declarations for local functions defined in this file:
*/
static int NativeAccess(const TCHAR *path, int mode);
static int NativeDev(const TCHAR *path);
static int NativeStat(const TCHAR *path, Tcl_StatBuf *statPtr,
static int NativeAccess(const WCHAR *path, int mode);
static int NativeDev(const WCHAR *path);
static int NativeStat(const WCHAR *path, Tcl_StatBuf *statPtr,
int checkLinks);
static unsigned short NativeStatMode(DWORD attr, int checkLinks,
int isExec);
static int NativeIsExec(const TCHAR *path);
static int NativeReadReparse(const TCHAR *LinkDirectory,
static int NativeIsExec(const WCHAR *path);
static int NativeReadReparse(const WCHAR *LinkDirectory,
REPARSE_DATA_BUFFER *buffer, DWORD desiredAccess);
static int NativeWriteReparse(const TCHAR *LinkDirectory,
static int NativeWriteReparse(const WCHAR *LinkDirectory,
REPARSE_DATA_BUFFER *buffer);
static int NativeMatchType(int isDrive, DWORD attr,
const TCHAR *nativeName, Tcl_GlobTypeData *types);
const WCHAR *nativeName, Tcl_GlobTypeData *types);
static int WinIsDrive(const char *name, int nameLen);
static int WinIsReserved(const char *path);
static Tcl_Obj * WinReadLink(const TCHAR *LinkSource);
static Tcl_Obj * WinReadLinkDirectory(const TCHAR *LinkDirectory);
static int WinLink(const TCHAR *LinkSource,
const TCHAR *LinkTarget, int linkAction);
static int WinSymLinkDirectory(const TCHAR *LinkDirectory,
const TCHAR *LinkTarget);
static Tcl_Obj * WinReadLink(const WCHAR *LinkSource);
static Tcl_Obj * WinReadLinkDirectory(const WCHAR *LinkDirectory);
static int WinLink(const WCHAR *LinkSource,
const WCHAR *LinkTarget, int linkAction);
static int WinSymLinkDirectory(const WCHAR *LinkDirectory,
const WCHAR *LinkTarget);
MODULE_SCOPE TCL_NORETURN void tclWinDebugPanic(const char *format, ...);
/*
@@ -191,19 +191,19 @@ MODULE_SCOPE TCL_NORETURN void tclWinDebugPanic(const char *format, ...);
static int
WinLink(
const TCHAR *linkSourcePath,
const TCHAR *linkTargetPath,
const WCHAR *linkSourcePath,
const WCHAR *linkTargetPath,
int linkAction)
{
TCHAR tempFileName[MAX_PATH];
TCHAR *tempFilePart;
WCHAR tempFileName[MAX_PATH];
WCHAR *tempFilePart;
DWORD attr;
/*
* Get the full path referenced by the target.
*/
if (!GetFullPathName(linkTargetPath, MAX_PATH, tempFileName,
if (!GetFullPathNameW(linkTargetPath, MAX_PATH, tempFileName,
&tempFilePart)) {
/*
* Invalid file.
@@ -217,7 +217,7 @@ WinLink(
* Make sure source file doesn't exist.
*/
attr = GetFileAttributes(linkSourcePath);
attr = GetFileAttributesW(linkSourcePath);
if (attr != INVALID_FILE_ATTRIBUTES) {
Tcl_SetErrno(EEXIST);
return -1;
@@ -227,7 +227,7 @@ WinLink(
* Get the full path referenced by the source file/directory.
*/
if (!GetFullPathName(linkSourcePath, MAX_PATH, tempFileName,
if (!GetFullPathNameW(linkSourcePath, MAX_PATH, tempFileName,
&tempFilePart)) {
/*
* Invalid file.
@@ -241,7 +241,7 @@ WinLink(
* Check the target.
*/
attr = GetFileAttributes(linkTargetPath);
attr = GetFileAttributesW(linkTargetPath);
if (attr == INVALID_FILE_ATTRIBUTES) {
/*
* The target doesn't exist.
@@ -254,7 +254,7 @@ WinLink(
*/
if (linkAction & TCL_CREATE_HARD_LINK) {
if (CreateHardLink(linkSourcePath, linkTargetPath, NULL)) {
if (CreateHardLinkW(linkSourcePath, linkTargetPath, NULL)) {
/*
* Success!
*/
@@ -306,17 +306,17 @@ WinLink(
static Tcl_Obj *
WinReadLink(
const TCHAR *linkSourcePath)
const WCHAR *linkSourcePath)
{
TCHAR tempFileName[MAX_PATH];
TCHAR *tempFilePart;
WCHAR tempFileName[MAX_PATH];
WCHAR *tempFilePart;
DWORD attr;
/*
* Get the full path referenced by the target.
*/
if (!GetFullPathName(linkSourcePath, MAX_PATH, tempFileName,
if (!GetFullPathNameW(linkSourcePath, MAX_PATH, tempFileName,
&tempFilePart)) {
/*
* Invalid file.
@@ -330,7 +330,7 @@ WinReadLink(
* Make sure source file does exist.
*/
attr = GetFileAttributes(linkSourcePath);
attr = GetFileAttributesW(linkSourcePath);
if (attr == INVALID_FILE_ATTRIBUTES) {
/*
* The source doesn't exist.
@@ -370,8 +370,8 @@ WinReadLink(
static int
WinSymLinkDirectory(
const TCHAR *linkDirPath,
const TCHAR *linkTargetPath)
const WCHAR *linkDirPath,
const WCHAR *linkTargetPath)
{
DUMMY_REPARSE_BUFFER dummy;
REPARSE_DATA_BUFFER *reparseBuffer = (REPARSE_DATA_BUFFER *) &dummy;
@@ -442,8 +442,8 @@ WinSymLinkDirectory(
int
TclWinSymLinkCopyDirectory(
const TCHAR *linkOrigPath, /* Existing junction - reparse point */
const TCHAR *linkCopyPath) /* Will become a duplicate junction */
const WCHAR *linkOrigPath, /* Existing junction - reparse point */
const WCHAR *linkCopyPath) /* Will become a duplicate junction */
{
DUMMY_REPARSE_BUFFER dummy;
REPARSE_DATA_BUFFER *reparseBuffer = (REPARSE_DATA_BUFFER *) &dummy;
@@ -473,7 +473,7 @@ TclWinSymLinkCopyDirectory(
int
TclWinSymLinkDelete(
const TCHAR *linkOrigPath,
const WCHAR *linkOrigPath,
int linkOnly)
{
/*
@@ -487,7 +487,7 @@ TclWinSymLinkDelete(
memset(reparseBuffer, 0, sizeof(DUMMY_REPARSE_BUFFER));
reparseBuffer->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;
hFile = CreateFile(linkOrigPath, GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
hFile = CreateFileW(linkOrigPath, GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (hFile != INVALID_HANDLE_VALUE) {
@@ -502,7 +502,7 @@ TclWinSymLinkDelete(
} else {
CloseHandle(hFile);
if (!linkOnly) {
RemoveDirectory(linkOrigPath);
RemoveDirectoryW(linkOrigPath);
}
return 0;
}
@@ -538,7 +538,7 @@ TclWinSymLinkDelete(
static Tcl_Obj *
WinReadLinkDirectory(
const TCHAR *linkDirPath)
const WCHAR *linkDirPath)
{
int attr, len, offset;
DUMMY_REPARSE_BUFFER dummy;
@@ -547,7 +547,7 @@ WinReadLinkDirectory(
Tcl_DString ds;
const char *copy;
attr = GetFileAttributes(linkDirPath);
attr = GetFileAttributesW(linkDirPath);
if (!(attr & FILE_ATTRIBUTE_REPARSE_POINT)) {
goto invalidError;
}
@@ -572,7 +572,7 @@ WinReadLinkDirectory(
*/
offset = 0;
#ifdef UNICODE
#if 1
if (reparseBuffer->MountPointReparseBuffer.PathBuffer[0] == L'\\') {
/*
* Check whether this is a mounted volume.
@@ -636,7 +636,7 @@ WinReadLinkDirectory(
}
#endif /* UNICODE */
Tcl_WinTCharToUtf((const TCHAR *)
Tcl_WinTCharToUtf((TCHAR *)
reparseBuffer->MountPointReparseBuffer.PathBuffer,
(int) reparseBuffer->MountPointReparseBuffer
.SubstituteNameLength, &ds);
@@ -675,14 +675,14 @@ WinReadLinkDirectory(
static int
NativeReadReparse(
const TCHAR *linkDirPath, /* The junction to read */
const WCHAR *linkDirPath, /* The junction to read */
REPARSE_DATA_BUFFER *buffer,/* Pointer to buffer. Cannot be NULL */
DWORD desiredAccess)
{
HANDLE hFile;
DWORD returnedLength;
hFile = CreateFile(linkDirPath, desiredAccess, FILE_SHARE_READ, NULL,
hFile = CreateFileW(linkDirPath, desiredAccess, FILE_SHARE_READ, NULL,
OPEN_EXISTING,
FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL);
@@ -732,7 +732,7 @@ NativeReadReparse(
static int
NativeWriteReparse(
const TCHAR *linkDirPath,
const WCHAR *linkDirPath,
REPARSE_DATA_BUFFER *buffer)
{
HANDLE hFile;
@@ -742,7 +742,7 @@ NativeWriteReparse(
* Create the directory - it must not already exist.
*/
if (CreateDirectory(linkDirPath, NULL) == 0) {
if (CreateDirectoryW(linkDirPath, NULL) == 0) {
/*
* Error creating directory.
*/
@@ -750,7 +750,7 @@ NativeWriteReparse(
TclWinConvertError(GetLastError());
return -1;
}
hFile = CreateFile(linkDirPath, GENERIC_WRITE, 0, NULL,
hFile = CreateFileW(linkDirPath, GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT
| FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
@@ -775,7 +775,7 @@ NativeWriteReparse(
TclWinConvertError(GetLastError());
CloseHandle(hFile);
RemoveDirectory(linkDirPath);
RemoveDirectoryW(linkDirPath);
return -1;
}
CloseHandle(hFile);
@@ -880,17 +880,7 @@ TclpFindExecutable(
Tcl_SetPanicProc(tclWinDebugPanic);
}
#ifdef UNICODE
GetModuleFileNameW(NULL, wName, MAX_PATH);
#else
GetModuleFileNameA(NULL, name, sizeof(name));
/*
* Convert to WCHAR to get out of ANSI codepage
*/
MultiByteToWideChar(CP_ACP, 0, name, -1, wName, MAX_PATH);
#endif
WideCharToMultiByte(CP_UTF8, 0, wName, -1, name, sizeof(name), NULL, NULL);
TclWinNoBackslash(name);
TclSetObjNameOfExecutable(Tcl_NewStringObj(name, -1), NULL);
@@ -925,7 +915,7 @@ TclpMatchInDirectory(
* May be NULL. In particular the directory
* flag is very important. */
{
const TCHAR *native;
const WCHAR *native;
if (types != NULL && types->type == TCL_GLOB_TYPE_MOUNT) {
/*
@@ -950,7 +940,7 @@ TclpMatchInDirectory(
native = Tcl_FSGetNativePath(pathPtr);
if (GetFileAttributesEx(native,
if (GetFileAttributesExW(native,
GetFileExInfoStandard, &data) != TRUE) {
return TCL_OK;
}
@@ -964,7 +954,7 @@ TclpMatchInDirectory(
} else {
DWORD attr;
HANDLE handle;
WIN32_FIND_DATA data;
WIN32_FIND_DATAW data;
const char *dirName; /* UTF-8 dir name, later with pattern
* appended. */
int dirLength;
@@ -993,7 +983,7 @@ TclpMatchInDirectory(
if (native == NULL) {
return TCL_OK;
}
attr = GetFileAttributes(native);
attr = GetFileAttributesW(native);
if ((attr == INVALID_FILE_ATTRIBUTES)
|| ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0)) {
@@ -1034,15 +1024,15 @@ TclpMatchInDirectory(
dirName = TclDStringAppendLiteral(&dsOrig, "*.*");
}
native = Tcl_WinUtfToTChar(dirName, -1, &ds);
native = (WCHAR *)Tcl_WinUtfToTChar(dirName, -1, &ds);
if ((types == NULL) || (types->type != TCL_GLOB_TYPE_DIR)) {
handle = FindFirstFile(native, &data);
handle = FindFirstFileW(native, &data);
} else {
/*
* We can be more efficient, for pure directory requests.
*/
handle = FindFirstFileEx(native,
handle = FindFirstFileExW(native,
FindExInfoStandard, &data,
FindExSearchLimitToDirectories, NULL, 0);
}
@@ -1107,7 +1097,7 @@ TclpMatchInDirectory(
native = data.cFileName;
attr = data.dwFileAttributes;
utfname = Tcl_WinTCharToUtf(native, -1, &ds);
utfname = Tcl_WinTCharToUtf((TCHAR *)native, -1, &ds);
if (!matchSpecialDots) {
/*
@@ -1167,7 +1157,7 @@ TclpMatchInDirectory(
*/
Tcl_DStringFree(&ds);
} while (FindNextFile(handle, &data) == TRUE);
} while (FindNextFileW(handle, &data) == TRUE);
FindClose(handle);
Tcl_DStringFree(&dsOrig);
@@ -1325,7 +1315,7 @@ NativeMatchType(
int isDrive, /* Is this a drive. */
DWORD attr, /* We already know the attributes for the
* file. */
const TCHAR *nativeName, /* Native path to check. */
const WCHAR *nativeName, /* Native path to check. */
Tcl_GlobTypeData *types) /* Type description to match against. */
{
/*
@@ -1596,12 +1586,12 @@ TclpGetUserHome(
static int
NativeAccess(
const TCHAR *nativePath, /* Path of file to access, native encoding. */
const WCHAR *nativePath, /* Path of file to access, native encoding. */
int mode) /* Permission setting. */
{
DWORD attr;
attr = GetFileAttributes(nativePath);
attr = GetFileAttributesW(nativePath);
if (attr == INVALID_FILE_ATTRIBUTES) {
/*
@@ -1670,7 +1660,7 @@ NativeAccess(
mask |= GENERIC_EXECUTE;
}
hFile = CreateFile(nativePath, mask,
hFile = CreateFileW(nativePath, mask,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL);
if (hFile != INVALID_HANDLE_VALUE) {
@@ -1701,7 +1691,7 @@ NativeAccess(
* what permissions the OS has set for a file.
*/
#ifdef UNICODE
#if 1
{
SECURITY_DESCRIPTOR *sdPtr = NULL;
unsigned long size;
@@ -1721,7 +1711,7 @@ NativeAccess(
*/
size = 0;
GetFileSecurity(nativePath,
GetFileSecurityW(nativePath,
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
| DACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION,
0, 0, &size);
@@ -1752,10 +1742,10 @@ NativeAccess(
}
/*
* Call GetFileSecurity() for real.
* Call GetFileSecurityW() for real.
*/
if (!GetFileSecurity(nativePath,
if (!GetFileSecurityW(nativePath,
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
| DACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION,
sdPtr, size, &size)) {
@@ -1884,9 +1874,9 @@ NativeAccess(
static int
NativeIsExec(
const TCHAR *path)
const WCHAR *path)
{
int len = _tcslen(path);
size_t len = wcslen(path);
if (len < 5) {
return 0;
@@ -1897,11 +1887,11 @@ NativeIsExec(
}
path += len-3;
if ((_tcsicmp(path, TEXT("exe")) == 0)
|| (_tcsicmp(path, TEXT("com")) == 0)
|| (_tcsicmp(path, TEXT("cmd")) == 0)
|| (_tcsicmp(path, TEXT("cmd")) == 0)
|| (_tcsicmp(path, TEXT("bat")) == 0)) {
if ((wcsicmp(path, L"exe") == 0)
|| (wcsicmp(path, L"com") == 0)
|| (wcsicmp(path, L"cmd") == 0)
|| (wcsicmp(path, L"cmd") == 0)
|| (wcsicmp(path, L"bat") == 0)) {
return 1;
}
return 0;
@@ -1928,14 +1918,14 @@ TclpObjChdir(
Tcl_Obj *pathPtr) /* Path to new working directory. */
{
int result;
const TCHAR *nativePath;
const WCHAR *nativePath;
nativePath = Tcl_FSGetNativePath(pathPtr);
if (!nativePath) {
return -1;
}
result = SetCurrentDirectory(nativePath);
result = SetCurrentDirectoryW(nativePath);
if (result == 0) {
TclWinConvertError(GetLastError());
@@ -1972,11 +1962,11 @@ TclpGetCwd(
Tcl_DString *bufferPtr) /* Uninitialized or free DString filled with
* name of current directory. */
{
TCHAR buffer[MAX_PATH];
WCHAR buffer[MAX_PATH];
char *p;
WCHAR *native;
if (GetCurrentDirectory(MAX_PATH, buffer) == 0) {
if (GetCurrentDirectoryW(MAX_PATH, buffer) == 0) {
TclWinConvertError(GetLastError());
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -2050,7 +2040,7 @@ TclpObjStat(
static int
NativeStat(
const TCHAR *nativePath, /* Path of file to stat */
const WCHAR *nativePath, /* Path of file to stat */
Tcl_StatBuf *statPtr, /* Filled with results of stat call. */
int checkLinks) /* If non-zero, behave like 'lstat' */
{
@@ -2076,7 +2066,7 @@ NativeStat(
* and if successful, mock up a BY_HANDLE_FILE_INFORMATION structure.
*/
fileHandle = CreateFile(nativePath, GENERIC_READ,
fileHandle = CreateFileW(nativePath, GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, NULL);
@@ -2134,17 +2124,17 @@ NativeStat(
WIN32_FILE_ATTRIBUTE_DATA data;
if (GetFileAttributesEx(nativePath,
if (GetFileAttributesExW(nativePath,
GetFileExInfoStandard, &data) != TRUE) {
HANDLE hFind;
WIN32_FIND_DATA ffd;
WIN32_FIND_DATAW ffd;
DWORD lasterror = GetLastError();
if (lasterror != ERROR_SHARING_VIOLATION) {
TclWinConvertError(lasterror);
return -1;
}
hFind = FindFirstFile(nativePath, &ffd);
hFind = FindFirstFileW(nativePath, &ffd);
if (hFind == INVALID_HANDLE_VALUE) {
TclWinConvertError(GetLastError());
return -1;
@@ -2194,28 +2184,28 @@ NativeStat(
static int
NativeDev(
const TCHAR *nativePath) /* Full path of file to stat */
const WCHAR *nativePath) /* Full path of file to stat */
{
int dev;
Tcl_DString ds;
TCHAR nativeFullPath[MAX_PATH];
TCHAR *nativePart;
WCHAR nativeFullPath[MAX_PATH];
WCHAR *nativePart;
const char *fullPath;
GetFullPathName(nativePath, MAX_PATH, nativeFullPath, &nativePart);
fullPath = Tcl_WinTCharToUtf(nativeFullPath, -1, &ds);
GetFullPathNameW(nativePath, MAX_PATH, nativeFullPath, &nativePart);
fullPath = Tcl_WinTCharToUtf((TCHAR *)nativeFullPath, -1, &ds);
if ((fullPath[0] == '\\') && (fullPath[1] == '\\')) {
const char *p;
DWORD dw;
const TCHAR *nativeVol;
const WCHAR *nativeVol;
Tcl_DString volString;
p = strchr(fullPath + 2, '\\');
p = strchr(p + 1, '\\');
if (p == NULL) {
/*
* Add terminating backslash to fullpath or GetVolumeInformation()
* Add terminating backslash to fullpath or GetVolumeInformationW()
* won't work.
*/
@@ -2224,13 +2214,13 @@ NativeDev(
} else {
p++;
}
nativeVol = Tcl_WinUtfToTChar(fullPath, p - fullPath, &volString);
nativeVol = (WCHAR *)Tcl_WinUtfToTChar(fullPath, p - fullPath, &volString);
dw = (DWORD) -1;
GetVolumeInformation(nativeVol, NULL, 0, &dw, NULL, NULL, NULL, 0);
GetVolumeInformationW(nativeVol, NULL, 0, &dw, NULL, NULL, NULL, 0);
/*
* GetFullPathName() turns special devices like "NUL" into "\\.\NUL",
* but GetVolumeInformation() returns failure for "\\.\NUL". This will
* GetFullPathNameW() turns special devices like "NUL" into "\\.\NUL",
* but GetVolumeInformationW() returns failure for "\\.\NUL". This will
* cause "NUL" to get a drive number of -1, which makes about as much
* sense as anything since the special devices don't live on any
* drive.
@@ -2370,15 +2360,15 @@ ClientData
TclpGetNativeCwd(
ClientData clientData)
{
TCHAR buffer[MAX_PATH];
WCHAR buffer[MAX_PATH];
if (GetCurrentDirectory(MAX_PATH, buffer) == 0) {
if (GetCurrentDirectoryW(MAX_PATH, buffer) == 0) {
TclWinConvertError(GetLastError());
return NULL;
}
if (clientData != NULL) {
if (_tcscmp((const TCHAR *) clientData, buffer) == 0) {
if (wcscmp((const WCHAR *) clientData, buffer) == 0) {
return clientData;
}
}
@@ -2419,8 +2409,8 @@ TclpObjLink(
{
if (toPtr != NULL) {
int res;
const TCHAR *LinkTarget;
const TCHAR *LinkSource = Tcl_FSGetNativePath(pathPtr);
const WCHAR *LinkTarget;
const WCHAR *LinkSource = Tcl_FSGetNativePath(pathPtr);
Tcl_Obj *normalizedToPtr = Tcl_FSGetNormalizedPath(NULL, toPtr);
if (normalizedToPtr == NULL) {
@@ -2439,7 +2429,7 @@ TclpObjLink(
return NULL;
}
} else {
const TCHAR *LinkSource = Tcl_FSGetNativePath(pathPtr);
const WCHAR *LinkSource = Tcl_FSGetNativePath(pathPtr);
if (LinkSource == NULL) {
return NULL;
@@ -2473,7 +2463,7 @@ TclpFilesystemPathType(
{
#define VOL_BUF_SIZE 32
int found;
TCHAR volType[VOL_BUF_SIZE];
WCHAR volType[VOL_BUF_SIZE];
char *firstSeparator;
const char *path;
Tcl_Obj *normPath = Tcl_FSGetNormalizedPath(NULL, pathPtr);
@@ -2488,13 +2478,13 @@ TclpFilesystemPathType(
firstSeparator = strchr(path, '/');
if (firstSeparator == NULL) {
found = GetVolumeInformation(Tcl_FSGetNativePath(pathPtr),
found = GetVolumeInformationW(Tcl_FSGetNativePath(pathPtr),
NULL, 0, NULL, NULL, NULL, volType, VOL_BUF_SIZE);
} else {
Tcl_Obj *driveName = Tcl_NewStringObj(path, firstSeparator - path+1);
Tcl_IncrRefCount(driveName);
found = GetVolumeInformation(Tcl_FSGetNativePath(driveName),
found = GetVolumeInformationW(Tcl_FSGetNativePath(driveName),
NULL, 0, NULL, NULL, NULL, volType, VOL_BUF_SIZE);
Tcl_DecrRefCount(driveName);
}
@@ -2504,7 +2494,7 @@ TclpFilesystemPathType(
} else {
Tcl_DString ds;
Tcl_WinTCharToUtf(volType, -1, &ds);
Tcl_WinTCharToUtf((TCHAR *)volType, -1, &ds);
return TclDStringToObj(&ds);
}
#undef VOL_BUF_SIZE
@@ -2574,10 +2564,10 @@ TclpObjNormalizePath(
*/
WIN32_FILE_ATTRIBUTE_DATA data;
const TCHAR *nativePath = Tcl_WinUtfToTChar(path,
const WCHAR *nativePath = (WCHAR *)Tcl_WinUtfToTChar(path,
currentPathEndPosition - path, &ds);
if (GetFileAttributesEx(nativePath,
if (GetFileAttributesExW(nativePath,
GetFileExInfoStandard, &data) != TRUE) {
/*
* File doesn't exist.
@@ -2718,8 +2708,8 @@ TclpObjNormalizePath(
Tcl_DStringAppend(&dsNorm, ((const char *)nativePath)
+ Tcl_DStringLength(&ds)
- (dotLen * sizeof(TCHAR)),
(int)(dotLen * sizeof(TCHAR)));
- (dotLen * sizeof(WCHAR)),
(int)(dotLen * sizeof(WCHAR)));
} else {
/*
* Normal path.
@@ -2776,10 +2766,10 @@ TclpObjNormalizePath(
if (1) {
WCHAR wpath[MAX_PATH];
const TCHAR *nativePath =
const WCHAR *nativePath =
Tcl_WinUtfToTChar(path, lastValidPathEnd - path, &ds);
DWORD wpathlen = GetLongPathNameProc(nativePath,
(TCHAR *) wpath, MAX_PATH);
(WCHAR *) wpath, MAX_PATH);
/*
* We have to make the drive letter uppercase.
@@ -2807,7 +2797,7 @@ TclpObjNormalizePath(
* native encoding, so we have to convert it to Utf.
*/
Tcl_WinTCharToUtf((const TCHAR *) Tcl_DStringValue(&dsNorm),
Tcl_WinTCharToUtf((TCHAR *) Tcl_DStringValue(&dsNorm),
Tcl_DStringLength(&dsNorm), &ds);
nextCheckpoint = Tcl_DStringLength(&ds);
if (*lastValidPathEnd != 0) {
@@ -2984,7 +2974,7 @@ TclpNativeToNormalized(
int len;
char *copy, *p;
Tcl_WinTCharToUtf((const TCHAR *) clientData, -1, &ds);
Tcl_WinTCharToUtf((TCHAR *) clientData, -1, &ds);
copy = Tcl_DStringValue(&ds);
len = Tcl_DStringLength(&ds);
@@ -3208,7 +3198,7 @@ TclNativeDupInternalRep(
return NULL;
}
len = sizeof(TCHAR) * (_tcslen((const TCHAR *) clientData) + 1);
len = sizeof(WCHAR) * (wcslen((const WCHAR *) clientData) + 1);
copy = ckalloc(len);
memcpy(copy, clientData, len);
@@ -3239,7 +3229,7 @@ TclpUtime(
{
int res = 0;
HANDLE fileHandle;
const TCHAR *native;
const WCHAR *native;
DWORD attr = 0;
DWORD flags = FILE_ATTRIBUTE_NORMAL;
FILETIME lastAccessTime, lastModTime;
@@ -3249,7 +3239,7 @@ TclpUtime(
native = Tcl_FSGetNativePath(pathPtr);
attr = GetFileAttributes(native);
attr = GetFileAttributesW(native);
if (attr != INVALID_FILE_ATTRIBUTES && attr & FILE_ATTRIBUTE_DIRECTORY) {
flags = FILE_FLAG_BACKUP_SEMANTICS;
@@ -3260,7 +3250,7 @@ TclpUtime(
* savings complications that utime gets wrong.
*/
fileHandle = CreateFile(native, FILE_WRITE_ATTRIBUTES, 0, NULL,
fileHandle = CreateFileW(native, FILE_WRITE_ATTRIBUTES, 0, NULL,
OPEN_EXISTING, flags, NULL);
if (fileHandle == INVALID_HANDLE_VALUE ||
@@ -3290,7 +3280,7 @@ int
TclWinFileOwned(
Tcl_Obj *pathPtr) /* File whose ownership is to be checked */
{
const TCHAR *native;
const WCHAR *native;
PSID ownerSid = NULL;
PSECURITY_DESCRIPTOR secd = NULL;
HANDLE token;
@@ -3300,7 +3290,7 @@ TclWinFileOwned(
native = Tcl_FSGetNativePath(pathPtr);
if (GetNamedSecurityInfo((LPTSTR) native, SE_FILE_OBJECT,
if (GetNamedSecurityInfoW((LPWSTR) native, SE_FILE_OBJECT,
OWNER_SECURITY_INFORMATION, &ownerSid, NULL, NULL, NULL,
&secd) != ERROR_SUCCESS) {
/*
+8 -8
View File
@@ -17,7 +17,7 @@
#include <lmcons.h>
/*
* GetUserName() is found in advapi32.dll
* GetUserNameW() is found in advapi32.dll
*/
#ifdef _MSC_VER
# pragma comment(lib, "advapi32.lib")
@@ -166,7 +166,7 @@ TclpInitPlatform(void)
/*
* Fill available functions depending on windows version
*/
handle = GetModuleHandle(TEXT("KERNEL32"));
handle = GetModuleHandleW(L"KERNEL32");
tclWinProcs.cancelSynchronousIo =
(BOOL (WINAPI *)(HANDLE)) GetProcAddress(handle,
"CancelSynchronousIo");
@@ -310,7 +310,7 @@ AppendEnvironment(
Tcl_SplitPath(buf, &pathc, &pathv);
/*
* The lstrcmpi() will work even if pathv[pathc-1] is random UTF-8
* The lstrcmpiA() will work even if pathv[pathc-1] is random UTF-8
* chars because I know shortlib is ascii.
*/
@@ -525,15 +525,15 @@ TclpGetUserName(
Tcl_DStringInit(bufferPtr);
if (TclGetEnv("USERNAME", bufferPtr) == NULL) {
TCHAR szUserName[UNLEN+1];
WCHAR szUserName[UNLEN+1];
DWORD cchUserNameLen = UNLEN;
if (!GetUserName(szUserName, &cchUserNameLen)) {
if (!GetUserNameW(szUserName, &cchUserNameLen)) {
return NULL;
}
cchUserNameLen--;
cchUserNameLen *= sizeof(TCHAR);
Tcl_WinTCharToUtf(szUserName, cchUserNameLen, bufferPtr);
cchUserNameLen *= sizeof(WCHAR);
Tcl_WinTCharToUtf((TCHAR *)szUserName, cchUserNameLen, bufferPtr);
}
return Tcl_DStringValue(bufferPtr);
}
@@ -573,7 +573,7 @@ TclpSetVariables(
TclGetProcessGlobalValue(&defaultLibraryDir), TCL_GLOBAL_ONLY);
if (!osInfoInitialized) {
HMODULE handle = GetModuleHandle(TEXT("NTDLL"));
HMODULE handle = GetModuleHandleW(L"NTDLL");
int(__stdcall *getversion)(void *) =
(int(__stdcall *)(void *)) GetProcAddress(handle, "RtlGetVersion");
osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
+5 -5
View File
@@ -65,7 +65,7 @@ MODULE_SCOPE TclWinProcs tclWinProcs;
*/
MODULE_SCOPE char TclWinDriveLetterForVolMountPoint(
const TCHAR *mountPoint);
const WCHAR *mountPoint);
MODULE_SCOPE void TclWinEncodingsCleanup();
MODULE_SCOPE void TclWinInit(HINSTANCE hInst);
MODULE_SCOPE TclFile TclWinMakeFile(HANDLE handle);
@@ -75,11 +75,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 HANDLE TclWinSerialOpen(HANDLE handle, const TCHAR *name,
MODULE_SCOPE HANDLE TclWinSerialOpen(HANDLE handle, const WCHAR *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 WCHAR *LinkOriginal,
const WCHAR *LinkCopy);
MODULE_SCOPE int TclWinSymLinkDelete(const WCHAR *LinkOriginal,
int linkOnly);
MODULE_SCOPE int TclWinFileOwned(Tcl_Obj *);
#if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
+4 -4
View File
@@ -64,7 +64,7 @@ TclpDlopen(
int flags)
{
HINSTANCE hInstance = NULL;
const TCHAR *nativeName;
const WCHAR *nativeName;
Tcl_LoadHandle handlePtr;
DWORD firstError;
@@ -76,7 +76,7 @@ TclpDlopen(
nativeName = Tcl_FSGetNativePath(pathPtr);
if (nativeName != NULL) {
hInstance = LoadLibraryEx(nativeName, NULL,
hInstance = LoadLibraryExW(nativeName, NULL,
LOAD_WITH_ALTERED_SEARCH_PATH);
}
if (hInstance == NULL) {
@@ -95,8 +95,8 @@ TclpDlopen(
firstError = (nativeName == NULL) ?
ERROR_MOD_NOT_FOUND : GetLastError();
nativeName = Tcl_WinUtfToTChar(Tcl_GetString(pathPtr), -1, &ds);
hInstance = LoadLibraryEx(nativeName, NULL,
nativeName = (WCHAR *)Tcl_WinUtfToTChar(Tcl_GetString(pathPtr), -1, &ds);
hInstance = LoadLibraryExW(nativeName, NULL,
LOAD_WITH_ALTERED_SEARCH_PATH);
Tcl_DStringFree(&ds);
}
+22 -22
View File
@@ -50,7 +50,7 @@ static Tcl_ThreadDataKey dataKey;
*/
static int notifierCount = 0;
static const TCHAR classname[] = TEXT("TclNotifier");
static const WCHAR classname[] = L"TclNotifier";
TCL_DECLARE_MUTEX(notifierMutex)
/*
@@ -83,7 +83,7 @@ Tcl_InitNotifier(void)
return tclNotifierHooks.initNotifierProc();
} else {
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
WNDCLASS class;
WNDCLASSW windowClass;
/*
* Register Notifier window class if this is the first thread to use
@@ -92,18 +92,18 @@ Tcl_InitNotifier(void)
Tcl_MutexLock(&notifierMutex);
if (notifierCount == 0) {
class.style = 0;
class.cbClsExtra = 0;
class.cbWndExtra = 0;
class.hInstance = TclWinGetTclInstance();
class.hbrBackground = NULL;
class.lpszMenuName = NULL;
class.lpszClassName = classname;
class.lpfnWndProc = NotifierProc;
class.hIcon = NULL;
class.hCursor = NULL;
windowClass.style = 0;
windowClass.cbClsExtra = 0;
windowClass.cbWndExtra = 0;
windowClass.hInstance = TclWinGetTclInstance();
windowClass.hbrBackground = NULL;
windowClass.lpszMenuName = NULL;
windowClass.lpszClassName = classname;
windowClass.lpfnWndProc = NotifierProc;
windowClass.hIcon = NULL;
windowClass.hCursor = NULL;
if (!RegisterClass(&class)) {
if (!RegisterClassW(&windowClass)) {
Tcl_Panic("Unable to register TclNotifier window class");
}
}
@@ -117,7 +117,7 @@ Tcl_InitNotifier(void)
tsdPtr->hwnd = NULL;
tsdPtr->thread = GetCurrentThreadId();
tsdPtr->event = CreateEvent(NULL, TRUE /* manual */,
tsdPtr->event = CreateEventW(NULL, TRUE /* manual */,
FALSE /* !signaled */, NULL);
return tsdPtr;
@@ -186,7 +186,7 @@ Tcl_FinalizeNotifier(
Tcl_MutexLock(&notifierMutex);
notifierCount--;
if (notifierCount == 0) {
UnregisterClass(classname, TclWinGetTclInstance());
UnregisterClassW(classname, TclWinGetTclInstance());
}
Tcl_MutexUnlock(&notifierMutex);
}
@@ -237,7 +237,7 @@ Tcl_AlertNotifier(
EnterCriticalSection(&tsdPtr->crit);
if (!tsdPtr->pending) {
PostMessage(tsdPtr->hwnd, WM_WAKEUP, 0, 0);
PostMessageW(tsdPtr->hwnd, WM_WAKEUP, 0, 0);
}
tsdPtr->pending = 1;
LeaveCriticalSection(&tsdPtr->crit);
@@ -350,7 +350,7 @@ Tcl_ServiceModeHook(
*/
if (mode == TCL_SERVICE_ALL && !tsdPtr->hwnd) {
tsdPtr->hwnd = CreateWindow(classname, classname,
tsdPtr->hwnd = CreateWindowW(classname, classname,
WS_TILED, 0, 0, 0, 0, NULL, NULL, TclWinGetTclInstance(),
NULL);
@@ -398,7 +398,7 @@ NotifierProc(
tsdPtr->pending = 0;
LeaveCriticalSection(&tsdPtr->crit);
} else if (message != WM_TIMER) {
return DefWindowProc(hwnd, message, wParam, lParam);
return DefWindowProcW(hwnd, message, wParam, lParam);
}
/*
@@ -470,7 +470,7 @@ Tcl_WaitForEvent(
* events currently sitting in the queue.
*/
if (!PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
if (!PeekMessageW(&msg, NULL, 0, 0, PM_NOREMOVE)) {
/*
* Wait for something to happen (a signal from another thread, a
* message, or timeout) or loop servicing asynchronous procedure
@@ -492,12 +492,12 @@ Tcl_WaitForEvent(
* Check to see if there are any messages to process.
*/
if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
if (PeekMessageW(&msg, NULL, 0, 0, PM_NOREMOVE)) {
/*
* Retrieve and dispatch the first message.
*/
result = GetMessage(&msg, NULL, 0, 0);
result = GetMessageW(&msg, NULL, 0, 0);
if (result == 0) {
/*
* We received a request to exit this thread (WM_QUIT), so
@@ -515,7 +515,7 @@ Tcl_WaitForEvent(
status = -1;
} else {
TranslateMessage(&msg);
DispatchMessage(&msg);
DispatchMessageW(&msg);
status = 1;
}
} else {
+42 -42
View File
@@ -190,7 +190,7 @@ static DWORD WINAPI PipeReaderThread(LPVOID arg);
static void PipeSetupProc(ClientData clientData, int flags);
static void PipeWatchProc(ClientData instanceData, int mask);
static DWORD WINAPI PipeWriterThread(LPVOID arg);
static int TempFileName(TCHAR name[MAX_PATH]);
static int TempFileName(WCHAR name[MAX_PATH]);
static int WaitForRead(PipeInfo *infoPtr, int blocking);
static void PipeThreadActionProc(ClientData instanceData,
int action);
@@ -462,18 +462,18 @@ TclWinMakeFile(
static int
TempFileName(
TCHAR name[MAX_PATH]) /* Buffer in which name for temporary file
WCHAR name[MAX_PATH]) /* Buffer in which name for temporary file
* gets stored. */
{
const TCHAR *prefix = TEXT("TCL");
if (GetTempPath(MAX_PATH, name) != 0) {
if (GetTempFileName(name, prefix, 0, name) != 0) {
const WCHAR *prefix = L"TCL";
if (GetTempPathW(MAX_PATH, name) != 0) {
if (GetTempFileNameW(name, prefix, 0, name) != 0) {
return 1;
}
}
name[0] = '.';
name[1] = '\0';
return GetTempFileName(name, prefix, 0, name);
return GetTempFileNameW(name, prefix, 0, name);
}
/*
@@ -532,7 +532,7 @@ TclpOpenFile(
HANDLE handle;
DWORD accessMode, createMode, shareMode, flags;
Tcl_DString ds;
const TCHAR *nativePath;
const WCHAR *nativePath;
/*
* Map the access bits to the NT access mode.
@@ -577,7 +577,7 @@ TclpOpenFile(
break;
}
nativePath = Tcl_WinUtfToTChar(path, -1, &ds);
nativePath = (WCHAR *)Tcl_WinUtfToTChar(path, -1, &ds);
/*
* If the file is not being created, use the existing file attributes.
@@ -585,7 +585,7 @@ TclpOpenFile(
flags = 0;
if (!(mode & O_CREAT)) {
flags = GetFileAttributes(nativePath);
flags = GetFileAttributesW(nativePath);
if (flags == 0xFFFFFFFF) {
flags = 0;
}
@@ -601,7 +601,7 @@ TclpOpenFile(
* Now we get to create the file.
*/
handle = CreateFile(nativePath, accessMode, shareMode,
handle = CreateFileW(nativePath, accessMode, shareMode,
NULL, createMode, flags, NULL);
Tcl_DStringFree(&ds);
@@ -649,7 +649,7 @@ TclFile
TclpCreateTempFile(
const char *contents) /* String to write into temp file, or NULL. */
{
TCHAR name[MAX_PATH];
WCHAR name[MAX_PATH];
const char *native;
Tcl_DString dstring;
HANDLE handle;
@@ -658,7 +658,7 @@ TclpCreateTempFile(
return NULL;
}
handle = CreateFile(name,
handle = CreateFileW(name,
GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_TEMPORARY|FILE_FLAG_DELETE_ON_CLOSE, NULL);
if (handle == INVALID_HANDLE_VALUE) {
@@ -720,7 +720,7 @@ TclpCreateTempFile(
TclWinConvertError(GetLastError());
CloseHandle(handle);
DeleteFile(name);
DeleteFileW(name);
return NULL;
}
@@ -743,7 +743,7 @@ TclpCreateTempFile(
Tcl_Obj *
TclpTempFileName(void)
{
TCHAR fileName[MAX_PATH];
WCHAR fileName[MAX_PATH];
if (TempFileName(fileName) == 0) {
return NULL;
@@ -935,8 +935,8 @@ TclpCreateProcess(
* process. */
{
int result, applType, createFlags;
Tcl_DString cmdLine; /* Complete command line (TCHAR). */
STARTUPINFO startInfo;
Tcl_DString cmdLine; /* Complete command line (WCHAR). */
STARTUPINFOW startInfo;
PROCESS_INFORMATION procInfo;
SECURITY_ATTRIBUTES secAtts;
HANDLE hProcess, h, inputHandle, outputHandle, errorHandle;
@@ -1047,7 +1047,7 @@ TclpCreateProcess(
* sink.
*/
startInfo.hStdOutput = CreateFile(TEXT("NUL:"), GENERIC_WRITE, 0,
startInfo.hStdOutput = CreateFileW(L"NUL:", GENERIC_WRITE, 0,
&secAtts, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
} else {
DuplicateHandle(hProcess, outputHandle, hProcess,
@@ -1067,7 +1067,7 @@ TclpCreateProcess(
* sink.
*/
startInfo.hStdError = CreateFile(TEXT("NUL:"), GENERIC_WRITE, 0,
startInfo.hStdError = CreateFileW(L"NUL:", GENERIC_WRITE, 0,
&secAtts, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
} else {
DuplicateHandle(hProcess, errorHandle, hProcess, &startInfo.hStdError,
@@ -1150,7 +1150,7 @@ TclpCreateProcess(
BuildCommandLine(execPath, argc, argv, &cmdLine);
if (CreateProcess(NULL, (TCHAR *) Tcl_DStringValue(&cmdLine),
if (CreateProcessW(NULL, (WCHAR *) Tcl_DStringValue(&cmdLine),
NULL, NULL, TRUE, (DWORD) createFlags, NULL, NULL, &startInfo,
&procInfo) == 0) {
TclWinConvertError(GetLastError());
@@ -1221,7 +1221,7 @@ HasConsole(void)
{
HANDLE handle;
handle = CreateFileA("CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE,
handle = CreateFileW(L"CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (handle != INVALID_HANDLE_VALUE) {
@@ -1276,14 +1276,14 @@ ApplicationType(
{
int applType, i, nameLen, found;
HANDLE hFile;
TCHAR *rest;
WCHAR *rest;
char *ext;
char buf[2];
DWORD attr, read;
IMAGE_DOS_HEADER header;
Tcl_DString nameBuf, ds;
const TCHAR *nativeName;
TCHAR nativeFullPath[MAX_PATH];
const WCHAR *nativeName;
WCHAR nativeFullPath[MAX_PATH];
static const char extensions[][5] = {"", ".com", ".exe", ".bat", ".cmd"};
/*
@@ -1291,10 +1291,10 @@ ApplicationType(
* is, then try adding .com, .exe, .bat and .cmd, in that order, to the name,
* looking for an executable.
*
* Using the raw SearchPath() function doesn't do quite what is necessary.
* Using the raw SearchPathW() function doesn't do quite what is necessary.
* If the name of the executable already contains a '.' character, it will
* not try appending the specified extension when searching (in other
* words, SearchPath will not find the program "a.b.exe" if the arguments
* words, SearchPathW will not find the program "a.b.exe" if the arguments
* specified "a.b" and ".exe"). So, first look for the file as it is
* named. Then manually append the extensions, looking for a match.
*/
@@ -1307,9 +1307,9 @@ 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 = (WCHAR *)Tcl_WinUtfToTChar(Tcl_DStringValue(&nameBuf),
Tcl_DStringLength(&nameBuf), &ds);
found = SearchPath(NULL, nativeName, NULL, MAX_PATH,
found = SearchPathW(NULL, nativeName, NULL, MAX_PATH,
nativeFullPath, &rest);
Tcl_DStringFree(&ds);
if (found == 0) {
@@ -1321,11 +1321,11 @@ ApplicationType(
* known type.
*/
attr = GetFileAttributes(nativeFullPath);
attr = GetFileAttributesW(nativeFullPath);
if ((attr == 0xffffffff) || (attr & FILE_ATTRIBUTE_DIRECTORY)) {
continue;
}
strcpy(fullName, Tcl_WinTCharToUtf(nativeFullPath, -1, &ds));
strcpy(fullName, Tcl_WinTCharToUtf((TCHAR *)nativeFullPath, -1, &ds));
Tcl_DStringFree(&ds);
ext = strrchr(fullName, '.');
@@ -1335,7 +1335,7 @@ ApplicationType(
break;
}
hFile = CreateFile(nativeFullPath,
hFile = CreateFileW(nativeFullPath,
GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
@@ -1415,8 +1415,8 @@ ApplicationType(
* application name from the arguments.
*/
GetShortPathName(nativeFullPath, nativeFullPath, MAX_PATH);
strcpy(fullName, Tcl_WinTCharToUtf(nativeFullPath, -1, &ds));
GetShortPathNameW(nativeFullPath, nativeFullPath, MAX_PATH);
strcpy(fullName, Tcl_WinTCharToUtf((TCHAR *)nativeFullPath, -1, &ds));
Tcl_DStringFree(&ds);
}
return applType;
@@ -1552,7 +1552,7 @@ BuildCommandLine(
int argc, /* Number of arguments. */
const char **argv, /* Argument strings in UTF. */
Tcl_DString *linePtr) /* Initialized Tcl_DString that receives the
* command line (TCHAR). */
* command line (WCHAR). */
{
const char *arg, *start, *special, *bspos;
int quote = 0, i;
@@ -1801,7 +1801,7 @@ TclpCreateCommandChannel(
* Start the background reader thread.
*/
infoPtr->readable = CreateEvent(NULL, TRUE, TRUE, NULL);
infoPtr->readable = CreateEventW(NULL, TRUE, TRUE, NULL);
infoPtr->readThread = CreateThread(NULL, 256, PipeReaderThread,
TclPipeThreadCreateTI(&infoPtr->readTI, infoPtr, infoPtr->readable),
0, NULL);
@@ -1816,7 +1816,7 @@ TclpCreateCommandChannel(
* Start the background writer thread.
*/
infoPtr->writable = CreateEvent(NULL, TRUE, TRUE, NULL);
infoPtr->writable = CreateEventW(NULL, TRUE, TRUE, NULL);
infoPtr->writeThread = CreateThread(NULL, 256, PipeWriterThread,
TclPipeThreadCreateTI(&infoPtr->writeTI, infoPtr, infoPtr->writable),
0, NULL);
@@ -3206,7 +3206,7 @@ TclpOpenTemporaryFile(
Tcl_Obj *extensionObj,
Tcl_Obj *resultingNameObj)
{
TCHAR name[MAX_PATH];
WCHAR name[MAX_PATH];
char *namePtr;
HANDLE handle;
DWORD flags = FILE_ATTRIBUTE_TEMPORARY;
@@ -3218,11 +3218,11 @@ TclpOpenTemporaryFile(
}
namePtr = (char *) name;
length = GetTempPath(MAX_PATH, name);
length = GetTempPathW(MAX_PATH, name);
if (length == 0) {
goto gotError;
}
namePtr += length * sizeof(TCHAR);
namePtr += length * sizeof(WCHAR);
if (basenameObj) {
const char *string = Tcl_GetString(basenameObj);
@@ -3231,8 +3231,8 @@ TclpOpenTemporaryFile(
namePtr += Tcl_DStringLength(&buf);
Tcl_DStringFree(&buf);
} else {
const TCHAR *baseStr = TEXT("TCL");
int length = 3 * sizeof(TCHAR);
const WCHAR *baseStr = L"TCL";
int length = 3 * sizeof(WCHAR);
memcpy(namePtr, baseStr, length);
namePtr += length;
@@ -3251,7 +3251,7 @@ TclpOpenTemporaryFile(
memcpy(namePtr, Tcl_DStringValue(&buf), Tcl_DStringLength(&buf) + 1);
Tcl_DStringFree(&buf);
handle = CreateFile(name,
handle = CreateFileW(name,
GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_NEW, flags, NULL);
} while (handle == INVALID_HANDLE_VALUE
&& --counter2 > 0
@@ -3300,7 +3300,7 @@ TclPipeThreadCreateTI(
#else
pipeTI = ckalloc(sizeof(TclPipeThreadInfo));
#endif /* !_PTI_USE_CKALLOC */
pipeTI->evControl = CreateEvent(NULL, FALSE, FALSE, NULL);
pipeTI->evControl = CreateEventW(NULL, FALSE, FALSE, NULL);
pipeTI->state = PTI_STATE_IDLE;
pipeTI->clientData = clientData;
pipeTI->evWakeUp = wakeEvent;
+93 -62
View File
@@ -94,7 +94,7 @@ static void AppendSystemError(Tcl_Interp *interp, DWORD error);
static int BroadcastValue(Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
static DWORD ConvertDWORD(DWORD type, DWORD value);
static void DeleteCmd(ClientData clientData);
static void DeleteCmd(void *clientData);
static int DeleteKey(Tcl_Interp *interp, Tcl_Obj *keyNameObj,
REGSAM mode);
static int DeleteValue(Tcl_Interp *interp, Tcl_Obj *keyNameObj,
@@ -116,14 +116,24 @@ static int ParseKeyName(Tcl_Interp *interp, char *name,
char **hostNamePtr, HKEY *rootKeyPtr,
char **keyNamePtr);
static DWORD RecursiveDeleteKey(HKEY hStartKey,
const TCHAR * pKeyName, REGSAM mode);
static int RegistryObjCmd(ClientData clientData,
const WCHAR * pKeyName, REGSAM mode);
static int RegistryObjCmd(void *clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
static int SetValue(Tcl_Interp *interp, Tcl_Obj *keyNameObj,
Tcl_Obj *valueNameObj, Tcl_Obj *dataObj,
Tcl_Obj *typeObj, REGSAM mode);
#if (TCL_MAJOR_VERSION < 9) && (TCL_MINOR_VERSION < 7)
# if TCL_UTF_MAX > 3
# define Tcl_WCharToUtfDString(a,b,c) Tcl_WinTCharToUtf(a,(b)*sizeof(WCHAR),c)
# define Tcl_UtfToWCharDString(a,b,c) Tcl_WinUtfToTChar(a,b,c)
# else
# define Tcl_WCharToUtfDString Tcl_UniCharToUtfDString
# define Tcl_UtfToWCharDString Tcl_UtfToUniCharDString
# endif
#endif
static unsigned char *
getByteArrayFromObj(
Tcl_Obj *objPtr,
@@ -143,8 +153,14 @@ getByteArrayFromObj(
return result;
}
#ifdef __cplusplus
extern "C" {
#endif
DLLEXPORT int Registry_Init(Tcl_Interp *interp);
DLLEXPORT int Registry_Unload(Tcl_Interp *interp, int flags);
#ifdef __cplusplus
}
#endif
/*
*----------------------------------------------------------------------
@@ -168,14 +184,14 @@ Registry_Init(
{
Tcl_Command cmd;
if (Tcl_InitStubs(interp, "8.5", 0) == NULL) {
if (Tcl_InitStubs(interp, "8.5-", 0) == NULL) {
return TCL_ERROR;
}
cmd = Tcl_CreateObjCommand(interp, "registry", RegistryObjCmd,
interp, DeleteCmd);
Tcl_SetAssocData(interp, REGISTRY_ASSOC_KEY, NULL, cmd);
return Tcl_PkgProvide(interp, "registry", "1.3.3");
return Tcl_PkgProvideEx(interp, "registry", "1.3.3", NULL);
}
/*
@@ -201,6 +217,7 @@ Registry_Unload(
{
Tcl_Command cmd;
Tcl_Obj *objv[3];
(void)flags;
/*
* Unregister the registry package. There is no Tcl_PkgForget()
@@ -215,7 +232,7 @@ Registry_Unload(
* Delete the originally registered command.
*/
cmd = Tcl_GetAssocData(interp, REGISTRY_ASSOC_KEY, NULL);
cmd = (Tcl_Command)Tcl_GetAssocData(interp, REGISTRY_ASSOC_KEY, NULL);
if (cmd != NULL) {
Tcl_DeleteCommandFromToken(interp, cmd);
}
@@ -242,9 +259,9 @@ Registry_Unload(
static void
DeleteCmd(
ClientData clientData)
void *clientData)
{
Tcl_Interp *interp = clientData;
Tcl_Interp *interp = (Tcl_Interp *)clientData;
Tcl_SetAssocData(interp, REGISTRY_ASSOC_KEY, NULL, NULL);
}
@@ -267,7 +284,7 @@ DeleteCmd(
static int
RegistryObjCmd(
ClientData clientData, /* Not used. */
void *dummy, /* Not used. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
@@ -286,6 +303,7 @@ RegistryObjCmd(
static const char *const modes[] = {
"-32bit", "-64bit", NULL
};
(void)dummy;
if (objc < 2) {
wrongArgs:
@@ -415,7 +433,7 @@ DeleteKey(
REGSAM mode) /* Mode flags to pass. */
{
char *tail, *buffer, *hostName, *keyName;
const TCHAR *nativeTail;
const WCHAR *nativeTail;
HKEY rootKey, subkey;
DWORD result;
Tcl_DString buf;
@@ -468,7 +486,8 @@ DeleteKey(
* Now we recursively delete the key and everything below it.
*/
nativeTail = Tcl_WinUtfToTChar(tail, -1, &buf);
Tcl_DStringInit(&buf);
nativeTail = Tcl_UtfToWCharDString(tail, -1, &buf);
result = RecursiveDeleteKey(subkey, nativeTail, saveMode);
Tcl_DStringFree(&buf);
@@ -524,8 +543,9 @@ DeleteValue(
}
valueName = Tcl_GetString(valueNameObj);
Tcl_WinUtfToTChar(valueName, valueNameObj->length, &ds);
result = RegDeleteValue(key, (const TCHAR *)Tcl_DStringValue(&ds));
Tcl_DStringInit(&ds);
Tcl_UtfToWCharDString(valueName, valueNameObj->length, &ds);
result = RegDeleteValueW(key, (const WCHAR *)Tcl_DStringValue(&ds));
Tcl_DStringFree(&ds);
if (result != ERROR_SUCCESS) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -568,7 +588,7 @@ GetKeyNames(
{
const char *pattern; /* Pattern being matched against subkeys */
HKEY key; /* Handle to the key being examined */
TCHAR buffer[MAX_KEY_LENGTH];
WCHAR buffer[MAX_KEY_LENGTH];
/* Buffer to hold the subkey name */
DWORD bufSize; /* Size of the buffer */
DWORD index; /* Position of the current subkey */
@@ -599,7 +619,7 @@ GetKeyNames(
resultPtr = Tcl_NewObj();
for (index = 0;; ++index) {
bufSize = MAX_KEY_LENGTH;
result = RegEnumKeyEx(key, index, buffer, &bufSize,
result = RegEnumKeyExW(key, index, buffer, &bufSize,
NULL, NULL, NULL, NULL);
if (result != ERROR_SUCCESS) {
if (result == ERROR_NO_MORE_ITEMS) {
@@ -613,7 +633,8 @@ GetKeyNames(
}
break;
}
name = Tcl_WinTCharToUtf(buffer, bufSize * sizeof(TCHAR), &ds);
Tcl_DStringInit(&ds);
name = Tcl_WCharToUtfDString(buffer, bufSize, &ds);
if (pattern && !Tcl_StringMatch(name, pattern)) {
Tcl_DStringFree(&ds);
continue;
@@ -663,7 +684,7 @@ GetType(
DWORD result, type;
Tcl_DString ds;
const char *valueName;
const TCHAR *nativeValue;
const WCHAR *nativeValue;
/*
* Attempt to open the key for reading.
@@ -679,8 +700,9 @@ GetType(
*/
valueName = Tcl_GetString(valueNameObj);
nativeValue = Tcl_WinUtfToTChar(valueName, valueNameObj->length, &ds);
result = RegQueryValueEx(key, nativeValue, NULL, &type,
Tcl_DStringInit(&ds);
nativeValue = Tcl_UtfToWCharDString(valueName, valueNameObj->length, &ds);
result = RegQueryValueExW(key, nativeValue, NULL, &type,
NULL, NULL);
Tcl_DStringFree(&ds);
RegCloseKey(key);
@@ -732,7 +754,7 @@ GetValue(
{
HKEY key;
const char *valueName;
const TCHAR *nativeValue;
const WCHAR *nativeValue;
DWORD result, length, type;
Tcl_DString data, buf;
@@ -757,12 +779,13 @@ GetValue(
Tcl_DStringInit(&data);
Tcl_DStringSetLength(&data, TCL_DSTRING_STATIC_SIZE - 1);
length = TCL_DSTRING_STATIC_SIZE/sizeof(TCHAR) - 1;
length = TCL_DSTRING_STATIC_SIZE/sizeof(WCHAR) - 1;
valueName = Tcl_GetString(valueNameObj);
nativeValue = Tcl_WinUtfToTChar(valueName, valueNameObj->length, &buf);
Tcl_DStringInit(&buf);
nativeValue = Tcl_UtfToWCharDString(valueName, valueNameObj->length, &buf);
result = RegQueryValueEx(key, nativeValue, NULL, &type,
result = RegQueryValueExW(key, nativeValue, NULL, &type,
(BYTE *) Tcl_DStringValue(&data), &length);
while (result == ERROR_MORE_DATA) {
/*
@@ -771,9 +794,9 @@ GetValue(
* HKEY_PERFORMANCE_DATA
*/
length = Tcl_DStringLength(&data) * (2 / sizeof(TCHAR));
Tcl_DStringSetLength(&data, (int) length * sizeof(TCHAR));
result = RegQueryValueEx(key, nativeValue,
length = Tcl_DStringLength(&data) * (2 / sizeof(WCHAR));
Tcl_DStringSetLength(&data, (int) length * sizeof(WCHAR));
result = RegQueryValueExW(key, nativeValue,
NULL, &type, (BYTE *) Tcl_DStringValue(&data), &length);
}
Tcl_DStringFree(&buf);
@@ -809,13 +832,13 @@ GetValue(
*/
while ((p < end) && *((WCHAR *) p) != 0) {
WCHAR *wp;
WCHAR *wp = (WCHAR *) p;
Tcl_WinTCharToUtf((TCHAR *) p, -1, &buf);
Tcl_DStringInit(&buf);
Tcl_WCharToUtfDString(wp, wcslen(wp), &buf);
Tcl_ListObjAppendElement(interp, resultPtr,
Tcl_NewStringObj(Tcl_DStringValue(&buf),
Tcl_DStringLength(&buf)));
wp = (WCHAR *) p;
while (*wp++ != 0) {/* empty body */}
p = (char *) wp;
@@ -823,7 +846,9 @@ GetValue(
}
Tcl_SetObjResult(interp, resultPtr);
} else if ((type == REG_SZ) || (type == REG_EXPAND_SZ)) {
Tcl_WinTCharToUtf((TCHAR *) Tcl_DStringValue(&data), -1, &buf);
WCHAR *wp = (WCHAR *) Tcl_DStringValue(&data);
Tcl_DStringInit(&buf);
Tcl_WCharToUtfDString((const WCHAR *)Tcl_DStringValue(&data), wcslen(wp), &buf);
Tcl_DStringResult(interp, &buf);
} else {
/*
@@ -880,7 +905,7 @@ GetValueNames(
resultPtr = Tcl_NewObj();
Tcl_DStringInit(&buffer);
Tcl_DStringSetLength(&buffer, (int) (MAX_KEY_LENGTH * sizeof(TCHAR)));
Tcl_DStringSetLength(&buffer, (int) (MAX_KEY_LENGTH * sizeof(WCHAR)));
index = 0;
result = TCL_OK;
@@ -897,12 +922,11 @@ GetValueNames(
*/
size = MAX_KEY_LENGTH;
while (RegEnumValue(key,index, (TCHAR *)Tcl_DStringValue(&buffer),
while (RegEnumValueW(key,index, (WCHAR *)Tcl_DStringValue(&buffer),
&size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
size *= sizeof(TCHAR);
Tcl_WinTCharToUtf((TCHAR *) Tcl_DStringValue(&buffer), (int) size,
&ds);
Tcl_DStringInit(&ds);
Tcl_WCharToUtfDString((const WCHAR *)Tcl_DStringValue(&buffer), size, &ds);
name = Tcl_DStringValue(&ds);
if (!pattern || Tcl_StringMatch(name, pattern)) {
result = Tcl_ListObjAppendElement(interp, resultPtr,
@@ -1008,8 +1032,9 @@ OpenSubKey(
*/
if (hostName) {
hostName = (char *) Tcl_WinUtfToTChar(hostName, -1, &buf);
result = RegConnectRegistry((TCHAR *)hostName, rootKey,
Tcl_DStringInit(&buf);
hostName = (char *) Tcl_UtfToWCharDString(hostName, -1, &buf);
result = RegConnectRegistryW((WCHAR *)hostName, rootKey,
&rootKey);
Tcl_DStringFree(&buf);
if (result != ERROR_SUCCESS) {
@@ -1023,12 +1048,13 @@ OpenSubKey(
*/
if (keyName) {
keyName = (char *) Tcl_WinUtfToTChar(keyName, -1, &buf);
Tcl_DStringInit(&buf);
keyName = (char *) Tcl_UtfToWCharDString(keyName, -1, &buf);
}
if (flags & REG_CREATE) {
DWORD create;
result = RegCreateKeyEx(rootKey, (TCHAR *)keyName, 0, NULL,
result = RegCreateKeyExW(rootKey, (WCHAR *)keyName, 0, NULL,
REG_OPTION_NON_VOLATILE, mode, NULL, keyPtr, &create);
} else if (rootKey == HKEY_PERFORMANCE_DATA) {
/*
@@ -1039,7 +1065,7 @@ OpenSubKey(
*keyPtr = HKEY_PERFORMANCE_DATA;
result = ERROR_SUCCESS;
} else {
result = RegOpenKeyEx(rootKey, (TCHAR *)keyName, 0, mode,
result = RegOpenKeyExW(rootKey, (WCHAR *)keyName, 0, mode,
keyPtr);
}
if (keyName) {
@@ -1159,7 +1185,7 @@ ParseKeyName(
static DWORD
RecursiveDeleteKey(
HKEY startKey, /* Parent of key to be deleted. */
const TCHAR *keyName, /* Name of key to be deleted in external
const WCHAR *keyName, /* Name of key to be deleted in external
* encoding, not UTF. */
REGSAM mode) /* Mode flags to pass. */
{
@@ -1168,7 +1194,7 @@ RecursiveDeleteKey(
HKEY hKey;
REGSAM saveMode = mode;
static int checkExProc = 0;
static FARPROC regDeleteKeyExProc = NULL;
static LSTATUS (* regDeleteKeyExProc) (HKEY, LPCWSTR, REGSAM, DWORD) = (LSTATUS (*) (HKEY, LPCWSTR, REGSAM, DWORD)) NULL;
/*
* Do not allow NULL or empty key name.
@@ -1179,13 +1205,13 @@ RecursiveDeleteKey(
}
mode |= KEY_ENUMERATE_SUB_KEYS | DELETE | KEY_QUERY_VALUE;
result = RegOpenKeyEx(startKey, keyName, 0, mode, &hKey);
result = RegOpenKeyExW(startKey, keyName, 0, mode, &hKey);
if (result != ERROR_SUCCESS) {
return result;
}
Tcl_DStringInit(&subkey);
Tcl_DStringSetLength(&subkey, (int) (MAX_KEY_LENGTH * sizeof(TCHAR)));
Tcl_DStringSetLength(&subkey, (int) (MAX_KEY_LENGTH * sizeof(WCHAR)));
mode = saveMode;
while (result == ERROR_SUCCESS) {
@@ -1194,7 +1220,7 @@ RecursiveDeleteKey(
*/
size = MAX_KEY_LENGTH;
result = RegEnumKeyEx(hKey, 0, (TCHAR *)Tcl_DStringValue(&subkey),
result = RegEnumKeyExW(hKey, 0, (WCHAR *)Tcl_DStringValue(&subkey),
&size, NULL, NULL, NULL, NULL);
if (result == ERROR_NO_MORE_ITEMS) {
/*
@@ -1207,19 +1233,19 @@ RecursiveDeleteKey(
HMODULE handle;
checkExProc = 1;
handle = GetModuleHandle(TEXT("ADVAPI32"));
regDeleteKeyExProc = (FARPROC)
handle = GetModuleHandleW(L"ADVAPI32");
regDeleteKeyExProc = (LSTATUS (*) (HKEY, LPCWSTR, REGSAM, DWORD))
GetProcAddress(handle, "RegDeleteKeyExW");
}
if (mode && regDeleteKeyExProc) {
result = regDeleteKeyExProc(startKey, keyName, mode, 0);
} else {
result = RegDeleteKey(startKey, keyName);
result = RegDeleteKeyW(startKey, keyName);
}
break;
} else if (result == ERROR_SUCCESS) {
result = RecursiveDeleteKey(hKey,
(const TCHAR *) Tcl_DStringValue(&subkey), mode);
(const WCHAR *) Tcl_DStringValue(&subkey), mode);
}
}
Tcl_DStringFree(&subkey);
@@ -1275,7 +1301,8 @@ SetValue(
}
valueName = Tcl_GetString(valueNameObj);
valueName = (char *) Tcl_WinUtfToTChar(valueName, valueNameObj->length, &nameBuf);
Tcl_DStringInit(&nameBuf);
valueName = (char *) Tcl_UtfToWCharDString(valueName, valueNameObj->length, &nameBuf);
if (type == REG_DWORD || type == REG_DWORD_BIG_ENDIAN) {
int value;
@@ -1287,7 +1314,7 @@ SetValue(
}
value = ConvertDWORD((DWORD) type, (DWORD) value);
result = RegSetValueEx(key, (TCHAR *) valueName, 0,
result = RegSetValueExW(key, (WCHAR *) valueName, 0,
(DWORD) type, (BYTE *) &value, sizeof(DWORD));
} else if (type == REG_MULTI_SZ) {
Tcl_DString data, buf;
@@ -1319,9 +1346,10 @@ SetValue(
Tcl_DStringAppend(&data, "", 1); /* NUL-terminated string */
}
Tcl_WinUtfToTChar(Tcl_DStringValue(&data), Tcl_DStringLength(&data)+1,
Tcl_DStringInit(&buf);
Tcl_UtfToWCharDString(Tcl_DStringValue(&data), Tcl_DStringLength(&data)+1,
&buf);
result = RegSetValueEx(key, (TCHAR *) valueName, 0,
result = RegSetValueExW(key, (WCHAR *) valueName, 0,
(DWORD) type, (BYTE *) Tcl_DStringValue(&buf),
(DWORD) Tcl_DStringLength(&buf));
Tcl_DStringFree(&data);
@@ -1330,7 +1358,8 @@ SetValue(
Tcl_DString buf;
const char *data = Tcl_GetString(dataObj);
data = (char *) Tcl_WinUtfToTChar(data, dataObj->length, &buf);
Tcl_DStringInit(&buf);
data = (char *) Tcl_UtfToWCharDString(data, dataObj->length, &buf);
/*
* Include the null in the length, padding if needed for WCHAR.
@@ -1338,7 +1367,7 @@ SetValue(
Tcl_DStringSetLength(&buf, Tcl_DStringLength(&buf)+1);
result = RegSetValueEx(key, (TCHAR *) valueName, 0,
result = RegSetValueExW(key, (WCHAR *) valueName, 0,
(DWORD) type, (BYTE *) data, (DWORD) Tcl_DStringLength(&buf) + 1);
Tcl_DStringFree(&buf);
} else {
@@ -1350,7 +1379,7 @@ SetValue(
*/
data = (BYTE *) getByteArrayFromObj(dataObj, &bytelength);
result = RegSetValueEx(key, (TCHAR *) valueName, 0,
result = RegSetValueExW(key, (WCHAR *) valueName, 0,
(DWORD) type, data, (DWORD) bytelength);
}
@@ -1410,7 +1439,8 @@ BroadcastValue(
}
str = Tcl_GetString(objv[0]);
wstr = (WCHAR *) Tcl_WinUtfToTChar(str, objv[0]->length, &ds);
Tcl_DStringInit(&ds);
wstr = Tcl_UtfToWCharDString(str, objv[0]->length, &ds);
if (Tcl_DStringLength(&ds) == 0) {
wstr = NULL;
}
@@ -1419,7 +1449,7 @@ BroadcastValue(
* Use the ignore the result.
*/
result = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE,
result = SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE,
(WPARAM) 0, (LPARAM) wstr, SMTO_ABORTIFHUNG, (UINT) timeout, &sendResult);
Tcl_DStringFree(&ds);
@@ -1454,7 +1484,7 @@ AppendSystemError(
DWORD error) /* Result code from error. */
{
int length;
TCHAR *tMsgPtr, **tMsgPtrPtr = &tMsgPtr;
WCHAR *tMsgPtr, **tMsgPtrPtr = &tMsgPtr;
const char *msg;
char id[TCL_INTEGER_SPACE], msgBuf[24 + TCL_INTEGER_SPACE];
Tcl_DString ds;
@@ -1463,9 +1493,9 @@ AppendSystemError(
if (Tcl_IsShared(resultPtr)) {
resultPtr = Tcl_DuplicateObj(resultPtr);
}
length = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
length = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (TCHAR *) tMsgPtrPtr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (WCHAR *) tMsgPtrPtr,
0, NULL);
if (length == 0) {
sprintf(msgBuf, "unknown error: %ld", error);
@@ -1473,7 +1503,8 @@ AppendSystemError(
} else {
char *msgPtr;
Tcl_WinTCharToUtf(tMsgPtr, -1, &ds);
Tcl_DStringInit(&ds);
Tcl_WCharToUtfDString(tMsgPtr, wcslen(tMsgPtr), &ds);
LocalFree(tMsgPtr);
msgPtr = Tcl_DStringValue(&ds);
+9 -9
View File
@@ -1283,7 +1283,7 @@ SerialWriterThread(
buf = infoPtr->writeBuf;
toWrite = infoPtr->toWrite;
myWrite.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
myWrite.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
/*
* Loop until all of the bytes are written or an error occurs.
@@ -1368,7 +1368,7 @@ SerialWriterThread(
HANDLE
TclWinSerialOpen(
HANDLE handle,
const TCHAR *name,
const WCHAR *name,
DWORD access)
{
SerialInit();
@@ -1387,7 +1387,7 @@ TclWinSerialOpen(
* finished
*/
handle = CreateFile(name, access, 0, 0, OPEN_EXISTING,
handle = CreateFileW(name, access, 0, 0, OPEN_EXISTING,
FILE_FLAG_OVERLAPPED, 0);
return handle;
@@ -1460,15 +1460,15 @@ TclWinOpenSerialChannel(
InitializeCriticalSection(&infoPtr->csWrite);
if (permissions & TCL_READABLE) {
infoPtr->osRead.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
infoPtr->osRead.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
}
if (permissions & TCL_WRITABLE) {
/*
* Initially the channel is writable and the writeThread is idle.
*/
infoPtr->osWrite.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
infoPtr->evWritable = CreateEvent(NULL, TRUE, TRUE, NULL);
infoPtr->osWrite.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
infoPtr->evWritable = CreateEventW(NULL, TRUE, TRUE, NULL);
infoPtr->writeThread = CreateThread(NULL, 256, SerialWriterThread,
TclPipeThreadCreateTI(&infoPtr->writeTI, infoPtr,
infoPtr->evWritable), 0, NULL);
@@ -1595,7 +1595,7 @@ SerialSetOptionProc(
BOOL result, flag;
size_t len, vlen;
Tcl_DString ds;
const TCHAR *native;
const WCHAR *native;
int argc;
const char **argv;
@@ -1617,8 +1617,8 @@ SerialSetOptionProc(
if (!GetCommState(infoPtr->handle, &dcb)) {
goto getStateFailed;
}
native = Tcl_WinUtfToTChar(value, -1, &ds);
result = BuildCommDCB(native, &dcb);
native = (const WCHAR *)Tcl_WinUtfToTChar(value, -1, &ds);
result = BuildCommDCBW(native, &dcb);
Tcl_DStringFree(&ds);
if (result == FALSE) {
+33 -33
View File
@@ -90,7 +90,7 @@
*/
static int initialized = 0;
static const TCHAR classname[] = TEXT("TclSocket");
static const WCHAR classname[] = L"TclSocket";
TCL_DECLARE_MUTEX(socketMutex)
/*
@@ -232,7 +232,7 @@ typedef struct {
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
static WNDCLASS windowClass;
static WNDCLASSW windowClass;
/*
* Static routines for this file:
@@ -343,16 +343,16 @@ InitializeHostName(
int *lengthPtr,
Tcl_Encoding *encodingPtr)
{
TCHAR tbuf[MAX_COMPUTERNAME_LENGTH + 1];
WCHAR wbuf[MAX_COMPUTERNAME_LENGTH + 1];
DWORD length = MAX_COMPUTERNAME_LENGTH + 1;
Tcl_DString ds;
if (GetComputerName(tbuf, &length) != 0) {
if (GetComputerNameW(wbuf, &length) != 0) {
/*
* Convert string from native to UTF then change to lowercase.
*/
Tcl_UtfToLower(Tcl_WinTCharToUtf(tbuf, -1, &ds));
Tcl_UtfToLower(Tcl_WinTCharToUtf((TCHAR *)wbuf, -1, &ds));
} else {
Tcl_DStringInit(&ds);
@@ -481,7 +481,7 @@ TclpFinalizeSockets(void)
if (tsdPtr->socketThread != NULL) {
if (tsdPtr->hwnd != NULL) {
PostMessage(tsdPtr->hwnd, SOCKET_TERMINATE, 0, 0);
PostMessageW(tsdPtr->hwnd, SOCKET_TERMINATE, 0, 0);
/*
* Wait for the thread to exit. This ensures that we are
@@ -777,7 +777,7 @@ TcpInputProc(
*/
while (1) {
SendMessage(tsdPtr->hwnd, SOCKET_SELECT,
SendMessageW(tsdPtr->hwnd, SOCKET_SELECT,
(WPARAM) UNSELECT, (LPARAM) statePtr);
/* single fd operation: this proc is only called for a connected socket. */
bytesRead = recv(statePtr->sockets->fd, buf, bufSize, 0);
@@ -840,7 +840,7 @@ TcpInputProc(
}
}
SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM)SELECT, (LPARAM)statePtr);
SendMessageW(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM)SELECT, (LPARAM)statePtr);
return bytesRead;
}
@@ -898,7 +898,7 @@ TcpOutputProc(
}
while (1) {
SendMessage(tsdPtr->hwnd, SOCKET_SELECT,
SendMessageW(tsdPtr->hwnd, SOCKET_SELECT,
(WPARAM) UNSELECT, (LPARAM) statePtr);
/* single fd operation: this proc is only called for a connected socket. */
@@ -950,7 +950,7 @@ TcpOutputProc(
}
}
SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM)SELECT, (LPARAM)statePtr);
SendMessageW(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM)SELECT, (LPARAM)statePtr);
return written;
}
@@ -1761,7 +1761,7 @@ TcpConnect(
SetEvent(tsdPtr->socketListLock);
/* activate accept notification */
SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
SendMessageW(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
(LPARAM) statePtr);
}
@@ -1841,7 +1841,7 @@ out:
* automatically places the socket into non-blocking mode.
*/
SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
SendMessageW(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
(LPARAM) statePtr);
} else {
/*
@@ -2017,7 +2017,7 @@ Tcl_MakeTcpClientChannel(
*/
statePtr->selectEvents = FD_READ | FD_CLOSE | FD_WRITE;
SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM)SELECT, (LPARAM)statePtr);
SendMessageW(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM)SELECT, (LPARAM)statePtr);
sprintf(channelName, SOCK_TEMPLATE, statePtr);
statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
@@ -2195,7 +2195,7 @@ error:
*/
ioctlsocket(sock, (long) FIONBIO, &flag);
SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
SendMessageW(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
(LPARAM) statePtr);
if (Tcl_SetChannelOption(interp, statePtr->channel, "-eofchar", "")
== TCL_ERROR) {
@@ -2265,7 +2265,7 @@ TcpAccept(
*/
newInfoPtr->selectEvents = (FD_READ | FD_WRITE | FD_CLOSE);
SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
SendMessageW(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
(LPARAM) newInfoPtr);
sprintf(channelName, SOCK_TEMPLATE, newInfoPtr);
@@ -2341,7 +2341,7 @@ InitSockets(void)
windowClass.hIcon = NULL;
windowClass.hCursor = NULL;
if (!RegisterClass(&windowClass)) {
if (!RegisterClassW(&windowClass)) {
TclWinConvertError(GetLastError());
goto initFailure;
}
@@ -2366,11 +2366,11 @@ InitSockets(void)
tsdPtr->socketList = NULL;
tsdPtr->hwnd = NULL;
tsdPtr->threadId = Tcl_GetCurrentThread();
tsdPtr->readyEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
tsdPtr->readyEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
if (tsdPtr->readyEvent == NULL) {
goto initFailure;
}
tsdPtr->socketListLock = CreateEvent(NULL, FALSE, TRUE, NULL);
tsdPtr->socketListLock = CreateEventW(NULL, FALSE, TRUE, NULL);
if (tsdPtr->socketListLock == NULL) {
goto initFailure;
}
@@ -2466,7 +2466,7 @@ SocketExitHandler(
*/
TclpFinalizeSockets();
UnregisterClass(classname, TclWinGetTclInstance());
UnregisterClassW(classname, TclWinGetTclInstance());
initialized = 0;
Tcl_MutexUnlock(&socketMutex);
}
@@ -2771,7 +2771,7 @@ SocketEventProc(
* async select handler and keep waiting.
*/
SendMessage(tsdPtr->hwnd, SOCKET_SELECT,
SendMessageW(tsdPtr->hwnd, SOCKET_SELECT,
(WPARAM) UNSELECT, (LPARAM) statePtr);
FD_ZERO(&readFds);
@@ -2783,7 +2783,7 @@ SocketEventProc(
mask |= TCL_READABLE;
} else {
statePtr->readyEvents &= ~(FD_READ);
SendMessage(tsdPtr->hwnd, SOCKET_SELECT,
SendMessageW(tsdPtr->hwnd, SOCKET_SELECT,
(WPARAM) SELECT, (LPARAM) statePtr);
}
}
@@ -2925,9 +2925,9 @@ WaitForSocketEvent(
* Reset WSAAsyncSelect so we have a fresh set of events pending.
*/
SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) UNSELECT,
SendMessageW(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) UNSELECT,
(LPARAM) statePtr);
SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
SendMessageW(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
(LPARAM) statePtr);
while (1) {
@@ -2992,7 +2992,7 @@ SocketThread(
* Create a dummy window receiving socket events.
*/
tsdPtr->hwnd = CreateWindow(classname, classname, WS_TILED, 0, 0, 0, 0,
tsdPtr->hwnd = CreateWindowW(classname, classname, WS_TILED, 0, 0, 0, 0,
NULL, NULL, windowClass.hInstance, arg);
/*
@@ -3012,11 +3012,11 @@ SocketThread(
/*
* Process all messages on the socket window until WM_QUIT. This threads
* exits only when instructed to do so by the call to
* PostMessage(SOCKET_TERMINATE) in TclpFinalizeSockets().
* PostMessageW(SOCKET_TERMINATE) in TclpFinalizeSockets().
*/
while (GetMessage(&msg, NULL, 0, 0) > 0) {
DispatchMessage(&msg);
while (GetMessageW(&msg, NULL, 0, 0) > 0) {
DispatchMessageW(&msg);
}
/*
@@ -3061,14 +3061,14 @@ SocketProc(
TcpFdList *fds = NULL;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
#ifdef _WIN64
GetWindowLongPtr(hwnd, GWLP_USERDATA);
GetWindowLongPtrW(hwnd, GWLP_USERDATA);
#else
GetWindowLong(hwnd, GWL_USERDATA);
GetWindowLongW(hwnd, GWL_USERDATA);
#endif
switch (message) {
default:
return DefWindowProc(hwnd, message, wParam, lParam);
return DefWindowProcW(hwnd, message, wParam, lParam);
break;
case WM_CREATE:
@@ -3078,10 +3078,10 @@ SocketProc(
*/
#ifdef _WIN64
SetWindowLongPtr(hwnd, GWLP_USERDATA,
SetWindowLongPtrW(hwnd, GWLP_USERDATA,
(LONG_PTR) ((LPCREATESTRUCT)lParam)->lpCreateParams);
#else
SetWindowLong(hwnd, GWL_USERDATA,
SetWindowLongW(hwnd, GWL_USERDATA,
(LONG) ((LPCREATESTRUCT)lParam)->lpCreateParams);
#endif
break;
@@ -3361,7 +3361,7 @@ TcpThreadActionProc(
* thread.
*/
SendMessage(tsdPtr->hwnd, SOCKET_SELECT,
SendMessageW(tsdPtr->hwnd, SOCKET_SELECT,
(WPARAM) notifyCmd, (LPARAM) statePtr);
}
+2 -2
View File
@@ -139,7 +139,7 @@ TesteventloopCmd(
while (!done) {
MSG msg;
if (!GetMessage(&msg, NULL, 0, 0)) {
if (!GetMessageW(&msg, NULL, 0, 0)) {
/*
* The application is exiting, so repost the quit message and
* start unwinding.
@@ -149,7 +149,7 @@ TesteventloopCmd(
break;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
DispatchMessageW(&msg);
}
(void) Tcl_SetServiceMode(oldMode);
framePtr = oldFramePtr;
+1 -1
View File
@@ -688,7 +688,7 @@ Tcl_ConditionWait(
*/
if (tsdPtr->flags == WIN_THREAD_UNINIT) {
tsdPtr->condEvent = CreateEvent(NULL, TRUE /* manual reset */,
tsdPtr->condEvent = CreateEventW(NULL, TRUE /* manual reset */,
FALSE /* non signaled */, NULL);
tsdPtr->nextPtr = NULL;
tsdPtr->prevPtr = NULL;
+2 -2
View File
@@ -544,8 +544,8 @@ NativeGetMicroseconds(void)
DWORD id;
InitializeCriticalSection(&timeInfo.cs);
timeInfo.readyEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
timeInfo.exitEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
timeInfo.readyEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
timeInfo.exitEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
timeInfo.calibrationThread = CreateThread(NULL, 256,
CalibrationThread, (LPVOID) NULL, 0, &id);
SetThreadPriority(timeInfo.calibrationThread,