summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-11 11:13:04 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-11 11:13:04 (GMT)
commit09f4817353f0b33e04d9866888e1408a16b1afa6 (patch)
treed4262914310531cab7e681e17e039d14aadd20bc
parent89b734f448914ba6791f56b91fd20fdf5f5b56e6 (diff)
parent22648e5ebc9138abf5aba928db74520ac22f23ab (diff)
downloadtcl-09f4817353f0b33e04d9866888e1408a16b1afa6.zip
tcl-09f4817353f0b33e04d9866888e1408a16b1afa6.tar.gz
tcl-09f4817353f0b33e04d9866888e1408a16b1afa6.tar.bz2
Merge 8.6
-rw-r--r--generic/tclEnv.c11
-rw-r--r--win/tclWinInit.c21
2 files changed, 19 insertions, 13 deletions
diff --git a/generic/tclEnv.c b/generic/tclEnv.c
index bc4f675..96d050d 100644
--- a/generic/tclEnv.c
+++ b/generic/tclEnv.c
@@ -127,6 +127,17 @@ TclSetupEnv(
/*msg*/ 0, /*createPart1*/ 0, /*createPart2*/ 0, &arrayPtr);
TclFindArrayPtrElements(varPtr, &namesHash);
+#if defined(_WIN32)
+ if (tenviron == NULL) {
+ /*
+ * When we are started from main(), the _wenviron array could
+ * be NULL and will be initialized by the first _wgetenv() call.
+ */
+
+ (void) _wgetenv(L"WINDIR");
+ }
+#endif
+
/*
* Go through the environment array and transfer its values into Tcl. At
* the same time, remove those elements we add/update from the hash table
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index 44067aa..420e324 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.c
@@ -624,15 +624,8 @@ TclpSetVariables(
*----------------------------------------------------------------------
*/
-#if defined(_WIN32)
-# define tenviron _wenviron
-# define tenviron2utfdstr(string, len, dsPtr) (Tcl_DStringInit(dsPtr), \
- (char *)Tcl_Char16ToUtfDString((const unsigned short *)(string), ((((len) + 2) >> 1) - 1), (dsPtr)))
-#else
-# define tenviron environ
-# define tenviron2utfdstr(tenvstr, len, dstr) \
- Tcl_ExternalToUtfDString(NULL, tenvstr, len, dstr)
-#endif
+# define tenviron2utfdstr(string, len, dsPtr) \
+ (char *)Tcl_Char16ToUtfDString((const unsigned short *)(string), ((((len) + 2) >> 1) - 1), (dsPtr))
int
TclpFindVariable(
@@ -644,7 +637,8 @@ TclpFindVariable(
* searches). */
{
int i, length, result = -1;
- const char *env, *p1, *p2;
+ const WCHAR *env;
+ const char *p1, *p2;
char *envUpper, *nameUpper;
Tcl_DString envString;
@@ -658,16 +652,17 @@ TclpFindVariable(
Tcl_UtfToUpper(nameUpper);
Tcl_DStringInit(&envString);
- for (i = 0, env = (const char *)tenviron[i];
+ for (i = 0, env = _wenviron[i];
env != NULL;
- i++, env = (const char *)tenviron[i]) {
+ i++, env = _wenviron[i]) {
/*
* Chop the env string off after the equal sign, then Convert the name
* to all upper case, so we do not have to convert all the characters
* after the equal sign.
*/
- envUpper = tenviron2utfdstr(env, -1, &envString);
+ Tcl_DStringInit(&envString);
+ envUpper = Tcl_WCharToUtfDString(env, -1, &envString);
p1 = strchr(envUpper, '=');
if (p1 == NULL) {
continue;