GNU bug report logs -
#32201
27.0.50; setenv should not change match-data
Previous Next
Reported by: John Shahid <jvshahid <at> gmail.com>
Date: Wed, 18 Jul 2018 19:20:01 UTC
Severity: normal
Tags: fixed, patch
Found in version 27.0.50
Fixed in version 26.2
Done: Noam Postavsky <npostavs <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #16 received at 32201 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Noam Postavsky <npostavs <at> 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 ?
[0001-Avoid-destroying-match-data-in-setenv.patch (text/x-diff, inline)]
From 7b592252f698ae07a2010302c74b42026fbbca5e Mon Sep 17 00:00:00 2001
From: John Shahid <jvshahid <at> 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
This bug report was last modified 6 years and 307 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.