From: Noam Postavsky <npostavs@users.sourceforge.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "Óscar Fuentes" <ofv@wanadoo.es>, 24956@debbugs.gnu.org
Subject: bug#24956: 26.0.50; On Windows, setting PATH in compilation-environment has no effect
Date: Fri, 18 Nov 2016 17:11:22 -0500 [thread overview]
Message-ID: <CAM-tV--fCzOsuNBBSDH61OoDCtAUay=cLrnXc7mpagvzML4UYQ@mail.gmail.com> (raw)
In-Reply-To: <83wpg1ce8b.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 17 bytes --]
Here is a patch.
[-- Attachment #2: v1-0001-Upcase-Path-and-ComSpec-in-process-environment.patch --]
[-- Type: application/octet-stream, Size: 4061 bytes --]
From b9a9230430c2b7dd5c3c81dacc8277ad7e6cfb32 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Fri, 18 Nov 2016 16:26:53 -0500
Subject: [PATCH v1] 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): Remove code upcasing "Path" and "ComSpec".
* src/callproc.c (set_initial_environment) [WINDOWSNT]: And put it here,
before adding those variables to process-environment.
---
src/callproc.c | 39 ++++++++++++++++++++++++++++++++++-----
src/w32.c | 19 -------------------
2 files changed, 34 insertions(+), 24 deletions(-)
diff --git a/src/callproc.c b/src/callproc.c
index dc3ca4a..8736f35 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1607,11 +1607,40 @@ set_initial_environment (void)
{
char **envp;
for (envp = environ; *envp; envp++)
- Vprocess_environment = Fcons (build_string (*envp),
- Vprocess_environment);
- /* Ideally, the `copy' shouldn't be necessary, but it seems it's frequent
- to use `delete' and friends on process-environment. */
- Vinitial_environment = Fcopy_sequence (Vprocess_environment);
+ {
+ Lisp_Object envstr = build_string (*envp);
+ Vinitial_environment = Fcons (envstr, Vinitial_environment);
+#ifdef WINDOWSNT
+ /* Special case: on NT, the PATH variable is actually named
+ "Path" although cmd.exe (perhaps NT itself) arranges for
+ environment variable lookup and setting to be case
+ insensitive. However, Emacs assumes a fully case sensitive
+ environment, so we need to change "Path" to "PATH" to match
+ the expectations of various elisp packages. We do this by
+ the sneaky method of modifying the string in the C runtime
+ environ entry.
+
+ The same applies to COMSPEC.
+
+ We want to do this here so that Vprocess_environment is
+ affected by this modification, without getting all the other
+ NT-specific modifications we do in init_environment. */
+ const char *upcased_var = NULL;
+ if (_strnicmp (*envp, "PATH=", 5) == 0)
+ upcased_var = "PATH";
+ else if (_strnicmp (*envp, "COMSPEC=", 8) == 0)
+ upcased_var = "COMSPEC";
+
+ if (upcased_var)
+ {
+ memcpy (*envp, upcased_var, strlen (upcased_var));
+ envstr = build_string (*envp);
+ }
+#endif
+ /* `process_environment' is often modified destructively, so
+ don't share any structure initial-environment. */
+ Vprocess_environment = Fcons (envstr, Vprocess_environment);
+ }
}
void
diff --git a/src/w32.c b/src/w32.c
index ad7d94a..d4a7d93 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -2852,25 +2852,6 @@ init_environment (char ** argv)
/* Rebuild system configuration to reflect invoking system. */
Vsystem_configuration = build_string (EMACS_CONFIGURATION);
- /* Another special case: on NT, the PATH variable is actually named
- "Path" although cmd.exe (perhaps NT itself) arranges for
- environment variable lookup and setting to be case insensitive.
- However, Emacs assumes a fully case sensitive environment, so we
- need to change "Path" to "PATH" to match the expectations of
- various elisp packages. We do this by the sneaky method of
- modifying the string in the C runtime environ entry.
-
- The same applies to COMSPEC. */
- {
- char ** envp;
-
- for (envp = environ; *envp; envp++)
- if (_strnicmp (*envp, "PATH=", 5) == 0)
- memcpy (*envp, "PATH=", 5);
- else if (_strnicmp (*envp, "COMSPEC=", 8) == 0)
- memcpy (*envp, "COMSPEC=", 8);
- }
-
/* Remember the initial working directory for getcwd. */
/* FIXME: Do we need to resolve possible symlinks in startup_dir?
Does it matter anywhere in Emacs? */
--
2.6.2.windows.1
next prev parent reply other threads:[~2016-11-18 22:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-16 22:22 bug#24956: 26.0.50; On Windows, setting PATH in compilation-environment has no effect Óscar Fuentes
2016-11-17 17:59 ` Noam Postavsky
2016-11-17 20:59 ` Eli Zaretskii
2016-11-17 21:27 ` Noam Postavsky
2016-11-18 9:46 ` Eli Zaretskii
2016-11-18 22:11 ` Noam Postavsky [this message]
2016-11-19 7:16 ` Eli Zaretskii
2016-11-21 23:19 ` Noam Postavsky
2016-11-22 16:01 ` Eli Zaretskii
2016-11-22 22:35 ` Noam Postavsky
2016-11-23 16:07 ` Eli Zaretskii
2016-11-27 20:01 ` Óscar Fuentes
2016-11-27 20:13 ` npostavs
2016-11-28 22:53 ` Noam Postavsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAM-tV--fCzOsuNBBSDH61OoDCtAUay=cLrnXc7mpagvzML4UYQ@mail.gmail.com' \
--to=npostavs@users.sourceforge.net \
--cc=24956@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=ofv@wanadoo.es \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.