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: Tue, 22 Nov 2016 17:35:17 -0500 [thread overview]
Message-ID: <CAM-tV-8gfvrgNh+X5c1uknEvWFAu0jwE6L_a+oxbSHSo0pid2Q@mail.gmail.com> (raw)
In-Reply-To: <8337ij8pwj.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 635 bytes --]
On Tue, Nov 22, 2016 at 11:01 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
> Why not compare in using _strnicmp instead of Fcompare_strings? That
> would save you the need to cons Lisp strings, and will be more
> efficient (Fcompare_strings is quite complex). Not that speed matters
> in this case, but it's just looks strange to me. Am I missing
> something?
Oops. Looking at Fupcase, I had somehow thought that unibyte vs
multibyte would be a problem (and hence I should use Fcompare_strings
to hide the details), but actually (as I think you've mentioned
before) that's not the case for environment variables.
Here's a new patch.
[-- Attachment #2: v3-0001-Upcase-Path-and-ComSpec-in-process-environment.patch --]
[-- Type: application/octet-stream, Size: 2108 bytes --]
From ecb8a7ea028235e67a955e63c5ee1ca5d574b04f Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Fri, 18 Nov 2016 16:26:53 -0500
Subject: [PATCH v3] 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.
---
src/w32.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/w32.c b/src/w32.c
index ad7d94a..086c1ac 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -2863,12 +2863,29 @@ init_environment (char ** argv)
The same applies to COMSPEC. */
{
char ** envp;
+ const char *path = "PATH=";
+ int path_len = strlen (path);
+ const char *comspec = "COMSPEC=";
+ int comspec_len = strlen (comspec);
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);
+ if (_strnicmp (*envp, path, path_len) == 0)
+ memcpy (*envp, path, path_len);
+ else if (_strnicmp (*envp, comspec, comspec_len) == 0)
+ memcpy (*envp, comspec, comspec_len);
+
+ /* Make the same modification to `process-environment' which has
+ already been initialized in set_initial_environment. */
+ for (Lisp_Object env = Vprocess_environment; CONSP (env); env = XCDR (env))
+ {
+ Lisp_Object entry = XCAR (env);
+ if (_strnicmp (SDATA (entry), path, path_len) == 0)
+ for (int i = 0; i < path_len; i++)
+ SSET (entry, i, path[i]);
+ else if (_strnicmp (SDATA (entry), comspec, comspec_len) == 0)
+ for (int i = 0; i < comspec_len; i++)
+ SSET (entry, i, comspec[i]);
+ }
}
/* Remember the initial working directory for getcwd. */
--
2.6.2.windows.1
next prev parent reply other threads:[~2016-11-22 22:35 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
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 [this message]
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAM-tV-8gfvrgNh+X5c1uknEvWFAu0jwE6L_a+oxbSHSo0pid2Q@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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).