all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
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: Mon, 21 Nov 2016 18:19:53 -0500	[thread overview]
Message-ID: <CAM-tV-9Lzuov4ZMf=q39oRNZDDGpjeHReCRiRu0NjEF3r9iOXw@mail.gmail.com> (raw)
In-Reply-To: <83shqoaqhy.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 755 bytes --]

On Sat, Nov 19, 2016 at 2:16 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
>   . I'd rather have the WINDOWSNT-specific code separate (on w32.c),
>     so perhaps the for-loop you modified could be left intact, and
>     instead we perform an additional pass over Vprocess_environment,
>     after it is already copied, to replace these two variables with
>     their upper-case equivalents, in that special code on w32.c.

Okay, here is a patch that does that.

>  . If you didn't already, please verify that these 2 variables in the
>    Emacs's own environment are also upcased, because otherwise I
>    think we will hit more such problems.

That would be the for loop just above my additions (I increased the
context so it's fully visible in the patch).

[-- Attachment #2: v2-0001-Upcase-Path-and-ComSpec-in-process-environment.patch --]
[-- Type: application/octet-stream, Size: 2099 bytes --]

From 1fe5e0dfb01a0400a90088d44f2f7fc2bd244a43 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Fri, 18 Nov 2016 16:26:53 -0500
Subject: [PATCH v2] 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 | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/w32.c b/src/w32.c
index ad7d94a..0739e51 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -2867,10 +2867,28 @@ init_environment (char ** argv)
     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);
+
+    /* Make the same modification to `process-environment' which has
+       already been initialized in set_initial_environment.  */
+    Lisp_Object env = Vprocess_environment;
+    Lisp_Object path = build_string ("PATH=");
+    Lisp_Object path_len = make_number (SBYTES (path));
+    Lisp_Object comspec = build_string ("COMSPEC=");
+    Lisp_Object comspec_len = make_number (SBYTES (comspec));
+    for (; CONSP (env); env = XCDR (env))
+    {
+      Lisp_Object entry = XCAR (env);
+      if (EQ (Fcompare_strings (entry, Qnil, path_len, path, Qnil, Qnil, Qt), Qt))
+        for (ptrdiff_t i = 0; i < SBYTES (path); i++)
+          SSET (entry, i, SREF (path, i));
+      else if (EQ (Fcompare_strings (entry, Qnil, comspec_len, comspec, Qnil, Qnil, Qt), Qt))
+        for (ptrdiff_t i = 0; i < SBYTES (comspec); i++)
+          SSET (entry, i, SREF (comspec, i));
+    }
   }
 
   /* 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


  reply	other threads:[~2016-11-21 23:19 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 [this message]
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-9Lzuov4ZMf=q39oRNZDDGpjeHReCRiRu0NjEF3r9iOXw@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.