From: John Shahid <jvshahid@gmail.com>
To: Noam Postavsky <npostavs@gmail.com>
Cc: 32201@debbugs.gnu.org
Subject: bug#32201: 27.0.50; setenv should not change match-data
Date: Thu, 19 Jul 2018 00:22:49 +0000 [thread overview]
Message-ID: <87efg0dqg6.fsf@gmail.com> (raw)
In-Reply-To: <87601c88d9.fsf@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 598 bytes --]
Noam Postavsky <npostavs@gmail.com> writes:
[...]
> Anyway, I don't think setenv should be changed, rather
> abbreviate-file-name should save-match-data around the expand-file-name
> call. After all, today you happened to use setenv in a hook, tomorrow
> someone will use another match-data modifying function.
I agree, but I also think that there is no reason for `setenv' to use
`string-match' instead of `string-match-p'. It doesn't seem to be using
the match data anyway. I attached the patch that replaces
`string-match' with `string-match-p' in `setenv' and `setenv-internal'.
WDYT ?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Avoid-destroying-match-data-in-setenv.patch --]
[-- Type: text/x-diff, Size: 1410 bytes --]
From 7b592252f698ae07a2010302c74b42026fbbca5e Mon Sep 17 00:00:00 2001
From: John Shahid <jvshahid@gmail.com>
Date: Wed, 18 Jul 2018 20:18:19 -0400
Subject: [PATCH] Avoid destroying match data in 'setenv'
* lisp/env.el (setenv,setenv-internal): Replace string-match with
string-match-p
---
lisp/env.el | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lisp/env.el b/lisp/env.el
index e47eb57836..7007ba33e5 100644
--- a/lisp/env.el
+++ b/lisp/env.el
@@ -113,11 +113,11 @@ setenv-internal
(not keep-empty)
env
(stringp (car env))
- (string-match pattern (car env)))
+ (string-match-p pattern (car env)))
(cdr env)
;; Try to find existing entry for VARIABLE in ENV.
(while (and scan (stringp (car scan)))
- (when (string-match pattern (car scan))
+ (when (string-match-p pattern (car scan))
(if value
(setcar scan (concat variable "=" value))
(if keep-empty
@@ -184,7 +184,7 @@ setenv
(setq variable (encode-coding-string variable locale-coding-system)))
(if (and value (multibyte-string-p value))
(setq value (encode-coding-string value locale-coding-system)))
- (if (string-match "=" variable)
+ (if (string-match-p "=" variable)
(error "Environment variable name `%s' contains `='" variable))
(if (string-equal "TZ" variable)
(set-time-zone-rule value))
--
2.18.0
next prev parent reply other threads:[~2018-07-19 0:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-18 19:18 bug#32201: 27.0.50; setenv should not change match-data John Shahid
[not found] ` <handler.32201.B.153194154418543.ack@debbugs.gnu.org>
2018-07-18 19:25 ` bug#32201: Acknowledgement (27.0.50; setenv should not change match-data) John Shahid
2018-07-18 22:52 ` bug#32201: 27.0.50; setenv should not change match-data Noam Postavsky
2018-07-19 0:22 ` John Shahid [this message]
2018-07-19 1:56 ` Noam Postavsky
2018-07-22 1:30 ` 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=87efg0dqg6.fsf@gmail.com \
--to=jvshahid@gmail.com \
--cc=32201@debbugs.gnu.org \
--cc=npostavs@gmail.com \
/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).