From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#40658: Fforward-comment: Incorrect recognition of end of comment in C++ Date: Thu, 16 Apr 2020 12:44:26 +0000 Message-ID: <20200416124426.GA5328@ACM> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="40117"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier To: 40658@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 16 14:45:13 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jP3tI-000AI1-76 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 16 Apr 2020 14:45:12 +0200 Original-Received: from localhost ([::1]:33802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jP3tH-0001cn-8x for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 16 Apr 2020 08:45:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56102) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jP3t9-0001bR-Iq for bug-gnu-emacs@gnu.org; Thu, 16 Apr 2020 08:45:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jP3t8-0000G3-Gm for bug-gnu-emacs@gnu.org; Thu, 16 Apr 2020 08:45:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54379) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jP3t8-0000Fp-DI for bug-gnu-emacs@gnu.org; Thu, 16 Apr 2020 08:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jP3t8-0007Ay-Ca for bug-gnu-emacs@gnu.org; Thu, 16 Apr 2020 08:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 16 Apr 2020 12:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 40658 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.158704107627532 (code B ref -1); Thu, 16 Apr 2020 12:45:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 16 Apr 2020 12:44:36 +0000 Original-Received: from localhost ([127.0.0.1]:37692 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jP3si-0007A0-79 for submit@debbugs.gnu.org; Thu, 16 Apr 2020 08:44:36 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:41306) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jP3sg-00079s-I7 for submit@debbugs.gnu.org; Thu, 16 Apr 2020 08:44:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56065) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jP3sf-0001T9-EF for bug-gnu-emacs@gnu.org; Thu, 16 Apr 2020 08:44:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jP3sd-0008Tm-Or for bug-gnu-emacs@gnu.org; Thu, 16 Apr 2020 08:44:33 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:42849 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1jP3sd-0008Sa-EE for bug-gnu-emacs@gnu.org; Thu, 16 Apr 2020 08:44:31 -0400 Original-Received: (qmail 24324 invoked by uid 3782); 16 Apr 2020 12:44:28 -0000 Original-Received: from acm.muc.de (p4FE15C1F.dip0.t-ipconnect.de [79.225.92.31]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Thu, 16 Apr 2020 14:44:26 +0200 Original-Received: (qmail 5361 invoked by uid 1000); 16 Apr 2020 12:44:26 -0000 Content-Disposition: inline X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:178446 Archived-At: Hello, Emacs. C++ comments can be continued onto the next line by an escaped NL. This is configured in Emacs with the variable comment-end-can-be-escaped. However, Fforward_comment (in the backward direction) doesn't take this into account. A BOL following an escaped NL cannot be at the end of a C++ line comment: // C++ comment first line \ Second line of comment ^ | point Point here is in the middle of a comment. It is therefore wrong in Fforward_comment not to check comment-end-can-be-escaped when immediately after an Sendcomment. This can be fixed thusly: diff --git a/src/syntax.c b/src/syntax.c index e24b98da32..ff125b137c 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -2572,8 +2572,9 @@ between them, return t; otherwise return nil. */) } else if (code == Sendcomment) { - found = back_comment (from, from_byte, stop, comnested, comstyle, - &out_charpos, &out_bytepos); + found = (!quoted || !Vcomment_end_can_be_escaped) + && back_comment (from, from_byte, stop, comnested, comstyle, + &out_charpos, &out_bytepos); if (!found) { if (c == '\n') This should clearly go into the master branch. I think it should also go into the emacs-27 release branch, since it is relevant for a nasty bug, bug #40052. There, scrolling in a C++ include file, which consists of a #define macro ~2,400 lines long is deadly slow. With the above fix in place, scrolling is over 4 times as fast, although still too slow. -- Alan Mackenzie (Nuremberg, Germany).