From 4cd8a31c0dfe5e52b32fabcc94f7e0f3dbeadce5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 3 Sep 2022 13:57:45 +0000 Subject: [PATCH 1/2] typo's --- unix/tclUnixSock.c | 4 ++-- win/tclWinSock.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c index 1a549141074a..858afdb9237d 100644 --- a/unix/tclUnixSock.c +++ b/unix/tclUnixSock.c @@ -418,7 +418,7 @@ TcpBlockModeProc( * * Side effects: * Processes socket events off the system queue. May process - * asynchroneous connects. + * asynchronous connects. * *---------------------------------------------------------------------- */ @@ -1328,7 +1328,7 @@ TcpConnect( } /* - * We need to forward the writable event that brought us here, bcasue + * We need to forward the writable event that brought us here, because * upon reading of getsockopt(SO_ERROR), at least some OSes clear the * writable state from the socket, and so a subsequent select() on * behalf of a script level [fileevent] would not fire. It doesn't diff --git a/win/tclWinSock.c b/win/tclWinSock.c index a05b8f613134..a4547a8d8f1c 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -566,7 +566,7 @@ TcpBlockModeProc( * * Side effects: * Processes socket events off the system queue. - * May process asynchroneous connect. + * May process asynchronous connect. * *---------------------------------------------------------------------- */ @@ -1706,7 +1706,7 @@ TcpConnect( continue; } /* - * For asynchroneous connect set the socket in nonblocking mode + * For asynchronous connect set the socket in nonblocking mode * and activate connect notification */ if (async_connect) { @@ -1794,7 +1794,7 @@ TcpConnect( /* * Clear the tsd socket list pointer if we did not wait for - * the FD_CONNECT asynchroneously + * the FD_CONNECT asynchronously */ tsdPtr->pendingTcpState = NULL; From 8c3f6e1e6bca96a034f99965b9feb2bbd9da650c Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Mon, 5 Sep 2022 11:37:54 +0000 Subject: [PATCH 2/2] Ticket [55a02f20ec] - fallback to USERPROFILE when setting HOME env on Windows --- tests/env.test | 40 +++++++++++++++++++++++++++++++++++++++- win/tclWinInit.c | 9 ++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/tests/env.test b/tests/env.test index 905cdab6304f..ea58b2671d02 100644 --- a/tests/env.test +++ b/tests/env.test @@ -105,6 +105,7 @@ variable keep { CommonProgramFiles CommonProgramFiles(x86) ProgramFiles ProgramFiles(x86) CommonProgramW6432 ProgramW6432 WINECONFIGDIR WINEDATADIR WINEDLLDIR0 WINEHOMEDIR PROCESSOR_ARCHITECTURE + USERPROFILE } variable printenvScript [makeFile [string map [list @keep@ [list $keep]] { @@ -409,7 +410,7 @@ test env-7.3 { return [info exists ::env(test7_3)] }} } -cleanup cleanup1 -result 1 - + test env-8.0 { memory usage - valgrind does not report reachable memory } -body { @@ -419,6 +420,43 @@ test env-8.0 { } -result {i'm with dummy} +test env-9.0 { + Initialization of HOME from HOMEDRIVE and HOMEPATH +} -constraints win -setup { + setup1 + unset -nocomplain ::env(HOME) + set ::env(HOMEDRIVE) X: + set ::env(HOMEPATH) \\home\\path +} -cleanup { + cleanup1 +} -body { + set pipe [open |[list [interpreter]] r+] + puts $pipe {puts $::env(HOME); flush stdout; exit} + flush $pipe + set result [gets $pipe] + close $pipe + set result +} -result {X:\home\path} + +test env-9.1 { + Initialization of HOME from USERPROFILE +} -constraints win -setup { + setup1 + unset -nocomplain ::env(HOME) + unset -nocomplain ::env(HOMEDRIVE) + unset -nocomplain ::env(HOMEPATH) +} -cleanup { + cleanup1 +} -body { + set pipe [open |[list [interpreter]] r+] + puts $pipe {puts $::env(HOME); flush stdout; exit} + flush $pipe + set result [gets $pipe] + close $pipe + set result +} -result $::env(USERPROFILE) + + # cleanup rename getenv {} diff --git a/win/tclWinInit.c b/win/tclWinInit.c index 4f59c1afbfae..eae44044faae 100644 --- a/win/tclWinInit.c +++ b/win/tclWinInit.c @@ -593,7 +593,14 @@ TclpSetVariables( Tcl_SetVar2(interp, "env", "HOME", Tcl_DStringValue(&ds), TCL_GLOBAL_ONLY); } else { - Tcl_SetVar2(interp, "env", "HOME", "c:\\", TCL_GLOBAL_ONLY); + /* None of HOME, HOMEDRIVE, HOMEPATH exists. Try USERPROFILE */ + ptr = Tcl_GetVar2(interp, "env", "USERPROFILE", TCL_GLOBAL_ONLY); + if (ptr != NULL && ptr[0]) { + Tcl_SetVar2(interp, "env", "HOME", ptr, TCL_GLOBAL_ONLY); + } else { + /* Last resort */ + Tcl_SetVar2(interp, "env", "HOME", "c:\\", TCL_GLOBAL_ONLY); + } } }