aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNoam Postavsky2016-11-18 16:26:53 -0500
committerNoam Postavsky2016-11-28 17:44:39 -0500
commit753c565df6aa693c75c38816059051a1aebbcbb1 (patch)
treed3d4c210cdc9d05e53d2dce281ea4acad271997d /src
parent13d468fc0793e23a2f7cd4338b4f5e42e16a96ee (diff)
downloademacs-753c565df6aa693c75c38816059051a1aebbcbb1.tar.gz
emacs-753c565df6aa693c75c38816059051a1aebbcbb1.zip
Upcase Path and ComSpec in process-environment
Since 2016-07-18 "Keep w32 environment settings internal only", the upcasing of environment variables "Path" and "ComSpec" occured after initializing process-environment. This meant that Lisp code trying to override "PATH" environment had no effect (Bug #24956). * src/w32.c (init_environment): Upcase the "Path" and "ComSpec" entries in Vprocess_environment.
Diffstat (limited to 'src')
-rw-r--r--src/w32.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/w32.c b/src/w32.c
index ad7d94a21d2..086c1acfb38 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -2863,12 +2863,29 @@ init_environment (char ** argv)
2863 The same applies to COMSPEC. */ 2863 The same applies to COMSPEC. */
2864 { 2864 {
2865 char ** envp; 2865 char ** envp;
2866 const char *path = "PATH=";
2867 int path_len = strlen (path);
2868 const char *comspec = "COMSPEC=";
2869 int comspec_len = strlen (comspec);
2866 2870
2867 for (envp = environ; *envp; envp++) 2871 for (envp = environ; *envp; envp++)
2868 if (_strnicmp (*envp, "PATH=", 5) == 0) 2872 if (_strnicmp (*envp, path, path_len) == 0)
2869 memcpy (*envp, "PATH=", 5); 2873 memcpy (*envp, path, path_len);
2870 else if (_strnicmp (*envp, "COMSPEC=", 8) == 0) 2874 else if (_strnicmp (*envp, comspec, comspec_len) == 0)
2871 memcpy (*envp, "COMSPEC=", 8); 2875 memcpy (*envp, comspec, comspec_len);
2876
2877 /* Make the same modification to `process-environment' which has
2878 already been initialized in set_initial_environment. */
2879 for (Lisp_Object env = Vprocess_environment; CONSP (env); env = XCDR (env))
2880 {
2881 Lisp_Object entry = XCAR (env);
2882 if (_strnicmp (SDATA (entry), path, path_len) == 0)
2883 for (int i = 0; i < path_len; i++)
2884 SSET (entry, i, path[i]);
2885 else if (_strnicmp (SDATA (entry), comspec, comspec_len) == 0)
2886 for (int i = 0; i < comspec_len; i++)
2887 SSET (entry, i, comspec[i]);
2888 }
2872 } 2889 }
2873 2890
2874 /* Remember the initial working directory for getcwd. */ 2891 /* Remember the initial working directory for getcwd. */