Attached a patch to use the win32 API function for setting env vars. Previously we were falling back on a hack to use putenv("...="), which doesn't clear the variable and just sets it to empty (that fallback is still used for iOS, though...)
I have not tested this on Windows yet, if someone could do this, I'd be grateful. felix
From 07f03cf852d2ffe499689cf082a895dcac1420de Mon Sep 17 00:00:00 2001 From: felix <fe...@call-with-current-continuation.org> Date: Wed, 12 Jun 2024 16:29:41 +0200 Subject: [PATCH] Use proper win32 API to set environment variable instead of falling back on putenv --- library.scm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library.scm b/library.scm index 4a8a2d33..ed0f53b7 100644 --- a/library.scm +++ b/library.scm @@ -6014,9 +6014,14 @@ extern char **environ; #else # if defined(_WIN32) && !defined(__CYGWIN__) # define C_unsetenv(s) C_setenv(s, C_SCHEME_FALSE) +static C_word C_fcall C_setenv(C_word x, C_word y) { + char *sx = C_c_string(x); + if(y == C_SCHEME_FALSE) SetEnvironmentVariable(sx, NULL); + else SetEnvironmentVariable(sx, C_c_string(y)); + return C_fix(0); +} # else # define C_unsetenv(s) C_fix(putenv((char *)C_data_pointer(s))) -# endif static C_word C_fcall C_setenv(C_word x, C_word y) { char *sx = C_c_string(x), *sy = (y == C_SCHEME_FALSE ? "" : C_c_string(y)); @@ -6031,6 +6036,7 @@ static C_word C_fcall C_setenv(C_word x, C_word y) { return(C_fix(putenv(buf))); } } +# endif #endif <# -- 2.42.0