From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#36328: 26.2; Args out of range on search-and-replace of *.cc file Date: Fri, 05 Jul 2019 00:09:47 +0300 Organization: LINKOV.NET Message-ID: <87ef35wlpg.fsf@mail.linkov.net> References: <20190622205033.GA9167@ACM> <20190623122207.GA4736@ACM> <20190623193258.GB4736@ACM> <87k1dc2e5h.fsf@mail.linkov.net> <20190624075218.GA4781@ACM> <87d0j27wiu.fsf@mail.linkov.net> <20190625094708.GB5471@ACM> <87lfxpzbb3.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="166658"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: Alan Mackenzie , Jayden Navarro , 36328@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 04 23:12:13 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hj91Y-000hDx-8E for geb-bug-gnu-emacs@m.gmane.org; Thu, 04 Jul 2019 23:12:12 +0200 Original-Received: from localhost ([::1]:48842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hj91W-0002EJ-A7 for geb-bug-gnu-emacs@m.gmane.org; Thu, 04 Jul 2019 17:12:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54305) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hj91Q-0002A5-B4 for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2019 17:12:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hj91P-0001MF-94 for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2019 17:12:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43212) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hj91P-0001M8-5d for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2019 17:12:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hj91O-0003a2-VA for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2019 17:12:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Jul 2019 21:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36328 X-GNU-PR-Package: emacs Original-Received: via spool by 36328-submit@debbugs.gnu.org id=B36328.156227469413704 (code B ref 36328); Thu, 04 Jul 2019 21:12:02 +0000 Original-Received: (at 36328) by debbugs.gnu.org; 4 Jul 2019 21:11:34 +0000 Original-Received: from localhost ([127.0.0.1]:52032 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hj90v-0003Yx-Mm for submit@debbugs.gnu.org; Thu, 04 Jul 2019 17:11:33 -0400 Original-Received: from aye.elm.relay.mailchannels.net ([23.83.212.6]:22802) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hj90t-0003YK-H0 for 36328@debbugs.gnu.org; Thu, 04 Jul 2019 17:11:32 -0400 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 7B8F42C2544; Thu, 4 Jul 2019 21:11:30 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a17.g.dreamhost.com (100-96-38-45.trex.outbound.svc.cluster.local [100.96.38.45]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id E6E8F2C257B; Thu, 4 Jul 2019 21:11:29 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a17.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.17.3); Thu, 04 Jul 2019 21:11:30 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Shade-Fumbling: 1be681c7091d7d42_1562274690303_3565070454 X-MC-Loop-Signature: 1562274690303:1932523968 X-MC-Ingress-Time: 1562274690303 Original-Received: from pdx1-sub0-mail-a17.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a17.g.dreamhost.com (Postfix) with ESMTP id 7F9217F6C4; Thu, 4 Jul 2019 14:11:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=KASTuyzy/DMZYPB3nG7SHybqDz0=; b= R9PzQ23yRySfYXmSNjLRZo+IFEiEbxxNg3ROai6Ol6NB3RrIcpakmvB3TeQmejBS j9E/Da8WSxWBSPYSLuMRSmJXlB3WvXFXQSNh/Zfo04W0iFQLEeeFWdRavGEaRYzo uVGZiTMUz2MUd7t7YsBexyPpAHrm0JdqzEocJjCCSuE= Original-Received: from mail.jurta.org (m91-129-109-127.cust.tele2.ee [91.129.109.127]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a17.g.dreamhost.com (Postfix) with ESMTPSA id DCF447F633; Thu, 4 Jul 2019 14:11:26 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a17 In-Reply-To: <87lfxpzbb3.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 25 Jun 2019 22:58:56 +0300") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduvddrfedvgdduiedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhofhffjgfkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrddutdelrdduvdejnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddtledruddvjedprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopegvlhhiiiesghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt 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: 209.51.188.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:162091 Archived-At: Eli, do you think this fix should be pushed to emacs-26? >> My feeling is that perform-replace (or, possibly, replace-highlight) is >> the best place to put a save-match-data. > > Doing this in perform-replace means adding save-match-data in all places > where replace-highlight is called, so maybe better to add it only once > in replace-highlight like Jayden proposed initially. > > But then it's important to add an explanatory comment since > the need of using of save-match-data is not self-evident here. > > Do you think this comment is clear enough? > > diff --git a/lisp/replace.el b/lisp/replace.el > index 9d1b7bf747..50c74be8f6 100644 > --- a/lisp/replace.el > +++ b/lisp/replace.el > @@ -2316,7 +2316,11 @@ replace-highlight > (isearch-forward (not backward)) > (isearch-other-end match-beg) > (isearch-error nil)) > - (isearch-lazy-highlight-new-loop range-beg range-end)))) > + (save-match-data > + ;; Preserve match-data for perform-replace since > + ;; isearch-lazy-highlight-new-loop calls `sit-for' that > + ;; does redisplay that might clobber match data (bug#36328). > + (isearch-lazy-highlight-new-loop range-beg range-end))))) > > (defun replace-dehighlight () > (when replace-overlay > diff --git a/lisp/term/tty-colors.el b/lisp/term/tty-colors.el > index 307586f221..5af8170203 100644 > --- a/lisp/term/tty-colors.el > +++ b/lisp/term/tty-colors.el > @@ -820,7 +820,7 @@ tty-color-canonicalize > "Return COLOR in canonical form. > A canonicalized color name is all-lower case, with any blanks removed." > (let ((case-fold-search nil)) > - (if (string-match "[A-Z ]" color) > + (if (string-match-p "[A-Z ]" color) > (replace-regexp-in-string " +" "" (downcase color)) > color)))