From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: John Shahid Newsgroups: gmane.emacs.bugs Subject: bug#32201: 27.0.50; setenv should not change match-data Date: Thu, 19 Jul 2018 00:22:49 +0000 Message-ID: <87efg0dqg6.fsf@gmail.com> References: <87h8kwe4ja.fsf@gmail.com> <87601c88d9.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1531959731 23362 195.159.176.226 (19 Jul 2018 00:22:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 19 Jul 2018 00:22:11 +0000 (UTC) User-Agent: mu4e 1.1.0; emacs 27.0.50 Cc: 32201@debbugs.gnu.org To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 19 02:22:06 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ffwhq-0005wB-BE for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Jul 2018 02:22:06 +0200 Original-Received: from localhost ([::1]:38776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffwjv-0007t6-KN for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Jul 2018 20:24:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffwjo-0007t1-1q for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2018 20:24:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffwji-00069J-SO for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2018 20:24:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42298) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ffwji-00069C-J6 for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2018 20:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ffwji-0007dB-BJ for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2018 20:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: John Shahid Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Jul 2018 00:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32201 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 32201-submit@debbugs.gnu.org id=B32201.153195978429264 (code B ref 32201); Thu, 19 Jul 2018 00:24:02 +0000 Original-Received: (at 32201) by debbugs.gnu.org; 19 Jul 2018 00:23:04 +0000 Original-Received: from localhost ([127.0.0.1]:47316 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ffwil-0007bv-D1 for submit@debbugs.gnu.org; Wed, 18 Jul 2018 20:23:04 -0400 Original-Received: from mail-qk0-f170.google.com ([209.85.220.170]:46170) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ffwij-0007b9-GL for 32201@debbugs.gnu.org; Wed, 18 Jul 2018 20:23:01 -0400 Original-Received: by mail-qk0-f170.google.com with SMTP id o2-v6so3395066qkc.13 for <32201@debbugs.gnu.org>; Wed, 18 Jul 2018 17:23:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=5jIY7Cm2FwkE9Hm02lsaehf4oY9PbZrG9MwKG9lAG/o=; b=M6M8GGe528dWy9fKT/j2o+e9eO9Zo8LzD3evjHhx0OCdtbMQMz+uH1uLoQuuZTl026 188S1r2n8Gl6AyzK2zTBV5zAW4FeUFciyYEG7X7AAHOWt2+IAb+EjB3YTJWQ6z0t71u/ f/NbQh3YrTqB6R+HxZnKIDvQl0clZi6yLYc+A9xMmCmPGehPX7PMi19pU+KcigdmrjiE 2YhpX0je1WRH2PPvuHkcIsRIj1+hV+DHgRE3Vd+MPBLb3Lvxup3+ocUEo6Lf9Ylx+nPb MRkfz/UUsqx3p7fm/obcEGGBydAZbed+bsNpkcj9BVcRDmaxvDA2XkOEp/wSp1bhaLrW maTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=5jIY7Cm2FwkE9Hm02lsaehf4oY9PbZrG9MwKG9lAG/o=; b=YAUFaZy8xGdF9puX9KvIGfZEs2IFkqEdATcf8JQFmp+yU9dw3sbin5hDHetj5Ae9jQ 2ER/FsWz2lgzgdfPyF82RDKz79gyz6MzTNGJu3MRgz5uCz5YdrJIM5bCjMf1ZKyNS46R CkV+OPbYtAbGTms5t1PEj7xmo67Y/KzbDFVZX6O4FN6NMMNWoiHl0g7gXxf+BZVzBSFq nIoyFjiawYPRSsH1pxxbc8SEKqMXmbOw+2PwS0bRMZ/4DDgvmQvABvO8MFhaUAFkT+VI 1AmeYs1+tHm3Gewhk1vRoL25X3XtCFK2rsWPgQaBNhQtntBnlzVlIGVzLBH3C8m4TyGL HZYg== X-Gm-Message-State: AOUpUlG1li/UV13wiwxjdtpSeVaJz4Uvcj3WrOD0o+x/YC0r2Mm0b00C 7AyOiEvTLN++/NPmo77w3aoBl8g1 X-Google-Smtp-Source: AAOMgpf6pGWx22Mr/lo9JhA8VeR0WcGwN17wk/J64jbDdtOmDY8botaVclSICoyXznsz6PY8hHRMfA== X-Received: by 2002:a37:ab14:: with SMTP id u20-v6mr7214110qke.120.1531959775590; Wed, 18 Jul 2018 17:22:55 -0700 (PDT) Original-Received: from 8a803f88ebe0 (cpe-184-152-55-93.nyc.res.rr.com. [184.152.55.93]) by smtp.gmail.com with ESMTPSA id s31-v6sm4659572qtc.68.2018.07.18.17.22.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 17:22:54 -0700 (PDT) In-reply-to: <87601c88d9.fsf@gmail.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:148652 Archived-At: --=-=-= Content-Type: text/plain Noam Postavsky 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 ? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Avoid-destroying-match-data-in-setenv.patch >From 7b592252f698ae07a2010302c74b42026fbbca5e Mon Sep 17 00:00:00 2001 From: John Shahid 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 --=-=-=--